Import Feelix Effects

Initialize the Effect

Effect configuration includes:

  • data_size – length of the data array.

  • angle – width of the effect (in degrees or ms).

  • quality – spacing between data points in the array.

  • control type – effect type (torque, angle, or velocity). Haptic effects can be dependent or independent (see Getting Started).

EffectConfig_s zigzag_spring_config { 
	.data_size = 6,
	.angle = 100,
	.quality = 20,
	.effect_type = Effect_type::INDEPENDENT,
	.control_type = Control_type::TORQUE
 };

float data_zigzag_spring[] = {1.0, 0.4, 0.8, 0.2, 0.6, 0.0};
FeelixEffect zigzag_spring = FeelixEffect(zigzag_spring_config, data_zigzag_spring);
enum Effect_type {
    INDEPENDENT  = 0, 
    DEPENDENT    = 1,
    NOTSET       = -12345 
};

enum Control_type {
    POSITION        = 3, 
    TORQUE          = 2,
    VELOCITY        = 1,
    VELOCITY_ANGLE  = 4,
    MOVE_TO         = 5,
    UNDEFINED       = -12345   //not yet known or invalid state
};

Play a Haptic Effect

Call playHapticEffectAtAngle(FeelixEffect effect, float angle_deg) in every loop to check the torque or angle based on the motor’s current position. Pass the FeelixEffect and the effect’s start position (in degrees) as arguments. Multiple effects can run in parallel or alternate using if statements.

Call move_feelix() to send data to the motor, it automatically sums overlapping effects.

feelix.playHapticEffectAtAngle(zigzag_spring, 80.0);
   
feelix.move_feelix();

Play a Velocity Effect

Call playVelocityEffect(FeelixEffect effect, void (*callback)() = NULL) in every loop to check the velocity based on the motor’s current speed. The optional callback is executed when the effect finishes.

Call move_feelix() to send data to the motor.

feelix.playVelocityEffect(velocity_effect);

feelix.move_feelix();

Change Feelix Effect Settings

Effect settings can be adjusted in the setup or main loop at run time.

  • Enable effecteffect.enable(); (enabled by default)

  • Disable effecteffect.disable();

  • Check if enabledeffect.isEnabled(); (returns true if enabled, false if not)

  • Start / Stop velocity effect

    effect.play(true, feelix.current_time);  //(time can be used for start delay)
    effect.play(false);                      // stop
    • play = true starts the effect

    • time can delay the start (default is millis())

    • play = false stops the effect

  • Check if velocity effect is playing - effect.isPlaying(); (returns true if playing, false if not)

  • Change effect scale

    • scale.x controls angle (for position/torque effects) or duration (for velocity effects).

    • scale.y controls intensity (%)

    effect.scale.x = 1.5; // default 1.0 scale from -1.0 to 1.0 
    effect.scale.y = 0.5; // default 1.0 scale from -1.0 to 1.0 
  • Change vertical position effect

    • position.y

    effect.position.y = -1.0; // default 0.0 scale from -1.0 to 1.0 
  • Repeat effecteffect.infinite = true; (default is false, works for both velocity and haptic effects)

  • Disable effect by direction (haptic only)

    effect.direction.cw = false;  // default true (clockwise)
    effect.direction.ccw = false; // default true (counterclockwise)

Last updated

Was this helpful?