Import Effects

Download the 'lite' version of the library to work with effects imported from Feelix

Version 2.2.3 of the SimpleFOC library may not be compiling, downgrade to an older version to resolve the issue

Initialize an exported effect

The code generated during export can be pasted in the FeelixEffect library ('lite' version).

Additionally, the motor has to be initialized as shown here.

#include "Feelix.h"

EffectConfig_s bump_config { 
    .data_size = 26,
    .angle = 120,
    .quality = 10,
    .effect_type = Effect_type::DEPENDENT,
    .control_type = Control_type::POSITION
 };

float data_bump[] = {-0.362436362, 0.0, -0.408459434, 0.098711278, -0.404538423, 0.291391915, -0.365721557, 0.507018542, -0.286210671, 0.673098857, -0.162736664, 0.769335491, 0.0, 0.799975852, 0.153987833, 0.774500160, 0.287550988, 0.684574980, 0.368372644, 0.524378006, 0.399189361, 0.309056731, 0.398715347, 0.111885261, 0.358331666, 0.002202121};
FeelixEffect bump = FeelixEffect(bump_config, data_bump);

Play an exported haptic effect

void setup() {

  feelix.init();
}

void loop() {
  
  /* these functions need to update at a high frequency */
  
  /* read angle, velocity, direction and time */
   feelix.run();
   
  /* get the values based on current angle */
  /* void playHapticEffectAtAngle(FeelixEffect, float angle (in degrees))
   feelix.playHapticEffectAtAngle(bump, 180);
   
  /* write value to motors */
   feelix.move_feelix();
}

Play an exported velocity effect

void setup() {

  feelix.init();
  
  delay(1000);
  
  velocity_effect.start(); // start the effect
}

void loop() {
  /* these functions need to update at a high frequency */
  
  /* read angle, velocity, direction and time */
   feelix.run();

  /* get the values based on current time*/
   feelix.playVelocityEffect(velocity_effect);

  /* write value to motors */
   feelix.move_feelix();
}

Access variables motor

The feelix.run() updates the following variables that can be accessed in the code:

The current angle of the motor in radians (float)

feelix.angle 

The velocity of the motor in rad/s (float)

feelix.velocity

The time since the program started is saved in (long) current_time, the time can be reset when the (long) start_time variable is set to millis()

feelix.current_time
feelix.start_time = millis();

Get the direction in which the motor is rotating, clockwise (1) and counterclockwise (-1).

feelix.rotation_dir

Change sensor direction opposed to motor direction

feelix.sensor_dir = Direction::CCW  /* default: Direction::CW */

Change effect settings

Enable effect (effects are enabled by default)

effect.enable();

Disable effect

effect.disable();

Check if an effect is enabled

/* variable will be true when enabled, false when disabled */
effect.enabled 

Start velocity effect

effect.start();

Stop velocity effect

effect.stop();

Change scale

scale.x changes the angle (position/torque effects) or the duration (velocity), and scale.y changes the intensity (voltage %), velocity (velocity %), or degrees. Depending on the type of effect (torque, position, velocity over time, or angle over time)

effect.scale.x = 1.5; /* default is 1.0 */
effect.scale.y = 0.5; /* default is 1.0 */

Loop velocity effect

effect.infinite = true; /* default is false */

Repeat a haptic effect every rotation

feelix.range = 360 /* repeat effect every 360 degrees (default) */
effect.infinite = true; /* default is false */

Disable effect in clockwise direction or counterclockwise direction (haptic only)

effect.direction.cw = false; /* default is true */
effect.direction.ccw = false; /* default is true */

Last updated