Python Raw MissionItem error

I’m trying to use MAVSDK-Python to construct a raw mission and send it to a simulated vehicle. Regular MissionItems are working just fine, but I need to override acceptance radius and yaw (for a fixed wing).

I’m constructing my mission like this:

   mission_items.append(mission_raw.MissionItem(
     0,
     3, #MAV_FRAME_GLOBAL_RELATIVE_ALT
     16, #MAV_CMD_NAV_WAYPOINT,
     0, 1,
       0, 1, 0, 0,
       *position,
     0
   ))

   await drone.mission.upload_mission(items)

position is a three element tuple of lat, lon, alt
And I’m getting this:

  File "MAVSDK-Python/examples/takeoff_and_land.py", line 74, in run
    await drone.mission_raw.upload_mission(mission_items)
  File "/usr/local/lib/python3.8/site-packages/mavsdk/mission_raw.py", line 563, in upload_mission
    elem.translate_to_rpc(rpc_elem)
  File "/usr/local/lib/python3.8/site-packages/mavsdk/mission_raw.py", line 309, in translate_to_rpc
    rpcMissionItem.x = self.x
TypeError: 34.034613757642056 has type float, but expected one of: int, long

I see here https://mavsdk.mavlink.io/develop/en/api_reference/structmavsdk_1_1_mission_raw_1_1_mission_item.html that the last elements of the MissionItem struct are int32_t, int32_t, float. Shouldn’t those be unions? The MAV_CMD_NAV_WAYPOINT command definitely puts floats in those positions.

It’s quite possible that I completely don’t understand how this works. I’m completely new to this SDK!

Okay, I now see in the docs that I need to multiply those floating point numbers by 10e7. But now I’m getting an even less instructive error:

raise MissionRawError(result, "upload_mission()", mission_items)
mavsdk.mission_raw.MissionRawError: INVALID_ARGUMENT: 'Invalid Argument'; origin: upload_mission(); params: ([<mavsdk.mission_raw.MissionItem object at 0x10515aa30>, <mavsdk.mission_raw.MissionItem object at 0x10515ac10>, <mavsdk.mission_raw.MissionItem object at 0x10515ad00>, <mavsdk.mission_raw.MissionItem object at 0x105274ca0>, <mavsdk.mission_raw.MissionItem object at 0x105274a30>],)

Hi, it’s me again. Follow along as I slowly solve my dumb mistakes!

Here’s what finally worked:

     [mission_raw.MissionItem(
       seq, # gotta include a real sequence number!
       3, #mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT
       16, #mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
       seq==0 and 1 or 0, # one of the commands must be current!
       1, # don't forget to autocontinue
         0, 1, 0, 90,
         int(position[0] * 10**7), # next time, I'll read the documentation
         int(position[1] * 10**7),
         position[2],
       0
     ) for position in positions]