Alex exoskeleton
ALEX SoftwareDocumentation
testOD.cpp
Go to the documentation of this file.
1 
2 
3 #include <iostream>
4 
5 #include "CANopen.h"
6 #include "CopleyDrive.h"
7 #include "Drive.h"
8 
9 pthread_mutex_t CO_CAN_VALID_mtx = PTHREAD_MUTEX_INITIALIZER;
10 volatile uint32_t CO_timer1ms = 0U;
11 
12 /* Helper functions ***********************************************************/
13 void CO_errExit(char *msg) {
14  perror(msg);
15  exit(EXIT_FAILURE);
16 }
17 
18 /* send CANopen generic emergency message */
19 void CO_error(const uint32_t info) {
20  CO_errorReport(CO->em, CO_EM_GENERIC_SOFTWARE_ERROR, CO_EMC_SOFTWARE_INTERNAL, info);
21  fprintf(stderr, "canopend generic error: 0x%X\n", info);
22 }
23 
24 using namespace std;
25 int main() {
26  // Create a Drive Object
27  std::cout << "1. Construct a CopleyDrive Object (which implements Drive Class), with NODE ID = 1 \n";
28  Drive *testDrive = new CopleyDrive(3);
29 
30  std::cout << "2. Read form OD and change OD\n";
31  cout << "current OD position : " << testDrive->getPos() << std::endl;
32  testDrive->setPos(10);
33  cout << "current OD position : " << testDrive->getPos() << std::endl;
34  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor1: " << CO_OD_RAM.targetMotorPositions.motor1 << std::endl;
35  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor2: " << CO_OD_RAM.targetMotorPositions.motor2 << std::endl;
36  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor3: " << CO_OD_RAM.targetMotorPositions.motor3 << std::endl;
37  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor4: " << CO_OD_RAM.targetMotorPositions.motor4 << std::endl;
38  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor5: " << CO_OD_RAM.targetMotorPositions.motor5 << std::endl;
39  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor6: " << CO_OD_RAM.targetMotorPositions.motor6 << std::endl;
40 }
void CO_error(const uint32_t info)
Definition: testOD.cpp:19
virtual bool setPos(int position)
Definition: Drive.cpp:21
Abstract class describing a Drive used to communicate with a CANbus device. Note that many functions ...
Definition: Drive.h:93
virtual int getPos()
Definition: Drive.cpp:37
unsigned int uint32_t
Definition: CO_command.h:31
An implementation of the Drive Object, specifically for Copley-branded devices (currently used on the...
Definition: CopleyDrive.h:16
volatile uint32_t CO_timer1ms
Definition: testOD.cpp:10
pthread_mutex_t CO_CAN_VALID_mtx
Definition: testOD.cpp:9
int main()
Definition: testOD.cpp:25
void CO_errExit(char *msg)
Definition: testOD.cpp:13