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

Hello Himanshu, You can access the x,y data of all the channels of sonar in the following manner.

void sonarCallback(const sensor_msgs::PointCloud::ConstPtr& msg) { for(i=0;i<16;i++) { datax=msg->points[i].x; datay=msg->points[i].y; ROS_INFO("[%f]",datax); ROS_INFO("[%f]",datay); } ROS_INFO("...."); } you can refer to the sensor_msgs/PointCloud for details.

Hello Himanshu, You can access the x,y data of all the channels of sonar in the following manner.

` void sonarCallback(const sensor_msgs::PointCloud::ConstPtr& msg) {

for(i=0;i<16;i++)
{
    for(i=0;i<16;i++)
    {
        datax=msg->points[i].x;
     datay=msg->points[i].y;
     ROS_INFO("[%f]",datax);
     ROS_INFO("[%f]",datay);
 }
 ROS_INFO("....");
}

}` you can refer to the sensor_msgs/PointCloud for details.