python implementation of the MAVLink protocol
SITL and pymavlink setup
- Terminal 1: from PX4 Firmware run
make posix_sitl_default jmavsim
Tip: Run SITL without GUI , good performance save resource
- Edit this file, which is part of jMAVSim repository, Visualizer3D.java13, and change setVisible(true) to setVisible(false).
# find . -name Visualizer3D.java
vim `find . -name Visualizer3D.java`
# search setVisible(true) //line 175
# change setVisible(true) to setVisible(false)
# compile and run again
make posix_sitl_default jmavsim
Now the SITL run without JMavsim GUI
| ___ \ \ \ / / / |
| |_/ / \ V / / /| |
| __/ / \ / /_| |
| | / /^\ \ \___ |
\_| \/ \/ |_/
px4 starting.
INFO [Unknown] Calling startup script: bash etc/init.d-posix/rcS 0
INFO [simulator] Waiting for initial data on UDP port 14560. Please start the flight simulator to proceed..
Init MAVLink
4000000 B/s on udp port 14556 remote port 14550
INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14557 remote port 14540
PyMavlink demo
- use ipython/ python console
from pymavlink import mavutil
master = mavutil.mavlink_connection("udp:127.0.0.1:14540")
#master
# <pymavlink.mavutil.mavudp at 0x7..>
master.recv_match()
_.to_dict()
{'alt': 487971,
'hdg': 40,
'lat': 473977416,
'lon': 85455938,
'mavpackettype': 'GLOBAL_POSITION_INT',
'relative_alt': -12,
'time_boot_ms': 357265,
'vx': -3,
'vy': 0,
'vz': 0}
No comments:
Post a Comment