Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to control a Robot?

asked 2013-09-23 23:17:28 -0600

updated 2013-09-23 23:19:12 -0600

Hello Everyone!

How to control a Robot?

I creat this robot and not know how to move this

http://gazebosim.org/wiki/Tutorials/1.9/buildrobot/addlaser

A lot of thanks!!

edit retag flag offensive close merge delete

5 Answers

Sort by » oldest newest most voted
1

answered 2013-09-24 09:38:54 -0600

GAugusto gravatar image

updated 2013-09-24 09:39:54 -0600

you have a few tutorials on older versions. the underscores used to set text to italic are making a few typos, make sure to notice them

1-this tutorial shows how to set the model velocities. http://gazebosim.org/wiki/Tutorials/1.3/intermediate/control_model for the above tutorial you might also find this usefull.

// *** QUATERNION / POSE DATA ******

  static double qw,qx,qy,qz, Rrad, Prad, Yrad;
  math::Vector3 p = model->GetWorldPose().pos;
  math::Quaternion r = model->GetWorldPose().rot;
  //from quaternion to Roll Pitch Yaw, in radians
  qw=r.w;   qx=r.x;     qy=r.y;     qz=r.z;
  Rrad=atan2(  2*(qw*qx+qy*qz),  1-2*(qx*qx+qy*qy)  );  //Roll
  Prad=asin(2*(qw*qy-qz*qx));                           //Pitch
  Yrad=atan2(  2*(qw*qz+qx*qy),  1-2*(qy*qy+qz*qz)  );  //Yaw

// ***************

        //set velocities

        float velx,vely;
        velx=Vlin*cos(Yrad);
        vely=Vlin*sin(Yrad);    
        this->model->SetLinearVel(math::Vector3(velx, vely, 0));
        this->model->SetAngularVel(math::Vector3(0, 0, Vang));

// ***************

2- or you can control the model using aplying joint forces, but this needs a robot with joints as wheels http://gazebosim.org/wiki/Tutorials/1.3/controlrobot/mobilebase

hope this helps.

edit flag offensive delete link more

Comments

Hey, I have a question related to controlling the robot from the keyboard. I made a rosenabled plugin to control the robot using the following method in this answer, by subscribing the twist type of msgs. http://answers.gazebosim.org/question/1991/what-is-the-best-way-to0-learn-gazebo-in-ros-for/ I am using groovy, and gazebo 1.9.1 with gazebo _rospckgs is there a way to use the keyboard-teleop to control the robot (turtlebot) from the keyboard manually instead. thanks in advance!

Zahra gravatar imageZahra ( 2013-09-24 12:38:00 -0600 )edit

the idea should be the same, the robot should have the topics for the vel comands, you just need to edit whatever controller (or the plugin) your using to publish the velocity commands to those topics. you can also change the plugin to match the controllers topics, whatever u see fit, they just need to match. in the same link at the end i sugest the use of one keyboard controller and to edit the controller to publish to the respective topics.

GAugusto gravatar imageGAugusto ( 2013-09-24 21:35:12 -0600 )edit

for example, if you have a controller publishing twist messages to "robot2/cmdvel" topic then you can change the plugin from "gz/cmdvel" to the same topic by changing the string name1 of the plugin from "gz" to "robot2". in case of a single robot it usualy does not have prefix so if you change the string name1 to "" (empty string) you will get the topic "/cmdvel". hope i was clear enough :S

GAugusto gravatar imageGAugusto ( 2013-09-24 21:40:16 -0600 )edit

for example, if you have a controller publishing twist messages to "robot2/cmdvel" topic then you can change the plugin from "gz/cmdvel" to the same topic by changing the string name1 of the plugin from "gz" to "robot2". in case of a single robot it usualy does not have prefix so if you change the string name1 to "" (empty string) you will get the topic "/cmdvel". hope i was clear enough :S

GAugusto gravatar imageGAugusto ( 2013-09-24 21:40:26 -0600 )edit

