CORC Project
CANOpen Robot Controller Software Documentation
testTraj.cpp
Go to the documentation of this file.
1 
12 #include "ExoRobot.h"
13 //using namespace std;
14 
15 #include "CANopen.h"
16 
17 pthread_mutex_t CO_CAN_VALID_mtx = PTHREAD_MUTEX_INITIALIZER;
18 volatile uint32_t CO_timer1ms = 0U;
19 
20 /* Helper functions ***********************************************************/
21 void CO_errExit(char *msg) {
22  perror(msg);
23  exit(EXIT_FAILURE);
24 }
25 
26 /* send CANopen generic emergency message */
27 void CO_error(const uint32_t info) {
28  CO_errorReport(CO->em, CO_EM_GENERIC_SOFTWARE_ERROR, CO_EMC_SOFTWARE_INTERNAL, info);
29  fprintf(stderr, "canopend generic error: 0x%X\n", info);
30 }
31 
32 int main(void) {
33  cout << ">>> Create ALEXTrajectory Generator >>>" << endl;
34 
35  ALEXTrajectoryGenerator *trajectoryGenerator = new ALEXTrajectoryGenerator();
36 
37  PilotParameters exoParams = {
38  .lowerleg_length = 0.44,
39  .upperleg_length = 0.44,
40  .ankle_height = 0.12,
41  .foot_length = 0.30,
42  .hip_width = 0.43,
43  .torso_length = 0.4,
44  .buttocks_height = 0.05};
45 
46  // Initial Pose -> Standing up
47  jointspace_state initialPose;
48  for (int i = 0; i < NUM_JOINTS; i++)
49  initialPose.q[i] = 0;
50  initialPose.time = 0;
51 
52  trajectoryGenerator->setPilotParameters(exoParams);
53  trajectoryGenerator->initialiseTrajectory(RobotMode::STNDUP, initialPose);
54  // Should be standing up
55 
56  double positions[NUM_JOINTS];
57  for (double i = 0; i <= 2; i = i + 0.1) {
58  trajectoryGenerator->calcPosition(i, positions);
59  for (int j = 0; j < NUM_JOINTS; j++) {
60  std::cout << rad2deg(positions[j]) << " ";
61  }
62  std::cout << endl;
63  }
64 
65  // exit(0);
66 }
void CO_error(const uint32_t info)
Definition: testTraj.cpp:27
#define NUM_JOINTS
Definition: RobotParams.h:16
void CO_errExit(char *msg)
Definition: testTraj.cpp:21
unsigned int uint32_t
Definition: CO_command.h:31
#define rad2deg(rad)
volatile uint32_t CO_timer1ms
Definition: testTraj.cpp:18
int main(void)
Definition: testTraj.cpp:32
pthread_mutex_t CO_CAN_VALID_mtx
Definition: testTraj.cpp:17