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

Moving Turtlebot to a goal without a map

asked 2013-06-24 23:04:54 -0500

lascre gravatar image

updated 2013-11-18 16:57:18 -0500

tfoote gravatar image

Hi there! We're two newbies. We installed Ros Electric on a pc acer aspire 5740g running Ubuntu Lucid 10.04. Our task is to move Turtlebot giving vocal commands. We're doing it writing publishers and subscribers in c++. We have a node which does the speech recognition, it publishes on a topic the identified word. When for example it publishes "advance" and "one", the turtlebot should move forward for one meter and then stop, waiting for new commands. We have to make the turtlebot do this without a map, only using odometry data. Our problem is that turtlebot doesn't stop after it has reached the goal.

To give you an idea of what we're doing, here's part of the code:

geometry_msgs::PoseWithCovarianceStamped msg; double pos_x,pos_y,pos_z,ori_x,ori_y,ori_z,ori_w;

void odomcallback(const geometry_msgs::PoseWithCovarianceStamped msg_turtlebot) { msg=msg_turtlebot; pos_x=msg.pose.pose.position.x; pos_y=msg.pose.pose.position.y; pos_z=msg.pose.pose.position.z; ori_x=msg.pose.pose.orientation.x; ori_y=msg.pose.pose.orientation.y; ori_z=msg.pose.pose.orientation.z; ori_w=msg.pose.pose.orientation.w; }

int main(int argc, char **argv) {
ros::init(argc, argv, "nodo_che_movimenta");
ros::NodeHandle node;
ros::Subscriber sub_odom = node.subscribe("odom", 1000, odomcallback);
ros::Publisher vel_pub = node.advertise<geometry_msgs::twist>("cmd_vel", 10);

[...]

geometry_msgs::Twist vel;
ros::Rate rate(10.0);
const double a=pos_x+1;

while (node.ok()) {
ros::spinOnce(); sostituto_quantita=quantita;
bool select=true;

if (attiva) {
printf("niente\n")

[...] if(complesso==103 ) { printf("complesso_on\n"); printf("Inserisci quantità\n"); if(sostituto_quantita==1 && select==true) { printf("1 meter\n"); if(pos_x<a) {vel.linear.x="0.3;" vel.linear.y="vel.linear.z=0.0;" vel.angular.x="vel.angular.y=vel.angular.z=0.0;" }="" <br=""> else { select=false; } } [...]

}
vel_pub.publish(vel);
rate.sleep(); }
ros::spin();
return 0; }

edit retag flag offensive close merge delete

Comments

I think you forgot to stop publishing or to put vel.linear.x = 0.0 after you reached the goal.

Lucile gravatar image Lucile  ( 2013-06-24 23:57:31 -0500 )edit

We tried to put vel.linear.x=0 instead of the bool variable, but it didn't work. We suppose that the real problem is the condition we put in the if instruction: if(pos_x<a). It is always true since both pos_x and a continously update their values.

lascre gravatar image lascre  ( 2013-06-25 02:50:57 -0500 )edit

An easy way to find it out is to print 'a' value.

Lucile gravatar image Lucile  ( 2013-06-25 05:30:30 -0500 )edit

I am not sure weither it would work or not (I am using python and not C++ for ROS programming), but you could try to remove the ros::spin() and to use ros::spinOnce() at the end of your while loop.

Lucile gravatar image Lucile  ( 2013-06-25 22:35:23 -0500 )edit

We printed the values both of the odometry and of the target using the printf function and we found out that they don't change at all! Is this a loop? How to find out? We tried also to remove ros::spin() and use ros::spinOnce(), but it didn't serve. It still doesn't want to perform the task.l.

lascre gravatar image lascre  ( 2013-06-26 07:13:30 -0500 )edit

I just answered on the google group

Lucile gravatar image Lucile  ( 2013-06-26 22:14:42 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-11-12 09:00:17 -0500

sudhanshu_mittal gravatar image

updated 2013-11-12 09:04:58 -0500

For just moving the robot, without any information of the environment(map): Run the following command:

Topic Name: "/move_base_simple/goal"

Message Type: "geometry_msgs/PoseStamped"

rostopic pub /move_base_simple/goal geometry_msgs/PoseStamped '{ header: { frame_id: "base_link" }, pose: { position: { x: -1.0, y: 0 }, orientation: { x: 0, y: 0, z: 0, w: 1.0}}}'
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-06-24 23:04:54 -0500

Seen: 1,720 times

Last updated: Nov 12 '13