该文件是 机器人学 配套的练习所使用的PUMA机器人编程系统的说明

  • 只能使用C++98标准
  • 没有动态内存分配。 不能使用malloc / free,new / delete。 静态分配所需的空间。 不遵守该规则可能会导致无法及时完成伺服环路(serve loop)。
  • 库里有用于矩阵和向量的类(PrMatrix,PrVector等)。 可以在包含目录中引用头文件。PrVector可以像数组(gv.tau [0])一样被索引,而PrMatrix可以像二维数组(gv.Lambda [0] [5])或函数gv.Lambda(0,5)。
  • 可以使用线性代数的常规规则对它们进行加,减和乘积运算,因此将矩阵乘以向量可以完全满足您的期望。 (如果两个向量相乘,结果是一个通过逐元素乘法产生的向量。这对于乘以kp或kv向量很有用。 如果需要标量,使用dot()方法。)
  • printf()太慢,无法从伺服循环运行,因此它是UiAgent.h中提供的Ui :: Display()方法的别名。 输出委托给低优先级任务。 但是,如果程序意外崩溃,则所有排队的printf()语句都将丢失。 如果需要出于调试目的而强制使用立即printf(),请改用fprintf(stdout,...)。 但是请谨慎使用fprintf():在QNX机器上,由于伺服循环无法及时完成,因此fprintf()语句很可能会导致崩溃。
  • 在当季度末处理项目时,可能需要调试崩溃的一种方法是分析核心转储。 运行“ gdb programmname core dump”,然后使用“ bt”命令查看堆栈跟踪。 在QNX计算机上,核心转储位于/var/dumps/servo.core中。 切记要清理计算机上的核心转储,否则磁盘空间将用完!

全局变量

与用户访问相关的所有变量和参数均在GlobalVariables.h中声明;用于分配和最终项目的所有生成的代码将位于control.cpp中。 你还可以在control.cpp中声明全局变量和函数。GlobalVariables.h在/opt/pumasim/include目录下。

注意:GUI为单位测量角度,在代码中使用弧度。 当数据从GUI发送到服务器时,将转换角度。 gv. 表示GlobalVariables实例的变量。

状态变量State variables

  • gv.dof : Degrees of freedom自由度
  • gv.curTime : Current simulator time当前模拟的时间
  • gv.tau : Vector of joint torques [in newton-meters]向量,关节扭矩 [公式]
  • gv.q : Vector of current joint space positions [rad]向量,关节角 [公式]
  • gv.dq : Vector of current joint space velocities [rad / sec]向量,关节空间速度
  • gv.kp : Vector of position gains (kp)向量, [公式]
  • gv.kv : Vector of velocity gains (kv)向量, [公式]
  • gv.qd : Vector of desired joint positions [rad]向量,目标关节角 [公式]
  • gv.dqd : Vector of desired joint velocities [rad / sec]向量,目标关节速度
  • gv.ddqd : Vector of desired joint accelerations [rad / sec2]向量,目标关节加速度
  • gv.x : Vector of current operational space positions
  • gv.dx : Vector of current operational space velocities
  • gv.xd : Vector of desired operational space positions
  • gv.dxd : Vector of desired operational space velocities
  • gv.ddxd : Vector of desired operational space accelerations
  • gv.elbow:Desired elbow configuration for track control mode用于轨迹控制模式的所需弯头配置
  • gv.T:Linear transformation for end-effector position/orientation末端执行器位置/方向的线性变换
  • gv.Td:Linear transformation for desired end-effector position/orientation所需末端执行器位置/方向的线性变换

运动学和动力学变量Kinematics & Dynamics Variables

  • gv.J : Jacobian
  • gv.Jtranspose : Jacobian transpose雅可比转置
  • gv.A : Mass matrix. Also called M in some robotics classes.质量矩阵。 在某些类中也称为M。
  • gv.B : Centrifugal/coriolis vector离心/科氏载体
  • gv.G : Gravity vector重力向量
  • gv.Lambda : Mass matrix in operational space操作空间中的质量矩阵
  • gv.mu : Centrifugal/coriolis vector in operational space工作空间中的离心/科里奥利矢量
  • gv.p : Gravity vector in operational space操作空间中的重力向量
  • gv.singularities : Bitmap of singularities
  • gv.E : Matrix converting linear/angular velocity to configuration parameters将线速度/角速度转换为配置参数的矩阵
  • gv.Einverse : Inverse of g E matrix g E矩阵的逆

Limit Variables

  • gv.qmin : Minimum joint positions allowance [rad]
  • gv.qmax : Maximum joint positions allowance [rad]
  • gv.dqmax : Maximum joint velocities allowance [rad / sec]
  • gv.ddqmax : Maximum joint accelerations allowance [rad / sec2]
  • gv.taumax : Maximum joint torques allowance [newton-meter]
  • gv.xmin : Vector of minimum operational-space coordinates
  • gv.xmax : Vector of maximum operational-space coordinates
  • gv.dxmax : Maximum operational space velocity allowance (scalar)
  • gv.ddxmax : Maximum operational space acceleration allowance (scalar)
  • gv.wmax : Maximum angular velocity in operational space (scalar)

