command_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, James Jackson and Daniel Koch, BYU MAGICC Lab
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef ROSFLIGHT_FIRMWARE_COMMAND_MANAGER_H
33 #define ROSFLIGHT_FIRMWARE_COMMAND_MANAGER_H
34 
36 
37 #include "rc.h"
38 
39 #include <cstdbool>
40 #include <cstdint>
41 
42 namespace rosflight_firmware
43 {
44 class ROSflight;
45 
46 typedef enum
47 {
48  RATE, // Channel is is in rate mode (mrad/s)
49  ANGLE, // Channel command is in angle mode (mrad)
50  THROTTLE, // Channel is direcly controlling throttle max/1000
51  PASSTHROUGH, // Channel directly passes PWM input to the mixer
53 
54 typedef struct
55 {
56  bool active; // Whether or not the channel is active
57  control_type_t type; // What type the channel is
58  float value; // The value of the channel
60 
61 typedef struct
62 {
63  uint32_t stamp_ms;
68 } control_t;
69 
71 {
72 private:
73  typedef struct
74  {
78  } mux_t;
79 
84 
85  // clang-format off
87  {false, ANGLE, 0.0},
88  {false, ANGLE, 0.0},
89  {false, RATE, 0.0},
90  {false, THROTTLE, 0.0}};
92  {false, ANGLE, 0.0},
93  {false, ANGLE, 0.0},
94  {false, RATE, 0.0},
95  {false, THROTTLE, 0.0}};
97  {false, ANGLE, 0.0},
98  {false, ANGLE, 0.0},
99  {false, RATE, 0.0},
100  {false, THROTTLE, 0.0}};
101 
103  {true, ANGLE, 0.0},
104  {true, ANGLE, 0.0},
105  {true, RATE, 0.0},
106  {true, THROTTLE, 0.0}};
108  {true, PASSTHROUGH, 0.0},
109  {true, PASSTHROUGH, 0.0},
110  {true, PASSTHROUGH, 0.0},
111  {true, THROTTLE, 0.0}};
112  // clang-format on
113 
114  typedef enum
115  {
118  } att_mode_t;
119 
121  {
126  };
127 
128  typedef struct
129  {
133 
135 
137 
140 
142 
143  void param_change_callback(uint16_t param_id) override;
144  void init_failsafe();
145 
146  bool do_roll_pitch_yaw_muxing(MuxChannel channel);
147  bool do_throttle_muxing(void);
148  void do_min_throttle_muxing();
149 
150  void interpret_rc(void);
151  bool stick_deviated(MuxChannel channel);
152 
153 public:
155  void init();
156  bool run();
157  bool rc_override_active();
159  void set_new_offboard_command(control_t new_offboard_command);
160  void set_new_rc_command(control_t new_rc_command);
162  inline const control_t &combined_control() const { return combined_command_; }
163  inline const control_t &rc_control() const { return rc_command_; }
164 };
165 
166 } // namespace rosflight_firmware
167 
168 #endif // ROSFLIGHT_FIRMWARE_COMMAND_MANAGER_H
rc_stick_override_t rc_stick_override_[3]
const control_t & combined_control() const
const control_t & rc_control() const
void param_change_callback(uint16_t param_id) override
void set_new_offboard_command(control_t new_offboard_command)
void set_new_rc_command(control_t new_rc_command)
bool do_roll_pitch_yaw_muxing(MuxChannel channel)
bool stick_deviated(MuxChannel channel)


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Sat May 9 2020 03:16:52