Skip to content

Commit

Permalink
Fixe temp.
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Perseghetti <[email protected]>
  • Loading branch information
bperseghetti committed Feb 9, 2023
1 parent 9a94667 commit c386760
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
20 changes: 10 additions & 10 deletions examples/standalone/scene_provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugin to update the scene using Gazebo Transport.

## Build

```
```bash
cd examples/standalone/scene_provider
mkdir build
cd build
Expand All @@ -21,14 +21,14 @@ make

In one terminal, start the scene provider:

```
```bash
cd examples/standalone/scene_provider/build
./scene_provider
```

On another terminal, start the example config:

```
```bash
gz gui -c examples/config/scene3d.config
```

Expand All @@ -42,35 +42,35 @@ Some commands to test camera tracking with this demo:

Move to box:

```
```bash
gz service -s /gui/move_to --reqtype gz.msgs.StringMsg --reptype gz.msgs.Boolean --timeout 2000 --req 'data: "box_model"'
```

Echo camera pose:

```
```bash
gz topic -e -t /gui/camera/pose
```

Follow box:

```
```bash
gz service -s /gui/follow --reqtype gz.msgs.StringMsg --reptype gz.msgs.Boolean --timeout 2000 --req 'data: "box_model"'
```

Update follow offset:

```
```bash
gz service -s /gui/follow/offset --reqtype gz.msgs.Vector3d --reptype gz.msgs.Boolean --timeout 2000 --req 'x: 5, y: 5, z: 5'
```

Set next follow pgain:
Set next follow p_gain:

```bash
gz service -s /gui/follow/pgain --reqtype gz.msgs.Double --reptype gz.msgs.Boolean --timeout 2000 --req 'data: 1.0'
gz service -s /gui/follow/p_gain --reqtype gz.msgs.Double --reptype gz.msgs.Boolean --timeout 2000 --req 'data: 1.0'
```

Update follow offset with new pgain:
Update follow offset with new p_gain:

```bash
gz service -s /gui/follow/offset --reqtype gz.msgs.Vector3d --reptype gz.msgs.Boolean --timeout 2000 --req 'x: 1, y: 1, z: 5'
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/camera_tracking/CameraTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void CameraTrackingPrivate::Initialize()
<< this->followOffsetService << "]" << std::endl;

// follow pgain
this->followPGainService = "/gui/follow/pgain";
this->followPGainService = "/gui/follow/p_gain";
this->node.Advertise(this->followPGainService,
&CameraTrackingPrivate::OnFollowPGain, this);
gzmsg << "Follow P gain service on ["
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/camera_tracking/CameraTracking.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace plugins
/// * `/gui/move_to/pose`: Move the user camera to a given pose.
/// * `/gui/follow`: Set the user camera to follow a given target,
/// identified by name.
/// * `/gui/follow/pgain`: Set the pgain for following.
/// * `/gui/follow/p_gain`: Set the pgain for following.
/// * `/gui/follow/offset`: Set the offset for following.
///
/// Topics:
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/camera_tracking/CameraTracking.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ColumnLayout {
'<li>/gui/move_to</li>' +
'<li>/gui/move_to/pose</li>' +
'<li>/gui/follow</li>' +
'<li>/gui/follow/pgain</li>' +
'<li>/gui/follow/p_gain</li>' +
'<li>/gui/follow/offset</li></ul><br>Topics provided:<br><ul>' +
'<li>/gui/camera/pose</li></ul>'

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/follow_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ gz_gui_add_plugin(FollowConfig
FollowConfig.cc
QT_HEADERS
FollowConfig.hh
TEST_SOURCES
# FollowConfig_TEST.cc
)
21 changes: 17 additions & 4 deletions src/plugins/follow_config/FollowConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@
/// \brief Private data class for FollowConfig
class gz::gui::plugins::FollowConfigPrivate
{
/// \brief Service request topic for follow name
public: std::string followTargetNameService;

/// \brief Service request topic for follow offset
public: std::string followOffsetService;

/// \brief Service request topic for follow p_gain
public: std::string followPGainService;

/// \brief Offset of camera from target being followed
Expand All @@ -48,20 +51,27 @@ class gz::gui::plugins::FollowConfigPrivate
/// \brief Follow P gain
public: double followPGain{0.01};

/// \brief Follow target name from sdf
public: std::string followTargetName;

public: transport::Node node;

/// \brief Process updated follow name from SDF
public: void UpdateFollowTargetName();

/// \brief Process updated follow offset
public: void UpdateFollowOffset();

/// \brief Process updated P Gain
public: void UpdateFollowPGain();

/// \brief flag for updating target name
public: bool newFollowUpdateTargetName = false;

/// \brief flag for updating P gain
public: bool newFollowUpdatePGain = false;

/// \brief flag for updating offset
public: bool newFollowUpdateOffset = false;

};
Expand Down Expand Up @@ -96,7 +106,7 @@ void FollowConfig::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
<< this->dataPtr->followOffsetService << "]" << std::endl;

// Follow target pgain service
this->dataPtr->followPGainService = "/gui/follow/pgain";
this->dataPtr->followPGainService = "/gui/follow/p_gain";
gzmsg << "FollowConfig: Follow P gain service on ["
<< this->dataPtr->followPGainService << "]" << std::endl;

Expand Down Expand Up @@ -189,7 +199,8 @@ void FollowConfigPrivate::UpdateFollowTargetName()
std::function<void(const msgs::Boolean &, const bool)> cbName =
[&](const msgs::Boolean &/*_rep*/, const bool _resultName)
{
if (!_resultName) {
if (!_resultName)
{
gzerr << "FollowConfig: Error sending follow target name." << std::endl;
} else {
gzmsg << "FollowConfig: Request Target Name: "
Expand All @@ -210,7 +221,8 @@ void FollowConfigPrivate::UpdateFollowOffset()
std::function<void(const msgs::Boolean &, const bool)> cbOffset =
[&](const msgs::Boolean &/*_rep*/, const bool _resultOffset)
{
if (!_resultOffset) {
if (!_resultOffset)
{
gzerr << "FollowConfig: Error sending follow offset." << std::endl;
} else {
gzmsg << "FollowConfig: Request Offset: "
Expand All @@ -233,7 +245,8 @@ void FollowConfigPrivate::UpdateFollowPGain()
std::function<void(const msgs::Boolean &, const bool)> cbPGain =
[&](const msgs::Boolean &/*_rep*/, const bool _resultPGain)
{
if (!_resultPGain) {
if (!_resultPGain)
{
gzerr << "FollowConfig: Error sending follow pgain." << std::endl;
} else {
gzmsg << "FollowConfig: Request PGain: "
Expand Down
2 changes: 1 addition & 1 deletion test/integration/camera_tracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ TEST(MinimalSceneTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Config))

msgs::Double reqPGain;
reqPGain.set_data(1.0);
executed = node.Request("/gui/follow/pgain", reqPGain, timeout, rep,
executed = node.Request("/gui/follow/p_gain", reqPGain, timeout, rep,
result);
EXPECT_TRUE(executed);
EXPECT_TRUE(result);
Expand Down

0 comments on commit c386760

Please sign in to comment.