comm_link.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_COMM_LINK_H
33 #define ROSFLIGHT_FIRMWARE_COMM_LINK_H
34 
35 #include "board.h"
36 #include "param.h"
37 #include "sensors.h"
38 #include "state_manager.h"
39 
40 #include <turbomath/turbomath.h>
41 
42 #include <cstdint>
43 
44 namespace rosflight_firmware
45 {
47 {
48 public:
49  enum class LogSeverity
50  {
51  LOG_INFO,
53  LOG_ERROR,
55  };
56 
57  enum class Command
58  {
59  COMMAND_READ_PARAMS,
60  COMMAND_WRITE_PARAMS,
61  COMMAND_SET_PARAM_DEFAULTS,
62  COMMAND_ACCEL_CALIBRATION,
63  COMMAND_GYRO_CALIBRATION,
64  COMMAND_BARO_CALIBRATION,
65  COMMAND_AIRSPEED_CALIBRATION,
66  COMMAND_RC_CALIBRATION,
67  COMMAND_REBOOT,
68  COMMAND_REBOOT_TO_BOOTLOADER,
69  COMMAND_SEND_VERSION
70  };
71 
73  {
74  enum class Mode
75  {
76  PASS_THROUGH,
77  ROLLRATE_PITCHRATE_YAWRATE_THROTTLE,
78  ROLL_PITCH_YAWRATE_THROTTLE
79  };
80 
81  struct Channel
82  {
83  float value;
84  bool valid;
85  };
86 
92  };
93 
94  struct AuxCommand
95  {
96  enum class Type
97  {
98  DISABLED,
99  SERVO,
100  MOTOR
101  };
102 
103  struct AuxChannel
104  {
106  float value;
107  };
108 
109  AuxChannel cmd_array[14];
110  };
111 
113  {
114  public:
115  virtual void param_request_list_callback(uint8_t target_system) = 0;
116  virtual void param_request_read_callback(uint8_t target_system,
117  const char *const param_name,
118  int16_t param_index) = 0;
119  virtual void param_set_int_callback(uint8_t target_system, const char *const param_name, int32_t param_value) = 0;
120  virtual void param_set_float_callback(uint8_t target_system, const char *const param_name, float param_value) = 0;
121  virtual void command_callback(Command command) = 0;
122  virtual void timesync_callback(int64_t tc1, int64_t ts1) = 0;
123  virtual void offboard_control_callback(const OffboardControl &control) = 0;
124  virtual void aux_command_callback(const AuxCommand &command) = 0;
125  virtual void external_attitude_callback(const turbomath::Quaternion &q) = 0;
126  virtual void heartbeat_callback() = 0;
127  };
128 
129  virtual void init(uint32_t baud_rate, uint32_t dev) = 0;
130  virtual void receive() = 0;
131 
132  // send functions
133 
134  virtual void send_attitude_quaternion(uint8_t system_id,
135  uint64_t timestamp_us,
136  const turbomath::Quaternion &attitude,
137  const turbomath::Vector &angular_velocity) = 0;
138  virtual void send_baro(uint8_t system_id, float altitude, float pressure, float temperature) = 0;
139  virtual void send_command_ack(uint8_t system_id, Command command, bool success) = 0;
140  virtual void send_diff_pressure(uint8_t system_id, float velocity, float pressure, float temperature) = 0;
141  virtual void send_heartbeat(uint8_t system_id, bool fixed_wing) = 0;
142  virtual void send_imu(uint8_t system_id,
143  uint64_t timestamp_us,
144  const turbomath::Vector &accel,
145  const turbomath::Vector &gyro,
146  float temperature) = 0;
147  virtual void send_log_message(uint8_t system_id, LogSeverity severity, const char *text) = 0;
148  virtual void send_mag(uint8_t system_id, const turbomath::Vector &mag) = 0;
149  virtual void send_named_value_int(uint8_t system_id,
150  uint32_t timestamp_ms,
151  const char *const name,
152  int32_t value) = 0;
153  virtual void send_named_value_float(uint8_t system_id,
154  uint32_t timestamp_ms,
155  const char *const name,
156  float value) = 0;
157  virtual void send_output_raw(uint8_t system_id, uint32_t timestamp_ms, const float raw_outputs[14]) = 0;
158  virtual void send_param_value_int(uint8_t system_id,
159  uint16_t index,
160  const char *const name,
161  int32_t value,
162  uint16_t param_count) = 0;
163  virtual void send_param_value_float(uint8_t system_id,
164  uint16_t index,
165  const char *const name,
166  float value,
167  uint16_t param_count) = 0;
168  virtual void send_rc_raw(uint8_t system_id, uint32_t timestamp_ms, const uint16_t channels[8]) = 0;
169  virtual void send_sonar(uint8_t system_id,
170  /* TODO enum type*/ uint8_t type,
171  float range,
172  float max_range,
173  float min_range) = 0;
174  virtual void send_status(uint8_t system_id,
175  bool armed,
176  bool failsafe,
177  bool rc_override,
178  bool offboard,
179  uint8_t error_code,
180  uint8_t control_mode,
181  int16_t num_errors,
182  int16_t loop_time_us) = 0;
183  virtual void send_timesync(uint8_t system_id, int64_t tc1, int64_t ts1) = 0;
184  virtual void send_version(uint8_t system_id, const char *const version) = 0;
185  virtual void send_gnss(uint8_t system_id, const GNSSData &data) = 0;
186  virtual void send_gnss_full(uint8_t system_id, const GNSSFull &data) = 0;
187  virtual void send_error_data(uint8_t system_id, const StateManager::BackupData &error_data) = 0;
188  virtual void send_battery_status(uint8_t system_id, float voltage, float current) = 0;
189 
190  // register listener
191  virtual void set_listener(ListenerInterface *listener) = 0;
192 };
193 
194 } // namespace rosflight_firmware
195 
196 #endif // ROSFLIGHT_FIRMWARE_COMM_LINK_H
virtual void send_diff_pressure(uint8_t system_id, float velocity, float pressure, float temperature)=0
static volatile int16_t gyro[3]
Definition: drv_mpu6050.c:277
float altitude
Definition: ms4525.c:41
float pressure
Definition: ms4525.c:41
float temperature
Definition: ms4525.c:41
virtual void send_rc_raw(uint8_t system_id, uint32_t timestamp_ms, const uint16_t channels[8])=0
virtual void send_attitude_quaternion(uint8_t system_id, uint64_t timestamp_us, const turbomath::Quaternion &attitude, const turbomath::Vector &angular_velocity)=0
virtual void send_battery_status(uint8_t system_id, float voltage, float current)=0
virtual void send_baro(uint8_t system_id, float altitude, float pressure, float temperature)=0
virtual void send_timesync(uint8_t system_id, int64_t tc1, int64_t ts1)=0
virtual void send_gnss(uint8_t system_id, const GNSSData &data)=0
virtual void init(uint32_t baud_rate, uint32_t dev)=0
static volatile int16_t accel[3]
Definition: drv_mpu6050.c:276
virtual void send_param_value_float(uint8_t system_id, uint16_t index, const char *const name, float value, uint16_t param_count)=0
ROSLIB_DECL std::string command(const std::string &cmd)
virtual void send_heartbeat(uint8_t system_id, bool fixed_wing)=0
virtual void send_log_message(uint8_t system_id, LogSeverity severity, const char *text)=0
static const channelConfig_t channels[CC_CHANNELS_PER_TIMER]
Definition: drv_timer.c:111
virtual void send_error_data(uint8_t system_id, const StateManager::BackupData &error_data)=0
virtual void send_version(uint8_t system_id, const char *const version)=0
virtual void send_imu(uint8_t system_id, uint64_t timestamp_us, const turbomath::Vector &accel, const turbomath::Vector &gyro, float temperature)=0
virtual void send_named_value_int(uint8_t system_id, uint32_t timestamp_ms, const char *const name, int32_t value)=0
virtual void set_listener(ListenerInterface *listener)=0
virtual void send_command_ack(uint8_t system_id, Command command, bool success)=0
virtual void send_output_raw(uint8_t system_id, uint32_t timestamp_ms, const float raw_outputs[14])=0
virtual void send_named_value_float(uint8_t system_id, uint32_t timestamp_ms, const char *const name, float value)=0
virtual void send_status(uint8_t system_id, bool armed, bool failsafe, bool rc_override, bool offboard, uint8_t error_code, uint8_t control_mode, int16_t num_errors, int16_t loop_time_us)=0
virtual void send_gnss_full(uint8_t system_id, const GNSSFull &data)=0
virtual void send_param_value_int(uint8_t system_id, uint16_t index, const char *const name, int32_t value, uint16_t param_count)=0
virtual void send_mag(uint8_t system_id, const turbomath::Vector &mag)=0
virtual void send_sonar(uint8_t system_id, uint8_t type, float range, float max_range, float min_range)=0


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