Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OSCAR::KB2017Interface Class Reference
[Device]

#include <KB2017Interface.h>

Inheritance diagram for OSCAR::KB2017Interface:

Inheritance graph
[legend]
List of all members.

Public Methods

 KB2017Interface (OSCARError &err=DUMMY_ERROR(noError))
virtual ~KB2017Interface ()
virtual bool Initialize ()
virtual bool Close ()
virtual bool Home (bool autoHomeMode=true)
virtual bool CheckServoStatus ()
virtual bool SetMotionTime (Control16Bit motionTime)
virtual bool SetExcessError (const Control32BitArray &excessError)
bool GetExcessError (Control32BitArray &excessError)
virtual bool SetPosLoopGain (const Control32BitArray &positionLoopGain)
bool GetPosLoopGain (Control32BitArray &positionLoopGain)
virtual bool SetControlByte (Control8Bit controlByte)
virtual bool SetInterruptMask (Control16Bit flag)
virtual bool SetCurrent (const Control32BitArray &currentvalue)
bool GetStatusByte (Control8Bit &statusByte)
bool MachineStop ()
bool IsArmPowerOn (bool &powerStatus)
bool SetServoValue (ControlType type, const VectorF &value)
bool GetServoValue (ControlType type, VectorF &value)
virtual bool getPosition (Control32BitArray &)
virtual bool setPosition (const Control32BitArray &)
virtual bool getVelocity (Control32BitArray &)
virtual bool setVelocity (const Control32BitArray &)
virtual bool getTorque (Control32BitArray &)
virtual bool setTorque (const Control32BitArray &)
void moveJoint (Vector &move)
bool setMotionTime (Control16Bit motionTime)
bool setExcessError (const Control32BitArray &excessError)

Public Attributes

bool leftLowHome
bool isHomed
Bit3IOmr2armio
Control16Bit timeDivide
bool isTimeDivisionSet
bool isExcessErrorSet
bool isLoopGainSet
bool isDesiredPositionSet
Control32BitArray positionLoopGains
Control32BitArray jointExcessError
Control32BitArray jointCommandMode
Control32BitArray positionCommand
Control16BitArray feedbackTorques
Control16BitArray feedbackVelocity
Control16BitArray commandVelocity
Control16BitArray commandTorques
Control16Bit motionTime
Control32Bit minPosGain
Control32Bit maxPosGain
Control32Bit minExcessError
Control32Bit maxExcessError
unsigned int feedbackDelay
unsigned int commandDelay

Constructor & Destructor Documentation

OSCAR::KB2017Interface::KB2017Interface OSCARError   err = DUMMY_ERROR(noError)
 