@GAuguto, When to load http://gazebosim.org/wiki/Tutorials/1.3/controlrobot/mobilebase

get a error:

Error [Plugin.hh:127] Failed to load plugin mypluginwithsensor.so: mypluginwithsensor.so: cannot open shared object file: No such file or directory

vncntmh gravatar imagevncntmh ( 2013-09-28 14:50:40 -0600 )edit
0

answered 2013-09-25 10:57:28 -0600

Zahra gravatar image

the topics once more are here since they are hard to read in the comment!

The topics :

/clock

/gazebo/cmd_vel

/gazebo/link_states

/gazebo/model_states

/gazebo/parameter_descriptions

/gazebo/parameter_updates

/gazebo/setlinkstate

/gazebo/setmodelstate

/rosout

/rosout_agg

with string name as std::string name = "turtlebotteleopkeyboard";

I started gazebo as : roslaunch package_name file.launch

edit flag offensive delete link more

Comments

those seam to be gazebo topics, did you use the "rostopic list" command or "gztopic list"?

GAugusto gravatar imageGAugusto ( 2013-09-25 11:01:19 -0600 )edit

I used rostopic list

Zahra gravatar imageZahra ( 2013-09-25 11:14:53 -0600 )edit

I used rostopic list

Zahra gravatar imageZahra ( 2013-09-25 11:15:08 -0600 )edit

ok, then try looking abit into the turtle bot controller for "turtlebottelopkeyboard/cmdvel" and change it to "gazebo/cmdvel". then try again.

GAugusto gravatar imageGAugusto ( 2013-09-25 11:27:43 -0600 )edit

Hello, from the turtlebot stack there is turltebotteleop src files https://github.com/turtlebot/turtlebotapps/blob/groovy/turtlebotteleop/src/turtlebotkey.cpp

I changed the turtlebotkey.cpp file, line 75 from: velpub_ = nh.advertise<geometrymsgs::Twist>("cmdvel", 1); to: velpub_ = nh.advertise<geometrymsgs::Twist>("/gazebo/cmd_vel", 1);

still not working, Any other ideas? many thanks

Zahra gravatar imageZahra ( 2013-09-26 05:32:16 -0600 )edit

i dont really see what to do, the objective should be to match the topics names. i suspect that somewhere both gazebo and turtlebot are adding prefixs by default, and thats where it needs changing :/ sorry i cant be of much more help.

GAugusto gravatar imageGAugusto ( 2013-09-26 08:52:33 -0600 )edit

btw something i remembered, i think you can change the name of topics with launch files, could be good to give it a look just to be safe. or just rosrun the turtlebot_key.cpp manualy and see what topics u get.

GAugusto gravatar imageGAugusto ( 2013-09-26 08:54:48 -0600 )edit

or just rosrun the turtlebot_key.cpp manualy and see what topics u get.

GAugusto gravatar imageGAugusto ( 2013-09-26 08:57:54 -0600 )edit

you can also try using http://wiki.ros.org/teleoptwistkeyboard , change the cmgvel to gazebo/cmdvel and see what topics you get

GAugusto gravatar imageGAugusto ( 2013-09-26 09:00:48 -0600 )edit

Changing the string names or the topic names didn’t work with me at all, but I managed to work around this prob by writing my own C++ program which is based on this tutorial and it worked just fine http://wiki.ros.org/pr2controllers/Tutorials/Using%20the%20robot%20base%20controllers%20to%20drive%20the%20robot#CA-1426c28b03091e68ce47656633f2c51ad6982d6867

Zahra gravatar imageZahra ( 2013-10-02 02:51:21 -0600 )edit
0

answered 2013-09-28 15:17:02 -0600

Arn-O gravatar image

3 ways to do that: - develop a "Gazebo plugin", which is a C++ calling Gazebo API (answer from iche033). The robot models do not need to be modified. - use ROS and gazeborospkgs, in this case the URDF or SDF model should be adapted, w. <gazebo> tags and so on, as described in the gazebo-ROS tutorial - player and do not know how the model should be modified

