aiservoBeginSplineMotion()

Description

Allows users to use curve planning as an interpolation method for servo motion. Enabling this feature can moderately suppress vibration during robot motion, making the robot's movements more stable. This feature is supported starting with Coding 315.

Syntax

aiservoBeginSplineMotion(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 overshoot 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.

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

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


 

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.