ASMESDC2018
/home/swerve/Github/sdc_2018/omni_robot/RCController6CH.h
Go to the documentation of this file.
1 
8 #include <IntervalTimer.h>
9 
10 #ifndef RC_CONTROLLER_6CH_H_
11 #define RC_CONTROLLER_6CH_H_
12 
13 #define CH_VALUE_MIN 1200 // min PPM signal in microseconds
14 #define CH_VALUE_MAX 1800 // max PPM signal in microseconds
15 
16 #define CH_VALUE_MAP_MIN -100 // minimum value to map the RC controller input to
17 #define CH_VALUE_MAP_MAX 100 // maximum value to map the RC controller input to
18 
19 #define CH_MAP_TYPE_BINARY 1 // maps channel values to 0 to 1
20 #define CH_MAP_TYPE_UNIDIRECTIONAL 2 // maps channel values to 0 to 100
21 #define CH_MAP_TYPE_BIDIRECTIONAL 3 // maps channel values to -100 to 100
22 
23 #define MAX_CHANNELS 6 // max channels of the RC controller
24 
25 #define CHANNEL_UPDATE_RATE 100000 // update rate in microseconds
26 #define PULSE_IN_TIMEOUT 100000 // timeout for pulse function in microseconds
27 
29  volatile long int timestamp; // time of last update
30  volatile int value_ch_1;
31  volatile int value_ch_2;
32  volatile int value_ch_3;
33  volatile int value_ch_4;
34  volatile int value_ch_5;
35  volatile int value_ch_6;
36  volatile int *values[6] = {&value_ch_1, &value_ch_2, &value_ch_3,
37  &value_ch_4, &value_ch_5, &value_ch_6}; // iterate through channel values
38 };
40  int PIN_CH_1;
41  int PIN_CH_2;
42  int PIN_CH_3;
43  int PIN_CH_4;
44  int PIN_CH_5;
45  int PIN_CH_6;
46  int *PINS[6] = {&PIN_CH_1, &PIN_CH_2, &PIN_CH_3, &PIN_CH_4,
47  &PIN_CH_5, &PIN_CH_6}; // iterate through pins
48 };
49 
51 public:
52 
53  /* Constructor Funcitons */
54  RCController6CH(int, void (*)());
61  RCController6CH(int, int, int, int, int, int, void (*)());
68  /* Public Funcitons */
69  void setupController(void (*)());
76  void updateChannels(void);
83  void displayChannels(void);
90 protected:
91 
94 
95  int CH_UPDATE_RATE = CHANNEL_UPDATE_RATE; // frequency at which the controller input model is executed
96 
97  friend class OmniRobot; // allow omni robot to access protected variables
98  friend class OffenseRobot; // allow offense robot to access protected variables
99 
100 private:
101 
102  IntervalTimer _interval_timer;
103 
104 };
105 
106 #endif /* RC_CONTROLLER_6CH_H_ */
107 
108 
#define CHANNEL_UPDATE_RATE
#define PIN_CH_1
Definition: OmniRobot.h:27
RCController6CHState state
RCController6CHPins pins
volatile int value_ch_3
volatile int value_ch_5
volatile long int timestamp
volatile int * values[6]
volatile int value_ch_2
volatile int value_ch_6
volatile int value_ch_1
volatile int value_ch_4