TeensyNanoExoCode
Loading...
Searching...
No Matches
Joint.h
Go to the documentation of this file.
1
11#ifndef Joint_h
12#define Joint_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 "ExoData.h"
20#include "Motor.h"
21#include "Controller.h"
22#include "TorqueSensor.h"
23#include "ParseIni.h"
24#include "board.h"
25#include "Joint.h"
26#include "config.h"
27#include "Utilities.h"
28#include "StatusDefs.h"
29#include "AnkleAngles.h"
30#include "AnkleIMU.h"
31
32#include <stdint.h>
33
44class _Joint
45{
46 static uint8_t left_torque_sensor_used_count;
47 static uint8_t right_torque_sensor_used_count;
49 static uint8_t left_motor_used_count;
50 static uint8_t right_motor_used_count;
53 // TODO: create object for each type of controller (joint type specific) and pointer to current controller.
54 // TODO: Create object for specific motor used based on config.
55 // TODO: Create joint base class that can then be used for each joint so that hip, knee, and ankle can each have joint specific controllers.
56 public:
63 _Joint(config_defs::joint_id id, ExoData* exo_data); // constructor:
64 virtual ~_Joint(){};
65
69 virtual void run_joint() = 0;
70
74 virtual void read_data();
75
80 virtual void check_calibration();
81
87 virtual void set_controller(uint8_t) = 0;
88
94 void set_motor(_Motor* new_motor);
95
96 // create some static member functions we can use for the initializer list.
97
108 static unsigned int get_torque_sensor_pin(config_defs::joint_id, ExoData*);
109
120 static unsigned int get_motor_enable_pin(config_defs::joint_id, ExoData*);
121
123 _Motor* _motor;
124 TorqueSensor _torque_sensor;
125 _Controller* _controller;
128 protected:
129 // give access to the larger data object and the joint specific data
130 ExoData* _data;
131 JointData* _joint_data;
133 // IO objects for the joint
134 //_Motor* _motor; /**< pointer to the base _Motor class so we can use any motor type.*/
135 //TorqueSensor _torque_sensor; /**< Torque sensor for the joint*/
136 //_Controller* _controller; /**< Pointer to the current controller. Using pointer so we just need to change the object we are pointing to when the controller changes.*/
137
138 // joint info
140 bool _is_left;
142};
143
147class HipJoint : public _Joint
148{
149 public:
150 HipJoint(config_defs::joint_id id, ExoData* exo_data);
151 ~HipJoint(){};
152
156 void run_joint();
157 //void read_data(); // See _Joint
158
164 void set_controller(uint8_t);
165 protected:
166 // Objects for joint specific controllers
167
168 ZeroTorque _zero_torque;
169 HeelToe _heel_toe;
170 ExtensionAngle _extension_angle;
171 BangBang _bang_bang;
172 LateStance _late_stance;
173 GaitPhase _gait_phase;
174 FranksCollinsHip _franks_collins_hip;
175 // UserDefined _user_defined; /**< user defined controller*/
176 Sine _sine;
177 Stasis _stasis;
178 Perturbation _perturbation;
179 Parabolic _parabolic;
180 ConstantTorque _constant_torque;
181 PtbGeneral _ptb_general;
182};
183
187class KneeJoint : public _Joint
188{
189 public:
190 KneeJoint(config_defs::joint_id id, ExoData* exo_data);
191 ~KneeJoint(){};
192
196 void run_joint(); // See _Joint
197 //void read_data(); // See _Joint
198
204 void set_controller(uint8_t); // See _Joint
205
206 protected:
207 // Objects for joint specific controllers
208 ZeroTorque _zero_torque;
209 // UserDefined _user_defined; /**< user defined controller*/
210 Sine _sine;
211 Stasis _stasis;
212 Perturbation _perturbation;
213 ConstantTorque _constant_torque;
214 ElbowMinMax _elbow_min_max;
215};
216
220class AnkleJoint : public _Joint
221{
222 public:
223 AnkleJoint(config_defs::joint_id id, ExoData* exo_data);
224 ~AnkleJoint(){};
225
229 void run_joint(); // See _Joint
230 //void read_data(); // See _Joint
231
237 void set_controller(uint8_t); // See _Joint
238
239 protected:
240 AnkleIMU _imu;
241 const float _imu_sample_rate_us{15000.0f};
242 float _previous_sample_us{0.0f};
243 AnkleAngles _ankle_angle;
244 // Objects for joint specific controllers
245 ZeroTorque _zero_torque;
246 ProportionalJointMoment _proportional_joint_moment;
247 ZhangCollins _zhang_collins;
248 // UserDefined _user_defined; /**< user defined controller*/
249 Sine _sine;
250 Stasis _stasis;
251 Perturbation _perturbation;
252 ConstantTorque _constant_torque;
253 PtbGeneral _ptb_general;
254 PropulsiveAssistive _propulsive_assistive;
255 ElbowMinMax _elbow_min_max;
256 CalibrManager _calibr_manager;
258};
259
260#endif
261#endif
Declares for the different controllers the exo can use. Controllers should inherit from _Controller c...
Declares a class used to store data for the Exo to access.
Declares a class for controlling and reading sensors for a joint.
Declares a class used to interface with motors.
Declares the functions needed and defines mapping between the INI keys and the exo components.
Stores the different status messages for the system.
Declares the class that is used to interface with a torque sensor.
Definition AnkleIMU.h:6
Class to store all the data related to the exo.
Definition ExoData.h:38
class to store information related to joint.
Definition JointData.h:33
joint_id
Definition ParseIni.h:106