Constructor for KB2017Interface Use this to construct a KB2017Interface object. The constructor does the following: - Sets default limits on position gains and excess errors - Sets default joint command mode for all 17 joints to *POSITION MODE* - Sets data member motionTime to a default value of 5 Note: 1) The default values for excess error range and position loop gains have been determined from experience. These values are safe to use. Extra precaution must observed when altering these values 2) The motionTime should be set in the application by the user soon after instantiation of the class, if the user desires to overwrite the default value. Else, the motionTime written to the memory register would be the default value (=5). 3) Some mechanical problem with the 4th joint on the left arm (from the ROBOT's perspective) makes it jerk causing the robot to shut down. By giving it an excess error of 20 degrees, we can avoid erratic shutdowns, but at the cost of safety.

Parameters:
err An OSCARError object that on return will hold the value of the error code that was generated when the constructor was called. If this error was not 'noError' you can call GetError() to get the details of the error code.
See also:
Initialize()

Home(bool autoHome)

~KB2017Interface()

virtual OSCAR::KB2017Interface::~KB2017Interface   [virtual]
 

Destructor for KB2017Interface. This invokes the Close() method if it hasnt been called, This method was made virtual so that it could be potentially overridden.

See also:
KB2017Interface()

Initialize()

Close()


Member Function Documentation

virtual bool OSCAR::KB2017Interface::CheckServoStatus   [virtual]
 

Serves as a diagnostic tool to check the status of the servos This method accomplishes the following: - Primarily checks for joint position excess errors and gives notification as to which joint had the error Note: The data member noOfConsecutiveErrors is used to monitor the number of successive failure. There is a safety feature, which shuts the robot down if there have been maxConsecutiveErrors (JointPosition Excess Errors). maxConsecutiveErrors sets a tolerance on the max no of errors in series.

Returns:
true or false. true implies successful initialization of the KB2017Interface false implies that there has been a joint limit error, or there is a read register error. If false, call GetError() for the causative error
Exceptions:
kb2017GeneralError kb2017GeneralError
kb2017CommError kb2017CommError
See also:
GetStatusByte(Control8Bit& statusByte)

virtual bool OSCAR::KB2017Interface::Close   [virtual]
 

Closes the dual arm interface. This method accomplishes the following: - Stops the machine by calling MachineStop() - Deletes pointer to BIT3IO object which is used to to read (write) from (to) the Mr2Arm's memory registers. A call to this method is *MANDATORY* before ending the application can be called. The following pseudo-code illustrates the usage of this method:.

int main(void) { OSCARError err = OSCARError(noError); KB2017Interface DualArm(err); Control16Bit motionTime = 4; //if this is ommitted, the motionTime is set to 5 (by default) if(!DualArm.SetMotionTime(motionTime)) return -1; //to overwrite the default value of 5 if(!DualArm.Initialize()) return -1; if(!DualArm.Home(false)) return -1; //refer to documentation for Home(bool autoHome) if(!DualArm.Close()) return -1; return 0; }

Returns:
true or false. true implies successful closure of the KB2017Interface false implies that initialize failed. If false, call GetError() for the causative error
See also:
~KB2017Interface()

KB2017Interface(OSCARError& err = OSCARError(noError))

Reimplemented from OSCAR::Device.

bool OSCAR::KB2017Interface::GetExcessError Control32BitArray   excessError
 

This function gets excess error values that are currently set for each joint. The returned excesserror vector is in radians.

Parameters:
excessError is the excess error vector (of size 17) which holds the current values of allowable excess error on each joint
Returns:
true or false. true implies successful reading of excess errors false implies that there has been failure to read the excess errors If false, call GetError() for the causative error
See also:
SetExcessError(const Control32BitArray& excessError)

setExcessError(const Control32BitArray& excessError)

virtual bool OSCAR::KB2017Interface::getPosition Control32BitArray   [virtual]
 

bool OSCAR::KB2017Interface::GetPosLoopGain Control32BitArray   positionLoopGain
 

This function gets positionLoopGain values that are currently set for each joint.

Parameters:
positionLoopGain is the positionLoop Gain vector (of size 17) which holds the current values of positionLoopGain on each joint. The positionLoopGain should lie between 0.0 and 1.7 (These values have been arrived at from experience and it is not advisable to change this without ample reason)
Returns:
true or false. true implies successful reading of Position Loop Gains false implies that there has been failure to read the Position Loop Gains If false, call GetError() for the causative error
See also:
SetPosLoopGain(Control32BitArray& positionLoopGain)

bool OSCAR::KB2017Interface::GetServoValue ControlType    type,
VectorF   value
[virtual]
 

This function is overridden here. A call to RobotServoInterface::GetServoValue() is made This function also deals with homing offsets, ie, if after homing, the left arm (from the robot's perspective) is low, an offset of 0.3306 radians (= 18.94 degrees) is added to its commanded position. This is an easy fix for that homing problem.

Parameters:
type holds the command mode, value holds the vector of size 17 containing jointposition commands
value A vector of size 17 that holds the value of the control type on return
Returns:
true or false. true implies success false implies that there has been failure If false, call GetError() for the causative error
See also:
SetServoValue(ControlType type, const VectorF& value)

Reimplemented from OSCAR::RobotServoInterface.

bool OSCAR::KB2017Interface::GetStatusByte Control8Bit   statusByte
 

This function gets the current value of the status byte.

Parameters:
statusByte holds the status byte that is read from STATUS$BYTE. Legal values for this are 0x01 and 0x10. If anything else, shut robot down. The value returned should be interpreted as follows: 0x01 (01) - Start-up/Resolver Null Mode 0x10 (16) - Absolute Mode/Normal Operating Mode 0x11 (17) - Excess Error in Joint J1 0x12 (18) - Excess Error in Joint J2 0x13 (19) - Excess Error in Joint J3 0x14 (20) - Excess Error in Joint J4 0x15 (21) - Excess Error in Joint J5 0x16 (22) - Excess Error in Joint J6 0x17 (23) - Excess Error in Joint J7 0x18 (24) - Excess Error in Joint J8 0x19 (25) - Excess Error in Joint J9 0x1A (26) - Excess Error in Joint J10 0x1B (27) - Excess Error in Joint J11 0x1C (28) - Excess Error in Joint J12 0x1D (29) - Excess Error in Joint J13 0x1E (30) - Excess Error in Joint J14 0x1F (31) - Excess Error in Joint J15 0x20 (32) - Excess Error in Joint J16 0x21 (33) - Excess Error in Joint J17 Note: The numbers within parenthesis are the decimal equivalent of the hex. This is provided here for easiness in deciphering the code. For joint numbering convention, scroll up to the beginning of this file
Returns:
true or false. true implies successful reading of statusByte false implies that there has been failure to read statusByte If false, call GetError() for the causative error
See also:
CheckServoStatus()

virtual bool OSCAR::KB2017Interface::getTorque Control32BitArray   [virtual]
 

virtual bool OSCAR::KB2017Interface::getVelocity Control32BitArray   [virtual]
 

virtual bool OSCAR::KB2017Interface::Home bool    autoHomeMode = true [virtual]
 

Should be used to home the dual arm. Note that the "home position" is not the "zero position" This method accomplishes the following: - Sets the jointExcessErrors and PositionLoopGains - Writes default values to MACHINE$START and CONTROL$BYTE registers To complete Initialize(), the user should press the ENABLE ARM button on the robot control panel and be prepared to press the EMERGENCY STOP button on the pendant (for safety reasons). After these have been complied with, the robot can be homed using Home() A call to this method is *MANDATORY* before any other method can be called. The following pseudo-code illustrates the usage of this method:.

int main(void) { OSCARError err = OSCARError(noError); KB2017Interface DualArm(err); Control16Bit motionTime = 4; //if this is ommitted, the motionTime is set to 5 (by default) if(!DualArm.SetMotionTime(motionTime)) return -1; //to overwrite the default value of 5 if(!DualArm.Initialize()) return -1; //refer to documentation for Initalize() if(!DualArm.Home(false)) return -1; if(!DualArm.Close()) return -1; return 0; }

Parameters:
autoHomeMode is a bool which should be used to indicate whether the autohome option should be enabled. The value of autoHomeMode should be interpreted as follows: autoHomeMode == true => The robot can be homed automatically by pressing the "Home" key on the keyboard. The OPERATOR should make sure while using autohome mode that the robot doesnt run into itself or into an obstacle, since there is no higher level coordinated control autoHomeMode == false => The robot has to be homed manually using keyboard commands
Returns:
true or false. true implies successful initialization of the KB2017Interface false implies that initialize failed. If false, call GetError() for the causative error
Exceptions:
kb2017HomeError #kb2017HomingError
See also:
Initialize()

KB2017Interface(OSCARError& err = OSCARError(noError))

virtual bool OSCAR::KB2017Interface::Initialize   [virtual]
 

Initializes the dual arm interface This method accomplishes the following: - Creates pointer to BIT3IO object which is used to to read (write) from (to) the Mr2Arm's memory registers. This pointer is appropriately named mr2armio - Sets the jointExcessErrors and PositionLoopGains - Writes default values to MACHINE$START and CONTROL$BYTE registers To complete Initialize(), the user should press the ENABLE ARM button on the robot control panel and be prepared to press the EMERGENCY STOP button on the pendant (for safety reasons). After these have been complied with, the robot can be homed using Home() A call to this method is *MANDATORY* before any other method can be called. The following pseudo-code illustrates the usage of this method:.

int main(void) { OSCARError err = OSCARError(noError); KB2017Interface DualArm(err); Control16Bit motionTime = 4; //if this is ommitted, the motionTime is set to 5 (by default) if(!DualArm.SetMotionTime(motionTime)) return -1; //to overwrite the default value of 5 if(!DualArm.Initialize()) return -1; if(!DualArm.Home(false)) return -1; //refer to documentation for Home(bool autoHome) if(!DualArm.Close()) return -1; return 0; }

Returns:
true or false. true implies successful initialization of the KB2017Interface false implies that initialize failed. If false, call GetError() for the causative error
See also:
Home(bool autoHome)

KB2017Interface(OSCARError& err = OSCARError(noError))

Reimplemented from OSCAR::Device.

bool OSCAR::KB2017Interface::IsArmPowerOn bool &    powerStatus
 

This function retrieves the status of arm power. This is done by reading from MACHINE$START MACHINE$START holds '1' if arm power is ON.

Parameters:
powerStatus holds info as to whether the arm power is off/on (powerStatus == true) => Arm Power is ON (powerStatus == false) => Arm Power is OFF
Returns:
true or false. true implies successful reading of power status false implies that there has been failure to read power status If false, call GetError() for the causative error
See also:
MachineStop()

bool OSCAR::KB2017Interface::MachineStop  
 

This function turns the arm power off. This is done by writing '0' to MACHINE$START.

Returns:
true or false. true implies successful shutting down of machine false implies that there has been failure to shut down If false, call GetError() for the causative error
See also:
IsArmPowerOn(bool& powerStatus)

void OSCAR::KB2017Interface::moveJoint Vector   move
 

virtual bool OSCAR::KB2017Interface::SetControlByte Control8Bit    controlByte [virtual]
 

This function provides a method to move each joint of robot per step each time. The control memory registers for CW and CCW motion of each joint are defined in "KB2017ControlRegisters.h". All dual port commands to the servo processor except for absolute position commands are placed in this location.

Parameters:
controlByte indicates which joint should be incremented in position and in which direction. This value is written to CONTROL$BYTE.
Returns:
true or false. true implies successful writing of controlByte to CONTROL$BYTE false implies that there has been failure to write controlByte to the memory register CONTROL$BYTE If false, call GetError() for the causative error
See also:
"KB2017ControlRegisters.h"

virtual bool OSCAR::KB2017Interface::SetCurrent const Control32BitArray   currentvalue [virtual]
 

This function sets current operation mode, and move the robot to the desired position set by SetDesiredPosition(...). The following are established by this method: - Runs a sanity check on input - Sets the value of each joint's command mode in the location JOINT$COM$MODE to 3 0 - Position Mode 1 - Velocity Mode 2 - Torque Mode 3 - Current Mode - Writes the value of param currentvalue to the register CURRENT$COMMAND - Sets the value '1' to COMMAND$FLAG to indicate that a new command has been placed in dual port memory.

Parameters:
currentvalue is the vector of size 17 that stores the input current value for each joint currentvalue is written to the register CURRENT$COMMAND
Returns:
true or false. true implies successful setting of currentvalue false implies that there has been failure to set currentvalue If false, call GetError() for the causative error
See also:
SetServoValue(ControlType type, const VectorF& value)

bool OSCAR::KB2017Interface::setExcessError const Control32BitArray   excessError
 

This function writes the jointExcessError vector value into EXCESS$ERROR.

Parameters:
excessError is the excess error vector after being multiplied by countsPerRadian (of size 17). The excess error is specified in radians and its value should lie between 0.0 and 0.7 (40 degrees)
Returns:
true or false. true implies successful writing of excess errors false implies that there has been failure to write the excess errors to the memory register EXCESS$ERROR If false, call GetError() for the causative error
See also:
SetExcessError(const Control32BitArray& excessError)

virtual bool OSCAR::KB2017Interface::SetExcessError const Control32BitArray   excessError [virtual]
 

Checks sanity of user input and sets the data member jointExcessError value. In doing so, every joint's user defined excess error (in radians) should be multiplied by a contant countsPerRadian before writing to memory. This function should be called before any mode of operation, i.e. before SetServoValue(Position/Velocity/Torque, _value) or SetCurent(...). Excess error is a check on the numerical difference between two successive position commands. This ensures that the robot does not perform large movements in one position step. This method invokes the protected setExcessError method to write it to the appropriate memory location.

Parameters:
excessError is the excess error vector of size 17. The excess error is specified in radians and its value should lie between 0.0 and 0.7 (40 degrees)
Returns:
true or false. true implies successful writing of excess errors false implies that there has been failure to write the excess errors to the memory register EXCESS$ERROR If false, call GetError() for the causative error
See also:
setExcessError(const Control32BitArray& excessError)

GetExcessError(const Control32BitArray& excessError)

virtual bool OSCAR::KB2017Interface::SetInterruptMask Control16Bit    flag [virtual]
 

This function sets flag into INTERRUPT$MASK to disable/enable the Motion Controller interrupt to the Servo Processor, allowing/disallowing the host processor to intercept the command (PROVIDED it is wired for the bus intercept). During normal operation this variable is '0'(ENABLE).

Parameters:
flag is written to INTERRUPT$MASK. (flag = 0) => ENABLE interrupt (flag = 1) => DISABLE interrupt
Returns:
true or false. true implies successful writing of flag to INTERRUPT$MASK false implies that there has been failure to write flag to the memory register INTERRUPT$MASK If false, call GetError() for the causative error

bool OSCAR::KB2017Interface::setMotionTime Control16Bit    motionTime
 

This function sets a time division number in register COM$DIV$NUMBER. This number is used to set the interpolation time the K/B2017 uses to complete its move to the desired position.

Parameters:
motionTime is the motion time input by the user. The default value of this time is 5, which is set in the constructor Note: (time division number) = motionTime * 5
Returns:
true or false. true implies successful setting of motion time false implies that there has been either a parameter mismatch or failure to write the motion time to the appropriate memory register If false, call GetError() for the causative error
See also:
SetMotionTime(Control16Bit)

KB2017Interface(OSCARError&)

virtual bool OSCAR::KB2017Interface::SetMotionTime Control16Bit    motionTime [virtual]
 

Checks sanity of the input motiontime and sets the data member motionTime This method accomplishes the following: - Invokes the protected setMotionTime() method to write the motionTime to the appropriate memory register.

Parameters:
motionTime is the motion time input by the user. The default valu of this time is 5, which is set in the constructor
Returns:
true or false. true implies successful setting of motion time false implies that there has been either a parameter mismatch or failure to write the motion time to the appropriate memory register If false, call GetError() for the causative error
See also:
setMotionTime(Control16Bit)

KB2017Interface(OSCARError&)

virtual bool OSCAR::KB2017Interface::setPosition const Control32BitArray   [virtual]
 

virtual bool OSCAR::KB2017Interface::SetPosLoopGain const Control32BitArray   positionLoopGain [virtual]
 

Checks sanity of user input and sets the data member positionLoopGains value. This function should be called before any mode of operation, i.e. before SetServoValue(Position/Velocity/Torque, _value) or SetCurent(...) and hence a call to it is made in the Initialize() method Invokes the protected setExcessError method to write it to the appropriate memory location.

Parameters:
positionLoopGain is the positionLoop Gain vector of size 17. The positionLoopGain should lie between 0.0 and 1.7 (These values have been arrived at from experience and it is not advisable to change this without ample reason)
Returns:
true or false. true implies successful writing of excess errors false implies that there has been failure to write the positionLoopGain to the memory register POS$LOOP$GAIN If false, call GetError() for the causative error
See also:
Initialize()

GetPosLoopGain(Control32BitArray& positionLoopGain)

bool OSCAR::KB2017Interface::SetServoValue ControlType    type,
const VectorF   value
[virtual]
 

This function is overridden here. The functionality to check whether the machine power is on is added over here. Only if machine power is on, will this function be executed, otherwise it returns false. This prevents the sending of set points by the application when the robot arm power is turned off. This function also deals with homing offsets, ie, if after homing, the left arm (from the robot's perspective) is low, an offset of 0.3306 radians (= 18.94 degrees) is added to its commanded position. This is an easy fix for that homing problem.

Parameters:
type holds the command mode, value holds the vector of size 17 containing jointposition commands
value A vector of size 17 that specifies the value of the control type
Returns:
true or false. true implies success, if arm power is ON false implies that there has been failure to add offsets, usually because the arm power is OFF If false, call GetError() for the causative error
See also:
setPosition(const Control32BitArray&)

setVelocity(const Control32BitArray&)

setTorque (const Control32BitArray&)

GetServoValue(ControlType type, VectorF& value)

Reimplemented from OSCAR::RobotServoInterface.

virtual bool OSCAR::KB2017Interface::setTorque const Control32BitArray   [virtual]
 

virtual bool OSCAR::KB2017Interface::setVelocity const Control32BitArray   [virtual]
 


Member Data Documentation

unsigned int OSCAR::KB2017Interface::commandDelay
 

Control16BitArray OSCAR::KB2017Interface::commandTorques
 

Control16BitArray OSCAR::KB2017Interface::commandVelocity
 

unsigned int OSCAR::KB2017Interface::feedbackDelay
 

Control16BitArray OSCAR::KB2017Interface::feedbackTorques
 

Control16BitArray OSCAR::KB2017Interface::feedbackVelocity
 

bool OSCAR::KB2017Interface::isDesiredPositionSet
 

bool OSCAR::KB2017Interface::isExcessErrorSet
 

bool OSCAR::KB2017Interface::isHomed
 

bool OSCAR::KB2017Interface::isLoopGainSet
 

bool OSCAR::KB2017Interface::isTimeDivisionSet
 

Control32BitArray OSCAR::KB2017Interface::jointCommandMode
 

Control32BitArray OSCAR::KB2017Interface::jointExcessError
 

bool OSCAR::KB2017Interface::leftLowHome
 

Control32Bit OSCAR::KB2017Interface::maxExcessError
 

Control32Bit OSCAR::KB2017Interface::maxPosGain
 

Control32Bit OSCAR::KB2017Interface::minExcessError
 

Control32Bit OSCAR::KB2017Interface::minPosGain
 

Control16Bit OSCAR::KB2017Interface::motionTime
 

Bit3IO* OSCAR::KB2017Interface::mr2armio
 

Control32BitArray OSCAR::KB2017Interface::positionCommand
 

Control32BitArray OSCAR::KB2017Interface::positionLoopGains
 

Control16Bit OSCAR::KB2017Interface::timeDivide
 


The documentation for this class was generated from the following file:
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations