ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

remapping with robot_state_publisher

asked 2012-05-30 23:01:07 -0600

ocli gravatar image

I am using the arm_navigation stack and can't seem to remap a published sensor_msgs/JointState topic through the robot_state_publisher generic launch file. The remapping and tf file is:

<launch>
    <node pkg="robot_state_publisher" type="state_publisher" name="rob_st_pub" >
      <remap from="joint_states_tf" to="joint_states" />
    </node>
</launch>

The topic is published correctly (verified with rostopic echo) under "/joint_states_tf" through this node

#include <ros/ros.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <sensor_msgs/JointState.h>

int main(int argc, char **argv){
    ros::init(argc,argv,"state_publisher");
    ros::NodeHandle nh;
    ros::Publisher pub = nh.advertise<sensor_msgs::JointState>("joint_states_tf",1000);
    ros::Rate lr(10);

    sensor_msgs::JointState msg;
    msg.name.push_back("tip_joint");
    msg.name.push_back("wrist_roll_joint");
    msg.name.push_back("wrist_flex_joint");
    msg.name.push_back("wrist_roll_joint");
    msg.name.push_back("elbow_flex_joint");
    msg.name.push_back("shoulder_lift_joint");
    msg.name.push_back("shoulder_roll_joint");
    msg.name.push_back("base_joint");


    for (int i = 0; i < 8; i++){
        msg.position.push_back(0.0);
        msg.velocity.push_back(0.0);
        msg.effort.push_back(0.0);
    }

    while(ros::ok()){
        msg.header.stamp = ros::Time::now();
        pub.publish(msg);
        ros::spinOnce();
    }
}

yet the output when using

rostopic echo /joint_states

is null and but the /tf topic is published correctly.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-05-31 00:11:10 -0600

dornhege gravatar image

updated 2012-05-31 00:11:42 -0600

You have it flipped. The remap says from what topic that is named in the binary to what topic in the ROS world it should be remapped.

If you either apply that remapping to you program launch or flip the remap parameters for the state publisher, it should work.

edit flag offensive delete link more

Comments

I wanted to remap from /joint_states_tf to /joint_states, not vice versa.

ocli gravatar image ocli  ( 2012-05-31 01:20:04 -0600 )edit

I think your understanding of remapping from/to is wrong. As you have set it up, you need to either remap the other way around or remap the other program. As you do it, it can't work.

dornhege gravatar image dornhege  ( 2012-05-31 01:32:47 -0600 )edit

I think that's very likely. I just switched them around and slowed the loop rate and it works, what is the purpose of robot state planner tutorial launch file where it remaps the non-existent publication from the /environment server then?

ocli gravatar image ocli  ( 2012-05-31 03:32:47 -0600 )edit

Are you referring to the example launch file in 2.2? That maps FROM joint_states, which is a topic of robot_state_publisher and thus correct.

dornhege gravatar image dornhege  ( 2012-05-31 03:50:16 -0600 )edit

Yes. Ah ok I got confused when looking at the rxgraph. Thankyou

ocli gravatar image ocli  ( 2012-05-31 04:23:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-05-30 23:01:07 -0600

Seen: 3,189 times

Last updated: May 31 '12