SC8000 Class Reference

Interface to a serial-servo-controller. More...

#include <Devices/sc8000.H>

Inheritance diagram for SC8000:
Inheritance graph
[legend]
Collaboration diagram for SC8000:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SC8000 (OptionManager &mgr, const std::string &descrName="SC8000 Servo Driver", const std::string &tagName="SC8000driver", const char *defdev="/dev/ttyUSB0")
 Default constructor; see ModelComponent.H.
 ~SC8000 ()
 Destructor.
bool move (const int servo, const float position)
 Moves servo # to given position in [-1.0 .. 1.0].
float getPosition (const int servo) const
 Gets the current position of given servo.
void calibrate (const int servo, const short neutralval, const short minval, const short maxval)
 Calibrate a servo.
bool moveRaw (const int servo, const short rawpos)
 Moves servo # to given RAW (uncalibrated) position in [0..65535].
short getPositionRaw (const int servo) const
 Gets the current RAW (uncalibrated) position [0..65535] of given servo.

Protected Member Functions

float rawToCalib (const int servo, const short rawpos) const
 Convert from raw (0..65535) to calibrated (-1.0..1.0) position.
short calibToRaw (const int servo, const float position) const
 Convert from calibrated (-1.0..1.0) to raw (0..65535) position.

Protected Attributes

nub::soft_ref< SerialitsPort
 Serial port to use.
rutz::shared_ptr< NModelParam
< float > > * 
zero
 zero calibration values
rutz::shared_ptr< NModelParam
< float > > * 
posmult
 positive multiplier calib
rutz::shared_ptr< NModelParam
< float > > * 
negmult
 negative multiplier calib
short * pos
 raw servo positions [0..65535]

Detailed Description

Interface to a serial-servo-controller.

The sc8000.C and sc8000.H files has the sc-8000 controller code that help control the servos via the controller. The class is SC8000 class. Its functions include moving a servo to a specified position, using a serial port. There are two ways to move the servos and thet their current positions: either using calibrated values in [-1.0..1.0], or using raw positions in [0..65535]. Calibrated positions are converted to raw using two linear ramps (one for each side of the neutral position) that can be set using the calibrate() function. EXAMPLE: if you do a calibrate(servo, 100, 20, 150), then, subsequently, move(servo, 0.0F) will be equivalent to moveRaw(servo, 100), move(servo, -1.0F) will be equivalent to moveRaw(servo, 20) and move(servo, 1.0F) will be equivalent to moveRaw(servo, 150).

Definition at line 63 of file sc8000.H.


Constructor & Destructor Documentation

SC8000::SC8000 ( OptionManager mgr,
const std::string descrName = "SC8000 Servo Driver",
const std::string tagName = "SC8000driver",
const char *  defdev = "/dev/ttyUSB0" 
)

Default constructor; see ModelComponent.H.

Definition at line 46 of file sc8000.C.

References ModelComponent::addSubComponent(), itsPort, negmult, pos, posmult, and zero.

SC8000::~SC8000 (  ) 

Destructor.

Definition at line 77 of file sc8000.C.


Member Function Documentation

void SC8000::calibrate ( const int  servo,
const short  neutralval,
const short  minval,
const short  maxval 
)

Calibrate a servo.

Calibration will be made so that move(servo, 0.0F) will send the value 'neutralval' to the servo, move(servo, -1.0F) will send minval and move(servo, 1.0F) will send maxval.

Definition at line 93 of file sc8000.C.

References negmult, posmult, and zero.

short SC8000::calibToRaw ( const int  servo,
const float  position 
) const [protected]

Convert from calibrated (-1.0..1.0) to raw (0..65535) position.

Definition at line 167 of file sc8000.C.

References negmult, posmult, and zero.

Referenced by move().

float SC8000::getPosition ( const int  servo  )  const

Gets the current position of given servo.

Definition at line 85 of file sc8000.C.

References pos, and rawToCalib().

short SC8000::getPositionRaw ( const int  servo  )  const

Gets the current RAW (uncalibrated) position [0..65535] of given servo.

Definition at line 138 of file sc8000.C.

References pos.

bool SC8000::move ( const int  servo,
const float  position 
)

Moves servo # to given position in [-1.0 .. 1.0].

Returns true on success, false if some serial error occurred.

Definition at line 81 of file sc8000.C.

References calibToRaw(), and moveRaw().

bool SC8000::moveRaw ( const int  servo,
const short  rawpos 
)

Moves servo # to given RAW (uncalibrated) position in [0..65535].

Returns true on success, false if some serial error occurred.

Definition at line 105 of file sc8000.C.

References itsPort, and pos.

Referenced by move().

float SC8000::rawToCalib ( const int  servo,
const short  rawpos 
) const [protected]

Convert from raw (0..65535) to calibrated (-1.0..1.0) position.

Definition at line 147 of file sc8000.C.

References negmult, posmult, and zero.

Referenced by getPosition().


Member Data Documentation

Serial port to use.

Definition at line 97 of file sc8000.H.

Referenced by moveRaw(), and SC8000().

negative multiplier calib

Definition at line 100 of file sc8000.H.

Referenced by calibrate(), calibToRaw(), rawToCalib(), and SC8000().

short* SC8000::pos [protected]

raw servo positions [0..65535]

Definition at line 101 of file sc8000.H.

Referenced by getPosition(), getPositionRaw(), moveRaw(), and SC8000().

positive multiplier calib

Definition at line 99 of file sc8000.H.

Referenced by calibrate(), calibToRaw(), rawToCalib(), and SC8000().

rutz::shared_ptr<NModelParam<float> >* SC8000::zero [protected]

zero calibration values

Definition at line 98 of file sc8000.H.

Referenced by calibrate(), calibToRaw(), rawToCalib(), and SC8000().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:47 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3