I may help with solution 2.

edit flag offensive delete link more

Comments

Great!, Could you help me with Gazebo API?

A lot of thanks!

vncntmh gravatar imagevncntmh ( 2013-09-28 17:47:33 -0600 )edit

I suggest to start with the rrbot tutorial and post your questions. This tuto contained anything that I needed. You may need several hours to master all the concepts if you start from scratch.

Arn-O gravatar imageArn-O ( 2013-09-29 10:18:06 -0600 )edit

Can you please tell how to control the model without ROS or plugin. I want to control using API only. Thank you.

rahul229229 gravatar imagerahul229229 ( 2015-05-11 02:21:14 -0600 )edit
0

answered 2013-09-25 09:37:07 -0600

Zahra gravatar image

GAugusto, thanks for replying! I followed your instructions but still I cannot control the robot with keyboard manually, thats what I have done:

in this page http://wiki.ros.org/turtlebot_teleop

a description for the published topics of turtlebot , one of them is turtlebottelopkeyboard/cmd_vel (<<msglink2(geometry_msgs twist)&gt;&gt;)="" <="" p="">

I changed the string name in my plugin :

from: std::string name = "gz";

to : std::string name = "turtlebotteleopkeyboard";

subscriber :

  this->sub = this->node->subscribe<geometry_msgs::Twist>("cmd_vel",10, boost::bind(&ROSMotorControllerPlugin::ROSCallback, this , _1));

Then, I started gazebo from roslunch since I am using gazeborospckgs

roslaunch package_name file.launch

I checked the rostopic list and this what I found /gazebo/cmd_vel I managed to control it with this line command but not manually :

rostopic pub -1 /gazebo/cmdvel geometrymsgs/Twist '{linear: { x: -0.040}}'

then I tried to change the topic name from "cmdvel" to “turtlebotteleopkeyboard/cmdvel “ and keeping the string name as it is “gz” , in rostopic list I got

/gazebo/turtlebotteleopkeyboard/cmd_vel

also, it didnt work with keyboard.

Note: I did all the above again when launching gazebo as “gazebo file.world” and also no change. So can you plz tell me what I am missing here?

Thanks a lot!

edit flag offensive delete link more

Comments

hmm, launch only the turtle bot controller, then type rostopic list and put here the topics it creates pls

GAugusto gravatar imageGAugusto ( 2013-09-25 10:37:26 -0600 )edit

The topics :

/clock /gazebo/cmdvel /gazebo/linkstates /gazebo/modelstates /gazebo/parameterdescriptions /gazebo/parameterupdates /gazebo/setlinkstate /gazebo/setmodelstate /rosout /rosoutagg

with string name as std::string name = "turtlebotteleopkeyboard"; I started gazebo as : roslaunch package_name file.launch

Zahra gravatar imageZahra ( 2013-09-25 10:51:23 -0600 )edit

change the "gz" to "turtlebottelopkeyboard" this is needed. to create the correct cmd vel topic.

i was using verison 1.5 and ROS fuerte, maybe on new versions the prefix "gazebo is always added. try also to change the published topic on the teleop controller by adding "gazebo" before "turtlebottelopkeyboard/cmdvel" to get "gazebo/turtlebottelopkeyboard/cmdvel" from the controller.

GAugusto gravatar imageGAugusto ( 2013-09-25 10:54:36 -0600 )edit
0

answered 2013-09-28 14:55:40 -0600

When to used:

http://gazebosim.org/wiki/Tutorials/1.3/controlrobot/mobilebase

Or

http://gazebosim.org/wiki/Tutorials/1.3/controlrobot/mobilebase_laser

Get a similar error:

Error [Plugin.hh:127] Failed to load plugin libmypluginwithsensor.so: mypluginwithsensor.so: cannot open shared object file: No such file or directory

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-09-23 23:17:28 -0600

Seen: 7,340 times

Last updated: Sep 28 '13