Potential-field Variables

  • gv.jlimit : (simulator only) Joint Limits potential field flag
  • gv.q0 : Vector of minimum distances to apply joint limit potential fields
  • gv.kj : Vector of gains for the joint limit potential field
  • gv.rho0 : Minimum distance to apply potential field controller
  • gv.eta : Gain for potential field controller
  • gv.sbound : Boundary of singularity [rad]
  • gv.line : Structure holding a line for the Line Trajector controller
  • gv.numObstacles : Number of obstacles, for the potential field controller
  • gv.obstacles : Array of obstacles, for the potential field controller

Functions to be modified in control.cpp

每次调用不同的控制模式时,将运行以下功能:

  • void InitControl() : Runs before the first servo loop
  • void initFloatControl() : Float Control Mode
  • void initOpenControl() : Open-Loop Control Mode
  • void initNjholdControl() : Joint Space Non-Dynamic Hold Mode
  • void initJholdControl() : Joint Space Dynamic Hold Mode
  • void initNholdControl() : Operational Space Non-Dynamic Hold Mode
  • void initHoldControl() : Operational Space Dynamic Hold Mode
  • void initNjmoveControl() : Joint Space Non-Dynamic Move Mode void initJmoveControl() : Joint Space Dynamic Move Mode
  • void initNjgotoControl() : Joint Space Non-Dynamic Velocity Saturation Mode关节空间非动态速度饱和模式
  • void initJgotoControl() : Joint Space Dynamic Velocity Saturation Mode
  • void initNjtrackControl() : Joint Space Non-Dynamic Cubic Spline Track Mode
  • void initJtrackControl() : Joint Space Dynamic Cubic Spline Track Mode
  • void initNxtrackControl() : Cartesian Space Non-Dynamic Cubic Spline Track Mode
  • void initXtrackControl() : Cartesian Space Dynamic Cubic Spline Track Mode
  • void initNgotoControl() : Operational Space Non-Dynamic Velocity Saturation Mode
  • void initGotoControl() : Operational Space Dynamic Velocity Saturation Mode
  • void initNtrackControl() : Operational Space Non-Dynamic Cubic Spline Track Mode
  • void initTrackControl() : Operational Space Dynamic Cubic Spline Track Mode
  • void initPfmoveControl() : Potential Field Move Mode
  • void initLineControl() : Potential Field Line Track Mode
  • void initProj1Control() : User-defined Final Project Control Mode 1
  • void initProj2Control() : User-defined Final Project Control Mode 2
  • void initPsroj3Control() : User-defined Final Project Control Mode 3

只要相关的控制模式处于活动状态,以下控制功能将连续执行(以时钟速率计算和发送扭矩值):

  • void PreprocessControl() : Runs before the control function
  • void PostprocessControl() : Runs after the control function
  • void noControl() : No Control, all Torque set to 0.0 void floatControl() : Arm Floats (gravity compensation)
  • void openControl() : Open-Loop (no feedback) control (caution !)
  • void njholdControl() : Arm holds current joint position (Non-Dynamic)手臂保持当前关节位置(非动态)
  • void jholdControl() : Arm holds current joint position (Dynamic)
  • void nholdControl() : Arm holds current end-effector position (Non-Dynamic)手臂保持当前的末端执行器位置(非动态)
  • void holdControl() : Arm holds current end-effector position (Dynamic)
  • void njmoveControl() : Joint Space, Non-Dynamic Feedback Control关节空间,非动态反馈控制
  • void jmoveControl() : Joint Space, Dynamic Feedback Control
  • void njgotoControl() : Arm joints move to desired angles with vel.sat.(Non-Dynamic)手臂关节通过vel.sat移动到所需角度(非动态)
  • void jgotoControl() : Arm joints move to desired angles with vel.sat.(Dynamic)
  • void njtrackControl() : Arm joints move following cubic spline traject.(Non- Dynamic)
  • void jtrackControl() : Arm joints move following cubic spline traject.(Dynamic)
  • void nxtrackControl() : End-effector moves to cartesian coordinates (Non-Dynamic)手臂关节按照三次样条曲线轨迹移动。(非动态)
  • void xtrackControl() : End-effector moves to cartesian coordinates (Dynamic)
  • void ngotoControl() : End-effector follows trajectory with vel.sat. (Non-Dynamic)
  • void gotoControl() : End-effector follows trajectory with vel.sat. (Dynamic)
  • void ntrackControl() : End-effector follows a cubic spline trajectory (Non-Dynamic)
  • void trackControl() : End-effector follows a cubic spline trajectory (Dynamic)
  • void pfmoveControl() : Potential Field Method, manipulator avoids obstacles
  • void lineControl() : Line Tracking Method (with potential field)
  • void proj1Control() : User-defined Final Project Control Mode 1
  • void proj2Control() : User-defined Final Project Control Mode 2
  • void proj3Control() : User-defined Final Project Control Mode 3

The following function is useful for debugging. It will execute whenever you type pdebug at the “CS225A:>” prompt以下功能对于调试很有用。 每当您在“ CS225A:>”提示符下键入pdebug时,它将执行:

  • void PrintDebug() : Print debugging information in response to the pdebug command打印调试信息以响应pdebug命令