Showing posts with label PyMavlink. Show all posts
Showing posts with label PyMavlink. Show all posts

Sunday, September 2, 2018

Mission Planner VirtualBOX Dronekit-sitl

MissionPlaner on virtualbox

Mission Planer setup

  • Host: ubuntu 16.04
  • Guest: Windows7
  • Virtualbox
  • Install VM VirtualBox Extension Pack (support USB2,3)
  • Install VB Guest Addition
  • Install Firfox (IE crash all the time)
  • .Net 4.62
  • Mission Planner
  • Set VBOX network in bridge mode

Demo: Using Dronekit and Dronekit-SITL

sudo pip install mavproxy sudo pip install dronekit sudo pip install dronekit-sitl
  • Terminal 1
dronekit-sitl copter
  • Terminal 2
export MP_IP="192.168.2.117" mavproxy.py --master tcp:127.0.0.1:5760 --out udp:127.0.0.1:14551 --out udp:`echo $MP_IP`:14550
  • Virtualbox (windows)
    • Change the connection type combo to udp
    • Select port 14550

Note

When run mavproxy got an error: AttributeError: 'module' object has no attribute 'MAV_TYPE_DODECAROTOR'

After some search in google , I found that pymavlink need to upgraded , download and install from pypi.org version 2.2.10 (current version 2.0.6)

Wednesday, August 22, 2018

Pymavlink Ardupilot SITL

  • ardupilot SITL

  • pamavlink

  • Terminal 1

sim_vehicle.py --console
  • Terminal 2 (python code)
from pymavlink import mavutil master = mavutil.mavlink_connection('tcp:127.0.0.1:5762') # Get some information ! while True: try: print(master.recv_match().to_dict()) except: pass

  • Terminal 3 (netstat -natp)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:5760 0.0.0.0:* LISTEN 5976/arducopter tcp 0 0 0.0.0.0:5762 0.0.0.0:* LISTEN 5976/arducopter tcp 0 0 0.0.0.0:5763 0.0.0.0:* LISTEN 5976/arducopter

python output

{'mavpackettype': 'TIMESYNC', 'ts1': 1854891080001, 'tc1': 0} {'custom_mode': 0, 'system_status': 3, 'base_mode': 81, 'autopilot': 3, 'mavpackettype': 'HEARTBEAT', 'type': 2, 'mavlink_version': 3} {'custom_mode': 0, 'system_status': 3, 'base_mode': 81, 'autopilot': 3, 'mavpackettype': 'HEARTBEAT', 'type': 2, 'mavlink_version': 3} {'custom_mode': 0, 'system_status': 3, 'base_mode': 81, 'autopilot': 3, 'mavpackettype': 'HEARTBEAT', 'type': 2, 'mavlink_version': 3}

Friday, August 17, 2018

PyMavlink and PX4 SITL

python implementation of the MAVLink protocol

  • Terminal 1: from PX4 Firmware run
make posix_sitl_default jmavsim

Tip: Run SITL without GUI , good performance save resource

source

  • 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

  • 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}