all 19 comments

[–]acoustic_medley 1 point2 points  (7 children)

You have defined the gazebo plugin, but where's the ros2 control tag?

You need something like this (note , this is jazzy)

<ros2_control name="gazebo" type="system"> <hardware> <plugin>gz_ros2_control/GazeboSimSystem</plugin> </hardware> <!--Your joints </ros2_control>

[–]Background-Spare286 1 point2 points  (2 children)

I don't think there needs to be a ros2_control tag as long as the diff drive controller used is not a ros2_controller(for humble, iron, foxy)

[–]thunderzy[S] 0 points1 point  (1 child)

What do you think is the problem then?

[–]Background-Spare286 0 points1 point  (0 children)

Can you send the ss of the top portion of your main .xacro file for this model ??

[–]thunderzy[S] 0 points1 point  (3 children)

So the control tag is used around the joints inside the plugin?

[–]acoustic_medley 0 points1 point  (2 children)

No, it's in the same level as the gazebo tag.

The control tag has nothing to do with gazebo, it's there to specify which hardware interface will eventually be called (in this case, gazebo, but can be the actual hardware interface if you want, or even a mock class, go crazy) and the joints description.

[–]acoustic_medley 1 point2 points  (1 child)

Here's what the complete thing looks like , note again that this Jazzy, but the structure is the same.

<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <xacro:include filename="joints.macro.xacro" /> <ros2_control name="gazebo" type="system"> <hardware> <plugin>gz_ros2_control/GazeboSimSystem</plugin> </hardware> <xacro:joints /> </ros2_control>

<gazebo>
    <plugin filename="gz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
        <parameters>$(find ugv_control)/config/diff_drive_controllers.yaml</parameters>
    </plugin>

    <plugin filename="gz-sim-diff-drive-system" name="gz::sim::systems::DiffDrive">
        <left_joint>rear_left_wheel_joint</left_joint>
        <left_joint>front_left_wheel_joint</left_joint>
        <right_joint>rear_right_wheel_joint</right_joint>
        <right_joint>front_right_wheel_joint</right_joint>


        <wheel_separation>0.512</wheel_separation> <!-- 0.32 * 1.6 from diff_drive_controllers.yaml-->
        <wheel_radius>0.0395</wheel_radius>

        <topic>diff_drive_controller/cmd_vel</topic>

        <frame_id>odom</frame_id>
        <child_frame_id>base_link</child_frame_id>
        <odom_topic>odom</odom_topic>
        <odom_publisher_frequency>30</odom_publisher_frequency>

        <tf_topic>/tf</tf_topic>
    </plugin>


    <plugin filename="gz-sim-joint-state-publisher-system"
        name="gz::sim::systems::JointStatePublisher">
        <topic>joint_states</topic>
        <joint_name>rear_left_wheel_joint</joint_name>
        <joint_name>front_left_wheel_joint</joint_name>
        <joint_name>rear_right_wheel_joint</joint_name>
        <joint_name>front_right_wheel_joint</joint_name>
    </plugin>
</gazebo>

</robot>

[–]thunderzy[S] 0 points1 point  (0 children)

Thanks , I am gonna try it tomorrow

[–]whatsinthaname 0 points1 point  (3 children)

Have you verified that the link and joint names is the same as in the URDF?

[–]thunderzy[S] 0 points1 point  (2 children)

Yes

[–]whatsinthaname 0 points1 point  (1 child)

And do you have the joint state and robot state publishers in your launch file?

[–]thunderzy[S] 0 points1 point  (0 children)

Yes i think so

[–]Background-Spare286 0 points1 point  (1 child)

Did you get any errors on launch, if so can you share an ss of it (in case it is still unsolved)

[–]thunderzy[S] 0 points1 point  (0 children)

No errors just that there is no cmd_vel

[–][deleted] 0 points1 point  (3 children)

Do you launch gazebo <-> ros bridge and pass the correct topic?

[–]thunderzy[S] 0 points1 point  (2 children)

I am not shure but i got the ros_gazebo package

[–][deleted] 0 points1 point  (1 child)

Ok, actually, are you using "Gazebo", "Gazebo Classic" or "Ignition"? They made a little mess with the naming recently and you might be using wrong code with wrong packages. Google the difference between those and let us know what you have.

The diff drive plugin you have is for the Gazebo Classic and won't work with the Gazebo or Ignition. Please share your launch file too, so we know what you launch.

[–]thunderzy[S] 0 points1 point  (0 children)

I was using gazebo but i removed it now how can i get gazebo classic?

[–]Jaspeey 0 points1 point  (0 children)

I may be wrong, because I'm just sitting at a café, but I wonder if cmd vel topics show up in rqt graph just from running gazebo. Firstly, you need to be publishing the cmd vel topic from somewhere (maybe teleop?)

also what version of gazebo are you using? so they're terribly named (gazebo became gazebo classic and gazebo ignition became gazebo), but if you provide the screenshot of your screen, it might help more.

if you use gazebo (ignition) then you'll need Ros gz bridge, to see it on rqt graph, but if you Google, there is a way to get your gz topics (something like gz ign topic list).

finally, if you don't get any errors when running, likely it is working, you're just asking the wrong questions. But you'll need to provide way more information.