ros-controls / ros2_control_demos

This repository aims at providing examples to illustrate ros2_control and ros2_controllers
https://control.ros.org
Apache License 2.0
412 stars 187 forks source link

Position data copied to velocity field of trajectory point message #427

Closed ecmjohnson closed 9 months ago

ecmjohnson commented 10 months ago

Example 7's trajectory generator copies position data to the trajectory point message's velocity vector (see snippet below). The example seems to work as expected regardless so if this is intended it would be nice to have a comment explaining why this is necessary.

https://github.com/ros-controls/ros2_control_demos/blob/efe3aa2446ebc1aa43cccd586d568cb25c3b0f49/example_7/reference_generator/send_trajectory.cpp#L79-L85

Changing to copy velocity data to the trajectory point message's velocity vector doesn't change the example's behaviour so I'm assuming only the position field of the trajectory point is used by the controller.

christophfroehlich commented 9 months ago

Thanks for reporting this. I think it also takes the velocity field

https://github.com/ros-controls/ros2_control_demos/blob/efe3aa2446ebc1aa43cccd586d568cb25c3b0f49/example_7/controller/r6bot_controller.cpp#L168-L171

but the hardware plugin does not check if velocity and/or position is commanded, it just overrides with the position if both are given. Introspection of the joint_states/velocity should make a difference though? https://github.com/ros-controls/ros2_control_demos/blob/efe3aa2446ebc1aa43cccd586d568cb25c3b0f49/example_7/hardware/r6bot_hardware.cpp#L105-L114

Do you want to create a PR fixing this?