servoBeginSplineMotion()

Description

Allows the user to specify curve planning as the interpolation method for the servo motion trajectory. Enabling curve interpolation can appropriately suppress vibration during robot motion, making the robot's movements more stable. This function is supported in the 86Duino IDE starting with Coding 300.

Syntax

servoBeginSplineMotion(mode, frames, frameTime, numFrames)

Parameters

mode: There are three modes to choose from.

  1. NATURAL_CUBIC: This mode moderately reduces vibration and smoothes robot motion. However, note that to comply with the NATURAL CUBIC SPLINE formula, the interpolated trajectory may deviate from the intended motion under certain robot frame arrangements. To avoid this, use the CONSTRAINED_CUBIC mode.
  2. CONSTRAINED_CUBIC: This mode follows the CONSTRAINED CUBIC SPLINE formula, eliminating the aforementioned drawbacks of NATURAL_CUBIC. However, this reduces the smoothing effect.
  3. CATMULL_ROM: Based on the CATMULL-ROM SPLINE formula, it effectively suppresses the overshooting caused by NATURAL_CUBIC and provides better smoothing than CONSTRAINED_CUBIC. (This setting is supported starting with Coding 315.)

frames: Array of frames for curve planning.

frameTime: Array of the time interval between each frame (in milliseconds).

numFrames: Number of frames for curve planning (i.e., the size of the frames array).

Postback

None

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

#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 following playback motion will have a smoothing effect using curve interpolation

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

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

    while(isServoMultiMoving() == true);

  }

  servoEndSplineMotion();  // Turn off the curve interpolation function

}

See also

- attach()
- ServoFrame
- positions[]
- playPositions()
- isServoMultiMoving()
- servoEndSplineMotion()


 

Library Reference Page

The text in the 86Duino reference material is licensed under the Creative Commons Attribution-Share Alike 3.0 License. The code examples in the reference material have been released into the public domain.