Feelix
  • Feelix Documentation
  • Getting started
    • Designing Effects
      • Torque Effects
      • Position Effects
      • Velocity Effects
      • Dependent/Independent Effects
    • Effect Library
    • Creating Collections
  • Create and edit
    • Edit tools
    • Effect Settings
    • Layers
    • Grid
    • Export Effects
    • TensorFlow
  • Uploading files
    • Setting up STM32
    • Connect and Upload
    • Hardware Settings
    • Troubleshooting Feelix
  • Hardware support
    • Hardware
    • PCB pinout
    • Setup
    • Dependencies
    • FeelixEffect Docs
      • Setup
      • Motor control
      • Import Effects
        • Import Haptic Effect
        • Import Velocity Effect
        • Functions and Parameters
      • I2C communication
  • Downloads
    • Feelix Design Tool
    • Feelix Arduino Library
    • 3D Models
    • Old Library Releases
Powered by GitBook
On this page
  • Initialize Haptic Effect
  • Play Haptic Effect in the Loop
  • Putting it all Together

Was this helpful?

  1. Hardware support
  2. FeelixEffect Docs
  3. Import Effects

Import Haptic Effect

Basic example: importing a haptic effect exported from Feelix and playing it in a loop.

PreviousImport EffectsNextImport Velocity Effect

Last updated 6 days ago

Was this helpful?

Initialize Haptic Effect

Content can be exported in Feelix see . The code generated during export can be pasted in the .

/* initialize Effect */ 
EffectConfig_s zigzag_spring_config { 
	.data_size = 6,			//number of data points
	.angle = 100, 			//width of the effect
	.quality = 20,			//spacing between data points 
					//(angle / (data_size - 1))
	.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);

Play Haptic Effect in the Loop

/* Play haptic effect at 80.0 degree angle
   value indicates left side value of the effect
   zigzag_spring_config angle indicates the width of the effect
 */
feelix.playHapticEffectAtAngle(zigzag_spring, 80.0);

Putting it all Together

#include "Feelix.h"

/* initialize Feelix */
Feelix feelix = Feelix();


/* initialize Effect */ 
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);

/* mirrored copy of the same effect */
FeelixEffect zigzag_spring_mirrored = FeelixEffect(zigzag_spring_config, data_zigzag_spring);


/* variables to read data and sensors without interrupting the loop */
const uint8_t loop_interval = 50;
volatile uint8_t loop_count = 0;


void setup() {

  Serial.begin(115200);
  
  feelix.init();

  /* mirror copied effect spring effect down to create inverse effect */
  zigzag_spring_mirrored.position.y = -1.0;

  delay(100);

}


void loop() {

  /* read angle, velocity and direction
   * this function needs to update at a high frequency without interruptions */
  feelix.run();

  /* functions within the loop that need to be called less frequently:
   * adapt frequency with loop_interval
   * E.g. for printing values and reading sensors;
   */
  if (loop_count++ > loop_interval) {
    loop_count = 0;

    /* blink pink LED */
    feelix.blinkStatusLED();  
    /* read motor temperature, shut down in case temperature exceeds 65.00 degrees */
    feelix.readTemperature();

    /* print angle and velocity (values are updated in feelix.run()) */
    Serial.println((String) feelix.angleDeg + "\t" + feelix.velocity + "\t" + 
                            feelix.temp + "\t" + feelix.driverVoltage + "\t");
  }

  /* example of a haptic effect 
     function needs to run every loop in order to be played 
     zigzag_spring positioned between x1:80 and x2:180 degrees 
     zigzag_spring_mirrored positioned between x1:180 and x2:280 degrees */

  feelix.playHapticEffectAtAngle(zigzag_spring, 80.0);
  feelix.playHapticEffectAtAngle(zigzag_spring_mirrored, 180.0);

  
  /* function to write the values of the effects to the motor */
  feelix.move_feelix();

}


Export Effects
FeelixEffect library