forward twist rotates robot gazebo ros control
I have made a urdf for diff drive robot. here i am using gazeboroscontol plugin to control this motor similary like turtlebot3. But when i send the forward twist command the robot is rotating instead of moving forward. Here is my xacro file:
<?xml version="1.0"?>
<!-- Revolute-Revolute Manipulator -->
<robot name="bini" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Constants for robot dimensions -->
<xacro:property name="PI" value="3.1415926535897931"/>
<xacro:property name="mass" value="1" /> <!-- arbitrary value for mass -->
<xacro:property name="width" value="0.1" /> <!-- Square dimensions (widthxwidth) of beams -->
<xacro:property name="height1" value="2" /> <!-- Link 1 -->
<xacro:property name="height2" value="1" /> <!-- Link 2 -->
<xacro:property name="height3" value="1" /> <!-- Link 3 -->
<xacro:property name="camera_link" value="0.05" /> <!-- Size of square 'camera' box -->
<xacro:property name="axel_offset" value="0.05" /> <!-- Space btw top of beam and the each joint -->
<!-- Modify this content if robots joint and link names are different -->
<xacro:arg name="left_wheel_joint_name" default="left_wheel_joint"/>
<xacro:arg name="right_wheel_joint_name" default="right_wheel_joint"/>
<xacro:arg name="right_wheel_link_name" default="right_wheel"/>
<xacro:arg name="left_wheel_link_name" default="left_wheel"/>
<xacro:arg name="front_wheel_link_name" default="front_wheel"/>
<xacro:arg name="back_wheel_link_name" default="back_wheel"/>
<xacro:arg name="imu_link_name" default="imu_link"/>
<xacro:arg name="lidar_link_name" default="base_scan"/>
<xacro:arg name="camera_link_name" default="camera_link"/>
<!-- Import all Gazebo-customization elements, including Gazebo colors -->
<xacro:include filename="$(find bini_simulation)/urdf/bini.gazebo" />
<!-- Import Rviz colors -->
<xacro:include filename="$(find bini_simulation)/urdf/materials.xacro" />
<!-- Import robot urdf which was directly exported from Solidwork-->
<xacro:include filename="$(find bini_description)/urdf/bini_description.urdf" />
<link name="base_footprint"/>
<joint name="base_joint" type="fixed">
<parent link="base_footprint"/>
<child link="base_link" />
<origin xyz="0.0167666250730711 -0.00206087262344925 0.0155567321901691" rpy="0 0 0"/>
</joint>
<!-- Transmission element segment for each moving joint in robot according to their type of control -->
<transmission name="tran1">
<type>transmission_interface/SimpleTransmission</type>
<joint name="$(arg left_wheel_joint_name)">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="motor1">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="tran2">
<type>transmission_interface/SimpleTransmission</type>
<joint name="$(arg right_wheel_joint_name)">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="motor2">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</robot>
The xacro file for gazebo plugin is:
<?xml version="1.0"?>
<robot>
<!-- simulation parameters segment for given joint -->
<gazebo reference="base_link">
<material>Gazebo/DarkGrey</material>
</gazebo>
<gazebo reference="$(arg left_wheel_link_name)">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>500000.0</kp>
<kd>10.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
<fdir1>1 0 0</fdir1>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="$(arg right_wheel_link_name)">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>500000.0</kp>
<kd>10.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
<fdir1>1 0 0</fdir1>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="$(arg front_wheel_link_name)">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.001</minDepth>
<maxVel>1.0</maxVel>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="$(arg back_wheel_link_name)">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.001</minDepth>
<maxVel>1.0</maxVel>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="$(arg imu_link_name)">
<sensor type="imu" name="imu">
<always_on>true</always_on>
</sensor>
<material>Gazebo/Grey</material>
</gazebo>
<!-- gazebo ros plugin segment -->
<!-- gazebo_ros_control plugin -->
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<!-- <robotNamespace>/bini</robotNamespace> -->
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
</plugin>
</gazebo>
<!-- gazebo_ros_imu plugin -->
<gazebo reference="$(arg imu_link_name)">
<gravity>true</gravity>
<sensor name="imu_sensor" type="imu">
<always_on>true</always_on>
<update_rate>100</update_rate>
<visualize>true</visualize>
<topic>__default_topic__</topic>
<plugin filename="libgazebo_ros_imu_sensor.so" name="imu_plugin">
<topicName>imu/data_raw</topicName>
<bodyName>imu_link</bodyName>
<updateRateHZ>10.0</updateRateHZ>
<gaussianNoise>0.0</gaussianNoise>
<xyzOffset>0 0 0</xyzOffset>
<rpyOffset>0 0 0</rpyOffset>
<frameName>imu_link</frameName>
<initialOrientationAsReference>false</initialOrientationAsReference>
</plugin>
<pose>0 0 0 0 0 0</pose>
</sensor>
</gazebo>
<!-- gazebo_ros_gpu_laser plugin -->
<gazebo reference="$(arg lidar_link_name)">
<sensor type="gpu_ray" name="head_hokuyo_sensor">
<pose>0 0 0 0 0 0</pose>
<visualize>false</visualize>
<update_rate>40</update_rate>
<ray>
<scan>
<horizontal>
<samples>720</samples>
<resolution>1</resolution>
<min_angle>-1.570796</min_angle>
<max_angle>1.570796</max_angle>
</horizontal>
</scan>
<range>
<min>0.10</min>
<max>30.0</max>
<resolution>0.01</resolution>
</range>
<noise>
<type>gaussian</type>
<!-- Noise parameters based on published spec for Hokuyo laser
achieving "+-30mm" accuracy at range < 10m. A mean of 0.0m and
stddev of 0.01m will put 99.7% of samples within 0.03m of the true
reading. -->
<mean>0.0</mean>
<stddev>0.01</stddev>
</noise>
</ray>
<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_gpu_laser.so">
<topicName>/scan</topicName>
<frameName>base_scan</frameName>
</plugin>
</sensor>
</gazebo>
<!-- gazebo_ros_camera plugin -->
<gazebo reference="$(arg camera_link_name)">
<sensor type="camera" name="camera1">
<update_rate>30.0</update_rate>
<camera name="head">
<horizontal_fov>1.3962634</horizontal_fov>
<image>
<width>800</width>
<height>800</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.02</near>
<far>300</far>
</clip>
<noise>
<type>gaussian</type>
<!-- Noise is sampled independently per pixel on each frame.
That pixel's noise value is added to each of its color
channels, which at that point lie in the range [0,1]. -->
<mean>0.0</mean>
<stddev>0.007</stddev>
</noise>
</camera>
<plugin name="camera_controller" filename="libgazebo_ros_camera.so">
<alwaysOn>true</alwaysOn>
<updateRate>0.0</updateRate>
<cameraName>bini/camera1</cameraName>
<imageTopicName>image_raw</imageTopicName>
<cameraInfoTopicName>camera_info</cameraInfoTopicName>
<frameName>camera_link_optical</frameName>
<!-- setting hackBaseline to anything but 0.0 will cause a misalignment
between the gazebo sensor image and the frame it is supposed to
be attached to -->
<hackBaseline>0.0</hackBaseline>
<distortionK1>0.0</distortionK1>
<distortionK2>0.0</distortionK2>
<distortionK3>0.0</distortionK3>
<distortionT1>0.0</distortionT1>
<distortionT2>0.0</distortionT2>
<CxPrime>0</CxPrime>
<Cx>0.0</Cx>
<Cy>0.0</Cy>
<focalLength>0.0</focalLength>
</plugin>
</sensor>
</gazebo>
</robot>
What could be the problem?
Asked by dinesh on 2021-11-04 01:26:20 UTC
Comments
suggestion: please improve the title of your question. "ros control plugin issue" doesn't really mean anything.
Simply describing the main symptom you observe is typically a good starting point for a title, and you already did that yourself in the question text:
if you shorten that a bit it would be a much better title than the current one.
Asked by gvdhoorn on 2021-11-04 01:47:55 UTC