Skip to content
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

/robot_controller/joint_trajectory topic is not translated to Gazebo Sim #456

Open
julianhfmn opened this issue Dec 19, 2024 · 9 comments
Open

Comments

@julianhfmn
Copy link

Hello,

I am on ROS2 Jazzy, Moveit2 and Gazebo Sim Harmonic. I use a custom robot 6DoF Robot which I did the moveit2 setup assistant for, and using the robot with moveit2 in Gazebo Sim Harmonic works.

My issue is, that although launching moveit servo with my custom robot without gazebo is functional, I cannot use it combined with Gazebo Sim.

The issue is see is the Gazebo Plugin for ROS2 Control.

When launching the robot without gazebo, I can use the hardware plugin in my ros2_control.xacro file as this:

    <hardware>
        <plugin>mock_components/GenericSystem</plugin>
    </hardware>

When launching my robot in gazebo, I use the gz_ros2_control package as this:

    <hardware>
        <plugin>gz_ros2_control/GazeboSimSystem</plugin>
    </hardware>

In the case of launching both gazebo and moveit servo, and only launching mock_components plugin, the robot controller I define in gazebo cannot be activated:

[controller_manager]: Could not switch controllers since prepare command mode switch was rejected.

The robot is not actuated and flops onto the ground. This makes sense, as the gazebo plugin is missing.

In the case of launching gz_ros2_control/GazeboSimSystem as my hardware plugin, I can see that my /robot_controller/joint_trajectory topic is populated, but neither the robot in rviz2 nor in gazebo move. Somehow, the gz_ros2_control/GazeboSimSystem does not pick up this topic, although it should? I can see, that the /robot_controller node is subscribed to /robot_controller/joint_trajectory.

I tested this with ompl and the standard moveit2 p2p motion I can set in the MotionPlanning plugin in rviz, and the /robot_controller/joint_trajectory is empty there, too.

How can I get the gazebo sim plugin to transfer my joint trajectory to gazebo and move the simulated robot?
Is it another topic I need to publish to for the plugin to work?

Thanks a lot in advance!

All the best and merry christmas,

Julian

@julianhfmn
Copy link
Author

I made some new findings:
Using either joint or position controllers with a std_msgs/msg/Float64MultiArray type is functional in gazebo.
It seems that only the /robot_controller/joint_trajectory topic is not working?

@christophfroehlich
Copy link
Contributor

Can you only launch gazebo with the robot and its controller and test it with the rqt_joint_trajectory_controller? It uses the same topic.

@julianhfmn
Copy link
Author

I tested what you proposed and neither in gazebo nor in rviz2 the joints move. So I assume even with a correct joint_trajectory message, somehow the control signals don't reach the sim.

@christophfroehlich
Copy link
Contributor

can you provide an example? is it a public repo?

@christophfroehlich
Copy link
Contributor

Furthermore, cart_example_position uses a joint_trajectory controller and this works as it should with rqt_joint_trajectory_controller:
ros2 launch gz_ros2_control_demos cart_example_position.launch.py

tested on rolling with gz_ros2_control from source

ros-rolling-ros-gz-bridge/noble,now 2.1.2-1noble.20241204.195601 amd64 [installed]
ros-rolling-ros-gz-interfaces/noble,now 2.1.2-1noble.20241125.160511 amd64 [installed,automatic]
ros-rolling-ros-gz-sim/noble,now 2.1.2-1noble.20241205.120818 amd64 [installed]

Can you reproduce that with jazzy/harmonic?

@phantson
Copy link

phantson commented Dec 24, 2024

Same issue here, using Gazebo and Ros Jazzy with MoveIt2 i have this error. Furthermore I can't even launch cart_example_position.launch.py, as it closes Gazebo instantly returning this error :

[GUI] [Wrn] [Component.hh:189] Trying to deserialize component with data type [N3sdf3v145WorldE], which doesn't have `operator>>`. Component will not be deserialized.
[gazebo-1] [GUI] [Msg] Loaded plugin [EntityTree] from path [/opt/ros/jazzy/opt/gz_sim_vendor/lib/gz-sim-8/plugins/gui/libEntityTree.so]

@christophfroehlich
Copy link
Contributor

Same issue here, using Gazebo and Ros Jazzy with MoveIt2 i have this error. Furthermore I can't even launch cart_example_position.launch.py, as it closes Gazebo instantly returning this error :

[GUI] [Wrn] [Component.hh:189] Trying to deserialize component with data type [N3sdf3v145WorldE], which doesn't have `operator>>`. Component will not be deserialized.
[gazebo-1] [GUI] [Msg] Loaded plugin [EntityTree] from path [/opt/ros/jazzy/opt/gz_sim_vendor/lib/gz-sim-8/plugins/gui/libEntityTree.so]

This looks like an ABI break or incompatible gz version. How have you installed gz and gz_ros2_control? Have you upgraded anything individually instead of sudo apt-get upgrade everything?

@julianhfmn
Copy link
Author

julianhfmn commented Dec 24, 2024

Can you reproduce that with jazzy/harmonic?

I tested it on jazzy. Only the ros2 run gz_ros2_control_demos example_position script works for me, for the effort and velocity controllers I only receive a:
[INFO] [1735055303.141716459] [effort_test_node]: node created
and the code stops again, without moving the robot.

Interestingly, although the robot moves in gazebo, the /joint_trajectory_controller/joint_trajector ros2 topic is not populated? I echo the topic and receive nothing, is it the same for you @christophfroehlich?

gz_ros2_control as well as the demos are installed as binaries for me.

My own repo sadly is not public, but using the moveit servo tutorial with the panda:
ros2 launch moveit_servo demo_ros_api.launch.py
I can move the robot and I also can echo the joint_trajectory topic, which works in my repo as well, only that the results are not translated to gazebo.
I could try a source install and see if that changes anything?
Although right now the velocity control works for me, too.

@christophfroehlich
Copy link
Contributor

Can you reproduce that with jazzy/harmonic?

I tested it on jazzy. Only the ros2 run gz_ros2_control_demos example_position script works for me, for the effort and velocity controllers I only receive a:
[INFO] [1735055303.141716459] [effort_test_node]: node created
and the code stops again, without moving the robot.

the example_ executables create a publisher and send some values, but don't launch gazebo. Try the launch files instead. See the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants