Ask Your Question

how to use the sensor_msgs/NavSatStatus ?

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

anish gravatar image

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


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 -

And in the documentation, it is shown we can get a status of it by using "sensor_msgs/NavSatStatus". as per this page -

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!


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

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

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 Your callback function should have this signature:

void callback(const sensor_msgs::NavSatFixConstPtr& satfix)

Looking at the link you have provided (, 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

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

Your Answer

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

Add Answer

Question Tools

1 follower


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

Seen: 26 times

Last updated: Jan 21