How to control a Robot?
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!!
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!!
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.
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!
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.
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
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
@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
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)>>)="" <="" 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!
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
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.
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
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
you can also try using http://wiki.ros.org/teleoptwistkeyboard , change the cmgvel to gazebo/cmdvel and see what topics you get
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
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.
Can you please tell how to control the model without ROS or plugin. I want to control using API only. Thank you.
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
Asked: 2013-09-23 23:17:28 -0500
Seen: 10,810 times
Last updated: Sep 28 '13
Controlling a robot (ragdoll) programmtically
How to control a single wheel(continus joint)
Is it possible to simulate a soccer game using Humanoids in Gazebo?
Does Ubuntu 13.04 support gazebo 1.9 and ros Hydro?
Existing projects on vehicle simulation?