ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to turn my robot with different controllers?

asked 2016-07-25 11:06:09 -0500

patrchri gravatar image

updated 2016-07-28 10:27:39 -0500

Hello,

I using ROS Kinetic and I have built a 4-wheel robot called labrob, which I want to control. The robot can be seen in the following picture: Screenshot from 2016-07-25 18-49-27.png

At this robot I have added 2 motors (at the two front wheels) and also differential_drive_controller plugins:

  <gazebo>
   <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
           <alwaysOn>true</alwaysOn>
            <updateRate>100</updateRate>
            <leftJoint>joint_f_r_wheel</leftJoint>
            <wheelDiameter>0.4</wheelDiameter>
            <torque>20</torque>
            <commandTopic>motor1/cmd_vel</commandTopic>
            <odometryTopic>odom</odometryTopic>
            <odometryFrame>odom</odometryFrame>
            <robotBaseFrame>base_footprint</robotBaseFrame>
            <robotNamespace>labrob</robotNamespace>
        <legacyMode>true</legacyMode>
   </plugin>
  </gazebo>

  <gazebo>
   <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
           <alwaysOn>true</alwaysOn>
            <updateRate>100</updateRate>
            <leftJoint>joint_f_l_wheel</leftJoint>
            <wheelDiameter>0.4</wheelDiameter>
            <torque>20</torque>
            <commandTopic>motor2/cmd_vel</commandTopic>
            <odometryTopic>odom</odometryTopic>
            <odometryFrame>odom</odometryFrame>
            <robotBaseFrame>base_footprint</robotBaseFrame>
            <robotNamespace>labrob</robotNamespace>
        <legacyMode>true</legacyMode>
   </plugin>
  </gazebo>

at the wheels that I want to control. But when I run it in gazebo and then do:

rostopic list

I cannot see the topics motor1/cmd_vel and motor2/cmd_vel . If, however, I add only one plugin for controlling both motors at the same time (in this case, the robot doesn't turn) like this:

  <gazebo>
   <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
           <alwaysOn>true</alwaysOn>
            <updateRate>100.0</updateRate>
            <leftJoint>joint_f_l_wheel</leftJoint>
            <rightJoint>joint_f_r_wheel</rightJoint>
        <wheelSeperation>0.53</wheelSeperation>
            <wheelDiameter>0.4</wheelDiameter>
            <torque>20</torque>
        <topicName>/labrob/cmd_vel</topicName>
            <odometryTopic>odom</odometryTopic>
            <odometryFrame>odom</odometryFrame>
            <robotBaseFrame>base_footprint</robotBaseFrame>
            <publishWheelJointState>false</publishWheelJointState>
        <legacyMode>true</legacyMode>
            <robotNamespace>labrob</robotNamespace>
   </plugin>
  </gazebo>

everything works fine and after rostopic list I can see the labrob/cmd_vel topic and publish messages on it. Could you please tell me what should I change, so I can control the motors separately? Or if there is another type of controller for this task?

Thank you for your answers and your time in advance.

Edited: I would like to ask what is the difference between <commandTopic> and <topicName>. None of the two are being identified by the rostopic list command. Also is there a relationship in the order I put the xml tags? For example, is it possible that I need to put <WheelDiameter> higher or lower in the code so it can be run correctly? Maybe it should be helpful to add that I get these messages on my terminal after the gazebo roslaunch of my model:

SUMMARY
========

PARAMETERS
 * /robot_description: <?xml version="1....
 * /rosdistro: kinetic
 * /rosversion: 1.12.2
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)
    labrob_spawn (gazebo_ros/spawn_model)

ROS_MASTER_URI=http://localhost:11311

core service [/rosout] found
process[gazebo-1]: started with pid [6836]
process[gazebo_gui-2]: started with pid [6843]
process[labrob_spawn-3]: started with pid [6850]
spawn_model script started
[ INFO] [1469543270.209498030]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1469543270.210093847]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[INFO] [WallTime: 1469543270.297032] [0.000000] Loading model xml from ros parameter
[INFO] [WallTime: 1469543270.299725] [0.000000] Waiting for service /gazebo/spawn_urdf_model
[ INFO] [1469543270.759606848, 0.023000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1469543270.795880524 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-26 06:29:11 -0500

F.Brosseau gravatar image

If you want to separate your motor's commands, you can :

  • use one plugin and change the message type expected for command topic
  • write a plugin that control only one motor. This plugin will be called for each of your motor.
  • maybe look at ros_control

With the code that you have posted :

  • maybe you can change the plugins name (conflict between two plugins having the same name)
  • your command topic expected by these plugins should probably be : /labrob/motor1/cmd_vel and /labrob/motor2/cmd_vel
edit flag offensive delete link more

Comments

With the code I have used, your recommendations didn't work. Do i miss something?

For your general recommendations :

  1. I don't know how to do it
  2. how can I write a non hard coded plugin for generally some motor?
  3. I have checked this, but this tutorial doesn't help me for now.
patrchri gravatar image patrchri  ( 2016-07-26 09:14:11 -0500 )edit

For 1 : there is a tutorial here

Then you can take the diff drive plugin code and change the msg type expected : gazebo_git

F.Brosseau gravatar image F.Brosseau  ( 2016-07-27 03:00:10 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-25 11:06:09 -0500

Seen: 2,101 times

Last updated: Jul 28 '16