mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 19:47:50 +08:00
*** empty log message ***
This commit is contained in:
@@ -5,7 +5,7 @@ getf('imu.sci');
|
|||||||
|
|
||||||
rand('seed', 0);
|
rand('seed', 0);
|
||||||
getf('quadrotor.sci');
|
getf('quadrotor.sci');
|
||||||
true_euler0 = [ 0.01; 0.2; 0.4];
|
true_euler0 = [ 0.0; 0.0; 0.0];
|
||||||
dt = 0.015625;
|
dt = 0.015625;
|
||||||
|
|
||||||
[time, true_rates, true_eulers] = quadrotor_gen_roll_step(true_euler0, dt);
|
[time, true_rates, true_eulers] = quadrotor_gen_roll_step(true_euler0, dt);
|
||||||
@@ -15,12 +15,17 @@ dt = 0.015625;
|
|||||||
|
|
||||||
|
|
||||||
xbasc();
|
xbasc();
|
||||||
|
subplot(3,1,1)
|
||||||
|
plot2d([time]', accel', style=[5, 3, 2], leg="a_x@a_y@a_z");
|
||||||
|
xtitle( 'Accel', 's', 'volts') ;
|
||||||
|
|
||||||
|
|
||||||
true_rates_deg = deg_of_rad(true_rates);
|
true_rates_deg = deg_of_rad(true_rates);
|
||||||
subplot(2,1,1)
|
subplot(3,1,2)
|
||||||
plot2d([time]', true_rates_deg', style=[5, 3, 2], leg="rate_p@rate_q@rate_r");
|
plot2d([time]', true_rates_deg', style=[5, 3, 2], leg="rate_p@rate_q@rate_r");
|
||||||
xtitle( 'True rates', 's', 'deg/s') ;
|
xtitle( 'True rates', 's', 'deg/s') ;
|
||||||
|
|
||||||
subplot(2,1,2)
|
subplot(3,1,3)
|
||||||
plot2d([time]', gyro', style=[5, 3, 2], leg="g_x@g_y@g_z");
|
plot2d([time]', gyro', style=[5, 3, 2], leg="g_x@g_y@g_z");
|
||||||
xtitle( 'Raw gyros', 's', 'adc') ;
|
xtitle( 'Raw gyros', 's', 'adc') ;
|
||||||
|
|
||||||
|
|||||||
@@ -80,30 +80,51 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function [accel, mag, gyro] = imu_sim_misaligned(time, rates, eulers)
|
function [accel, mag, gyro] = imu_sim_misaligned(time, rates, eulers)
|
||||||
gyro_supply = 5.;
|
gyro_supply = [5.00 ; 5.00 ; 5.00 ]; // volt
|
||||||
gyro_neutral = [512; 512; 512];
|
gyro_neutral_offset = [0.01 ; -0.01 ; 0.05 ]; // volt
|
||||||
gyro_gains = rad_of_deg([ 300/512; 300/512; 300/512]);
|
gyro_gains = [0.0049 ; 0.0051 ; 0.004876]; // volt/deg/s
|
||||||
gyro_sigma_noise = [ 3; 3; 3];
|
gyro_sigma_noise = [0.003 ; 0.003 ; 0.003 ]; // volt^2
|
||||||
|
|
||||||
gyro_offset_deg = [0 0 0
|
gyro_adc_resolution = 2^10 * [1; 1; 1];
|
||||||
0 0 0
|
|
||||||
0 0 0 ];
|
gyro_rot_deg = [0 0 0
|
||||||
|
0 0 88
|
||||||
|
-3 93 0 ];
|
||||||
|
|
||||||
gyro_orientation = [] ;
|
accel_supply = [3.30 ; 3.30 ; 3.30 ]; // volt
|
||||||
|
accel_neutral_offset = [0.01 ; -0.01 ; 0.05 ]; // volt
|
||||||
gyro_align = [ 1 0 0
|
accel_gains = [0.3 ; 0.301 ; 0.299 ]; // volt/g
|
||||||
0.1 1 0
|
accel_sigma_noise = [0.008 ; 0.008 ; 0.008 ]; // volt^2
|
||||||
0 0 1 ];
|
|
||||||
|
|
||||||
|
accel_adc_resolution = 2^10 * [1; 1; 1];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DCM_GX = dcm_of_euler(rad_of_deg(gyro_rot_deg(:,1)));
|
||||||
|
DCM_GY = dcm_of_euler(rad_of_deg(gyro_rot_deg(:,2)));
|
||||||
|
DCM_GZ = dcm_of_euler(rad_of_deg(gyro_rot_deg(:,3)));
|
||||||
|
|
||||||
|
gyro_align = [ DCM_GX(1,:)
|
||||||
|
DCM_GY(1,:)
|
||||||
|
DCM_GZ(1,:) ];
|
||||||
|
|
||||||
accel = [];
|
accel = [];
|
||||||
mag = [];
|
mag = [];
|
||||||
gyro = [];
|
gyro = [];
|
||||||
for i=1:length(time),
|
for i=1:length(time),
|
||||||
gyro_noise = rand(3, 1, "normal") .* gyro_sigma_noise;
|
g_volt = 0.5 * gyro_supply + gyro_neutral_offset + ...
|
||||||
// gyro_noise = [ 0; 0; 0];
|
(gyro_align * deg_of_rad(rates(:, i))) .* gyro_gains + ...
|
||||||
g = gyro_neutral + (gyro_align * rates(:, i)) ./ gyro_gains + gyro_noise;
|
rand(3, 1, "normal") .* gyro_sigma_noise ;
|
||||||
g = round(g);
|
g_adc = round(g_volt ./ gyro_supply .* gyro_adc_resolution);
|
||||||
gyro = [gyro g];
|
gyro = [gyro g_adc];
|
||||||
|
|
||||||
|
DCM = dcm_of_euler(eulers(:,i));
|
||||||
|
|
||||||
|
a_volt = 0.5 * accel_supply + accel_neutral_offset + ...
|
||||||
|
(DCM * [0; 0; 1]) .* accel_gains + ...
|
||||||
|
rand(3, 1, "normal") .* accel_sigma_noise ;
|
||||||
|
a_adc = round(a_volt ./ accel_supply .* accel_adc_resolution);
|
||||||
|
accel = [accel a_adc];
|
||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -47,3 +47,22 @@ function [time, rates, eulers] = quadrotor_gen_roll_step(euler0, dt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function [time, rates, eulers] = quadrotor_gen_cste_rot(euler0, dt)
|
||||||
|
len_gen = 20.;
|
||||||
|
nb_samples = len_gen / dt;
|
||||||
|
omega_1 = rad_of_deg(150);
|
||||||
|
omega_2 = rad_of_deg(120);
|
||||||
|
|
||||||
|
eulers=[euler0];
|
||||||
|
for i=2:nb_samples
|
||||||
|
t = (i-1)*dt;
|
||||||
|
time = [time t];
|
||||||
|
euler = [ t * omega_1
|
||||||
|
0
|
||||||
|
0 ] + euler0;
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user