TF frame error
hi, all,
I am trying to set up a simple TF tree to convert incoming odometer data. however, the listener doesn't seem picking up anything at all. the tf_monitor shows no frame either.
~$ rosrun tf tf_monitor
RESULTS: for all Frames
Frames:
All Broadcasters:
how do I make it work? here's the broadcaster code.
void OdoCallback(const nav_msgs::Odometry::ConstPtr& odom_in)
{
ros::Time current_time = ros::Time::now();
tf::TransformBroadcaster odom_broadcaster;
tf::Stamped<tf::Pose> transform;
transform.setOrigin( tf::Vector3(odom_in->pose.pose.position.x, odom_in->pose.pose.position.y, 0.0) );
tf::Quaternion q;
q.setRPY(odom_in->pose.pose.orientation.z, 0, 0);
transform.setRotation(q);
odom_broadcaster.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "/odom_frame", "/base_link"));
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "sensor_convert_node");
ros::NodeHandle n;
ros::Subscriber odo_sub = n.subscribe("odom", 100, OdoCallback);
printf("setting up laser filter\r\n");
ros::Rate loop_rate(100);
while (ros::ok())
{
ros::Time start = ros::Time::now();
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
and here's the listener code
int main(int argc, char** argv){
ros::init(argc, argv, "robot_tf_listener");
ros::NodeHandle n;
tf::TransformListener listener;
ros::Rate r(50);
while(n.ok()){
tf::Stamped<tf::Pose> ident (tf::Transform(tf::createIdentityQuaternion(),
tf::Vector3(0,0,0)), ros::Time(0), "/odom_frame");
tf::Stamped<tf::Pose> odom_pose;
try{
listener.transformPose("/odom_frame",ident, odom_pose);
}
catch (tf::TransformException &ex) {
ROS_ERROR("%s",ex.what());
ros::Duration(1.0).sleep();
}
ros::spinOnce();
r.sleep();
}
return 0;
}
your help is appreciated.
Ray