Alex exoskeleton
ALEX SoftwareDocumentation
testTraj.cpp
Go to the documentation of this file.
1 
3 #include "ExoRobot.h"
4 //using namespace std;
5 
6 #include "CANopen.h"
7 
8 pthread_mutex_t CO_CAN_VALID_mtx = PTHREAD_MUTEX_INITIALIZER;
9 volatile uint32_t CO_timer1ms = 0U;
10 
11 /* Helper functions ***********************************************************/
12 void CO_errExit(char *msg) {
13  perror(msg);
14  exit(EXIT_FAILURE);
15 }
16 
17 /* send CANopen generic emergency message */
18 void CO_error(const uint32_t info) {
19  CO_errorReport(CO->em, CO_EM_GENERIC_SOFTWARE_ERROR, CO_EMC_SOFTWARE_INTERNAL, info);
20  fprintf(stderr, "canopend generic error: 0x%X\n", info);
21 }
22 
23 int main(void) {
24  //TODO add keyboard initializer to initiRobot.
25  //INITINPUT
26  /* // Create Exo object + initialise derived Joints + trajectory Generator
27  cout << ">>> Creating ExoRobot" << endl;
28  ExoRobot exo;
29  // print joint positions
30  cout << ">>> Current Robot Position (expected value: all joints 0) >>>" << endl;
31  exo.printStatus();
32  // Initialise Position Control
33  cout << ">>> Initialsing Position Control >>> \n"
34  << exo.initPositionControl() << endl;
35  exo.setSpecificTrajectory(RobotMode::SITDWN);
36  exo.startNewTraj();*/
37 
38  cout << ">>> Create ALEXTrajectory Generator >>>" << endl;
39 
40  ALEXTrajectoryGenerator *trajectoryGenerator = new ALEXTrajectoryGenerator();
41 
42  PilotParameters exoParams = {
43  .lowerleg_length = 0.44,
44  .upperleg_length = 0.44,
45  .ankle_height = 0.12,
46  .foot_length = 0.30,
47  .hip_width = 0.43,
48  .torso_length = 0.4,
49  .buttocks_height = 0.05};
50 
51  // Initial Pose -> Standing up
52  jointspace_state initialPose;
53  for (int i = 0; i < NUM_JOINTS; i++)
54  initialPose.q[i] = 0;
55  initialPose.time = 0;
56 
57  trajectoryGenerator->setPilotParameters(exoParams);
58  trajectoryGenerator->initialiseTrajectory(RobotMode::STNDUP, initialPose);
59  // Should be standing up
60 
61  double positions[NUM_JOINTS];
62  for (double i = 0; i <= 2; i = i + 0.1) {
63  trajectoryGenerator->calcPosition(i, positions);
64  for (int j = 0; j < NUM_JOINTS; j++) {
65  std::cout << rad2deg(positions[j]) << " ";
66  }
67  std::cout << endl;
68  }
69 
70  // exit(0);
71 }
void CO_error(const uint32_t info)
Definition: testTraj.cpp:18
#define NUM_JOINTS
Definition: RobotParams.h:13
void CO_errExit(char *msg)
Definition: testTraj.cpp:12
unsigned int uint32_t
Definition: CO_command.h:31
#define rad2deg(rad)
volatile uint32_t CO_timer1ms
Definition: testTraj.cpp:9
int main(void)
Definition: testTraj.cpp:23
pthread_mutex_t CO_CAN_VALID_mtx
Testing ExoRobot new classes.
Definition: testTraj.cpp:8