Perfect ๐Ÿ‘ letโ€™s go step by step so you can use a YAML mission file to make PX4 fly a circle in Mission mode with MAVROS.


๐Ÿ”น Step 1. Create the YAML file

Make a file called circle_mission.yaml in your workspace (e.g. ~/ros2_ws/):

waypoints:
  - frame: 3                # MAV_FRAME_GLOBAL_REL_ALT
    command: 22             # MAV_CMD_NAV_TAKEOFF
    is_current: true
    autocontinue: true
    param1: 0.0
    param2: 0.0
    param3: 0.0
    param4: 0.0
    x_lat: 47.397750        # starting latitude (replace with your home location)
    y_long: 8.545594        # starting longitude
    z_alt: 10.0             # takeoff altitude (m)

  # Circle waypoints (polygon approximation, 8 points)
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397930, y_long: 8.545594, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397900, y_long: 8.545744, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397750, y_long: 8.545774, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397600, y_long: 8.545744, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397570, y_long: 8.545594, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397600, y_long: 8.545444, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397750, y_long: 8.545414, z_alt: 10.0 }
  - { frame: 3, command: 16, is_current: false, autocontinue: true, x_lat: 47.397900, y_long: 8.545444, z_alt: 10.0 }

๐Ÿ‘‰ Replace the latitude/longitude with your SITL home position or your real GPS coords.


๐Ÿ”น Step 2. Clear any old mission

Run this in a terminal:

ros2 service call /mavros/mission/clear mavros_msgs/srv/WaypointClear "{}"


๐Ÿ”น Step 3. Push the YAML mission

Unfortunately, ros2 service call doesnโ€™t directly accept a YAML file with many waypoints.

You have two good options:

Option A: QGroundControl (easy)

Option B: Python helper (ROS2 node)