Ask Your Question
0

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
0

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

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

Stats

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

Seen: 22 times

Last updated: Jan 21