Ask Your Question
2

move turtlebot 1 meter forward

asked 2012-05-23 05:18:10 -0500

ZeroCool gravatar image

I would like to move my turtlebot forward for 1 meter (in the direction he is facing). The way i do it is like this:

  • subscribe to topic "/camera/depth_registered/points"
  • create a "fake point" (just like kinect would return. Im creating the fake point just to see if the point calculation is correct.)
  • transform the point into /map space
  • publish the point to /move_base_simple/goal

The code:

 geometry_msgs::PointStamped p;
 geometry_msgs::PointStamped p1;
 p.header.stamp = ros::Time();
 std::string frame1 = "/camera_depth_optical_frame";
 p.header.frame_id = frame1.c_str();

 p.point.x = 0;
 p.point.y = 0;
 p.point.z = 1; // 1 meter

 std::string frame = "map";

 try
 {
   listener.transformPoint(frame,p,p1);
 }catch(tf::TransformException& ex) { ROS_ERROR("exception while transforming..."); }

 // create message for move_base_simple/goal 
 geometry_msgs::PoseStamped msg;
 msg.header.stamp = ros::Time();
 std::string frame = "/map";
 msg.header.frame_id = frame.c_str();
 msg.pose.position = p1.point;
 msg.pose.orientation = tf::createQuaternionMsgFromYaw(0.0);
 publisher.publish(msg);

The problem is when i visualize the goal in rviz it is wrong so the robot moves into the wrong way. Can someone please explain how to fix this i'm struggling with this for days and im quite desperate.

Thanks!

edit retag flag offensive close merge delete

Comments

Hi ZeroCool, i'm struggling with this same problem. Please can you send your all code? Thank for your interest.

ros_master gravatar image ros_master  ( 2014-11-03 04:09:36 -0500 )edit

Hello everybody

I am also doing the same thing, transformation of point from point cloud to world coordinate(/map frame). Please provide me the solution(code snippet) for the transformation.

puneet gravatar image puneet  ( 2016-02-12 19:47:17 -0500 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2012-05-23 05:46:25 -0500

joq gravatar image

Your main problem is probably using /camera_depth_optical_frame. Optical frames are oriented differently from normal coordinates. As mentioned already, /base_link is probably a better choice.

edit flag offensive delete link more

Comments

Yes i know, the reason why I am using camera_depth_optical_frame is that I am getting the point from kinect (which has a different coordinate system than ros). When transforming the point do I have to consider the robots orientation? Or will using /base_link take care of everything?

ZeroCool gravatar image ZeroCool  ( 2012-05-23 07:06:14 -0500 )edit
1

The tf package takes care of both translation and orientation: /base_link will probably work.

joq gravatar image joq  ( 2012-05-23 08:23:05 -0500 )edit

So I just change (in the code) /camera_depth_optical_frame to /base_link and leave other things unchanged? thank you for your help. I'll try it and post an answer. One more thing, if I use /base_link won't that ignore the kinect offset (on turtlebot the kinect is offseted by about 20cm in x)?

ZeroCool gravatar image ZeroCool  ( 2012-05-23 08:40:09 -0500 )edit

Your original question was about moving the robot forward one meter. A (1, 0, 0) goal pose with orientation (0, 0, 0, 1) relative to /base_link should work for that. If your actual problem requires some pose relative to the kinect, then use /camera_depth (or whatever), but not the "optical" frame.

joq gravatar image joq  ( 2012-05-23 08:52:16 -0500 )edit

tf should take care of your offsets, as long as you have built your tf tree properly.

Procópio gravatar image Procópio  ( 2012-05-23 08:57:49 -0500 )edit
2

answered 2012-05-23 05:36:17 -0500

Procópio gravatar image

If you are transforming the goto point frame from the camera to the map, you have to make sure the robot is well localized in the map. Also, you can try using the /base_link (or whatever your robot's frame is called) as the destination frame. Finally, I think you should prefer to use actionlib to send a goal to move_base, instead of publishing a message. Check SendingSimpleGoals

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-05-23 05:18:10 -0500

Seen: 2,471 times

Last updated: Nov 03 '14