103 pvp.
pos = (((short)buf[3])<<8) | buf[4];
104 pvp.
vel = (((short)buf[5])<<8) | buf[6];
138 p[3] =
static_cast<byte>(positiveVelocity);
139 p[4] =
static_cast<byte>(negativeVelocity);
214 p[3] = (
byte) (limit >> 8);
232 p[3] = (
byte) (limit_lin >> 8);
233 p[4] = (
byte) limit_lin;
266 p[3] = (
byte) (limit >> 8);
276 if ((subcommand > 255) || (subcommand < 240)) {
287 p[2] = (
byte) subcommand;
300 std::vector<byte> sendBuf(14), recvBuf(2, 0);
305 sendBuf[2] =
static_cast<byte>(targetPosition >> 8);
306 sendBuf[3] =
static_cast<byte>(targetPosition);
307 sendBuf[4] =
static_cast<byte>(duration >> 8);
308 sendBuf[5] =
static_cast<byte>(duration);
310 sendBuf[6] =
static_cast<byte>(p1 >> 8);
311 sendBuf[7] =
static_cast<byte>(p1);
312 sendBuf[8] =
static_cast<byte>(p2 >> 8);
313 sendBuf[9] =
static_cast<byte>(p2);
314 sendBuf[10] =
static_cast<byte>(p3 >> 8);
315 sendBuf[11] =
static_cast<byte>(p3);
316 sendBuf[12] =
static_cast<byte>(p4 >> 8);
317 sendBuf[13] =
static_cast<byte>(p4);
319 protocol->
comm(&sendBuf.front(), &recvBuf.front(), &readBytes);
334 int encoderStop = encoderOffset - rotationDirection*
static_cast<int>(encodersPerCycle*(angleRange/(2.0*
M_PI)));
372 mov(
GetPVP()->pos + dif, wait, tolerance, timeout);
377 mov(
GetPVP()->pos - dif, wait, tolerance, timeout);
399 KNI::Timer t(waitTimeout), poll_t(POLLFREQUENCY);
411 if (std::abs(target -
GetPVP()->pos) < encTolerance)
431 inc(enc, wait, tolerance, timeout);
438 dec(enc, wait, tolerance, timeout);
443 mov(enc, wait, tolerance, timeout);
short actpos
actual position
_encT rad2enc(_angleT const &angle, _angleT const &angleOffset, _encT const &epc, _encT const &encOffset, _encT const &rotDir)
TMotCmdFlg mcf
motor flag after calibration
unsigned char byte
type specification (8 bit)
void setTolerance(int tolerance)
TMotTPS tps
target position
bool checkEncoderInRange(int encoder)
byte maxppwm
max. val for pos. voltage
void setControllerParameters(byte kSpeed, byte kPos, byte kI)
Set the controller parameters.
void setCalibrated(bool calibrated)
TMotPVP pvp
reading motor parameters
TMotInit _initialParameters
void setPwmLimits(byte maxppwm, byte maxnpwm)
Set the PWM limits (for the drive controller)
CCplBase * protocol
protocol interface
Abstract base class for protocol definiton.
const int POLLFREQUENCY
Polling position every POLLFREQUENCY milliseconds.
TMotGNL gnl
motor generals
bool enable
enable/disable
int enc_per_cycle
number of encoder units needed to complete 360 degrees;
void sendTPS(const TMotTPS *_tps)
send data
void inc(int dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Increments the motor specified by an index postion in encoder units.
void sendSpline(short targetPosition, short duration, short p1, short p2, short p3, short p4)
non-linear movement ended, new: poly move finished
void recvPVP()
receive data
void decDegrees(double dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Decrements the motor specified by an index postion in degrees.
CKatBase * own
parent robot
void setAccelerationLimit(short acceleration)
Set the acceleration limits.
byte maxppwm_nmp
Max. value for positive voltage (0 => 0%, +70 => 100%)
byte revision
firmware revision number
short maxnspeed
max. allowed reverse speed; pos!
void setCalibrationParameters(bool doCalibration, short order, TSearchDir direction, TMotCmdFlg motorFlagAfter, int encoderPositionAfter)
void getParameterOrLimit(int subcommand, byte *R1, byte *R2, byte *R3)
byte maxnpwm
max. val for neg. voltage; pos!
int crash_limit_lin_nmp
Limit of error in position in linear movement.
TMotSFW sfw
slave firmware
void WaitUntilElapsed() const
virtual void comm(const byte *pack, byte *buf, byte *size)=0
Base communication function.
byte subtype
slave subtype
TMotAPS aps
actual position
void setPositionCollisionLimit(int limit)
Set the collision limit.
TMotCLB _calibrationParameters
calibration structure
void mov(int tar, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Moves the motor specified by an index to a given target position in encoder units.
byte kI_nmp
Integral factor (1/kI) of control output added to the final control output.
short maxpspeed
max. allowed forward speed
void incDegrees(double dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Increments the motor specified by an index postion in degrees.
void sendAPS(const TMotAPS *_aps)
send data
void setCrashLimitLinear(int limit_lin)
Set the crash limit linear.
bool checkAngleInRange(double angle)
check limits in encoder values
short tarpos
target position
void setCrashLimit(int limit)
Set the crash limit.
TMotDYL dyl
dynamic limits
int enc_minpos
motor's minimum position in encoder values
int crash_limit_nmp
Limit of error in position.
TMotSCP scp
static controller parameters
bool init(CKatBase *_own, const TMotDesc _motDesc, CCplBase *protocol)
short order
order in which this motor will be calibrated. range: 0..5
void setInitialParameters(double angleOffset, double angleRange, int encodersPerCycle, int encoderOffset, int rotationDirection)
int enc_maxpos
motor's maximum position in encoder values
void resetBlocked()
unblock the motor.
TSearchDir dir
search direction for mech. stopper
byte kP_speed
Proportional factor of the speed compensator.
void dec(int dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Decrements the motor specified by an index postion in encoder units.
TMotStsFlg msf
motor status flag
motor description (partly)
TMotCmdFlg mcfAPS
motor command flag
byte maxaccel_nmp
Maximal acceleration and deceleration.
byte maxaccel
max acceleration
byte subversion
firmware subversion number
byte maxnpwm_nmp
Max. value for negative voltage (0 => 0%, +70 => 100%)
void waitForMotor(int tar, int encTolerance=100, short mode=0, int waitTimeout=TM_ENDLESS)
Waits until the Motor has reached the given targen position.
void recvSFW()
receive data
int enc_range
motor's range in encoder values
TMotCmdFlg mcfTPS
motor command flag
byte pwm
pulse with modulation
byte kP
prop. factor of pos comp
short maxpspeed_nmp
Max. allowed forward speed.
int enc_tolerance
encoder units of tolerance to accept that a position has been reached
void setSpeedCollisionLimit(int limit)
Set the collision limit.
byte version
firmware version number
byte kpos_nmp
Proportional factor of position compensator.
in desired position, new: fixed, state holding
short maxnspeed_nmp
Max. allowed reverse speed.
TMotENL _encoderLimits
motor limits in encoder values
void setSpeedLimits(short positiveVelocity, short negativeVelocity)
Set speed limits.
byte kspeed_nmp
Proportional factor of speed compensator.
void movDegrees(double tar, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Moves the motor specified by an index to a given target position in degrees.