TeensyNanoExoCode
Loading...
Searching...
No Matches
Leg.h
Go to the documentation of this file.
1
11#ifndef Leg_h
12#define Leg_h
13
14// Arduino compiles everything in the src folder even if not included so it causes and error for the nano if this is not included.
15#if defined(ARDUINO_TEENSY36) || defined(ARDUINO_TEENSY41)
16
17#include "Arduino.h"
18
19#include "joint.h"
20#include "controller.h"
21#include "FSR.h"
22#include "ParseIni.h"
23#include "Board.h"
24#include "Utilities.h"
25#include "StatusDefs.h"
26#include "ThIMU.h"
27#include "InclinationDetector.h"
28
29#include <stdint.h>
30#include <algorithm>
31
36class Leg
37{
38 public:
39 //Leg();
40 Leg(bool is_left, ExoData* exo_data); // constructor:
41
45 void run_leg();
46
50 void check_calibration();
51
57 void read_data();
58
62 void update_motor_cmds();
63
67 void set_controller(int joint, int controller);
68
72 void clear_step_time_estimate();
73
78 void disable_motors();
79
80 float get_Kt_for_joint(uint8_t id);
81
82 private:
87 void _check_thresholds();
88
96 float _calc_percent_gait();
97
105 float _calc_percent_stance();
106
114 float _calc_percent_swing();
115
122 float _update_expected_duration();
123
130 float _update_expected_stance_duration();
131
138 float _update_expected_swing_duration();
139
147 bool _check_ground_strike();
148
156 bool _check_toe_on();
157 bool _check_toe_off();
158
159 // data that can be accessed
160 ExoData* _data;
161 LegData* _leg_data;
163 // joint objects for the leg.
164 // The order these are listed are important as it will determine the order their constructors are called in the initializer list.
165 HipJoint _hip;
166 KneeJoint _knee;
167 AnkleJoint _ankle;
169 FSR _heel_fsr;
171 FSR _toe_fsr;
173 InclinationDetector* inclination_detector;
174
175
176 bool _is_left;
178 bool _prev_heel_contact_state;
179 bool _prev_toe_contact_state;
181 bool _prev_toe_contact_state_toe_off;
182 bool _prev_toe_contact_state_toe_on;
184 static const uint8_t _num_steps_avg = 3;
185 unsigned int _step_times[_num_steps_avg]; //
186
187 unsigned int _stance_times[_num_steps_avg];
188 unsigned int _swing_times[_num_steps_avg];
189
190 unsigned int _ground_strike_timestamp;
191 unsigned int _prev_ground_strike_timestamp;
192 unsigned int _expected_step_duration;
194 unsigned int _toe_strike_timestamp;
195 unsigned int _prev_toe_strike_timestamp;
196 unsigned int _expected_stance_duration;
197 unsigned int _toe_off_timestamp;
198 unsigned int _prev_toe_off_timestamp;
199 unsigned int _expected_swing_duration;
200
201};
202#endif
203#endif
Declares for the different controllers the exo can use. Controllers should inherit from _Controller c...
Declares a class used to interface with a force sensitive resistor.
Declares a class for controlling and reading sensors for a joint.
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 store all the data related to the exo.
Definition ExoData.h:38
Given stance and ankle angle data, return the current estimate of inclination.
Definition InclinationDetector.h:19
class to store information related to the leg.
Definition LegData.h:30