CORC Project
CANOpen Robot Controller Software Documentation
testOD.cpp
Go to the documentation of this file.
1 
12 #include <iostream>
13 
14 #include "CANopen.h"
15 #include "CopleyDrive.h"
16 #include "Drive.h"
17 
18 pthread_mutex_t CO_CAN_VALID_mtx = PTHREAD_MUTEX_INITIALIZER;
19 volatile uint32_t CO_timer1ms = 0U;
20 
21 /* Helper functions ***********************************************************/
22 void CO_errExit(char *msg) {
23  perror(msg);
24  exit(EXIT_FAILURE);
25 }
26 
27 /* send CANopen generic emergency message */
28 void CO_error(const uint32_t info) {
29  CO_errorReport(CO->em, CO_EM_GENERIC_SOFTWARE_ERROR, CO_EMC_SOFTWARE_INTERNAL, info);
30  fprintf(stderr, "canopend generic error: 0x%X\n", info);
31 }
32 
33 using namespace std;
34 int main() {
35  // Create a Drive Object
36  std::cout << "1. Construct a CopleyDrive Object (which implements Drive Class), with NODE ID = 1 \n";
37  Drive *testDrive = new CopleyDrive(3);
38 
39  std::cout << "2. Read form OD and change OD\n";
40  cout << "current OD position : " << testDrive->getPos() << std::endl;
41  testDrive->setPos(10);
42  cout << "current OD position : " << testDrive->getPos() << std::endl;
43  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor1: " << CO_OD_RAM.targetMotorPositions.motor1 << std::endl;
44  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor2: " << CO_OD_RAM.targetMotorPositions.motor2 << std::endl;
45  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor3: " << CO_OD_RAM.targetMotorPositions.motor3 << std::endl;
46  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor4: " << CO_OD_RAM.targetMotorPositions.motor4 << std::endl;
47  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor5: " << CO_OD_RAM.targetMotorPositions.motor5 << std::endl;
48  cout << "Read Specifically from CO_OD_RAM.targetMotorPositions.motor6: " << CO_OD_RAM.targetMotorPositions.motor6 << std::endl;
49 }
void CO_error(const uint32_t info)
Definition: testOD.cpp:28
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:105
virtual int getPos()
Definition: Drive.cpp:39
An implementation of the Drive Object, specifically for the Copley Drive.
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:23
volatile uint32_t CO_timer1ms
Definition: testOD.cpp:19
pthread_mutex_t CO_CAN_VALID_mtx
Definition: testOD.cpp:18
The Drive class is used to interface with a CANOpen motor drive. According to the CiA402 standard...
int main()
Definition: testOD.cpp:34
void CO_errExit(char *msg)
Definition: testOD.cpp:22