Difference between revisions of "Using Transforms to Robot Base View"

From wikidb
Jump to: navigation, search
(Created page with "= Motivation = One approach is to transform odometry results to a robot base. This would leave use with a speed in the robot's x direction and an angular z component. If the...")
 
(ROS Transform References)
Line 14: Line 14:
  
 
* [http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20listener%20%28C%2B%2B%29 Writing a tf Listener]
 
* [http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20listener%20%28C%2B%2B%29 Writing a tf Listener]
 +
 +
= My Code =
 +
 +
  #include <tf/transform_listener.h>
 +
 +
And added the following to the main loop:
 +
 +
    while (ros::ok()) {
 +
        ros::spinOnce();
 +
        loop_rate.sleep();
 +
 +
tf::StampedTransform transform;
 +
geometry_msgs::Twist t;
 +
try {
 +
    // tf_listener.lookupTransform("/odom", "/base_link",
 +
    //     ros::Time(0), transform);
 +
    tf_listener.lookupTwist("/base_link", "/odom",
 +
      ros::Time(0), ros::Duration(0.1), t);
 +
        }
 +
catch (tf::TransformException ex){
 +
    ROS_ERROR("%s", ex.what());
 +
    ros::Duration(1.0).sleep();
 +
}
 +
 +
// ROS_INFO ("x %.2f, y %.2f", transform.getOrigin().x(), transform.getOrigin().y());
 +
ROS_INFO ("x %.2f, y %.2f", t.linear.x, t.linear.y);

Revision as of 12:05, 20 September 2017

Motivation

One approach is to transform odometry results to a robot base. This would leave use with a speed in the robot's x direction and an angular z component. If the x speed is positive, the robot is moving forward. This simplifies reasoning. This page documents investigations. The investigation of this path is not completed.

Not currently successful

ROS Transforms

This is a dead end. ROS transforms tell us where we the robot base is in our map space but does not transform to robot space.

ROS Transform References

My Code

 #include <tf/transform_listener.h>

And added the following to the main loop:

   while (ros::ok()) {
       ros::spinOnce();
       loop_rate.sleep();

tf::StampedTransform transform; geometry_msgs::Twist t; try { // tf_listener.lookupTransform("/odom", "/base_link", // ros::Time(0), transform); tf_listener.lookupTwist("/base_link", "/odom", ros::Time(0), ros::Duration(0.1), t);

       }

catch (tf::TransformException ex){ ROS_ERROR("%s", ex.what()); ros::Duration(1.0).sleep(); }

// ROS_INFO ("x %.2f, y %.2f", transform.getOrigin().x(), transform.getOrigin().y()); ROS_INFO ("x %.2f, y %.2f", t.linear.x, t.linear.y);