CORC Project
CANOpen Robot Controller Software Documentation
ActuatedJoint.cpp
Go to the documentation of this file.
1 
12 #include "ActuatedJoint.h"
13 
14 #include "DebugMacro.h"
15 
16 ActuatedJoint::ActuatedJoint(int jointID, double jointMin, double jointMax, Drive *drive) : Joint(jointID, jointMin, jointMax) {
17  this->drive = drive;
18 }
19 //TODO: add in check
21  if (driveMode_ == POSITION_CONTROL) {
22  if (drive->initPosControl(profile)) {
23  driveMode = driveMode_;
24  return POSITION_CONTROL;
25  }
26  }
27  if (driveMode_ == VELOCITY_CONTROL) {
28  if (drive->initVelControl(profile)) {
29  driveMode = driveMode_;
30  return POSITION_CONTROL;
31  }
32  }
33  // \todo Implement Torque
34  return ERROR;
35 }
36 
38  if (driveMode == POSITION_CONTROL) {
39  drive->setPos(toDriveUnits(desQ));
41  return SUCCESS;
42  } else {
43  // Replace once complete
44  return INCORRECT_MODE;
45  }
46 }
47 
49  if (driveMode == VELOCITY_CONTROL) {
50  drive->setVel(toDriveUnits(velocity));
51  return SUCCESS;
52  } else {
53  // Replace once complete
54  return INCORRECT_MODE;
55  }
56 }
57 
59  /*\todo Replace once complete*/
60  return UNKNOWN_ERROR;
61 }
62 
65 }
66 
69  drive->enable();
70  return true;
71  }
72  return false;
73 }
virtual bool setPos(int position)
Definition: Drive.cpp:21
virtual bool initPosControl(motorProfile posControlMotorProfile)=0
Defines some macros for debugging output.
virtual DriveState getDriveState()
Get the current state of the drive.
Definition: Drive.cpp:76
Abstract class describing a Drive used to communicate with a CANbus device. Note that many functions ...
Definition: Drive.h:105
ControlMode
Definition: Drive.h:32
virtual int toDriveUnits(double jointValue)=0
Converts from the joint value to the equivalent value for the drive.
virtual bool enable()
Sets the state of the drive to "enabled".
Definition: Drive.cpp:66
The ActuatedJoint class is a abstract class which represents a joint in a Robot objec. This class implements the Joint class, and specifically represents a joint which is actuated. This therefore requires a Drive object which will be used to interact with the physical hardware.
virtual ControlMode setMode(ControlMode driveMode_, motorProfile profile)
Set the mode of the device (nominally, position, velocity or torque control)
virtual void readyToSwitchOn()
Set the joint ready to switch On.
virtual setMovementReturnCode_t setTorque(double torque)
Set the torque set point.
setMovementReturnCode_t
Definition: ActuatedJoint.h:35
ActuatedJoint(int jointID, double jointMin, double jointMax, Drive *drive)
Construct a new Actuated Joint object.
virtual bool readyToSwitchOn()
Changes the state of the drive to "ready to switch on".
Definition: Drive.cpp:61
Drive * drive
Contains a Drive object, which is a CANOpen device which is used to control the physical hardware...
Definition: ActuatedJoint.h:54
virtual setMovementReturnCode_t setPosition(double desQ)
Set the Position object.
struct to hold desired velocity, acceleration and deceleration values for a drives motor controller p...
Definition: Drive.h:94
virtual bool setVel(int velocity)
Definition: Drive.cpp:27
virtual bool initVelControl(motorProfile velControlMotorProfile)=0
virtual setMovementReturnCode_t setVelocity(double velocity)
Sets a velocity set point (in joint units)
ControlMode driveMode
The current mode of the drive.
Definition: ActuatedJoint.h:60
bool enable()
Enable the joint.
virtual bool posControlConfirmSP()
Flips Bit 4 of Control Word (0x6041) - A new set point is only confirmed if the transition is from 0 ...
Definition: Drive.cpp:85
Abstract class representing any joints within a Robot.
Definition: Joint.h:23
Definition: Drive.h:37