servoBeginSplineMotion()

[Servo86]

描述

It allows users to specify a curve plan as the interpolation method for the servo motion trajectory, and when the curve interpolation function is enabled, it can appropriately suppress the vibration generated during the robot motion and make the robot motion more stable. 86Duino IDE supports this function from Coding 300 onwards.

語法

servoBeginSplineMotion(mode, frames, frameTime, numFrames)

參數

  • mode: There are 3 modes to choose from.
    • NATURAL_CUBIC: It can appropriately reduce the vibration of the 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 the robot’s frame arrangement may exceed the expected motion in some ways. CONSTRAINED_CUBIC mode.
    • 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. (This setting is supported from Coding 315)
  • 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 "Servo86.h"
Servo Servo1;
Servo Servo2;
Servo Servo3;
 
ServoFrame Frames[3];
unsigned long playtime[3] = {200, 500, 100};
void setup() {
   Servo1.attach(21); Servo2.attach(22); Servo3.attach(23);
   Frames[0].positions[0] = 1500; Frames[0].positions[1] = 1500; Frames[0].positions[2] = 1310;
   Frames[1].positions[0] = 2040; Frames[1].positions[1] = 1450; Frames[1].positions[2] = 1840;
   Frames[2].positions[0] = 2040; Frames[2].positions[1] = 1060; Frames[2].positions[2] = 1840;
   Frames[0].playPositions(playtime[0]);
   Serial.println("Natural CUBIC");
}
 
void loop() {
   servoBeginSplineMotion(NATURAL_CUBIC, Frames, playtime, 3);
   // The actions played below will have the smoothing effect of curve interpolation
   for (int i=0; i<3; i++) {
     Frames[i].playPositions(playtime[i]);
     while(isServoMultiMoving() == true);
   }
   servoEndSplineMotion(); // disable curve interpolation
}

參考


函式庫參考主頁面

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

發表評論

上部へスクロール