Skip to content

Commit

Permalink
Add spin box to View Angle plugin for configuring view control sensit…
Browse files Browse the repository at this point in the history
…ivity (#1799)

Closes #1027

Adds spin box that lets users sets the view controller sensitivity. The limits of the spin box are: [0.01, 10.0] with a step size of 0.1.

Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Dec 7, 2022
1 parent ba96ec8 commit 70c412c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/gui/plugins/view_angle/ViewAngle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ namespace ignition::gazebo
/// \brief View Control reference visual service name
public: std::string viewControlRefVisualService;

/// \brief View Control sensitivity service name
public: std::string viewControlSensitivityService;

/// \brief Move gui camera to pose service name
public: std::string moveToPoseService;

Expand Down Expand Up @@ -161,7 +164,12 @@ void ViewAngle::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
this->dataPtr->viewControlService = "/gui/camera/view_control";

// view control reference visual requests
this->dataPtr->viewControlRefVisualService = "/gui/camera/reference_visual";
this->dataPtr->viewControlRefVisualService =
"/gui/camera/view_control/reference_visual";

// view control sensitivity requests
this->dataPtr->viewControlSensitivityService =
"/gui/camera/view_control/sensitivity";

// Subscribe to camera pose
std::string topic = "/gui/camera/pose";
Expand Down Expand Up @@ -299,6 +307,29 @@ void ViewAngle::OnViewControlReferenceVisual(bool _enable)
this->dataPtr->viewControlRefVisualService, req, cb);
}

/////////////////////////////////////////////////
void ViewAngle::OnViewControlSensitivity(double _sensitivity)
{
std::function<void(const msgs::Boolean &, const bool)> cb =
[](const msgs::Boolean &/*_rep*/, const bool _result)
{
if (!_result)
ignerr << "Error setting view controller sensitivity" << std::endl;
};

if (_sensitivity <= 0.0)
{
ignerr << "View controller sensitivity must be greater than 0" << std::endl;
return;
}

msgs::Double req;
req.set_data(_sensitivity);

this->dataPtr->node.Request(
this->dataPtr->viewControlSensitivityService, req, cb);
}

/////////////////////////////////////////////////
QList<double> ViewAngle::CamPose() const
{
Expand Down
4 changes: 4 additions & 0 deletions src/gui/plugins/view_angle/ViewAngle.hh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ namespace gazebo
/// false to hide it
public slots: void OnViewControlReferenceVisual(bool _enable);

/// \brief Callback in Qt thread when camera view controller changes.
/// \param[in] _sensitivity View control sensitivity vlaue
public slots: void OnViewControlSensitivity(double _sensitivity);

/// \brief Get the current gui camera pose.
public: Q_INVOKABLE QList<double> CamPose() const;

Expand Down
24 changes: 24 additions & 0 deletions src/gui/plugins/view_angle/ViewAngle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,30 @@ ColumnLayout {
}
}

// view control sensitivity
GridLayout {
Layout.fillWidth: true
Layout.margins: 10
columns: 2

Label {
id: viewControlSensitivityLabel
text: "View control sensitivity"
}
IgnSpinBox {
id: viewControlSensitivitySpinBox
Layout.fillWidth: true
value: 1.0
maximumValue: 10.0
minimumValue: 0.01
decimals: 2
stepSize: 0.1
onEditingFinished:{
ViewAngle.OnViewControlSensitivity(value)
}
}
}

// toggle view control reference visual
CheckBox {
Layout.alignment: Qt.AlignHCenter
Expand Down

0 comments on commit 70c412c

Please sign in to comment.