Introduction to common services of mavros (no wonder Prometheus unlocks and cut offboard is achieved by calling the service, the official offboard sample code of PX4 is also cut offboard by calling the service, the original service is written in MAVROS!)

No wonder Prometheus unlocks and cuts offboard by calling the service (enter 999). The official offboard sample code of PX4 also cuts offboard by calling the service. I was curious about where the service was written before. It turned out to be MAVROS. of! ! ! !

 

I found it, and it really is.

https://gitee.com/maxibooksiyi/mavros/blob/master/mavros_msgs/srv/SetMode.srv

 

 

See this blog post below

https://blog.csdn.net/sinat_16643223/article/details/114060304

Reprinted from: https://blog.csdn.net/zouxu634866/article/details/104112964

Introduction to common services of mavros

Xiaoxu who is always bitten by mosquitoes 2020-01-30 11:13:21 498 Collection 4

Category column: offboard ros

Last release: 2020-01-30 11:13:21 First release: 2020-01-30 11:13:21

Copyright statement: This article is the original article of the blogger and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting.

Link to this article: https://blog.csdn.net/zouxu634866/article/details/104112964

copyright

In mavros , there are two most commonly used services, one is unlocking, and the other is mode switching. Of course, there are other services, such as modifying waypoint information through mavros , but they are not commonly used, so the following only introduces unlocking and mode switching, which are in the previous blog offboardThe source code analysis has already been introduced.


For the usage of these two services, please refer to the previous blog. I won’t repeat them here. I will add which modes can be switched in the mode switching service, and those modes besides the offboard mode.

The source code of mavros needs to be used here : Location:

/ home / zouxu / mavros _ws / src / mavros / mavros / src / lib

Of course, the premise of this location is that you used the source installation method when installing mavros . There is a mavros workspace mavros _ws on your computer. If you don't have this, you can download the source code on github .

We open the directory: uas_stringify.cpp

It has a mode for apm firmware, we only look at the firmware part of px4:

//! PX4 custom mode -> string
static const cmode_map px4_cmode_map{
   
   {
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_MANUAL),           "MANUAL" },
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_ACRO),             "ACRO" },
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_ALTCTL),           "ALTCTL" },
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_POSCTL),           "POSCTL" },
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_OFFBOARD),         "OFFBOARD" },
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_STABILIZED),       "STABILIZED" },
	{ px4::define_mode(px4::custom_mode::MAIN_MODE_RATTITUDE),        "RATTITUDE" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_MISSION), "AUTO.MISSION" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_LOITER),  "AUTO.LOITER" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_RTL),     "AUTO.RTL" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_LAND),    "AUTO.LAND" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_RTGS),    "AUTO.RTGS" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_READY),   "AUTO.READY" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_TAKEOFF), "AUTO.TAKEOFF" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_FOLLOW_TARGET), "AUTO.FOLLOW_TARGET" },
	{ px4::define_mode_auto(px4::custom_mode::SUB_MODE_AUTO_PRECLAND), "AUTO.PRECLAND" },
}};

Listed later are the modes that can be switched.

Guess you like

Origin blog.csdn.net/sinat_16643223/article/details/114796332