Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

4 frame positioned relative to each other

Hi!

Recently, I have started to play in ROS and now I am trying to display 4 frames in RVIZ without success. The problem is that, the frames should be positioned relative to each other and me, with my ignorant brain cant realize the mistake.

static tf2_ros::TransformBroadcaster br;
for (int i = 1; i <= myRobot->getJointNumber(); i++) {
    stringstream name, prevName;
    name << "{" << i << "}";
    prevName << "{" << (i-1) << "}";
    geometry_msgs::TransformStamped transformStamped;
    transformStamped.header.stamp = ros::Time::now();

    transformStamped.header.frame_id = prevName.str();
    transformStamped.child_frame_id = name.str();

    transformStamped.transform.translation.x = 0.0;
    transformStamped.transform.translation.y = 0.0;
    transformStamped.transform.translation.z = 0.0;
    tf2::Quaternion q;
    q.setRPY(0, 0, 0);
    transformStamped.transform.rotation.x = q.x();
    transformStamped.transform.rotation.y = q.y();
    transformStamped.transform.rotation.z = q.z();
    transformStamped.transform.rotation.w = q.w();

    frames.push_back(transformStamped);
    br.sendTransform(transformStamped);
}

Only one or two frames shows up, which are directly linked to the fixed frame.

And here is two image to see how it is shown: image description https://drive.google.com/file/d/0By6anwacYsC3b0ZYR0QwZXd1d0E/view?usp=sharing

4 frame positioned relative to each other

Hi!

Recently, I have started to play in ROS and now I am trying to display 4 frames in RVIZ without success. The problem is that, the frames should be positioned relative to each other and me, with my ignorant brain cant realize the mistake.

static tf2_ros::TransformBroadcaster br;
for (int i = 1; i <= myRobot->getJointNumber(); i++) {
    stringstream name, prevName;
    name << "{" << i << "}";
    prevName << "{" << (i-1) << "}";
    geometry_msgs::TransformStamped transformStamped;
    transformStamped.header.stamp = ros::Time::now();

    transformStamped.header.frame_id = prevName.str();
    transformStamped.child_frame_id = name.str();

    transformStamped.transform.translation.x = 0.0;
    transformStamped.transform.translation.y = 0.0;
    transformStamped.transform.translation.z = 0.0;
    tf2::Quaternion q;
    q.setRPY(0, 0, 0);
    transformStamped.transform.rotation.x = q.x();
    transformStamped.transform.rotation.y = q.y();
    transformStamped.transform.rotation.z = q.z();
    transformStamped.transform.rotation.w = q.w();

    frames.push_back(transformStamped);
    br.sendTransform(transformStamped);
}

Only one or two frames shows up, which are directly linked to the fixed frame.

And here is two image to see how it is shown: image description https://drive.google.com/file/d/0By6anwacYsC3b0ZYR0QwZXd1d0E/view?usp=sharing

rosrun tf view_frames : https://drive.google.com/file/d/0By6anwacYsC3RjBEc3NlQUZkYlE/view