svoe

Dependencies:   mbed mbed-STM32F103C8T6 MPU6050_1

realtime.h

Committer:
dima285
Date:
2018-11-03
Revision:
12:721a9ea55e91
Parent:
10:5bdd3dfd5f59
Child:
13:789b451cc27d

File content as of revision 12:721a9ea55e91:

Ticker rt_ticker;
bool realtime_flag;
/*float balance_prop = 0.8;
float balance_diff = 1.2;
float x_prop = 40;
float x_diff = 25;
float azimuth_prop = 0.8;
float azimuth_diff = 0.65;*/

void balance()
{
    float a = x_prop * (current.x - target.x) + x_diff * current.speed;
    if (a > max_accel) a = max_accel ; if (a < -max_accel) a = -max_accel;
    float delta_v = (2*balance_prop*ax + balance_diff*5.73*gy - a) * t_step; 
    
    set_motor_speed(motor_speed[0] - delta_v, motor_speed[1] - delta_v);
    
    wifi.printf("%.2f %.2f %.2f %.2f;",a,gy,ax,delta_v*100);
}


void realtime(){ //35uS - (3.5mS @ 115200) - (500uS @ 921600) (w/o sin,cos)
/*    float path_error = target_path-current_path;
    float target_speed = 0.1*path_error;//1m/s at 10cm
    float linear_acceleration = 1*(target_speed-current_speed);*/    

    
    realtime_flag = 1; 
}

void realtime_init(){
    rt_ticker.attach(&realtime, t_step);    }