aiservoBeginSplineMotion()

描述

允许使用者使用曲线规划作为伺服机运动的插补方法,开启此功能后,可适度抑制机器人运动过程产生的震动,让机器人动作更稳定。此功能在 Coding 315 以后开始支援。

语法

aiservoBeginSplineMotion(mode, frames, frameTime, numFrames)

参数

mode:有 3 种模式可选择。

  1. NATURAL_CUBIC:可适度降低机器人运动中的震动,平滑化机器人动作,需要注意的是,为了符合 NATURAL CUBIC SPLINE 公式定义,机器人的 Frame 编排在某些方式下,插补出来的轨迹可能会超出预期动作(overshooting),如果不希望此状况发生,可使用 CONSTRAINED_CUBIC 模式。
  2. CONSTRAINED_CUBIC:依据 CONSTRAINED CUBIC SPLINE 公式定义,可保证不会有上述 NATURAL_CUBIC 的缺点,但会降低平滑化的效果。
  3. CATMULL_ROM:依据 CATMULL-ROM SPLINE 公式定义,能有效抑制 NATURAL_CUBIC 所产生的 overshooting,且平滑化的效果优于 CONSTRAINED_CUBIC

frames:要进行曲线规划的 frame 阵列。

frameTime:每个 frame 播放的间隔时间阵列(时间单位为 ms)。

numFrames:要进行曲线规划的 frames 数量(即 frames 阵列大小)。

回传

范例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

#include "AIServo86.h"

AIServo Servo1;

AIServo Servo2;

AIServo Servo3;

AIServoPort(ROBOTIS, AX12) bus;

AIServoFrame Frames[3];

unsigned long playtime[3] = {200, 500, 100};

void setup() {

  Servo1.attach(bus, 21); Servo2.attach(bus, 22); Servo3.attach(bus, 23);

  Frames[0].positions[0] = 150; Frames[0].positions[1] = 150; Frames[0].positions[2] = 130;

  Frames[1].positions[0] = 240; Frames[1].positions[1] = 140; Frames[1].positions[2] = 180;

  Frames[2].positions[0] = 240; Frames[2].positions[1] = 160; Frames[2].positions[2] = 180;

  Frames[0].playPositions(playtime[0]);

  Serial.println("Natural CUBIC");

}

 

void loop() {

  aiservoBeginSplineMotion(NATURAL_CUBIC, Frames, playtime, 3);

  for (int i=0; i<3; i++) {

    Frames[i].playPositions(playtime[i]);

    while(isAIServoMultiMoving() == true);

  }

  aiservoEndSplineMotion();

}

See also

- attach()
- AIServoFrame
- positions[]
- playPositions()
- isAIServoMultiMoving()
- aiservoEndSplineMotion()


 

函式库参考主页面

86Duino 参考资料中的文字采用 知识共享署名-相同方式共享 3.0 授权授权。参考资料中的程式码范例已发布到公共领域。