Error using guided mode

In guided mode I’m trying to move to a specific lat lon using the following pymavlink command

master.mav.set_position_target_global_int_send(
0, # time_boot_ms (not used)
master.target_system,
master.target_component,
mavutil.mavlink.SET_POSITION_TARGET_GLOBAL_INT,
3, # coordinate frame - mav_frame global
3580, # type mask - use position
30391986, # latitiude *1e7
-97901289, # longitude *1e7
0, # altitude in m above sea level, home or terrain
0, # x vel in m/s positive is north
0, # y vel
0, # z vel
0, # accel x
0, # accel y
0, # accel z
0, # yaw in rad - 0 is forward
0) # yaw rate rad/s

The error I’m getting is as follows:

AttributeError: module 'pymavlink.dialects.v20.ardupilotmega' has no attribute 'SET_POSITION_TARGET_GLOBAL_INT'

I’ve checked that the SET_POSITION_TARGET_GLOBAL_INT enum is in my python3.8/site-packages/pymavlink/dialects/v20/common.xml file.

I’m using

pymavlink 2.4.41
arduboat 4.3.13

Any help fixing the error is much appreciated!

Hi @TMJ,

What are you attempting to do with your fifth code line? You’re already specifying the message type in the function name (in your first line), so I’m not sure why the fifth line is there or what you’re expecting it to do. Checking the mavutil.mavlink module also reveals that SET_POSITION_TARGET_GLOBAL_INT is not a variable within it, although there are various relevant variables for the enum flags (e.g. POSITION_TARGET_TYPEMASK_AX_IGNORE), and there’s a variable for the message ID (MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT), although that’s not relevant given you’re using a function dedicated to that message.

In case it’s relevant, we have an (old) example of using that message here, with a focus on setting a depth target for ArduSub. It may help to follow the syntax and structure used there, with the values changed as appropriate for your use-case :slight_smile:

Thanks Eliot. This works:

master.mav.set_position_target_global_int_send(
0, # time_boot_ms (not used)
master.target_system,
master.target_component,
mavutil.mavlink.MAV_FRAME_GLOBAL_INT, # coordinate frame - mav_frame global
3580, # type mask - use position
30391280, #30391986, # latitiude *1e7 30391280 -97902180
-97902180, #-97901289, # longitude *1e7
-.9, # altitude in m above sea level, home or terrain
0, # x vel in m/s positive is north
0, # y vel
0, # z vel
0, # accel x
0, # accel y
0, # accel z
0, # yaw in rad - 0 is forward
0) # yaw rate rad/s