Pololu Class Reference

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

#include <Devices/Pololu.H>

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

List of all members.

Public Member Functions

 Pololu (OptionManager &mgr, const std::string &descrName="Mini-Pololu Servo Driver", const std::string &tagName="MiniPololudriver", const char *defdev="/dev/ttyS0")
 Default constructor; see ModelComponent.H.
 ~Pololu ()
 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 byte neutralval, const byte minval, const byte maxval)
 Calibrate a servo.
bool moveRaw (const int servo, const byte rawpos)
 Moves servo # to given RAW (uncalibrated) position in [0..255].
bool moveRawHack (const int servo, const byte rawpos, const int port=1)
 hack work around for moveRaw. Remove when serial stuff is fixed
byte getPositionRaw (const int servo) const
 Gets the current RAW (uncalibrated) position [0..255] of given servo.
bool setSpeed (const int servo, const byte speed)
 Set the speed at which the servo moves.
bool setNeutral (const int servo, const short int pos)
 set the neutral position
bool setParam (const int servo, bool on_off, bool direction, char range)
 set servo param

Protected Member Functions

float rawToCalib (const int servo, const byte rawpos) const
 Convert from raw (0..255) to calibrated (-1.0..1.0) position.
byte calibToRaw (const int servo, const float position) const
 Convert from calibrated (-1.0..1.0) to raw (0..255) 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
bytepos
 raw servo positions [0..255]

Detailed Description

Interface to a serial-servo-controller.

The Pololu.C and Pololu.H files has the mini_Pololu controller code that help control the servos via the controller. The class is Pololu 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..255]. 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 62 of file Pololu.H.


Constructor & Destructor Documentation

Pololu::Pololu ( OptionManager mgr,
const std::string descrName = "Mini-Pololu Servo Driver",
const std::string tagName = "MiniPololudriver",
const char *  defdev = "/dev/ttyS0" 
)

Default constructor; see ModelComponent.H.

Definition at line 44 of file Pololu.C.

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

Pololu::~Pololu (  ) 

Destructor.

Definition at line 76 of file Pololu.C.

References negmult, pos, posmult, and zero.


Member Function Documentation

void Pololu::calibrate ( const int  servo,
const byte  neutralval,
const byte  minval,
const byte  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 97 of file Pololu.C.

References negmult, posmult, and zero.

byte Pololu::calibToRaw ( const int  servo,
const float  position 
) const [protected]

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

Definition at line 245 of file Pololu.C.

References negmult, posmult, and zero.

Referenced by move().

float Pololu::getPosition ( const int  servo  )  const

Gets the current position of given servo.

Definition at line 89 of file Pololu.C.

References pos, and rawToCalib().

byte Pololu::getPositionRaw ( const int  servo  )  const

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

Definition at line 216 of file Pololu.C.

References pos.

bool Pololu::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 85 of file Pololu.C.

References calibToRaw(), and moveRaw().

bool Pololu::moveRaw ( const int  servo,
const byte  rawpos 
)

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

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

Definition at line 109 of file Pololu.C.

References itsPort, and pos.

Referenced by move().

bool Pololu::moveRawHack ( const int  servo,
const byte  rawpos,
const int  port = 1 
)

hack work around for moveRaw. Remove when serial stuff is fixed

Definition at line 191 of file Pololu.C.

float Pololu::rawToCalib ( const int  servo,
const byte  rawpos 
) const [protected]

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

Definition at line 225 of file Pololu.C.

References negmult, posmult, and zero.

Referenced by getPosition().

bool Pololu::setNeutral ( const int  servo,
const short int  pos 
)

set the neutral position

Definition at line 150 of file Pololu.C.

References itsPort.

bool Pololu::setParam ( const int  servo,
bool  on_off,
bool  direction,
char  range 
)

set servo param

Definition at line 169 of file Pololu.C.

References itsPort.

bool Pololu::setSpeed ( const int  servo,
const byte  speed 
)

Set the speed at which the servo moves.

Definition at line 131 of file Pololu.C.

References itsPort.


Member Data Documentation

Serial port to use.

Definition at line 108 of file Pololu.H.

Referenced by moveRaw(), Pololu(), setNeutral(), setParam(), and setSpeed().

negative multiplier calib

Definition at line 111 of file Pololu.H.

Referenced by calibrate(), calibToRaw(), Pololu(), rawToCalib(), and ~Pololu().

byte* Pololu::pos [protected]

raw servo positions [0..255]

Definition at line 112 of file Pololu.H.

Referenced by getPosition(), getPositionRaw(), moveRaw(), Pololu(), and ~Pololu().

positive multiplier calib

Definition at line 110 of file Pololu.H.

Referenced by calibrate(), calibToRaw(), Pololu(), rawToCalib(), and ~Pololu().

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

zero calibration values

Definition at line 109 of file Pololu.H.

Referenced by calibrate(), calibToRaw(), Pololu(), rawToCalib(), and ~Pololu().


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