-
Notifications
You must be signed in to change notification settings - Fork 771
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
[ros2] Port get/set properties services #868
Conversation
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.
Thank you for getting started on this! The general direction looks good to me, I'm happy to review this again once you make more progress.
Also, I think you've already seen this, but just in case, here's a guide that should help a bit. For example, you can remove all references to Gazebo <= 8.
|
||
void GazeboRosPropertiesPrivate::GetWorldProperties( | ||
gazebo_msgs::srv::GetWorldProperties::Request::SharedPtr _req, | ||
gazebo_msgs::srv::GetWorldProperties::Response::SharedPtr _res) |
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 agree with @ironmig that GetWorldProperties
has a misleading name and if we want to keep the functionality we should rename it to GetModelList
.
} | ||
} | ||
|
||
/*void GazeboRosPropertiesPrivate::SetPhysicsProperties( |
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.
Yes, I agree that it's good to avoid duplication, and porting just the dynamic reconfigure part should be enough. Note that on ROS 2 that would be implemented with basic parameters, I think you'll need to register a callback with ros_node_->register_param_change_callback.
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.
Review.
Regarding the required tests, I guess the services that have a get/set are pretty straight forward to implement. What about the test for Is it a good idea to spawn a custom xml file and expect the |
Continuing the test discussion: GetJointProperties.srv [Response]
SetJointProperties.srv [Request]
ODEJointProperties message
|
Note: updated PR commit. Update: Confusion between different pose elements. Leaving as it was in ros1 version. |
Probably the easiest way would be to have the model already in the world instead of going through the trouble of spawning it. For example, this test world has a simple model with a joint.
I vote for removing duplication and having a clear separation of concerns across the plugins.
Very good point. This touches a broader topic about refactoring physics properties so that those which are common across physics engines are in a common message and only the engine specific ones are in separate messages. This subject is definitely larger than the scope of this pull request though, ideally we will eventually have some consistency across So I'd propose one of these solutions for now:
|
Regarding
The reason is that another package I have to migrate is using the ODE-> damping. Will keep this for now . I will spend some time with the new organization of joint properties across physics engines once the ros2 branch gets stable (merges _state, _time_cmds and upcoming _properties). Not vital thing right now. |
Updated main commit right now. Current state. UPDATED:
TODO:
|
Hi @chapulina, Pushed ready-to-merge code, ready for a new review, possibly final?. CI errors are fine on my side. Regarding dynamic physics reconfigure:
|
TODO(@nzlz ) : rebase against new PS: Sorry I haven't been able to make time to review the latest changes. |
Rebased against |
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.
Sorry for the delay! I did another pass on the PR.
One thing that stood out to me is how the messages use outdated fields, like body
and geom
to refer to link
and collision
. It would be really nice to update those, but I understand if this is too much trouble.
I started fixing some linter errors on cb891db, but could you take care of the rest? Make sure there are no failures when you run colcon test --packages-select gazebo_ros
.
Great demo and tests!
gazebo_msgs/srv/GetModelList.srv
Outdated
float64 sim_time # current sim time | ||
string[] model_names # list of models in the world | ||
bool success # return true if get successful | ||
string status_message # comments if available |
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.
Mind removing the status_message
field? It's something that is present in gazebo_ros1
and we'd like to stop doing. I also added a note to the contribution guide. No need to remove it from the old messages you're using.
@@ -44,6 +46,12 @@ class GazeboRosFactoryPrivate | |||
/// \param[in] _world_name The world's name | |||
void OnWorldCreated(const std::string & _world_name); | |||
|
|||
/// \brief Function for receiving the model list from a gazebo world. | |||
/// \param[out] res Response |
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.
Please document all fields, even if they're going to be ignored
gazebo_msgs/srv/GetModelList.srv
Outdated
@@ -0,0 +1,5 @@ | |||
--- | |||
float64 sim_time # current sim time |
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.
How about getting rid of this field and putting sim time in the header instead? Like this:
_res->header.stamp = Convert<builtin_interfaces::msg::Time>(world_->SimTime());
@@ -19,7 +19,9 @@ | |||
#include <gazebo/physics/Entity.hh> | |||
#include <gazebo/physics/PhysicsIface.hh> | |||
#include <gazebo/physics/World.hh> | |||
#include <gazebo/physics/Model.hh> |
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.
Nitpick: keep includes in alphabetic order
#include <gazebo_msgs/srv/set_link_properties.hpp> | ||
#include <gazebo_msgs/srv/set_light_properties.hpp> | ||
#include <gazebo_msgs/srv/set_physics_properties.hpp> | ||
#include <gazebo_ros/node.hpp> |
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.
Alphabetize includes
_res->diffuse.r = light.diffuse().r(); | ||
_res->diffuse.g = light.diffuse().g(); | ||
_res->diffuse.b = light.diffuse().b(); | ||
_res->diffuse.a = light.diffuse().a(); |
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.
Consider adding a conversion function from gazebo::msgs::Color
to std_msgs::ColorRGBA
, not required though
for(unsigned int i = 0;i< _req->ode_joint_config.fmax.size();i++) | ||
joint->SetParam("fmax", i, _req->ode_joint_config.fmax[i]); | ||
for(unsigned int i = 0;i< _req->ode_joint_config.vel.size();i++) | ||
joint->SetParam("vel", i, _req->ode_joint_config.vel[i]); |
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.
humm vel
doesn't seem to work for me. Not an issue with this PR though, probably a problem on Gazebo.
ros2 service call /demo/set_joint_properties 'gazebo_msgs/SetJointProperties' '{joint_name: "simple_arm::arm_shoulder_pan_joint", ode_joint_config: {damping: {1.0}}}' | ||
|
||
Or a links properties: | ||
ros2 service call /demo/set_link_properties 'gazebo_msgs/SetLinkProperties' '{link_name: "simple_arm::arm_base", mass: 150.0 , izz: 2.0}' |
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.
This is fun 😄
mass->SetInertiaMatrix(_req->ixx, _req->iyy, _req->izz, _req->ixy, _req->ixz, _req->iyz); | ||
mass->SetMass(_req->mass); | ||
body->SetGravityMode(_req->gravity_mode); | ||
// @todo: mass change unverified |
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.
Your demo shows that this works, so this todo can be removed
gazebo_msgs::srv::SetLightProperties::Response::SharedPtr _res) | ||
{ | ||
gazebo::physics::LightPtr phy_light = world_->LightByName(_req->light_name); | ||
if (phy_light == NULL) { |
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.
Please use nullptr
instead of NULL
* [ros2] World plugin to get/set entity state services (#839) remove status_message * [ros2] Port time commands (pause / reset) (#866) * [ros2] Migration of get/set world, model, joint, link, light properties * Trying to pass CI test, try n1. * clean up some linter warnings * Requested changes in review, unfinished * Fix uncrustify * Address reviews * more tests, joint types Signed-off-by: Louise Poubel <louise@openrobotics.org> * Revert changes to GetModelProperties message Document gazebo_ros_properties header * Convert msgs pose to math pose and use it on SetCoG Signed-off-by: Louise Poubel <louise@openrobotics.org>
This has been merged into |
* [ros2] Port elevator to ROS2 * [ros2] Fix test for diff drive (ros-simulation#951) * use c_str() (ros-simulation#950) (ros-simulation#954) Signed-off-by: Karsten Knese <karsten@openrobotics.org> * [ros2] Port projector to ROS2 (ros-simulation#956) * [ros2] Port projector to ROS2 * fix small typo * [ros2] Port planar move to ROS2 (ros-simulation#958) * [ros2] Port planar move to ROS2 * Add test for pose conversion * [ros2] Add ackermann drive plugin (ros-simulation#947) * [ros2] Add ackermann drive plugin * Minor fixes Use gazebo database model * Update example usage * Fix TF for demo * changelog * 3.3.2 * [ros2] Port harness to ROS2 (ros-simulation#944) * [ros2] Port hand of god to ROS2 (ros-simulation#957) * [ros2] Port hand of god to ROS2 * Minor fixes * [ros2] Port model states to ROS2 (ros-simulation#968) * [ros2] Port model states to ROS2 * remove unported code Signed-off-by: Louise Poubel <louise@openrobotics.org> * Add Gazebo builtin plugins to LD_LIBRARY_PATH (ros-simulation#974) * Add Gazebo builtin plugins to LD_LIBRARY_PATH Signed-off-by: Louise Poubel <louise@openrobotics.org> * cross-platform Signed-off-by: Louise Poubel <louise@openrobotics.org> * [ros2] Fix tests on Dashing (ros-simulation#953) * [ros2] Fix camera triggered test on Dashing backport remove noe fix and re-enable distortion tests * improve robustness of joint state pub test Signed-off-by: Louise Poubel <louise@openrobotics.org> * Fix for multiple video plugins (ros-simulation#898) (ros-simulation#937) * Fix for multiple video plugins (ros-simulation#898) * Fix crash on shutdown * Fix gazebo node destructor * [ros2] Port bumper sensor to ROS2 (ros-simulation#943) * [ros2] Port bumper sensor to ROS2 * Add author name * Minor fixes and add contact msg conversion * Remove unused header includes * [ros2] Port gazebo_ros_path plugin to ROS2 (ros-simulation#925) * [ros2] Port gazebo_ros_path plugin * Minor fixes * Change plugin launch file to python script * Fix for flake8 test * set gazebo library dirs (ros-simulation#963) Signed-off-by: Karsten Knese <karsten@openrobotics.org> * [ros2] Port Link states to ROS2 (ros-simulation#969) * [ros2] Port model states to ROS2 * [ros2] Port link states to ROS2 * Change usage of body -> link * Remove link_states from .ros1_unported * fix video test Signed-off-by: chapulina <louise@openrobotics.org> * [ros2] Port joint pose trajectory to ROS2 (ros-simulation#955) * [ros2] Port joint pose trajectory to ROS2 * Add conversion tests Minor fixes * [ros2] Port gazebo launch scripts to ROS2 (ros-simulation#962) * [ros2] Port gazebo launch scripts to ROS2 * Add gdb and valgrind option * Use shell command for extra gazebo args * [ros2] Port vacuum gripper to ROS2 (ros-simulation#960) * [ros2] Port vacuum gripper to ROS2 * Fix gripper forces * Add option to set max_distance Change SetForce -> Add Force * [ros2] Port spawn model to ROS2 (ros-simulation#948) * [ros2] Port spawn model to ROS2 * Delete .ros1_unported files * Fixes and add demo Change spawn_model to spawn_entity * Rename demo launch and add checks for service * Fix reading xml file from param and model states * remove diplicate Signed-off-by: Louise Poubel <louise@openrobotics.org> * Use gazebo launch file * Change topic behaviour * [ros2] Spawn <plugin> without <ros> (ros-simulation#983) Signed-off-by: Louise Poubel <louise@openrobotics.org> * [ros2] Backport depth camera to dashing (ros-simulation#967) * [ros2] Backport depth camera to dashing * don't install header that will be removed Signed-off-by: Louise Poubel <louise@openrobotics.org> * fix linting error Signed-off-by: Louise Poubel <louise@openrobotics.org> * Address reviews on ros-simulation#868 (ros-simulation#972) * [ros2] World plugin to get/set entity state services (ros-simulation#839) remove status_message * [ros2] Port time commands (pause / reset) (ros-simulation#866) * [ros2] Migration of get/set world, model, joint, link, light properties * Trying to pass CI test, try n1. * clean up some linter warnings * Requested changes in review, unfinished * Fix uncrustify * Address reviews * more tests, joint types Signed-off-by: Louise Poubel <louise@openrobotics.org> * Revert changes to GetModelProperties message Document gazebo_ros_properties header * Convert msgs pose to math pose and use it on SetCoG Signed-off-by: Louise Poubel <louise@openrobotics.org> * [ros2] Adding GPS plugin (ros-simulation#982) * Adding gps plugin sensor * Adding test for the gps plugin * Adding GPS world demo and other small text corrections * [ros2] Adding option to select the frame where the force will be applied (ros-simulation#978) * Adding option to select the frame where the force will be applied A new parameter was added on the plugin with the options 'world' and 'link' frame. The default value is 'world'. Internally the AddRelativeForce() and torque functions are used instead of the AddForce() when the body option is selected. * Modifying force test for the 'world' frame, and adding test for the force on the 'link' frame The new world file starts with the box rotated. * Fix cpplint and uncrustify on force plugin files * Removing OnUpdateRelative() from the force plugin This function could potentially break the ABI, therefore is been removed. * body -> link, warn -> info, more examples Signed-off-by: Louise Poubel <louise@openrobotics.org> * [backport] Backport multicamera to dashing (ros-simulation#984) * [backport] Backport multicamera to dashing * fix test - use correct world Signed-off-by: Louise Poubel <louise@openrobotics.org> * Add maintainer (ros-simulation#985) Signed-off-by: Louise Poubel <louise@openrobotics.org> * [ros2] Conditional launch includes (ros-simulation#979) * [ros2] Conditional launch includes Signed-off-by: Louise Poubel <louise@openrobotics.org> * remove unused import Signed-off-by: Louise Poubel <louise@openrobotics.org> * changelog Signed-off-by: Louise Poubel <louise@openrobotics.org> * 3.3.3 * [ros2] Uncommenting bond option on spawn_entity (wait Ctrl+C then remove entity) (ros-simulation#986) * Uncommenting bond option on spawn_entity (wait Ctrl+C then remove entity) Instead of waiting for a shutdown callback to be created in rclpy, we can use the try/except to get the SIGINT signal, then delete the entity. * Message formatting Signed-off-by: Louise Poubel <louise@openrobotics.org> * linter 😅 Signed-off-by: Louise Poubel <louise@openrobotics.org> * [ros2] Remove ported / deprecated (ros-simulation#989) Signed-off-by: Louise Poubel <louise@openrobotics.org> * Remove ROS-specific arguments before passing to argparse (ros-simulation#994) This resolves argparse errors when trying to launch the spawn_entity script as a ROS node. For example, a launch file like the following wouldn't work without this change: <launch> <arg name="model_urdf" default="$(find-pkg-share mymodels)/urdf/ball.urdf" /> <node pkg="gazebo_ros" exec="spawn_entity.py" name="spawner" args="-entity foo -file /path/to/my/model/foo.urdf" /> </launch> Signed-off-by: Jacob Perron <jacob@openrobotics.org> * fix multi_camera_plugin on windows (ros-simulation#999) * changelog Signed-off-by: Louise Poubel <louise@openrobotics.org> * 3.3.4 * Update changelogs * 3.4.0 * generate a .dsv file for the environment hook * Update changelogs * 3.4.1 * changelog Signed-off-by: Louise Poubel <louise@openrobotics.org> * 3.4.2 * fix pathsep for windows (ros-simulation#1028) * Image publishers use SensorDataQoSProfile (ros-simulation#1031) All other sensor publishers were updated previously to use the same profile (ros-simulation#926). I'm not sure if the image publishers were overlooked or the image_transport API didn't support setting the QoS profile at the time. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * [backport][ros2] make transient local reliable (ros-simulation#1033) (ros-simulation#1036) * [ros2] make transient local reliable (ros-simulation#1033) * make transient local reliable Signed-off-by: Karsten Knese <karsten@openrobotics.org> * fix master Signed-off-by: Karsten Knese <karsten@openrobotics.org> * add launch test Signed-off-by: Karsten Knese <karsten@openrobotics.org> * make it actual latched Signed-off-by: Karsten Knese <karsten@openrobotics.org> * alpha sort Signed-off-by: Karsten Knese <karsten@openrobotics.org> * add launch_test dependency Signed-off-by: Karsten Knese <karsten@openrobotics.org> * more dependencies Signed-off-by: Karsten Knese <karsten@openrobotics.org> * remove debug print Signed-off-by: Karsten Knese <karsten@openrobotics.org> * is_initialized -> ok Signed-off-by: Karsten Knese <karsten@openrobotics.org> * Update gazebo_ros/test/entity_spawner.test.py Co-Authored-By: chapulina <louise@openrobotics.org> * use erase-remove idiom Signed-off-by: Karsten Knese <karsten@openrobotics.org> * use ReadyToTest() Signed-off-by: Karsten Knese <karsten@openrobotics.org> Co-authored-by: chapulina <louise@openrobotics.org> * Set timeout and call gzserver directly Signed-off-by: Louise Poubel <louise@openrobotics.org> Co-authored-by: chapulina <louise@openrobotics.org> * changelog Signed-off-by: Louise Poubel <louise@openrobotics.org> * 3.4.3 * Measure IMU orientation with respect to world (ros-simulation#1058) Report the IMU orientation from the sensor plugin with respect to the world frame. This complies with convention documented in REP 145: https://www.ros.org/reps/rep-0145.html In order to not break existing behavior, users should opt-in by adding a new SDF tag. Co-authored-by: Jacob Perron <jacob@openrobotics.org> * Measure IMU orientation with respect to world (dashing) (ros-simulation#1065) Report the IMU orientation from the sensor plugin with respect to the world frame. This complies with convention documented in REP 145: https://www.ros.org/reps/rep-0145.html In order to not break existing behavior, users should opt-in by adding a new SDF tag. Co-authored-by: Jacob Perron <jacob@openrobotics.org> * wait for service with variable timeout (ros-simulation#1090) * wait for service with variable timeout Signed-off-by: Karsten Knese <karsten@openrobotics.org> Co-authored-by: chapulina <louise@openrobotics.org> * Backport Gazebo11/Bionic fix for boost variant (ros-simulation#1102) * Backport Gazebo11/Bionic fix for boost variant (ros-simulation#1103) * Prepare changelogs * 3.3.5 * Prepare changelogs * 3.4.4 * [eloquent] Fix Windows build. (ros-simulation#1077) * Adding Windows bringup. * Remove unported gazebo_ros_control (ros-simulation#1108) Signed-off-by: Louise Poubel <louise@openrobotics.org> * use target include directories (ros-simulation#1040) Signed-off-by: Karsten Knese <karsten@openrobotics.org> Co-authored-by: Louise Poubel <louise@openrobotics.org> * Apply acceleration until both left and right reach targetspeed (ros-simulation#1009) Co-authored-by: Louise Poubel <louise@openrobotics.org> * Fix all Foxy tests Signed-off-by: Louise Poubel <louise@openrobotics.org> * uncrustifyyyyyy Signed-off-by: Louise Poubel <louise@openrobotics.org> * changelog Signed-off-by: Louise Poubel <louise@openrobotics.org> * 3.5.0 Co-authored-by: Shivesh Khaitan <shiveshkhaitan@gmail.com> Co-authored-by: chapulina <louise@openrobotics.org> Co-authored-by: Karsten Knese <Karsten1987@users.noreply.github.com> Co-authored-by: alexfneves <alexfneves@gmail.com> Co-authored-by: Jacob Perron <jacob@openrobotics.org> Co-authored-by: Jonathan Noyola <noyolajonathan@gmail.com> Co-authored-by: Jose Luis Rivero <jrivero@osrfoundation.org> Co-authored-by: Dirk Thomas <dirk-thomas@users.noreply.github.com> Co-authored-by: Steven Peters <scpeters@openrobotics.org> Co-authored-by: Sean Yen <seanyen@microsoft.com> Co-authored-by: scgroot <steffen@boast.nl>
First approach to the migration of get/set properties.
As I stated in #779 I am trying to migrate the properties related services to ros2.
This a World plugin. I tried to follow the same structure as
ros2_state
branch.get_physics_properties
andset_physics_properties
are commented as @ironmig stated in #779:Also seems like
get_world_properties
needs some change too:Note: This is just a first version, the intend is not to merge but to discuss the structure of these functionalities.
Note2: I will be off a few days, so feel free to reuse/update this code in any way.