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

Revision history [back]

click to hide/show revision 1
initial version

I solved the problem. I put the if-else condition in the void callback function. Here is the code:

void Localization::callback(const ti_mmwave_rospkg::RadarScan::ConstPtr& msg) { id = msg->point_id;

if (id == 0){
    r_a = msg->range;
    theta_a = msg->bearing;
    ROS_INFO("Range A is = %.2f", r_a);
    ROS_INFO("Bearing A is = %.2f", theta_a);
}else if (id == 1){
    r_b = msg->range;
    theta_b = msg->bearing;
    ROS_INFO("Range B is = %.2f", r_b);
    ROS_INFO("Bearing B is = %.2f", theta_b);
}

}

click to hide/show revision 2
No.2 Revision

I solved the problem. I put the if-else condition in the void callback function. Here is the code:

void Localization::callback(const ti_mmwave_rospkg::RadarScan::ConstPtr& msg) 
{
    id = msg->point_id;

msg->point_id;
 if (id == 0){
     r_a = msg->range;
     theta_a = msg->bearing;
     ROS_INFO("Range A is = %.2f", r_a);
     ROS_INFO("Bearing A is = %.2f", theta_a);
 }else if (id == 1){
     r_b = msg->range;
     theta_b = msg->bearing;
     ROS_INFO("Range B is = %.2f", r_b);
     ROS_INFO("Bearing B is = %.2f", theta_b);
    }

}

}