Using tf for plotting frames in rviz
So I'm developing some lab exercises for an introductory robotics course. In one of the first labs, we want students to be able to plot tf frames in rviz by defining the transformations between them:
void plotf(Eigen::Matrix4f h, std::string parentName, std::string childName){
tf::TransformBroadcaster br;
tf::Transform frame;
frame.setOrigin(tf::Vector3(h(0,3), h(1,3), h(2,3)));
frame.setBasis(tf::Matrix3x3(h(0,0), h(0,1), h(0,2),
h(1,0), h(1,1), h(1,2),
h(2,0), h(2,1), h(2,2)));
ros::Duration(0.3).sleep();
br.sendTransform(tf::StampedTransform(frame, ros::Time::now(), parentName, childName));
ros::Duration(0.3).sleep();
}
This function works (though only after putting those odd delays in).
We'd also like them to be able to look up the transformation between various frames. I'm having trouble getting lookupTransform()
to work, however. It says that the frames don't exist.
Any advice on the delays or the inability to look up transforms?
If the problem looking them up is that they are only published once (rather than continuously), I suppose I could write a node that continuously publishes frames and also change plotf(...)
accordingly.