# icepaka89's profile - activity

2016-07-19 14:36:40 -0500 asked a question Pioneer2dx Wheel Rotation Problems?

I am using the differential drive controller, a ros gazebo plugin, to move my pioneer2dx around in a simulation. I'm kinda new to this, and I'm having a rather amusing problem. I took the sdf file from this source:

http://machineawakening.blogspot.com/...

Whenever I run this file (rosrun gazebo_ros gazebo -file sim.world), I go to another terminal and use rospub to publish simple values to the /pioneer2dx/cmd_vel topic:

rostopic pub -1 /pioneer2dx/cmd_vel geometry_msgs/Twist \ '{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'

However instead of rotating the wheels like normal wheels would rotate (the center of rotation being the center of the wheel), the wheels seem to rotate perpendicular to the chassis of the model (they do not appear to be rotating as if a hinge were there). It's a bit hard to explain, but the issue can be reproduced by using the sdf file in the link and the above command.

My goal is to eventually write a simple program that will publish to the /pioneer2dx/cmd_vel topic and move it around different environments. What part of the sdf file is causing the wheels to not spin properly? Thanks in advance.

2016-07-13 13:20:27 -0500 commented answer Can someone please tell me how to use the diff drive plugin?

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

2016-07-13 13:14:46 -0500 commented answer Can someone please tell me how to use the diff drive plugin?

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" ) )

2016-07-12 13:27:13 -0500 commented answer Can someone please tell me how to use the diff drive plugin?

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

2016-07-11 13:42:14 -0500 asked a question Can someone please tell me how to use the diff drive plugin?

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.

## 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 ...

2016-07-08 13:57:38 -0500 asked a question How to install gazebo_ros_pkgs??

So I am trying to create a simulation in which I control a bunch of pioneer2dx robots and I need stuff thats in gazebo_ros_pkgs to move them they way I want (DiffDrive plugin). However it seems that there is no version for ros kinetic & gazebo 7. I tried downloading the jade version but I can't even do that. I'll type "sudo apt-get install ros-jade-gazebo-ros-pkgs", only to get the following error:

E: Unable to locate package ros-jade-gazebo-ros-pkgs

2016-07-07 13:40:41 -0500 commented answer How to Control Pioneer2DX in Gazebo...?

Thanks for your help, however I can't seem to get this to work. I'm getting that "joints" doesn't exist. I dont really understand/know how programming in gazebo works so sorry if this is a menial issue. I have included my plugin and world file above. Please let me know where I went wrong. Thanks.

2016-07-06 14:21:17 -0500 asked a question How to Control Pioneer2DX in Gazebo...?

So I am using gazebo to simulate a pioneer2dx model, however I can't find a good documentation on how to control it properly. Right now my plugin uses the SetLinerVel function to move the robot, however this just pushed the robot along. I want to know how to be able to control the actual wheels of the robot (i.e. set the angular velocity of the hinges). Is there a way to do this? Also is there a way to get the sensor values from the robot? Thanks.

## UPDATE

Here is my plugin c++ code:

#include <boost/bind.hpp>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <stdio.h>

namespace gazebo
{
class PioneerProg : public ModelPlugin
{
public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
{
// Store the pointer to the model
this->model = _parent;

// Listen to the update event. This event is broadcast every
// simulation iteration.
this->updateConnection = event::Events::ConnectWorldUpdateBegin(
boost::bind(&PioneerProg::OnUpdate, this, _1));
}

// Called by the world update start event
public: void OnUpdate(const common::UpdateInfo & /*_info*/)
{
// Apply a small linear velocity to the model.
//this->model->SetLinearVel(math::Vector3(0.06, 0, 0));
joints[LEFT_FRONT_WHEELING] = this->parent->GetJoint(left_wheel_hinge);
joints[LEFT_FRONT_WHEELING]->SetParam("fmax", 0, torque);
joints[LEFT_FRONT_WHEELING]->SetParam("vel", 0, wheel_data_[LEFT_FRONT_WHEELING]/(wheel_diameter_/2.0));

}

// Pointer to the model
private: physics::ModelPtr model;

// Pointer to the update event connection
private: event::ConnectionPtr updateConnection;
};

// Register this plugin with the simulator
GZ_REGISTER_MODEL_PLUGIN(PioneerProg)
}


And here is my world file xml code:

<?xml version="1.0" ?>
<sdf version="1.5">
<world name="default">
<!-- A global light source -->
<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"/>
</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>

2016-06-14 13:19:23 -0500 commented question How to add Gazebo Plugin to Simulation?

Hi Peter, I have updated my question. I hope this clears things up. With the information added in the edit, I would like to know: 1. How to use c++ code in my ROS node to link the plugin to the models. 2. If it is possible to access code from a gazebo plugin in a ROS node

2016-06-13 14:38:22 -0500 asked a question How to add Gazebo Plugin to Simulation?

Hello! So I am writing a program that will, in theory, ask the user for a (variable) number of robots and spawn the correct number of pioneer2DX models in an empty gazebo world, all done through ROS. I want to add Gazebo plugins that will allow the ROS node to communicate with each pioneer spawned in the simulation. So I would like to write a plugin that can be linked to each of the pioneers I spawned in the empty world. Is there a way to accomplish this through ROS? Since the models are spawned during run time, I need the ROS node to be able to do the linking. Is there a way to do this? Or perhaps an alternative method that will still allow my ROS node to communicate with the dynamic number of robots spawned? I've been looking through the tutorials but I can't seem to find much that helps here. Thanks!!

##UPDATE##
To be more specific, I would like to create a plugin that can be attached to ANY pioneer2DX model I add (i.e. each model runs the plugin). I would like the plugin to have control functions (i.e. moving forward, backward, turning; retrieve sensor values, etc.) that can directly manipulate the robot in the simulation. I would like these functions to be accessible by my ROS node. For example, if my ROS node wants to move a model, it can call these functions from the plugin to do so.

Additionally, since there are going to be a variable number of robots each time the simulation is run (this number will be given by the user), I would like the ROS node to have the ability to link the said plugin to each robot in the simulation (which will be named pionner1, ... , pioneer[n]). This will happen when the simulation starts. And when the plugin is linked to the model, the ROS node should be able to communicate with it and call its functions to command the robot to move and give its sensor values as needed.

I hope this clears things up a bit. Sorry for being a bit vague before.

icepaka89@icepaka89-Latitude-D520:~$gazebo icepaka89@icepaka89-Latitude-D520:~$