remotecontrolboard.cpp
来自「一个语言识别引擎」· C++ 代码 · 共 2,110 行 · 第 1/5 页
CPP
2,110 行
if (pid)
return pid->setErrorLimits(limits);
return false;
}
/** Get the current error for a joint.
* @param j joint number
* @param err pointer to the storage for the return value
* @return true/false on success failure
*/
virtual bool getError(int j, double *err) {
if (pid)
return pid->getError(j, err);
*err = 0.0;
return false;
}
/** Get the error of all joints.
* @param errs pointer to the vector that will store the errors.
* @return true/false on success/failure.
*/
virtual bool getErrors(double *errs) {
if (pid)
return pid->getErrors(errs);
ACE_OS::memset (errs, 0, sizeof(double)*nj);
return false;
}
/** Get the output of the controller (e.g. pwm value)
* @param j joint number
* @param out pointer to storage for return value
* @return success/failure
*/
virtual bool getOutput(int j, double *out) {
if (pid)
return pid->getOutput(j, out);
*out = 0.0;
return false;
}
/** Get the output of the controllers (e.g. pwm value)
* @param outs pinter to the vector that will store the output values
*/
virtual bool getOutputs(double *outs) {
if (pid)
return pid->getOutputs(outs);
ACE_OS::memset(outs, 0, sizeof(double)*nj);
return false;
}
virtual bool setOffset(int j, double v)
{
if (pid)
return pid->setOffset(j,v);
return false;
}
/** Get current pid value for a specific joint.
* @param j joint number
* @param pid pointer to storage for the return value.
* @return success/failure
*/
virtual bool getPid(int j, Pid *p) {
if (pid)
return pid->getPid(j, p);
ACE_OS::memset(p, 0, sizeof(Pid));
return false;
}
/** Get current pid value for a specific joint.
* @param pids vector that will store the values of the pids.
* @return success/failure
*/
virtual bool getPids(Pid *pids) {
if (pid)
return pid->getPids(pids);
ACE_OS::memset(pids, 0, sizeof(Pid)*nj);
return false;
}
/** Get the current reference position of the controller for a specific joint.
* @param j joint number
* @param ref pointer to storage for return value
* @return reference value
*/
virtual bool getReference(int j, double *ref) {
if (pid)
return pid->getReference(j, ref);
*ref=0.0;
return false;
}
/** Get the current reference position of all controllers.
* @param refs vector that will store the output.
*/
virtual bool getReferences(double *refs) {
if (pid)
return pid->getReferences(refs);
ACE_OS::memset(refs, 0, sizeof(double)*nj);
return false;
}
/** Get the error limit for the controller on a specific joint
* @param j joint number
* @param limit pointer to storage
* @return success/failure
*/
virtual bool getErrorLimit(int j, double *limit) {
if (pid)
return pid->getErrorLimit(j, limit);
*limit = 0.0;
return false;
}
/** Get the error limit for all controllers
* @param limits pointer to the array that will store the output
* @return success or failure
*/
virtual bool getErrorLimits(double *limits) {
if (pid)
return pid->getErrorLimits(limits);
ACE_OS::memset(limits, 0, sizeof(double)*nj);
return false;
}
/** Reset the controller of a given joint, usually sets the
* current position of the joint as the reference value for the PID, and resets
* the integrator.
* @param j joint number
* @return true on success, false on failure.
*/
virtual bool resetPid(int j) {
if (pid)
return pid->resetPid(j);
return false;
}
/**
* Disable the pid computation for a joint
* @param j is the axis number
* @return true if successful, false on failure
**/
virtual bool disablePid(int j) {
if (pid)
return pid->disablePid(j);
return false;
}
/**
* Enable the pid computation for a joint
* @param j is the axis number
* @return true/false on success/failure
*/
virtual bool enablePid(int j) {
if (pid)
return pid->enablePid(j);
return false;
}
/* IPositionControl */
/**
* Get the number of controlled axes. This command asks the number of controlled
* axes for the current physical interface.
* @param ax pointer to storage
* @return true/false.
*/
virtual bool getAxes(int *ax) {
if (pos)
return pos->getAxes(ax);
*ax = 0;
return false;
}
/**
* Set position mode. This command
* is required by control boards implementing different
* control methods (e.g. velocity/torque), in some cases
* it can be left empty.
* return true/false on success/failure
*/
virtual bool setPositionMode() {
if (pos)
return pos->setPositionMode();
return false;
}
/**
* Set new reference point for a single axis.
* @param j joint number
* @param ref specifies the new ref point
* @return true/false on success/failure
*/
virtual bool positionMove(int j, double ref) {
if (pos)
return pos->positionMove(j, ref);
return false;
}
/** Set new reference point for all axes.
* @param refs array, new reference points.
* @return true/false on success/failure
*/
virtual bool positionMove(const double *refs) {
if (pos)
return pos->positionMove(refs);
return false;
}
/** Set relative position. The command is relative to the
* current position of the axis.
* @param j joint axis number
* @param delta relative command
* @return true/false on success/failure
*/
virtual bool relativeMove(int j, double delta) {
if (pos)
return pos->relativeMove(j, delta);
return false;
}
/** Set relative position, all joints.
* @param deltas pointer to the relative commands
* @return true/false on success/failure
*/
virtual bool relativeMove(const double *deltas) {
if (pos)
return pos->relativeMove(deltas);
return false;
}
/**
* Check if the current trajectory is terminated. Non blocking.
* @param true if the trajectory is terminated, false otherwise
* @return false on failure
*/
virtual bool checkMotionDone(int j, bool *flag) {
if (pos)
return pos->checkMotionDone(j, flag);
*flag = true;
return false;
}
/**
* Check if the current trajectory is terminated. Non blocking.
* @param true if the trajectory is terminated, false otherwise
*/
virtual bool checkMotionDone(bool *flag) {
if (pos)
return pos->checkMotionDone(flag);
*flag = true;
return false;
}
/** Set reference speed for a joint, this is the speed used during the
* interpolation of the trajectory.
* @param j joint number
* @param sp speed value
* @return true/false upon success/failure
*/
virtual bool setRefSpeed(int j, double sp) {
if (pos)
return pos->setRefSpeed(j, sp);
return false;
}
/** Set reference speed on all joints. These values are used during the
* interpolation of the trajectory.
* @param spds pointer to the array of speed values.
* @return true/false upon success/failure
*/
virtual bool setRefSpeeds(const double *spds) {
if (pos)
return pos->setRefSpeeds(spds);
return false;
}
/** Set reference acceleration for a joint. This value is used during the
* trajectory generation.
* @param j joint number
* @param acc acceleration value
* @return true/false upon success/failure
*/
virtual bool setRefAcceleration(int j, double acc) {
if (pos)
return pos->setRefAcceleration(j, acc);
return false;
}
/** Set reference acceleration on all joints. This is the valure that is
* used during the generation of the trajectory.
* @param accs pointer to the array of acceleration values
* @return true/false upon success/failure
*/
virtual bool setRefAccelerations(const double *accs) {
if (pos)
return pos->setRefAccelerations(accs);
return false;
}
/** Get reference speed for a joint. Returns the speed used to
* generate the trajectory profile.
* @param j joint number
* @param ref pointer to storage for the return value
* @return true/false on success or failure
*/
virtual bool getRefSpeed(int j, double *ref) {
if (pos)
return pos->getRefSpeed(j, ref);
*ref = 0.0;
return false;
}
/** Get reference speed of all joints. These are the values used during the
* interpolation of the trajectory.
* @param spds pointer to the array that will store the speed values.
* @return true/false on success/failure.
*/
virtual bool getRefSpeeds(double *spds) {
if (pos)
return pos->getRefSpeeds(spds);
ACE_OS::memset(spds, 0, sizeof(double)*nj);
return false;
}
/** Get reference acceleration for a joint. Returns the acceleration used to
* generate the trajectory profile.
* @param j joint number
* @param acc pointer to storage for the return value
* @return true/false on success/failure
*/
virtual bool getRefAcceleration(int j, double *acc) {
if (pos)
return pos->getRefAcceleration(j, acc);
*acc = 0.0;
return false;
}
/** Get reference acceleration of all joints. These are the values used during the
* interpolation of the trajectory.
* @param accs pointer to the array that will store the acceleration values.
* @return true/false on success or failure
*/
virtual bool getRefAccelerations(double *accs) {
if (pos)
return pos->getRefAccelerations(accs);
ACE_OS::memset(accs, 0, sizeof(double)*nj);
return false;
}
/** Stop motion, single joint
* @param j joint number
* @return true/false on success/failure
*/
virtual bool stop(int j) {
if (pos)
return pos->stop(j);
return false;
}
/**
* Stop motion, multiple joints
* @return true/false on success/failure
*/
virtual bool stop() {
if (pos)
return pos->stop();
return false;
}
/* IVelocityControl */
/**
* Set new reference speed for a single axis.
* @param j joint number
* @param v specifies the new ref speed
* @return true/false on success/failure
*/
virtual bool velocityMove(int j, double v) {
if (vel)
return vel->velocityMove(j, v);
return false;
}
/**
* Set a new reference speed for all axes.
* @param v is a vector of double representing the requested speed.
* @return true/false on success/failure.
*/
virtual bool velocityMove(const double *v) {
if (vel)
return vel->velocityMove(v);
return false;
}
/**
* Set the controller to velocity mode.
* @return true/false on success/failure.
*/
virtual bool setVelocityMode() {
if (vel)
return vel->setVelocityMode();
return false;
}
/* IEncoders */
/**
* Reset encoder, single joint. Set the encoder value to zero
* @param j is the axis number
* @return true/false on success/failure
*/
virtual bool resetEncoder(int j) {
if (enc)
return enc->resetEncoder(j);
return false;
}
/**
* Reset encoders. Set the encoder values to zero for all axes
* @return true/false
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?