Ask Your Question
0

Subscriber receives 0 value

asked 2016-07-02 02:23:19 -0600

RohitM gravatar image

updated 2016-07-02 20:24:31 -0600

I am publishing the pose from a node and receiving it another node. For some reason the subscriber is always getting a 0 value. Below is the ROS_INFO output of both the published message and the subscribed message.

[ INFO] [1467443650.648643683]: 0.174000    -0.289000     -0.275000

[ INFO] [1467443634.965920060]: 0.000000      0.000000       0.000000

This is a code snippet of the callback function where I am ROS_INFOing the message.

void BaseModule::KinematicsPoseMsgCallback( manipulator_base_module_msgs::KinematicsPose msg) 
{   
    if( enable == false )
        return;
    ROS_INFO("%f      %f       %f", msg.pose.position.x, msg.pose.position.y, msg.pose.position.z);
    Robotis->kinematics_pose_msg = msg;

Does anyone know why this might be the case? Please tell me if you need any more information to solve this problem. Thanks.

Edit: These are the publisher messages:

ros::Publisher k_i = n.advertise<manipulator_base_module_msgs::KinematicsPose>("kinematics_input", 10);
manipulator_base_module_msgs::KinematicsPose kin;
kin.pose.position.x = 0.174;
kin.pose.position.y = -0.289;
kin.pose.position.z = -0.275;
k_i.publish(kin);
edit retag flag offensive close merge delete

Comments

How do you publish the messages? What does rostopic echo show? [BTW: if( enable == false ) -> if (not enable)

NEngelhard gravatar imageNEngelhard ( 2016-07-02 19:41:37 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-03 01:18:54 -0600

gvdhoorn gravatar image
void BaseModule::KinematicsPoseMsgCallback( manipulator_base_module_msgs::KinematicsPose msg)
{
  [..]
}

I'm not sure, but it could be that you are seeing the behaviour you report because you setup your callback to get a KinematicsPose instance by value, instead of by reference.

Could you try changing the callback to:

void BaseModule::KinematicsPoseMsgCallback( manipulator_base_module_msgs::KinematicsPoseConstPtr& msg)

that should probably make it work the way you expect.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-07-02 02:23:19 -0600

Seen: 35 times

Last updated: Jul 03 '16