2024-09-11 09:40:46 +00:00
|
|
|
#ifndef BEHAVIOUR_H_
|
|
|
|
#define BEHAVIOUR_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include "SimplexNoise.h" //Library from https://github.com/jshaw/SimplexNoise
|
|
|
|
#include "definitions.h"
|
|
|
|
#include "servo.h"
|
|
|
|
|
|
|
|
extern dxl_servo servos[SERVO_COUNT];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SERVO_COUNT_MAIN 3
|
|
|
|
#define SERVO_COUNT_PERIPHERAL 3
|
|
|
|
|
2024-09-11 15:15:34 +00:00
|
|
|
#define WEIGHT_COUNT 8 //enter number of weights here for array size
|
2024-09-11 09:40:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define WEIGHT_UPDATE_INTERVAL 100
|
|
|
|
#define SERVOWEIGHT_UPDATE_INTERVAL SERVO_UPDATE_INTERVAL
|
|
|
|
|
2024-09-12 09:23:52 +00:00
|
|
|
#define MOOD_UPDATE_INTERVAL 1000.0/50
|
|
|
|
|
2024-09-11 09:40:46 +00:00
|
|
|
|
|
|
|
#define W_PITCH 0
|
|
|
|
#define W_ROLL 1
|
|
|
|
#define W_NOISE 2
|
|
|
|
#define W_NOISESLOW 3
|
|
|
|
#define W_SIN 4
|
|
|
|
#define W_COS 5
|
|
|
|
#define W_LOOKDIRECTION 6
|
2024-09-11 15:15:34 +00:00
|
|
|
#define W_OFFSET 7
|
2024-09-11 09:40:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct Mood{
|
2024-09-12 09:23:52 +00:00
|
|
|
float arousal; //-1.0 to 1.0
|
|
|
|
float valence; //-1.0 to 1.0
|
2024-09-11 09:40:46 +00:00
|
|
|
};
|
|
|
|
extern Mood mood;
|
|
|
|
|
2024-09-11 12:19:10 +00:00
|
|
|
|
|
|
|
|
2024-09-12 09:23:52 +00:00
|
|
|
void updateMood(unsigned long millis,float gyroX,float gyroY,float gyroZ,bool bellyup, bool body_present, bool contact_main, bool contact_peripheralL, bool contact_peripheralR,float height,float temp_ambient,float temp_object,float pumpspeed, float servoerror);
|
2024-09-11 15:15:34 +00:00
|
|
|
void updateMatrixWeights(unsigned long millis,bool bellyup, bool body_present, bool contact_main, bool contact_peripheralL, bool contact_peripheralR, float pitch, float roll);
|
|
|
|
void updateServosByWeights(unsigned long millis,float pitch,float roll);
|
2024-09-12 09:23:52 +00:00
|
|
|
float interpolateTo(float value,float aimvalue,float timestep,float speed);
|
2024-09-11 09:40:46 +00:00
|
|
|
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max);
|
|
|
|
|
|
|
|
#endif
|