My robot controllers work with gazebo plugin, but not without it
My robot us able to be controlled in gazebo, using the rosrun teleoptwist keyboard (node). However, if i directly use
rostopic pub /head_controller_1/command std_msgs/Float64 "data: 1000.0"
or
rostopic pub /head_controller_/command std_msgs/Float64 "data: 1000.0"
The robot is not moving in gazebo. But I can see the joints and the robot wheels rotating in Gazebo.
This is the code for my robots xacro file: I defined the controllers in a separate config.yaml file:
<?xml version="1.0" ?>
<robot name="walle" xmlns:xacro="http://www.ros.org/wiki/xacro">
<gazebo reference="base_link">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="link_01">
<material>Gazebo/Yellow</material>
</gazebo>
<gazebo reference="link_02">
<material>Gazebo/Yellow</material>
</gazebo>
<gazebo>
<plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller">
<legacyMode>false</legacyMode>
<alwaysOn>true</alwaysOn>
<updateRate>20</updateRate>
<leftJoint>base_link__link_01</leftJoint>
<rightJoint>base_link__link_02</rightJoint>
<wheelSeparation>0.2</wheelSeparation>
<wheelDiameter>0.35</wheelDiameter>
<torque>0.1</torque>
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<robotBaseFrame>base_link</robotBaseFrame>
</plugin>
</gazebo>
<link name="base_link">
<visual>
<origin rpy="0 0 0" xyz="0 0 0.1"/>
<geometry>
<box size="2 1 0.3"/>
</geometry>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0.1"/>
<geometry>
<box size="2 1 0.3"/>
</geometry>
</collision>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0.1"/>
<mass value="1"/>
<inertia ixx="0.03" ixy="0.0" ixz="0.0" iyy="0.03" iyz="0.0" izz="0.03"/>
</inertial>
<collision name="caster_front_collision">
<origin rpy="0 0 0" xyz= "0.5 0 -0.05"/>
<geometry>
<sphere radius="0.25"/>
</geometry>
<surface>
<friction>
<ode>
<mu>0</mu>
<mu2>0</mu2>
<slip1>1.0</slip1>
<slip2>1.0</slip2>
</ode>
</friction>
</surface>
</collision>
<visual name="caster_front_visual">
<origin rpy="0 0 0" xyz ="0.5 0 -0.05"/>
<geometry>
<sphere radius="0.25"/>
</geometry>
</visual>
</link>
<joint name="base_link__link_01" type="continuous">
<axis xyz="0 1 0"/>
<limit effort = "10.0" velocity="1.0"/>
<joint_properties damping="1.0" friction="1.0"/>
<!--<limit effort = "1000.0" lower="-3.14" upper="3.14" velocity="0.5"/>-->
<origin rpy="0 0 0" xyz="-0.5 0.5 0"/>
<parent link="base_link"/>
<child link="link_01"/>
</joint>
<transmission name="trans_base_link__link_01">
<type>transmission_interface/SimpleTransmission</type>
<joint name="base_link__link_01">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="motor_base_link__link_01">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<link name="link_01">
<visual>
<origin rpy="0 1.5707 1.5707" xyz="0 0.2 0"/>
<geometry>
<cylinder radius="0.35" length="0.4"/>
</geometry>
</visual>
<collision>
<origin rpy="0 1.5707 1.5707" xyz="0 0.2 0"/>
<geometry>
<cylinder radius="0.35" length="0.4"/>
</geometry>
</collision>
<inertial>
<origin rpy="0 1.5707 1.5707" xyz="0 0.2 0"/>
<mass value="1"/>
<inertia ixx="0.03" ixy="0.0" ixz="0.0" iyy="0.03" iyz="0.0" izz="0.03"/>
</inertial>
</link>
<!--Second Wheel-->
<joint name="base_link__link_02" type="continuous">
<axis xyz="0 1 0"/>
<limit effort = "10.0" velocity="1.0"/>
<joint_properties damping="1.0" friction="1.0"/>
<origin rpy="0 0 0" xyz="-0.5 -0.5 0"/>
<parent link="base_link"/>
<child link="link_02"/>
</joint>
<transmission name="trans_base_link__link_02">
<type>transmission_interface/SimpleTransmission</type>
<joint name="base_link__link_02">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="motor_base_link__link_02">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<link name="link_02">
<visual>
<origin rpy="0 1.5707 1.5707" xyz="0 -0.2 0"/>
<geometry>
<cylinder radius="0.35" length="0.4"/>
</geometry>
</visual>
<collision>
<origin rpy="0 1.5707 1.5707" xyz="0 -0.2 0"/>
<geometry>
<cylinder radius="0.35" length="0.4"/>
</geometry>
</collision>
<inertial>
<origin rpy="0 1.5707 1.5707" xyz="0 -0.2 0"/>
<mass value="1"/>
<inertia ixx="0.03" ixy="0.0" ixz="0.0" iyy="0.03" iyz="0.0" izz="0.03"/>
</inertial>
</link>
<!-- Add ROS plugin so we can interact with our robot -->
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
</plugin>
</gazebo>
</robot>
Asked by Whitchurch on 2022-07-07 16:40:38 UTC
Comments
It is not clear what question you are asking us.
Please edit your description using the "edit" button near the end of the text, and explain in more detail what changes you made that broke things.
Asked by Mike Scheutzow on 2022-07-10 10:21:54 UTC