ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I have not tried this yet but this is what I would do:
...
pt = PointStamped()
pt.point.x = 0.0
pt.point.y = 0.0
pt.point.z = 10.0
tf2_geometry_msgs::do_transform(pt, transformed_pt, transformStamped);
http://docs.ros.org/diamondback/api/tf2_geometry_msgs/html/namespacetf2.html
2 | No.2 Revision |
I have not tried this yet but this is what I would do:
...
pt = PointStamped()
PointStamped();
pt.point.x = 0.0
0.0;
pt.point.y = 0.0
0.0;
pt.point.z = 10.0
10.0;
tf2_geometry_msgs::do_transform(pt, transformed_pt, transformStamped);
http://docs.ros.org/diamondback/api/tf2_geometry_msgs/html/namespacetf2.html
3 | No.3 Revision |
I have not tried this yet but this is what I would do:
...
pt = PointStamped();
geometry_msgs::PointStamped();
pt.point.x = 0.0;
pt.point.y = 0.0;
pt.point.z = 10.0;
tf2_geometry_msgs::do_transform(pt, transformed_pt, transformStamped);
http://docs.ros.org/diamondback/api/tf2_geometry_msgs/html/namespacetf2.html
4 | No.4 Revision |
I have not tried this yet but this is what I would do:
...
pt = geometry_msgs::PointStamped();
pt.point.x = 0.0;
pt.point.y = 0.0;
pt.point.z = 10.0;
tf2_geometry_msgs::do_transform(pt, geometry_msgs::PointStamped initial_pt;
ros::Publisher odom_pub = node.advertise<geometry_msgs::vector3>("/visualization_marker", 1);
tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tfListener(tfBuffer);
ros::Rate rate(10.0);
while (node.ok()){
geometry_msgs::TransformStamped transformStamped;
try{
transformStamped = tfBuffer.lookupTransform("/base_2", "/base_1", ros::Time(0));
geometry_msgs::PointStamped transformed_pt ;
tf2_geometry_msgs::do_transform(initial_pt, transformed_pt, transformStamped);
geometry_msgs::vector3 v;
v.x = transformed_pt.point.x;
v.y = transformed_pt.point.y;
v.z = transformed_pt.point.z;
odom_pub.publish(v);
}
catch (tf2::TransformException &ex) {
ROS_WARN("%s",ex.what());
ros::Duration(1.0).sleep();
continue;
}
from http://docs.ros.org/diamondback/api/tf2_geometry_msgs/html/namespacetf2.html
or extracting a snippet from http://wiki.ros.org/tf2/Tutorials/Using%20stamped%20datatypes%20with%20tf2%3A%3AMessageFilter
geometry_msgs::PointStamped initial_pt;
ros::Publisher odom_pub = node.advertise<geometry_msgs::vector3>("/visualization_marker", 1);
tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tfListener(tfBuffer);
ros::Rate rate(10.0);
initial_pt.header.frame_id = "/base1";
while (node.ok()){
try
{
tbuffer_.transform(initial_pt, transformed_pt, "/base2");
geometry_msgs::vector3 v;
v.x = transformed_pt.point.x;
v.y = transformed_pt.point.y;
v.z = transformed_pt.point.z;
odom_pub.publish(v);
}
catch (tf2::TransformException &ex)
{
ROS_WARN("Failure %s\n", ex.what()); //Print exception which was caught
continue;
}
}