Hi Everyone,
I am preparing for ship-born multicopter operations tried to write a script to dynamically update the home point based on the ships location. For this purpose I have two GNSS GNSS ground stations on a boom roughly 2m apart from each other so I can periodically calculate a home point in a certain distance and direction to my reference system. All of this is working. My only problem is sending the new home point to the FC via MavLink, but I always get an error like: “NameError: name ‘MAVLink’ is not defined”
Here is a simplified example I use for testing:
import time
import MissionPlanner # Import Mission Planner functionality
#from MissionPlanner.MAVLink import MAVLink
import clr
clr.AddReference(“MissionPlanner.Utilities”) # For MAVLink commands
clr.AddReference(‘System’) # Add reference to .NET System library
clr.AddReference(“MissionPlanner.MAVLink”)
from System.IO.Ports import SerialPort
import mathtime.sleep(3)
home_lat=60.123
home_lon=120.123
alt1=10.3while True:
# Set the home point using the MAVLink command MAV_CMD_DO_SET_HOME
MAV.doCommand(MAVLink.MAV_CMD_DO_SET_HOME, 1, 0, 0, 0, home_lat, home_lon, alt1)
print(f"Updated Home Point to: Latitude {home_lat}, Longitude {home_lon}, Altitude {alt1}")# Update home point every 10 seconds time.sleep(10)
My guess is that I don’t have all required packages installed or that MissionPlanner does not find them.
I am fairly new to using python with MissionPlanner so any help is highly appreciated.
For reference: I use Mission Planner 1.3.82 (win10) and a cubeOrange with ArduCopter v4.5.7