Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 1516

TF tutorials question

$
0
0
Hello, I am new to tf and in ros in general - so some follow up questions may rise. My main questions will be marked with **bold**. I have built a 3 wheel robot on which I have put a lidar (hokuyo_link) and I am trying to setup the tf for my robot. I have managed to manipulate the lidar data for some simple obstacle avoidance movements, but my aim is to use the navigation stack and a main prerequisite for that is the tf. So what I am trying to implement is a odom -> base_link -> hokuyo_link tf, if I have understood correctly the logic. For a start, I want to create a tf between my lidar and my base_link. For this purpose, I am following this [tutorial](http://wiki.ros.org/navigation/Tutorials/RobotSetup/TF) and I have some questions. I have wrote a broadcaster -**do I need this broadcaster or it is implemented automatically from gazebo during simulation?** - copied from the tutorial but changed with my geometric data, and I am trying to write a listener: #include #include #include void transformPoint(const tf::TransformListener& listener){ //we'll create a point in the base_laser frame that we'd like to transform to the base_link frame geometry_msgs::PointStamped laser_point; laser_point.header.frame_id = "hokuyo_link"; //we'll just use the most recent transform available for our simple example laser_point.header.stamp = ros::Time(); //just an arbitrary point in space laser_point.point.x = 1.0; laser_point.point.y = 0.2; laser_point.point.z = 0.0; try{ geometry_msgs::PointStamped base_point; listener.transformPoint("base_link", laser_point, base_point); ROS_INFO("base_laser: (%.2f, %.2f. %.2f) -----> base_link: (%.2f, %.2f, %.2f) at time %.2f", laser_point.point.x, laser_point.point.y, laser_point.point.z, base_point.point.x, base_point.point.y, base_point.point.z, base_point.header.stamp.toSec()); } catch(tf::TransformException& ex){ ROS_ERROR("Received an exception trying to transform a point from \"hokuyo_link\" to \"base_link\": %s", ex.what()); } } int main(int argc, char** argv){ ros::init(argc, argv, "robot_tf_listener"); ros::NodeHandle n; tf::TransformListener listener(ros::Duration(10)); //we'll transform a point once every second ros::Timer timer = n.createTimer(ros::Duration(1.0), boost::bind(&transformPoint, boost::ref(listener))); ros::spin(); } The only thing I changed is the name used for the laser link. **The arbitrary point used in the tutorial are in my case my lidar data?** And also, if my previous question has a positive answer, this means that **the node that listens to the tf channel, needs to subscribe to the /laser/scan topic to get the data ?** Thanks for your answers and for your time in advance, Chris

Viewing all articles
Browse latest Browse all 1516

Trending Articles