Rosanswers logo

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

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.


Originally posted by ZeroCool on ROS Answers with karma: 151 on 2012-05-23

Post score: 2

Original comments

Comment by ros_master on 2014-11-03:
Hi ZeroCool, i'm struggling with this same problem. Please can you send your all code? Thank for your interest.

Comment by puneet on 2016-02-12:
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.


2 Answers 2


Rosanswers logo

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.

Originally posted by joq with karma: 25443 on 2012-05-23

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by ZeroCool on 2012-05-23:
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?

Comment by joq on 2012-05-23:
The tf package takes care of both translation and orientation: /base_link will probably work.

Comment by ZeroCool on 2012-05-23:
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)?

Comment by joq on 2012-05-23:
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.

Comment by Procópio on 2012-05-23:
tf should take care of your offsets, as long as you have built your tf tree properly.


Rosanswers logo

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

Originally posted by Procópio with karma: 4402 on 2012-05-23

This answer was NOT ACCEPTED on the original site

Post score: 2


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.