aiservoBeginSplineMotion()

[AIservo86]

描述

This function allows users to use Spline as the interpolation method for servo motion. When this function is turned on, it can appropriately suppress the vibration generated during robot motion and make robot motion more stable. This feature is supported from Coding 315 onwards.

語法

aiservoBeginSplineMotion(mode, frames, frameTime, numFrames)

參數

  • mode: There are 3 modes to choose from.
  • NATURAL_CUBIC: It can moderately reduce the vibration of robot movement and smooth out the robot motion. It should be noted that in order to meet the definition of NATURAL CUBIC SPLINE formula, the interpolated trajectory of robot frame arrangement may exceed the expected motion (overshooting) in some ways.
  • CONSTRAINED_CUBIC: Defined by the CONSTRAINED CUBIC SPLINE formula, which guarantees that there will be no NATURAL_CUBIC defects as described above, but will reduce the smoothing effect.
  • CATMULL_ROM: Defined by the CATMULL-ROM SPLINE formula, it can effectively suppress the overshooting caused by NATURAL_CUBIC, and the smoothing effect is better than CONSTRAINED_CUBIC.
  • frames: The frame array to be used for curve planning.
  • frameTime: the interval time array (in ms) for each frame to be played.
  • numFrames: the number of frames to be curved (i.e. the size of the frames array).

回傳

範例

#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();
}

參考


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール