TeensyNanoExoCode
Loading...
Searching...
No Matches
ExoData.h
Go to the documentation of this file.
1
11#ifndef ExoData_h
12#define ExoData_h
13
14#include "Arduino.h"
15
16#include "LegData.h"
17#include <stdint.h>
18#include "ParseIni.h"
19#include "Board.h"
20#include "StatusLed.h"
21#include "StatusDefs.h"
22/*
23 * ExoData was broken out from the Exo class as we were originally going to have it mirrored on a second microcontroller that handled BLE.
24 * It doesn't need to be done this way if we aren't, and is pretty cumbersome.
25 * Just thought you might be wondering about the weirdness.
26 */
27
28// moved status values to StatusDefs.h
29
30// Type used for the for each joint method, the function should take JointData as input and return void
31typedef void (*for_each_joint_function_t) (JointData*, float*);
32
33
37class ExoData
38{
39 public:
40 ExoData(uint8_t* config_to_send); // constructor
41
47 void reconfigure(uint8_t* config_to_send);
48
54 template <typename F>
55 void for_each_joint(F &&func)
56 {
57 func(&left_leg.hip, NULL);
58 func(&left_leg.knee, NULL);
59 func(&left_leg.ankle, NULL);
60 func(&right_leg.hip, NULL);
61 func(&right_leg.knee, NULL);
62 func(&right_leg.ankle, NULL);
63 }
64 template <typename F>
65 void for_each_joint(F &&func, float* args)
66 {
67 func(&left_leg.hip, args);
68 func(&left_leg.knee, args);
69 func(&left_leg.ankle, args);
70 func(&right_leg.hip, args);
71 func(&right_leg.knee, args);
72 func(&right_leg.ankle, args);
73 }
74
75 // Returns a list of all of the joint IDs that are currently being used
76 uint8_t get_used_joints(uint8_t* used_joints);
77
84 JointData* get_joint_with(uint8_t id);
85
89 void print();
90
96 void set_status(uint16_t status_to_set);
102 uint16_t get_status(void);
103
109
114 void start_pretrial_cal();
115
116
117
119 bool estop;
124 uint32_t mark;
126 uint8_t* config;
127 uint8_t config_len;
133 private:
134 uint16_t _status;
135};
136
137#endif
void(* for_each_joint_function_t)(JointData *, float *)
Definition ExoData.h:31
Declares a class used to store data for leg to access.
Declares the functions needed and defines mapping between the INI keys and the exo components.
Stores the different status messages for the system.
Class to set an RGB LED to different colors based on the state of the system.
Class to store all the data related to the exo.
Definition ExoData.h:38
void for_each_joint(F &&func, float *args)
Definition ExoData.h:65
void set_default_parameters()
Set the default controller parameters for the current controller. These are the first row in the cont...
Definition ExoData.cpp:103
void for_each_joint(F &&func)
performs a function for each joint
Definition ExoData.h:55
bool user_paused
Definition ExoData.h:131
float battery_value
Definition ExoData.h:120
uint32_t mark
Definition ExoData.h:124
LegData right_leg
Definition ExoData.h:122
int error_joint_id
Definition ExoData.h:130
int error_code
Definition ExoData.h:129
JointData * get_joint_with(uint8_t id)
Get the joint pointer for a joint id.
Definition ExoData.cpp:56
uint8_t get_used_joints(uint8_t *used_joints)
Definition ExoData.cpp:37
uint8_t config_len
Definition ExoData.h:127
uint16_t get_status(void)
Get the status object.
Definition ExoData.cpp:98
void start_pretrial_cal()
Start the pretrial calibration process.
Definition ExoData.cpp:116
void print()
Prints all the exo data.
Definition ExoData.cpp:122
uint8_t * config
Definition ExoData.h:126
void reconfigure(uint8_t *config_to_send)
reconfigures the the exo data if the configuration changes after constructor called.
Definition ExoData.cpp:31
LegData left_leg
Definition ExoData.h:121
void set_status(uint16_t status_to_set)
Set the status object.
Definition ExoData.cpp:88
bool estop
Definition ExoData.h:119
bool sync_led_state
Definition ExoData.h:118
class to store information related to joint.
Definition JointData.h:33
class to store information related to the leg.
Definition LegData.h:30
JointData knee
Definition LegData.h:43
JointData ankle
Definition LegData.h:44
JointData hip
Definition LegData.h:42