Hello everyone. I recorded a bag file using messages generated by Stage simulator; thus, when bag file is played, both odometric and scanner messages are sent again. I wrote a function that should receive a laser message and find the associated odometric message, using waitForTransform, on professor's suggestion:
void messageListener::laserCallback(const sensor_msgs::LaserScan msg){
//std::string frame_id = msg->header.frame_id;
ros::Time t = msg.header.stamp;
tf::StampedTransform laserPose;
std::string error;
if (listener->waitForTransform ("/odom", "/base_scan", t, ros::Duration(0.5), ros::Duration(0.01), &error)){
listener->lookupTransform("/odom", "/base_scan", t, laserPose);
double yaw,pitch,roll;
tf::Matrix3x3 mat = laserPose.getBasis();
mat.getRPY(roll, pitch, yaw);
pos_node pn;
pn.x = laserPose.getOrigin().x();
pn.y = laserPose.getOrigin().y();
pn.angle = yaw;
const vector<float>& ranges = msg.ranges;
scan_node temp_sn;
temp_sn.cartesian = polar2cart(ranges, msg.angle_min, msg.angle_increment, msg.range_min, msg.range_max);
vector<scan_node> tempScanVec;
tempScanVec.push_back(temp_sn);
extractCorners(&tempScanVec, 0.1, 0.1, 0.3);
line2angle(&tempScanVec);
pn.corn_vec = tempScanVec[0].corners_list;
nodeInfo.push_back(pn);
}
else
printf("Nothing to do\n");
}
The problem is that the IF block where the trasnform should be found is never executed and I always get the nothing to do printing; this makes me understand that somehow transform is never found. I suppose that problem may regard parameters of the function itself. This is the way I perform subscription:
ros::NodeHandle n;
ros::Subscriber sub_n = n.subscribe("/base_scan", 1000, &messageListener::laserCallback, this);
Does anyone know where I'm mistaking? Thanks
Originally posted by ubisum on ROS Answers with karma: 23 on 2014-01-22
Post score: 0