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

how to use the sensor_msgs/NavSatStatus ?

asked 2020-01-16 13:42:17 -0600

anish gravatar image

updated 2020-01-21 13:52:26 -0600

Hai,

I am trying to send a fake GPS position from MAVROS to pixhawk for non_gps navigation using optical flow. I'm using - "sensor_msgs/NavSatFix" for giving lat, long & alt. as per this page - http://docs.ros.org/api/sensor_msgs/h...

And in the documentation, it is shown we can get a status of it by using "sensor_msgs/NavSatStatus". as per this page - http://docs.ros.org/api/sensor_msgs/h...

but I get the following error when I use "sensor_msgs/NavSatStatus":-

ROS_INFO("status = %d", sensor_msgs.NavSatStatus.status); (this is my line of code)

error: expected primary-expression before ‘.’ token

I guess I am not understanding how to use "sensor_msgs/NavSatStatus", I don't get why this error is coming. any help in this is appreciated!

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-01-21 15:12:13 -0600

lucascoelho gravatar image

First of all, you have to create a subscriber for the sensor_msgs/NavSatFix message. Take a look here on how to create a subscriber http://wiki.ros.org/roscpp/Overview/P... Your callback function should have this signature:

void callback(const sensor_msgs::NavSatFixConstPtr& satfix)

Looking at the link you have provided (http://docs.ros.org/api/sensor_msgs/h...), we can see that the NavSatStatus is provided on an attribute called status. And this attribute stores the actual status in another variable called status (see here http://docs.ros.org/api/sensor_msgs/h...)

Then, in order to print the status, I think your callback function would be something like this:

void callback(const sensor_msgs::NavSatFixConstPtr& satfix)
{
    ROS_INFO("status = %d", satfix.status.status);
}

Let me know if that works.

edit flag offensive delete link more

Comments

Thanks a lot, it fixed my confusion as well.

Rika gravatar image Rika  ( 2021-08-09 00:50:30 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2020-01-16 13:42:17 -0600

Seen: 630 times

Last updated: Jan 21 '20