Alex exoskeleton
ALEX SoftwareDocumentation
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  // \todo Implement other modes here as well
28  return ERROR;
29 }
30 
32  if (driveMode == POSITION_CONTROL) {
33  drive->setPos(toDriveUnits(desQ));
35  return SUCCESS;
36  } else {
37  // Replace once complete
38  return INCORRECT_MODE;
39  }
40 }
41 
43  if (driveMode == VELOCITY_CONTROL) {
44  drive->setVel(toDriveUnits(velocity));
45  return SUCCESS;
46  } else {
47  // Replace once complete
48  return INCORRECT_MODE;
49  }
50 }
51 
53  // Replace once complete
54  return UNKNOWN_ERROR;
55 }
56 
59 }
60 
63  drive->enable();
64  return true;
65  }
66  return false;
67 }
virtual bool setPos(int position)
Definition: Drive.cpp:21
virtual bool initPosControl(motorProfile posControlMotorProfile)=0
virtual DriveState getDriveState()
Get the current state of the drive.
Definition: Drive.cpp:65
Abstract class describing a Drive used to communicate with a CANbus device. Note that many functions ...
Definition: Drive.h:93
ControlMode
Definition: Drive.h:25
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:55
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:21
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:50
Drive * drive
Contains a Drive object, which is a CANOpen device which is used to control the physical hardware...
Definition: ActuatedJoint.h:39
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:83
virtual bool setVel(int velocity)
Definition: Drive.cpp:27
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:45
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:74
Abstract class representing any joints within a Robot.
Definition: Joint.h:19
Definition: Drive.h:30