Mavlink Set_Mode Flight mode

2,291 views
Skip to first unread message

Enzo Buono

unread,
Jun 22, 2015, 11:29:25 AM6/22/15
to mav...@googlegroups.com
Hi to all,
I am programming an "app" with c++, I can arm disarm takeoff utilizing mavlink library, but I don't undersand wich message I could use for change flight mode with my apm. I have a quadcopter and I want to change the current flight mode in Guided MODE. I tried to use MAV_CMD_DO_SET_HOME but It seems unsupported. So I tried with MAVLINK_MSG_ID_SET_HOME but nothing change. In mission planner there is a button that change the mode, which is the message that It sends? Sorry for my english...

Hamish Willee

unread,
Jun 23, 2015, 7:33:09 PM6/23/15
to mav...@googlegroups.com
Hi Enzo

If you were programming this in DroneKit you'd just set the mode attribute. But as you're not, you need to call the set the SET_MODE command directly. The full set of commands you can call in GUIDED mode is listed in Copter Commands in Guided Mode (actually to be precise these are the commands you can mostly call in any mode, but which are intended for guided mode).

From my DroneKit testing MAV_CMD_DO_SET_HOME does work, but the changes aren't visible on the map immediately. If you fetch the set of commands from the drone then a watching GCS will see that the home position has changed.

Cheerio
H

Bill Bonney

unread,
Jun 23, 2015, 8:38:47 PM6/23/15
to mav...@googlegroups.com
It’s not hard (easier if it was documented like dronekit ;) )

static inline void mavlink_msg_set_mode_send(mavlink_channel_t chan, uint8_t target_system, uint8_t base_mode, uint32_t custom_mode)

Use a base mode of MAV_MODE_FLAG_CUSTOM_MODE_ENABLED

and then the custom modes are defined in define.h in ArduCopter dir.


// Auto Pilot modes
// ----------------
#define STABILIZE 0                     // hold level position
#define ACRO 1                          // rate control
#define ALT_HOLD 2                      // AUTO control
#define AUTO 3                          // AUTO control
#define GUIDED 4                        // AUTO control
#define LOITER 5                        // Hold a single location
#define RTL 6                           // AUTO control
#define CIRCLE 7                        // AUTO control
#define LAND 9                          // AUTO control
#define OF_LOITER 10                    // Hold a single location using optical flow sensor
#define DRIFT 11                        // DRIFT mode (Note: 12 is no longer used)
#define SPORT 13                        // earth frame rate control
#define FLIP        14                  // flip the vehicle on the roll axis
#define AUTOTUNE    15                  // autotune the vehicle's roll and pitch gains
#define POSHOLD     16                  // position hold with manual override
#define NUM_MODES   17


On Jun 22, 2015, at 08:29, Enzo Buono <ipink...@inwind.it> wrote:

Hi to all,
I am programming an "app" with c++, I can arm disarm takeoff utilizing mavlink library, but I don't undersand wich message I could use for change flight mode with my apm. I have a quadcopter and I want to change the current flight mode in Guided MODE. I tried to use MAV_CMD_DO_SET_HOME but It seems unsupported. So I tried with MAVLINK_MSG_ID_SET_HOME but nothing change. In mission planner there is a button that change the mode, which is the message that It sends? Sorry for my english...

--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "MAVLink" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an mavlink+u...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

Enzo Buono

unread,
Jun 24, 2015, 5:07:07 AM6/24/15
to mav...@googlegroups.com
Thank you very much Bill, it works now! But now I would know if drone send a message when he reached a waypoint, I need to know when a drone reached a waypoint in guided mode, so I think that I must add a new mavlink message, but I don't know which is the function that handle the navigation to a waypoint and If there is a code that tell me that. Thank you for your attention :)

Hamish Willee

unread,
Jun 24, 2015, 7:42:42 PM6/24/15
to mav...@googlegroups.com
Hi Enzo

There is no message when you reach the destination in guided mode (in AUTO/missions of course you can tell you've reached a location when the current command number changes). 

In the DroneKit examples I wrote my own "proximity" detector. 

Regards
Hamish

murtaza bagwala

unread,
Jul 15, 2015, 7:34:53 AM7/15/15
to mav...@googlegroups.com
So what I get from above discussion is that there are two ways of setting the mode
1) Using command _message with MAV_CMD
2) Using msg_ set_mode with parameter base mode and custom mode

What is the difference between the two are they same or ArduPlane treats them in different way ?
Reply all
Reply to author
Forward
0 new messages