UniversalRobots / Universal_Robots_ROS2_Gazebo_Simulation

BSD 3-Clause "New" or "Revised" License
69 stars 29 forks source link

Gazebo and RViz seem to be some sort of asynchronous when used with joint_state_publisher_gui #25

Closed Icon45 closed 1 year ago

Icon45 commented 1 year ago

Hi,

i’ve tried to use the joint state pubisher gui to move the robot in rviz and Gazebo. While i was getting movement in RViz the robot in Gazebo stood still.

I’ve also noticed that when i fire up the launch file with the joint state publisher gui the robot in RViz is orientated horizontally and the one in Gazebo stands up vertically.

danzimmerman commented 1 year ago

This is normal, the motion of the robot in Gazebo is controlled by the ros2_control controller joint_trajectory_controller. You need to send appropriate action goal messages (FollowJointTrajectoryGoal) to that controller.

joint_state_publisher_gui is useful for visualization when you don't have a "robot" publishing joint states.

In the case of Gazebo simulation, the "robot" is Gazebo, plugins, and associated other nodes, which include a joint state broadcaster that gets the actual joint angles, velocities, etc. reported by the joints in the physics simulation and publishes them on /joint_states (see here).

If you want a test to get the Gazebo-simulated robot to move, try

ros2 launch ur_robot_driver test_joint_trajectory_controller.launch.py

The robot should move around and RViz should follow along, since it's listening to the joint states published by the broadcaster.

I don't know off the top of my head if there's a GUI equivalent to joint_state_publisher_gui that you could use to send slider-driven commands to a ros2_control controller... usually that would be kind of dangerous on a real robot and you wouldn't want to do it, at least not without some supervisory checking of how fast the robot would move.

Icon45 commented 1 year ago

Thank you very much for the explanation!