-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force Visuallization #1184
Force Visuallization #1184
Conversation
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Adding a new message is backwards compatible, so I think we should be able to target this at Citadel 🏰 |
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Louise Poubel <louise@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some preliminary comments
src/Link.cc
Outdated
const std::string &_pluginName) const | ||
{ | ||
static transport::Node node; | ||
static auto pub = node.Advertise<msgs::WrenchVisual>("/force_viz"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be member variables? Otherwise all links will share the same node and publisher.
It would also be good to namespace the topic with the world name, in case there are multiple simulations running.
static auto pub = node.Advertise<msgs::WrenchVisual>("/force_viz"); | |
static auto pub = node.Advertise<msgs::WrenchVisual>("/world/" + worldName + "/view_forces"); |
src/Link.cc
Outdated
wrenchVisual.mutable_entity()->set_type(msgs::Entity_Type_LINK); | ||
msgs::Set(wrenchVisual.mutable_wrench()->mutable_force(), _force); | ||
msgs::Set(wrenchVisual.mutable_wrench()->mutable_torque(), _torque); | ||
pub.Publish(wrenchVisual); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with your ign-gui
marker performance PR (gazebosim/gz-gui#307), I'm still getting really bad performance for the markers.
I think we could drastically reduce the number of markers if we skip publishing the wrench visuals in some cases:
- If the wrench is zero we shouldn't even add it and return straight away
- If the wrench is the same as before, we don't need to publish new markers.
I started prototyping these ideas, but it still needs some cleanup. Let me know what you think, here's what I have so far:
diff
diff --git a/src/Link.cc b/src/Link.cc
index ef30f76a..f3222bee 100644
--- a/src/Link.cc
+++ b/src/Link.cc
@@ -44,6 +44,9 @@ class ignition::gazebo::LinkPrivate
{
/// \brief Id of link entity.
public: Entity id{kNullEntity};
+
+ /// \brief
+ public: std::pair<math::Vector3d, math::Vector3d> lastPublishedWrench;
};
using namespace ignition;
@@ -362,6 +365,17 @@ void Link::AddAndVisualizeWorldWrench(EntityComponentManager &_ecm,
const math::Vector3d &_torque,
const std::string &_pluginName) const
{
+ if (_force == math::Vector3d::Zero && _torque == math::Vector3d::Zero)
+ return;
+
+ this->AddWorldWrench(_ecm, _force, _torque);
+ if (_force.Equal(this->dataPtr->lastPublishedWrench.first, 0.1) &&
+ _torque.Equal(this->dataPtr->lastPublishedWrench.second, 0.1))
+ {
+ return;
+ }
+ this->dataPtr->lastPublishedWrench = {_force, _torque};
+
static transport::Node node;
static auto pub = node.Advertise<msgs::WrenchVisual>("/force_viz");
@@ -374,5 +388,4 @@ void Link::AddAndVisualizeWorldWrench(EntityComponentManager &_ecm,
msgs::Set(wrenchVisual.mutable_wrench()->mutable_force(), _force);
msgs::Set(wrenchVisual.mutable_wrench()->mutable_torque(), _torque);
pub.Publish(wrenchVisual);
- this->AddWorldWrench(_ecm, _force, _torque);
}
diff --git a/src/systems/buoyancy/Buoyancy.cc b/src/systems/buoyancy/Buoyancy.cc
index 49445ac5..61c5d224 100644
--- a/src/systems/buoyancy/Buoyancy.cc
+++ b/src/systems/buoyancy/Buoyancy.cc
@@ -127,6 +127,8 @@ class ignition::gazebo::systems::BuoyancyPrivate
/// \brief Scoped names of entities that buoyancy should apply to. If empty,
/// all links will receive buoyancy.
public: std::unordered_set<std::string> enabled;
+
+ public: std::set<std::shared_ptr<Link>> links;
};
//////////////////////////////////////////////////
@@ -345,8 +347,6 @@ void Buoyancy::PreUpdate(const ignition::gazebo::UpdateInfo &_info,
return true;
}
- Link link(_entity);
-
std::vector<Entity> collisions = _ecm.ChildrenByComponents(
_entity, components::Collision());
@@ -445,7 +445,21 @@ void Buoyancy::PreUpdate(const ignition::gazebo::UpdateInfo &_info,
// World pose of the link.
math::Pose3d linkWorldPose = worldPose(_entity, _ecm);
- Link link(_entity);
+ std::shared_ptr<Link> link{nullptr};
+ auto it = std::find_if(this->dataPtr->links.begin(), this->dataPtr->links.end(),
+ [&_entity](const std::shared_ptr<Link> &_link)
+ {
+ return _link->Entity() == _entity;
+ });
+ if (it != this->dataPtr->links.end())
+ {
+ link = *it;
+ }
+ else
+ {
+ link = std::make_shared<Link>(_entity);
+ this->dataPtr->links.insert(link);
+ }
math::Vector3d buoyancy;
// By Archimedes' principle,
@@ -467,7 +481,7 @@ void Buoyancy::PreUpdate(const ignition::gazebo::UpdateInfo &_info,
// Apply the wrench to the link. This wrench is applied in the
// Physics System.
- link.AddAndVisualizeWorldWrench(_ecm,
+ link->AddAndVisualizeWorldWrench(_ecm,
buoyancy, torque, "BuoyancyPlugin");
return true;
}
@@ -526,10 +540,10 @@ void Buoyancy::PreUpdate(const ignition::gazebo::UpdateInfo &_info,
}
}
auto [force, torque] = this->dataPtr->ResolveForces(
- link.WorldInertialPose(_ecm).value());
+ link->WorldInertialPose(_ecm).value());
// Apply the wrench to the link. This wrench is applied in the
// Physics System.
- link.AddAndVisualizeWorldWrench(
+ link->AddAndVisualizeWorldWrench(
_ecm, force, torque, "BuoyancyPlugin");
}
diff --git a/src/systems/buoyancy_engine/BuoyancyEngine.cc b/src/systems/buoyancy_engine/BuoyancyEngine.cc
index eda84a3c..9d4a4262 100644
--- a/src/systems/buoyancy_engine/BuoyancyEngine.cc
+++ b/src/systems/buoyancy_engine/BuoyancyEngine.cc
@@ -42,6 +42,8 @@ class ignition::gazebo::systems::BuoyancyEnginePrivateData
public: void OnCmdBuoyancyEngine(
const ignition::msgs::Double &_volumeSetPoint);
+ public: Link link{kNullEntity};
+
/// \brief Current volume of bladder in m^3
public: double bladderVolume = 3e-5;
@@ -118,6 +120,7 @@ void BuoyancyEnginePlugin::Configure(
<< "] was not found in model [" << model.Name(_ecm) << "]" << std::endl;
return;
}
+ this->dataPtr->link = Link(this->dataPtr->linkEntity);
if (_sdf->HasElement("min_volume"))
{
@@ -235,8 +238,7 @@ void BuoyancyEnginePlugin::PreUpdate(
zForce = - gravity->Data() * this->dataPtr->fluidDensity
* (this->dataPtr->bladderVolume - this->dataPtr->neutralVolume);
}
- ignition::gazebo::Link link(this->dataPtr->linkEntity);
- link.AddAndVisualizeWorldWrench(_ecm, zForce, {0, 0, 0}, "Buoyancy Engine");
+ this->dataPtr->link.AddAndVisualizeWorldWrench(_ecm, zForce, {0, 0, 0}, "Buoyancy Engine");
}
IGNITION_ADD_PLUGIN(
diff --git a/src/systems/lift_drag/LiftDrag.cc b/src/systems/lift_drag/LiftDrag.cc
index f797a314..be3f0956 100644
--- a/src/systems/lift_drag/LiftDrag.cc
+++ b/src/systems/lift_drag/LiftDrag.cc
@@ -59,6 +59,9 @@ class ignition::gazebo::systems::LiftDragPrivate
/// \brief Model interface
public: Model model{kNullEntity};
+ /// \brief Model interface
+ public: Link link{kNullEntity};
+
/// \brief Coefficient of Lift / alpha slope.
/// Lift = C_L * q * S
/// where q (dynamic pressure) = 0.5 * rho * v^2
@@ -198,6 +201,7 @@ void LiftDragPrivate::Load(const EntityComponentManager &_ecm,
this->validConfig = false;
return;
}
+ this->link = Link(this->linkEntity);
}
else
{
@@ -467,8 +471,7 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm)
// \todo(addisu) Create a convenient API for applying forces at offset
// positions
const auto totalTorque = torque + cpWorld.Cross(force);
- Link link(this->linkEntity);
- link.AddAndVisualizeWorldWrench(_ecm, force, totalTorque, "LiftDrag");
+ this->link.AddAndVisualizeWorldWrench(_ecm, force, totalTorque, "LiftDrag");
// Debug
// auto linkName = _ecm.Component<components::Name>(this->linkEntity)->Data();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had time to work in more performance improvements upstream. I do like the idea of not publishing a zero wmarker as the marker has been published already. Curious though how slow it is though. The cacheing in the buoyancy plugin seems like a good idea but doesn't belong in this PR. Fundamentally the upstream marker manager should be rewritten though as we seem to be doing a lot of work on a render thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious though how slow it is though.
With the ign-gui
PR, tens of thousands of markers get dropped for me, which causes the visualization to be outdated and eventually it doesn't match the model anymore.
The cacheing in the buoyancy plugin seems like a good idea but doesn't belong in this PR.
The caching that I proposed above happens within Link
and is used directly by the new function being added in this PR.
I think it's ok for this kind of optimization to come later if we have a working version to start with. But this PR is not working for me. I'm not being able to reproduce your gifs from above, maybe I just need a different branch combination?
Fundamentally the upstream marker manager should be rewritten though as we seem to be doing a lot of work on a render thread.
I agree that the marker manager could be improved, but I think there are lots of improvements we can do in this PR too to avoid publishing unnecessary markers. Even if the marker manager is improved to handle a stream of thousands of repeated markers, I don't think we should be publishing that.
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Hi @arjo129, it would be great to have force visualisation supported and have started to look at / modify this PR on https://github.com/srmainwaring/gz-sim/commits/arjo/forceviz. It's WIP but some thoughts so far:
It's still a |
Thanks! It's great to have some help. Yeah those are great suggestions. For now your best bet is to publish messages as the gui client runs in a different process from the server. |
Yes, the physics plugins running in the server will still publish a wrench message of some type (at say 50Hz), but the visualization plugin will render directly rather than publish marker messages. This should help performance. |
That sounds perfect. |
I've got an initial version running using entity_wrench instead of the custom wrench_visual messages. I've used your approach to retrieve the messages via components from the ECM in the GUISystem plugin, however only the first message is retrieved and subsequent updates from Link are not captured. Do you have any insight what might be causing this? (your comments in the last few commits seem to indicate this was an outstanding problem). |
That is indeed something that I ran into. For whatever reason updating the message does not seem to work as expected. At this point my best guess is it may have something to do with serialization. Perhaps we aren't serializing the whole ecm when sending it over to the gui and the way that we handle incremental serialization may be broken. |
Yes, there is something odd going on. If I try to retrieve the pose and entityWrench (a new component containing msgs::EntityWrench) components using _ecm.Each<components::WorldPose, components::EntityWrench>(
[&](const Entity &_entity,
components::WorldPose *_worldPose,
components::EntityWrench *_entityWrench) -> bool
{
...
} only the first update is received. On the other hand: _ecm.Each<components::WorldPose>(
[&](const Entity &_entity,
components::WorldPose *_worldPose) -> bool
{
...
} updates the pose correctly. So perhaps there is something missing in the component data update in Update Inspecting the way that _ecm.SetChanged(this->dataPtr->id, components::EntityWrench::typeId, state); And now it works! |
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Visualize the forces Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Make cylinders point in correct direction. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Buoyancy Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add a fancy UI Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add panel mode Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add visible force list Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add color selection Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add force visuallization Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add scale factor Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> set default 1 Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Remove need for specificying color Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Codecheck Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> update the API according to the PR feedback Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> remove dependence on ECM for GUI update Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> update the API according to the PR feedback Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> add multicopter to log Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Move to ECM to improve time sync issues Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> still broken Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> removing component also doesn't seem to work. Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: rebase on main (gz-sim8) Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: extend gazebosim#1184 1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: modify lift-drag example - Modify example to use JointController rather than ApplyForce. - Add GUI config example for VisualizeForce plugin. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: ensure world pose is enabled when publishing forces - Enable WorldPose and EntityWrench components if visualization label is set. - Add methods to clean up force visuals. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: fix issue where only one force per link was visible - Add component that publishes a map of wrenches keyed by the force label for each entity. - Update Link to populate and publish the component. - Update VisualizeForces to read all the forces for each entity. - The component requires a custom serializer. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: update render function - Follow naming used in VisualizationCapabilities. - Remove FindScene and use existing function in gz::rendering. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: update error message in Link - Publish error once. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: add user configurable update rate - Add parameter to control update rate on GUI. - Provide additional debug info. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: add debug info - Publish both EntityWrench (single message) and EntityWrenches (map) from Link. - Process both EntityWrench and EntityWrenches in the VisualizeForces update. - Toggle #if - #endif to compare update refresh (single message updating, map is not). Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: use msgs::EntityWrenchMap message. - Use new message type msgs::EntityWrenchMap. - Disable components::EntityWrench and components::EntityWrenches. - Enable components::EntityWrenchMap. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: remove custom config used for debugging. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: remove unused code. - Remove unused components. - Remove debug / prototyping code from Link and VisualizeForces. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Visualize the forces Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Make cylinders point in correct direction. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Buoyancy Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add a fancy UI Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add panel mode Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add visible force list Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add color selection Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add force visuallization Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Add scale factor Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> set default 1 Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Remove need for specificying color Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Codecheck Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> update the API according to the PR feedback Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> remove dependence on ECM for GUI update Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> update the API according to the PR feedback Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> add multicopter to log Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Move to ECM to improve time sync issues Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> still broken Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> removing component also doesn't seem to work. Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org> Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: rebase on main (gz-sim8) Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: extend gazebosim#1184 1 Replace markers with direct use of visuals. - In QML use Text.AlignVCenter instead of VerticalAlignment.Center on Label. - Modify indent in header file (no-indent in namespace). - Use Visuals directly instead of publishing marker messages. 2. Add EntityWrench component. - Add EntityWrench component with data msgs::EntityWrench. - Publish EntityWrench - Remove unused marker code from VisualizeForces. 3. Remove WrenchVisual_V component - Remove the WrenchVisual_V component. - Remove dependency on wrench_visual messages. - Update getRenderColor function to use msgs::EntityWrench. 4. Update Link - Remove pose lookup from EntityWrench section. - Adjust indentation. 5. Add pose to entity wrench queue - Capture entity pose as well as wrench data. 6. Mark EntityWrench component as changed in Link - Ensure SetChanged is called when EntityWrench component is updated. - Account for force direction when displaying visual. 7. Linter fixes 8. Simplify example gui config 9. Linter fixes 10. Set visualization label to null option if label is empty. 11. Fix force pose. - Only require the position of the link pose (not its orientation). 12. Remove unused code - Remove translation of visual as arrows have origin at shaft base. - Remove thread debug comments (not required). - Comment removal of components - should not be required now Link.cc used SetChanged. 13. Add parameter to control scale of visual - Add parameter <scale>. - Update class doc strings. - Rename arrowVisuals to visuals. - Remove further debug comments. - Scale visual by force magnitude. 14. Linter fixes 15. Disable arrow head as it does not scale correctly 16. VisualizeForces: update copyright notice. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: modify lift-drag example - Modify example to use JointController rather than ApplyForce. - Add GUI config example for VisualizeForce plugin. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: ensure world pose is enabled when publishing forces - Enable WorldPose and EntityWrench components if visualization label is set. - Add methods to clean up force visuals. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: fix issue where only one force per link was visible - Add component that publishes a map of wrenches keyed by the force label for each entity. - Update Link to populate and publish the component. - Update VisualizeForces to read all the forces for each entity. - The component requires a custom serializer. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: update render function - Follow naming used in VisualizationCapabilities. - Remove FindScene and use existing function in gz::rendering. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: update error message in Link - Publish error once. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: add user configurable update rate - Add parameter to control update rate on GUI. - Provide additional debug info. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: add debug info - Publish both EntityWrench (single message) and EntityWrenches (map) from Link. - Process both EntityWrench and EntityWrenches in the VisualizeForces update. - Toggle #if - #endif to compare update refresh (single message updating, map is not). Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: use msgs::EntityWrenchMap message. - Use new message type msgs::EntityWrenchMap. - Disable components::EntityWrench and components::EntityWrenches. - Enable components::EntityWrenchMap. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: remove custom config used for debugging. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> VisualizeForces: remove unused code. - Remove unused components. - Remove debug / prototyping code from Link and VisualizeForces. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
🎉 New feature
Summary
Force visualization - Opening PR for visibility.
This PR adds the ability to visualize forces via a GUI plugin as they get applied by plugins. It depends on the following PR in ignition msgs: gazebosim/gz-msgs#200
Here are some fancier gifs:
Test it
Go to the three dots and select "Visuallize Forces".
TODO:
Use arrows(do this in a separate PR)Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge