简体   繁体   中英

Geofence with pymavlink or dronekit-python

I'm trying to set fence for the copter using dronekit-python.I found command MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION in this document .

But it doesn't work when I use the vehicle.message_factory.command_long_send (which is the function command_long_send in class MAVLink from the file ardupilotmega.py actually ), I cannot find mavutil.mavlink.MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION either (so I use integer 5003 directly).

After reading the source code of ardupilotmega.py, I found that there is a function called fence_point_send , so can anyone tell me how to use it? How can I set the geofence just like what Misson Planner do with python?

You should use this command MAV_CMD_DO_FENCE_ENABLE to enable or disable geo-fence. geo-fence has two parameters.

  1. FENCE_ALT_MAX: The maximum altitude that the vehicle can reach.
  2. FENCE_RADIUS : The maximum circle radius the vehicle can move in.

To change the parameters in code, you should use a function like PARAM_SET and pass the name and value for the parameter.

PS: You can do all that using GCS like Mission Planner, APM Planner2 or Mavproxy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM