Hi all,
I’m working on a project with the goal to build soaring flights over the sea shore, to help NGO protecting sea environment.
After a deep look on MP documentation, it seems that writing Python scripts to enhance the Ardupilot soaring module will be the right way.
(If you want to help on this project, you’re welcome !! )
So, I’ve installed Pymavlink + SITL + MAVPROXY under WSL
- It works fine, SITL/Mavproxy are working well under Ubuntu => and MANY thanks to the process built by the Ardupilot dev team, it’s really usefull !! (I tried before with Cygwin, a nightmare …)
- Now I’ve got problems to build scripts to make tests under SITL/Mavproxy, it’s more about my understanding on how to use the MAVLINK commands
Below an example about take off , quick flight and landing
When I’m starting this script, this is what I’ve got in my WSL console:
nico@LAPTOP:~/test-scripts/pymavlink$ ./Test1.py
Connected to system: 1 , component: 0
Waiting for the vehicle to arm
Armed!
End flight
nico@LAPTOP:~/
Nothing in the Mavproxy pop-up and nothing in the map, nothing in the SITL console as well
So it seems that I’ve got many to learn, but your help here will be very appreciated !
#!/usr/bin/python3
# test
import time
import math
from pymavlink import mavutil
# connect to SITL
master = mavutil.mavlink_connection('tcp:127.0.0.1:5762')
# wait for a heartbeat
master.wait_heartbeat()
# inform user
print("Connected to system:", master.target_system, ", component:", master.target_component)
# arm
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
0, # confirmation
1, # param1 (1 to indicate arm)
0, # param2 (all other params meaningless)
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
# wait arming confirmed
print("Waiting for the vehicle to arm")
master.motors_armed_wait()
print('Armed!')
# Disarm
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
0, # confirmation
1, # param1 (0 to indicate disarm)
0, # param2 (all other params meaningless)
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
# wait until disarming confirmed
master.motors_disarmed_wait()
# mode Guided
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_MODE,
0, # confirmation
1, # param1 (MAV_MODE_FLAG_CUSTOM_MODE_ENABLED)
15, # param2 (flightmode number)
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
#takeoff
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_NAV_TAKEOFF,
0, # confirmation
30, # param1 (pitch angle)
0, # param2
0, # param3
0, # param4
0, # param5
0, # param6
100) # param7 (altitude)
#create NAV
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
0, # confirmation
0, # param1
50, # param2 (Acc radius)
0, # param3 (Pass by)
0, # param4
-35.36470932, # param5 (lat)
149.16790353, # param6 (long)
100) # param7 (altitude)
# message MISSION_ITEM_INT
mavutil.mavlink.MISSION_ITEM_INT()
# landing
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_NAV_LAND,
0, # confirmation
0, # Abort Alt
2, # Land Mode
0,
10, # Yaw Angle
-35.363262, #lat
149.165237, #long
584) #alt
# end
print ("End flight")