Hi all,
I am trying to load a “fences.waypoint” file to my APM using python and pymavlink. My setup is the following: i am using Mission planner SITL to simulate and test my code. i also use pymavlink and python 3. My aim is to use built-in Fences and Dijkstra’s algorithm for pathfinding.
This is the screenshot of an example file.
I am able to write Waypoints as a mission to APM and run it on SITL by using the following code.
I couldn’t understand how to use fenceloader = mavwp.MAVFenceLoader() efficiently. any help will be useful.
Thanks.
wp = mavwp.MAVWPLoader()
.
.
.
p = mavutil.mavlink.MAVLink_mission_item_message(self.master.target_system, self.master.target_component, ln_seq, ln_frame,
ln_command,
ln_current, ln_autocontinue, ln_param1, ln_param2, ln_param3, ln_param4, ln_x, ln_y, ln_z)
self.cmd_set_home(home_location,home_altitude)
msg = self.master.recv_match(type = ["COMMAND_ACK"],blocking = True)
logger.info(msg)
logger.info(f"Set home location: {home_location[0]} {home_location[1]}")
sleep(1)
#send waypoint to airframe
self.master.waypoint_clear_all_send()
self.master.waypoint_count_send(self.wp.count())
for i in range(self.wp.count()):
msg = self.master.recv_match(type=["MISSION_REQUEST"],blocking=True)
logger.info(msg)
self.master.mav.send(self.wp.wp(msg.seq))
logger.info(f"Sending waypoint {msg.seq}")