SITL MAVPROXY ignores --mav20

Hello, I am trying to run simple SITL and read mavlink data.

I run SITL using

sudo python sim_vehicle.py -v ArduCopter -m "--mav20" -f hexa --console --map -L WIPB

the -m argument is for extra MAVproxy argumentss.
Simulation starts to work, and MAVProxy has got --mav20 argument

SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--mav20" "--map" "--console"
RiTW: Starting ArduCopter : /home/alek/ardupilot/build/sitl/bin/arducopter -S -I0 --home 53.117324,23.146073,0,353 --model hexa --speedup 1 --defaults /home/alek/ardupilot/Tools/autotest/default_params/copter.parm,/home/alek/ardupilot/Tools/autotest/default_params/copter-hexa.parm

Despite of using --mav20 when i run some C code to read data i can see

Bytes Received: 34
Datagram: fe 1a a5 01 01 1b e4 81 6e 6e 00 00 00 00 00 00 00 00 17 fc 02 00 02 00 01 00 b7 00 37 00 c2 01 e9 b1
Received packet: SYS: 1, COMP: 1, LEN: 26, MSG ID: 27

And as i can see it is mavlink v 1.0 ( 0xFE instead of 0xFD etc).

I have got also SERIAL0_PROTOCOL, SERIAL1_PROTOCOL and SERIAL2_PROTOCOL sets to use MAVLINK2.0.
What more i can do, to use MAVLINK 2.0 standard?
Thanks for any help:slight_smile:

1 Like

I run SITL using

Everything you do there looks OK and should probably be sufficient.

One easy way to check if you’re running mavlink2 is to look at the MEMINFO
message. This is it under mavlink1:

STABILIZE> status MEMINFO
STABILIZE> 108: MEMINFO {brkval : 0, freemem : 0}

after a simple “param set SERIAL0_PROTOCOL 2”, I restarted SITL like this:

./Tools/autotest/sim_vehicle.py -v ArduCopter -m “–mav20”

And now get this:

STABILIZE> status meminfo
STABILIZE> 77: MEMINFO {brkval : 0, freemem : 0, freemem32 : 131072}

freemem32 is a mavlink2 extension - it won’t appear unless mavlink2 is
working.

What more i can do, to use MAVLINK 2.0 standard?

I wonder if you restarted the simulation after setting the
SERIAL0_PROTOCOL parameter?

Yours,

1 Like

Thank You very much for reply. I am a litte bit confused.

When I run simulation WITHOUT --mav20 and witch SERIAL0_PROTOCOL 1.0

SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--map" "--console"

param fetch SERIAL0_PROTOCOL STABILIZE> Requested parameter SERIAL0_PROTOCOL SERIAL0_PROTOCOL = 1.000000

meminfo shows
status meminfo STABILIZE> 123: MEMINFO {brkval : 0, freemem : 0, freemem32 : 0}

When I run simulation WITHOUT --mav20 and witch SERIAL0_PROTOCOL 2.0

SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--map" "--console"

param fetch SERIAL0_PROTOCOL
STABILIZE> Requested parameter SERIAL0_PROTOCOL
SERIAL0_PROTOCOL = 2.000000

meminfo shows
status meminfo
STABILIZE> 121: MEMINFO {brkval : 0, freemem : 0, freemem32 : 131072}

When I run simulation WITH --mav20 and witch SERIAL0_PROTOCOL 1.0

SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--mav20" "--map" "--console"

param fetch SERIAL0_PROTOCOL
STABILIZE> Requested parameter SERIAL0_PROTOCOL
SERIAL0_PROTOCOL = 1.000000

meminfo shows
STABILIZE> 264: MEMINFO {brkval : 0, freemem : 0, freemem32 : 0}

When I run simulation WITH --mav20 and witch SERIAL0_PROTOCOL 2.0

 SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--mav20" "--map" "--console"
param fetch SERIAL0_PROTOCOL
STABILIZE> Requested parameter SERIAL0_PROTOCOL
SERIAL0_PROTOCOL = 2.000000

status MEMINFO
STABILIZE> 366: MEMINFO {brkval : 0, freemem : 0, freemem32 : 131072}

It looks like freemem32 is 0 when i use SERIAL0_PROTOCOL 1 regardless --mav20 argument.
Maybe i should change MAVProxy version ?

python mavproxy.py --version
WARNING: You should uninstall ModemManager as it conflicts with APM and Pixhawk
MAVProxy is a modular ground station using the mavlink protocol
MAVProxy Version: 1.6.1

May ModemManager cause problems?

1 Like

Thank You very much for reply. I am a litte bit confused.

Ah, yes. Are you restarting the simulation each time with the different
serial protocols? It does matter.

I suggest just find something which gives you 1031072 in freemem32 and
keep doing that…

Maybe i should change MAVProxy version ?

That won’t help :slight_smile:

python mavproxy.py --version
WARNING: You should uninstall ModemManager as it conflicts with APM and Pix
hawk
MAVProxy is a modular ground station using the mavlink protocol
MAVProxy Version: 1.6.1

May ModemManager cause problems?

ummm… yes? :slight_smile: apt-get remove modemmanager

Yours,

Everytime i changed SERIAL0_PROTOCOL i was restarting the simulation:)

OK i go back to use --mav20 and SERIAL0_PROTOCOL 2, and it gives me 131072 in freemem32.

It was quite a silly question:), i removed it.

Maybe problem is in software that i use to display data. I am using this *.c file
c example udp reading. I compiled this with mavlink 2.0 genereted files.
In for loop there is code that sends Heartbeat, can this cause problems?
for (;:wink:
{

		/*Send Heartbeat */
		mavlink_msg_heartbeat_pack(1, 200, &msg, MAV_TYPE_HELICOPTER, MAV_AUTOPILOT_GENERIC, MAV_MODE_GUIDED_ARMED, 0, MAV_STATE_ACTIVE);
		len = mavlink_msg_to_send_buffer(buf, &msg);
bytes_sent = sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in));

Maybe problem is in software that i use to display data. I am using this
*.c file
c example udp reading. I compiled this with mavlink 2.0 genereted files.
In for loop there is code that sends Heartbeat, can this cause problems?

Have you indicated that the messages should be encoded using mavlink2
using mavlink_set_proto_version(…) ?

Peter

I have example c program compiled with mavlink1.0 and mavlink2.0 .
I made simple test by using QGround Control with two version of program.

When i run program compiled using 2.0

There was extra info in QGroundControl command, that it was switched to 2.0 and received Heartbeats looks like 2.0.
When i run program compiled using 1.0

There was no additional info in QGroundControl windows, and received Heartbeats looks like 1.0

Maybe i am wrong, but i think that c compiled program use mavlink 2.0 headers properly.

I made one extra test, i turned c program off and started MAVProxy with --mav20
next i edited simple python udp read python Udp Example
import socket

UDP_IP = "127.0.0.1"
UDP_PORT = 14550

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

data, addr = sock.recvfrom(2048)
data

received data
'\xfd\x1a\x00\x00\xfa\x01\x01\x1b\x00\x00o\x16F\x12\x00\x00\x00\x00\x00\x00\x00\x00\x17\xfc\x04\x00\x04\x00\x04\x00\xb7\x007\x00\xc2\x01\x98D'

It looks OK now, It starts with 0xFD. I do not know what helped, maybe it was ModemManager. Peter Barket sincerely thank you for your time!

1 Like