px4_custom_mode.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  *
00003  *   Copyright (c) 2013-2015 PX4 Development Team. All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in
00013  *    the documentation and/or other materials provided with the
00014  *    distribution.
00015  * 3. Neither the name PX4 nor the names of its contributors may be
00016  *    used to endorse or promote products derived from this software
00017  *    without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00023  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00029  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  *
00032  ****************************************************************************/
00033 
00044 #pragma once
00045 
00046 //#include <stdint.h>
00047 
00048 namespace px4 {
00055 union custom_mode {
00056         enum MAIN_MODE : uint8_t {
00057                 MAIN_MODE_MANUAL = 1,
00058                 MAIN_MODE_ALTCTL,
00059                 MAIN_MODE_POSCTL,
00060                 MAIN_MODE_AUTO,
00061                 MAIN_MODE_ACRO,
00062                 MAIN_MODE_OFFBOARD,
00063                 MAIN_MODE_STABILIZED,
00064                 MAIN_MODE_RATTITUDE
00065         };
00066 
00067         enum SUB_MODE_AUTO : uint8_t {
00068                 SUB_MODE_AUTO_READY = 1,
00069                 SUB_MODE_AUTO_TAKEOFF,
00070                 SUB_MODE_AUTO_LOITER,
00071                 SUB_MODE_AUTO_MISSION,
00072                 SUB_MODE_AUTO_RTL,
00073                 SUB_MODE_AUTO_LAND,
00074                 SUB_MODE_AUTO_RTGS
00075         };
00076 
00077         struct {
00078                 uint16_t reserved;
00079                 uint8_t main_mode;
00080                 uint8_t sub_mode;
00081         };
00082         uint32_t data;
00083         float data_float;
00084 
00085         custom_mode() : data(0)
00086         { };
00087 
00088         explicit custom_mode(uint32_t val) : data(val)
00089         { };
00090 
00091         constexpr custom_mode(uint8_t mm, uint8_t sm) :
00092                 reserved(0),
00093                 main_mode(mm),
00094                 sub_mode(sm)
00095         { };
00096 };
00097 
00105 constexpr uint32_t define_mode(enum custom_mode::MAIN_MODE mm, uint8_t sm = 0) {
00106         return custom_mode(mm, sm).data;
00107 }
00108 
00117 constexpr uint32_t define_mode_auto(enum custom_mode::SUB_MODE_AUTO sm) {
00118         return define_mode(custom_mode::MAIN_MODE_AUTO, sm);
00119 }
00120 };      // namespace px4


mavros
Author(s): Vladimir Ermakov
autogenerated on Sat Jun 8 2019 19:55:19