ROS Subscriber does not return correct value from the topic

1 view (last 30 days)
I've been using the Robotics Toolbox for a while now and I've never seen something like this before. It looks like a Matlab bug, but I don't know if I am doing something wrong.
In summary, I have a simulation running in gazebo that publishes to the topic: '/mavros/state' I created a simple subscriber as follows:
stateSub = rossubscriber('mavros/state');
msg = receive(stateSub)
The msg I received was the following:
MessageType: 'mavros_msgs/State'
Header: [1x1 Header]
Connected: 1
Armed: 0
Guided: 0
Mode: 'AUTO.RTL'
However, at the same time I was running the following command in a linux terminal:
rostopic echo /mavros/state
The echoed value in this terminal for the topic '/mavros/state' was the following:
seq: 1230
secs: 1487749325
nsecs: 495354524
frame_id: ''
connected: True
armed: True
guided: True
mode: AUTO.RTL
Note that there is a disparity between the value that I got in Matlab and the one I got in the terminal: Matlab says that the Armed and Guided properties are 0 (false), while the terminal says their values are 1 (true).
I know for a fact that the values expected from Armed and Guided are 1 (true), which means that the receive function is returning the wrong value for these properties.
Is this a Matlab bug? Any idea why this would be happening?
Observation: the message type for 'mavros/state' is of the type 'mavros_msgs/State', with the following definitions (obtained from running rosmsg info mavros_msgs/State in a matlab terminal):
std_msgs/Header Header
logical Connected
logical Armed
logical Guided
char Mode

Answers (1)

Marcelino Almeida
Marcelino Almeida on 23 Feb 2017
I just updated my Matlab to R2016b (I had R2016a before) and the problem remains.
Running echo in matlab:
rostopic echo /mavros/state
Connected : 1
Armed : 0
Guided : 0
Seq : 3483
FrameId :
Sec : 1487832172
Nsec : 513096941
Running in a Linux terminal:
seq: 3483
secs: 1487832172
nsecs: 513096941
frame_id: ''
connected: True
armed: True
guided: True
Again, all values are precisely equal in both, except for "Guided" and "Armed". I can't make much sense of this except accept that this is a Matlab bug.


Find more on Network Connection and Exploration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!