Home | Tutorials | Wiki | Issues
Ask Your Question
0

Can someone please tell me how to use the diff drive plugin?

asked 2016-07-11 13:42:14 -0600

icepaka89 gravatar image

updated 2016-07-14 14:40:15 -0600

So I am very new to gazebo, working on my first project. So far my program spawns robots randomly in a given area. I want to be able to control them via a ROS node. Since Im using Pioneer2dx models, I am trying to use the diff drive plugin. I have spent literally days trying to find relevant information online, to no avail. I have also posted multiple forum questions on here and got answers that either didn't work or weren't useful to me. Here's what I REALLY need to know:

  1. How to access the diff drive plugin from my code (what is the #include).

  2. What functions do I need to use to get the robot to move in the simulation

  3. How to link this plugin to my pioneer2dx model in the world file.

Please help! thanks in advance. . .

UPDATE

Here is my world file:

<sdf version="1.5"> <world name="default"> <include> <uri>model://sun</uri> </include>

    <!-- A ground plane -->
    <include>
        <uri>model://ground_plane</uri>
    </include>

    <!-- Generate Population -->
    <population name="pioneer_population1">
        <!-- Define the population model type -->
        <model name="pioneer1">
            <include>
                <static>false</static>
                <uri>model://pioneer2dx</uri>
            </include>
            <!-- <plugin name="pioneer_prog" filename="libpioneer_prog.so"/> -->
            <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
                        <alwaysOn>true</alwaysOn>
                        <updateRate>10</updateRate>
                            <leftJoint>left_wheel_hinge</leftJoint>
                        <rightJoint>right_wheel_hinge</rightJoint>
                        <wheelSeparation>0.5380</wheelSeparation>
                        <wheelDiameter>0.2410</wheelDiameter>
                        <torque>20</torque>
                        <commandTopic>cmd_vel</commandTopic>
                    <odometryTopic>odom</odometryTopic>
                        <odometryFrame>odom</odometryFrame>
                        <robotBaseFrame>base_footprint</robotBaseFrame> 
                        <robotNamespace>gz</robotNamespace> 
             </plugin> 
        </model>

        <!-- Center spawn around (0,0,0) with orientation <0,0,0> -->
        <pose>0 0 0 0 0 0</pose>

        <!-- Size of spawn area -->
        <box>
            <size>8 8 0.01</size>
        </box>

        <!-- world_builder will insert this line based on user params -->
        <!-- MODEL_COUNT -->

        <!-- /MODEL_COUNT -->

        <!-- Define how the models will be distributed -->
        <!-- Distribution types: random, uniform, grid, linear-x, 
        liner-y, linear-z -->
        <distribution>
            <type>random</type>
        </distribution>
    </population>
</world>

</sdf>

I get this error when i try to open the world file:

Launching simulator. . .done
Warning [parser.cc:437] Converting a deprecated SDF source[data-string].
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
Couldn't find an AF_INET address for []
^CCouldn't find an AF_INET address for []

why would my world file be giving me an error to do with ros::init()?


UPDATE 2

As it turns out, the ros::init() error was caused by problems with my CMakeLists.txt file in my gazebo plugin directory. My file structure is the same as that used in the gazebo plugin tutorials. I needed to add these lines to CMakeLists.txt in order to include any ROS headers into my gazebo plugin:

find_package(roscpp ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-12 03:50:17 -0600

JuliusS gravatar image

updated 2016-07-12 03:51:14 -0600

Well, I'm quite new here too, but:

  1. PLugins are usually just attached to a model element so you don't really 'include' it. A plugin is a .so library that is attached to your model and has some known methods to interact with gazebo/ros.

Just go through the gazebo plugin tutorial and also look at the source code for diffdrive plugin. You should find that you are passing parameters to the diffdrive plugin from the sdf and it should take care of the rest.

I personally ended up using my own version of it as I was using older gazebo/ROS version and stuff was just not working for me.

  1. Go to gazebo api doc, under joint see whats applicable to you. Something like setvelocity or setforce should do the trick.

  2. This is described in tutorials.

edit flag offensive delete link more

Comments

Thanks for taking the time to respond! I have linked the plugin to my model in my .world file, as you said. I also set values for it from within the .world file. However my main problem is i want to be able to command the robots through code. I have a central program that will be commanding multiple robots via ros topics. I have included my world file in the question. I also get an error when i run this, which is also included in the question. As far as I have tested, the error isnt from my code

icepaka89 gravatar imageicepaka89 ( 2016-07-12 13:27:13 -0600 )edit

Well, the ''Converting a deprecated SDF source'' looks to me like an error relating to sdf version and gazebo version missmatch. What gazebo are you using? What ROS are you using? Is there a mismatch in gazebo-sdf versions? A ROS init error probably means the plugin is creating a ROS node (as it should), you should look up this error and see if it is indicative of some known issue. Alternatively, find the source code for the plugin, compile and debug it yourself:

JuliusS gravatar imageJuliusS ( 2016-07-13 10:19:19 -0600 )edit

I believe it is here : http://docs.ros.org/jade/api/gazebo_plugins/html/gazebo__ros__diff__drive_8cpp_source.html Make sure you replace 'jade' with whatever version of ROS you have

JuliusS gravatar imageJuliusS ( 2016-07-13 10:19:49 -0600 )edit

I am using ROS Kinetic, and gazebo 7, and its running on ubuntu 16.04. I took a look at the source code and found what may be the issue... I'm assuming that the void GazeboRosDiffDrive::Load ( physics::ModelPtr _parent, sdf::ElementPtr _sdf ) function is the first thing to be called when using this plugin. The first two lines of this function are: this->parent = _parent; gazebo_ros_ = GazeboRosPtr ( new GazeboRos ( _parent, _sdf, "DiffDrive" ) )

icepaka89 gravatar imageicepaka89 ( 2016-07-13 13:14:46 -0600 )edit

the constructor for GazeboRos is located at line 129 of gazebo_ros_utils.h, and constructs a ROS node:
rosnode_ = boost::shared_ptr<ros::nodehandle> ( new ros::NodeHandle ( namespace_ ) );
However there is never a call to ros::init() in the constructor... This would lead me to assume that its possible this could be an actual bug in to code for this plugin? Or is there something I am missing? I'm gonna try downloading the source code and debugging it myself, i will post my results

icepaka89 gravatar imageicepaka89 ( 2016-07-13 13:20:27 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-07-11 13:42:14 -0600

Seen: 3,314 times

Last updated: Jul 14 '16