mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:58:48 +08:00
introduced radio control scripts in sim
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
<dl_setting var="booz_stabilization_pgain.z" min="-4000" step="1" max="-1" module="stabilization/booz_stabilization_attitude" shortname="pgain psi"/>
|
||||
<dl_setting var="booz_stabilization_dgain.z" min="-4000" step="1" max="-1" module="stabilization/booz_stabilization_attitude" shortname="dgain r"/>
|
||||
<dl_setting var="booz_stabilization_igain.z" min="-300" step="1" max="0" module="stabilization/booz_stabilization_attitude" shortname="igain psi"/>
|
||||
<dl_setting var="booz_stabilization_ddgain.z" min="0" step="1" max="500" module="stabilization/booz_stabilization_attitude" shortname="ddgain r"/>
|
||||
<dl_setting var="booz_stabilization_ddgain.z" min="0" step="1" max="1000" module="stabilization/booz_stabilization_attitude" shortname="ddgain r"/>
|
||||
</dl_settings>
|
||||
|
||||
<dl_settings NAME="Vert Loop">
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>-1</x>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
@@ -255,7 +255,7 @@
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>1</x>
|
||||
<x>-1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
@@ -276,7 +276,7 @@
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>-1</x>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
@@ -295,7 +295,7 @@
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>1</x>
|
||||
<x>-1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
@@ -317,7 +317,7 @@
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<y>1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
@@ -336,7 +336,7 @@
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>1</y>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
@@ -357,7 +357,7 @@
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<y>1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
@@ -376,7 +376,7 @@
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>1</y>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define RC_UPDATE_FREQ 40.
|
||||
#define ROLL_COEF (-BOOZ_STABILIZATION_ATTITUDE_SP_MAX_PHI / MAX_PPRZ)
|
||||
#define PITCH_COEF ( BOOZ_STABILIZATION_ATTITUDE_SP_MAX_THETA / MAX_PPRZ)
|
||||
#define YAW_COEF (- BOOZ_STABILIZATION_ATTITUDE_SP_MAX_R / MAX_PPRZ / RC_UPDATE_FREQ)
|
||||
#define YAW_COEF (-BOOZ_STABILIZATION_ATTITUDE_SP_MAX_R / MAX_PPRZ / RC_UPDATE_FREQ)
|
||||
|
||||
#define YAW_DEADBAND_EXCEEDED() \
|
||||
(radio_control.values[RADIO_CONTROL_YAW] > BOOZ_STABILIZATION_ATTITUDE_DEADBAND_R || \
|
||||
@@ -54,8 +54,8 @@
|
||||
} \
|
||||
\
|
||||
struct FloatRMat sp_rmat; \
|
||||
/* FLOAT_RMAT_OF_EULERS_312(sp_rmat, _sp); */ \
|
||||
FLOAT_RMAT_OF_EULERS_321(sp_rmat, _sp); \
|
||||
FLOAT_RMAT_OF_EULERS_312(sp_rmat, _sp); \
|
||||
/* FLOAT_RMAT_OF_EULERS_321(sp_rmat, _sp);*/ \
|
||||
FLOAT_QUAT_OF_RMAT(booz_stab_att_sp_quat, sp_rmat); \
|
||||
/*FLOAT_EULERS_OF_QUAT(sp_euler321, sp_quat);*/ \
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ void nps_autopilot_run_step(double time __attribute__ ((unused))) {
|
||||
booz2_main_periodic();
|
||||
|
||||
/* 25 */
|
||||
if (time < 5) {
|
||||
double hover = 0.25;
|
||||
//double hover = 0.2493;
|
||||
if (time < 8) {
|
||||
// double hover = 0.25;
|
||||
double hover = 0.2493;
|
||||
// double hover = 0.23;
|
||||
// double hover = 0.;
|
||||
// if (time > 20) hover = 0.25;
|
||||
@@ -66,7 +66,6 @@ void nps_autopilot_run_step(double time __attribute__ ((unused))) {
|
||||
double pitch = 0.000;
|
||||
double roll = 0.0000;
|
||||
|
||||
|
||||
autopilot.commands[SERVO_FRONT] = hover + yaw + pitch;
|
||||
autopilot.commands[SERVO_BACK] = hover + yaw - pitch;
|
||||
autopilot.commands[SERVO_RIGHT] = hover - yaw - roll ;
|
||||
|
||||
@@ -8,36 +8,65 @@ void nps_radio_control_init(void) {
|
||||
nps_radio_control.next_update = 0.;
|
||||
}
|
||||
|
||||
static void radio_control_script_step_roll(double time);
|
||||
static void radio_control_script_ff(double time);
|
||||
|
||||
#define MODE_SWITCH_MANUAL -1.0
|
||||
#define MODE_SWITCH_AUTO1 0.0
|
||||
#define MODE_SWITCH_AUTO2 1.0
|
||||
|
||||
void nps_radio_control_run_script(double time) {
|
||||
#define RADIO_CONTROL_TAKEOFF_TIME 8
|
||||
|
||||
void radio_control_script_takeoff(double time) {
|
||||
|
||||
nps_radio_control.roll = 0.;
|
||||
nps_radio_control.pitch = 0.;
|
||||
nps_radio_control.yaw = 0.;
|
||||
nps_radio_control.throttle = 0.;
|
||||
nps_radio_control.mode = MODE_SWITCH_MANUAL;
|
||||
/* starts motors */
|
||||
if (time < 1.) {
|
||||
if (time < 1.)
|
||||
nps_radio_control.yaw = 1.;
|
||||
nps_radio_control.throttle = 0.;
|
||||
nps_radio_control.mode = MODE_SWITCH_MANUAL;
|
||||
}
|
||||
else if (time < 3.5) {
|
||||
else
|
||||
nps_radio_control.yaw = 0.;
|
||||
nps_radio_control.throttle = 0.;
|
||||
nps_radio_control.mode = MODE_SWITCH_MANUAL;
|
||||
|
||||
}
|
||||
|
||||
void radio_control_script_step_roll(double time) {
|
||||
nps_radio_control.throttle = 0.99;
|
||||
nps_radio_control.mode = MODE_SWITCH_AUTO2;
|
||||
|
||||
if (((int32_t)rint((time*0.5)))%2) {
|
||||
nps_radio_control.roll = 0.2;
|
||||
nps_radio_control.yaw = 0.5;
|
||||
}
|
||||
else
|
||||
nps_radio_control.roll = RadOfDeg(10);
|
||||
}
|
||||
|
||||
void radio_control_script_ff(double time __attribute__ ((unused))) {
|
||||
nps_radio_control.throttle = 0.99;
|
||||
nps_radio_control.mode = MODE_SWITCH_AUTO2;
|
||||
if (time < RADIO_CONTROL_TAKEOFF_TIME+3)
|
||||
nps_radio_control.pitch = -1.;
|
||||
else if (time < RADIO_CONTROL_TAKEOFF_TIME+6) {
|
||||
// nps_radio_control.roll = 0.5;
|
||||
nps_radio_control.pitch = -1.;
|
||||
}
|
||||
else {
|
||||
nps_radio_control.yaw = 0.;
|
||||
nps_radio_control.throttle = 0.99;
|
||||
nps_radio_control.mode = MODE_SWITCH_AUTO2;
|
||||
// nps_radio_control.throttle = 0.265;
|
||||
// nps_radio_control.mode = MODE_SWITCH_MANUAL;
|
||||
nps_radio_control.pitch = 0.;
|
||||
nps_radio_control.roll = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
if (((int32_t)rint((time*0.5)))%2)
|
||||
nps_radio_control.roll = 0.15;
|
||||
else
|
||||
nps_radio_control.roll = -0.15;
|
||||
|
||||
|
||||
void nps_radio_control_run_script(double time) {
|
||||
if (time < RADIO_CONTROL_TAKEOFF_TIME)
|
||||
radio_control_script_takeoff(time);
|
||||
else {
|
||||
// radio_control_script_step_roll(time);
|
||||
radio_control_script_ff(time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user