mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 18:06:39 +08:00
Merge branch 'master' of github.com:PX4/Firmware
This commit is contained in:
Binary file not shown.
@@ -33,6 +33,8 @@ then
|
|||||||
param set FW_T_SINK_MIN 4.0
|
param set FW_T_SINK_MIN 4.0
|
||||||
param set FW_Y_ROLLFF 1.1
|
param set FW_Y_ROLLFF 1.1
|
||||||
param set FW_L1_PERIOD 16
|
param set FW_L1_PERIOD 16
|
||||||
|
param set RC_SCALE_ROLL 1.0
|
||||||
|
param set RC_SCALE_PITCH 1.0
|
||||||
|
|
||||||
param set SYS_AUTOCONFIG 0
|
param set SYS_AUTOCONFIG 0
|
||||||
param save
|
param save
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ then
|
|||||||
param set FW_T_SINK_MIN 4.0
|
param set FW_T_SINK_MIN 4.0
|
||||||
param set FW_Y_ROLLFF 1.1
|
param set FW_Y_ROLLFF 1.1
|
||||||
param set FW_L1_PERIOD 16
|
param set FW_L1_PERIOD 16
|
||||||
|
param set RC_SCALE_ROLL 1.0
|
||||||
|
param set RC_SCALE_PITCH 1.0
|
||||||
|
|
||||||
param set SYS_AUTOCONFIG 0
|
param set SYS_AUTOCONFIG 0
|
||||||
param save
|
param save
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ then
|
|||||||
param set FW_T_SINK_MIN 4.0
|
param set FW_T_SINK_MIN 4.0
|
||||||
param set FW_Y_ROLLFF 1.1
|
param set FW_Y_ROLLFF 1.1
|
||||||
param set FW_L1_PERIOD 16
|
param set FW_L1_PERIOD 16
|
||||||
|
param set RC_SCALE_ROLL 1.0
|
||||||
|
param set RC_SCALE_PITCH 1.0
|
||||||
|
|
||||||
param set SYS_AUTOCONFIG 0
|
param set SYS_AUTOCONFIG 0
|
||||||
param save
|
param save
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ then
|
|||||||
param set FW_T_SINK_MIN 4.0
|
param set FW_T_SINK_MIN 4.0
|
||||||
param set FW_Y_ROLLFF 1.1
|
param set FW_Y_ROLLFF 1.1
|
||||||
param set FW_L1_PERIOD 17
|
param set FW_L1_PERIOD 17
|
||||||
|
param set RC_SCALE_ROLL 1.0
|
||||||
|
param set RC_SCALE_PITCH 1.0
|
||||||
|
|
||||||
param set SYS_AUTOCONFIG 0
|
param set SYS_AUTOCONFIG 0
|
||||||
param save
|
param save
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ private:
|
|||||||
|
|
||||||
bool _running;
|
bool _running;
|
||||||
int _led_interval;
|
int _led_interval;
|
||||||
|
bool _should_run;
|
||||||
int _counter;
|
int _counter;
|
||||||
|
|
||||||
void set_color(rgbled_color_t ledcolor);
|
void set_color(rgbled_color_t ledcolor);
|
||||||
@@ -136,6 +137,7 @@ RGBLED::RGBLED(int bus, int rgbled) :
|
|||||||
_brightness(1.0f),
|
_brightness(1.0f),
|
||||||
_running(false),
|
_running(false),
|
||||||
_led_interval(0),
|
_led_interval(0),
|
||||||
|
_should_run(false),
|
||||||
_counter(0)
|
_counter(0)
|
||||||
{
|
{
|
||||||
memset(&_work, 0, sizeof(_work));
|
memset(&_work, 0, sizeof(_work));
|
||||||
@@ -248,6 +250,11 @@ RGBLED::led_trampoline(void *arg)
|
|||||||
void
|
void
|
||||||
RGBLED::led()
|
RGBLED::led()
|
||||||
{
|
{
|
||||||
|
if (!_should_run) {
|
||||||
|
_running = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
case RGBLED_MODE_BLINK_SLOW:
|
case RGBLED_MODE_BLINK_SLOW:
|
||||||
case RGBLED_MODE_BLINK_NORMAL:
|
case RGBLED_MODE_BLINK_NORMAL:
|
||||||
@@ -409,10 +416,10 @@ RGBLED::set_mode(rgbled_mode_t mode)
|
|||||||
{
|
{
|
||||||
if (mode != _mode) {
|
if (mode != _mode) {
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
bool should_run = false;
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case RGBLED_MODE_OFF:
|
case RGBLED_MODE_OFF:
|
||||||
|
_should_run = false;
|
||||||
send_led_enable(false);
|
send_led_enable(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -423,7 +430,7 @@ RGBLED::set_mode(rgbled_mode_t mode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RGBLED_MODE_BLINK_SLOW:
|
case RGBLED_MODE_BLINK_SLOW:
|
||||||
should_run = true;
|
_should_run = true;
|
||||||
_counter = 0;
|
_counter = 0;
|
||||||
_led_interval = 2000;
|
_led_interval = 2000;
|
||||||
_brightness = 1.0f;
|
_brightness = 1.0f;
|
||||||
@@ -431,7 +438,7 @@ RGBLED::set_mode(rgbled_mode_t mode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RGBLED_MODE_BLINK_NORMAL:
|
case RGBLED_MODE_BLINK_NORMAL:
|
||||||
should_run = true;
|
_should_run = true;
|
||||||
_counter = 0;
|
_counter = 0;
|
||||||
_led_interval = 500;
|
_led_interval = 500;
|
||||||
_brightness = 1.0f;
|
_brightness = 1.0f;
|
||||||
@@ -439,7 +446,7 @@ RGBLED::set_mode(rgbled_mode_t mode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RGBLED_MODE_BLINK_FAST:
|
case RGBLED_MODE_BLINK_FAST:
|
||||||
should_run = true;
|
_should_run = true;
|
||||||
_counter = 0;
|
_counter = 0;
|
||||||
_led_interval = 100;
|
_led_interval = 100;
|
||||||
_brightness = 1.0f;
|
_brightness = 1.0f;
|
||||||
@@ -447,14 +454,14 @@ RGBLED::set_mode(rgbled_mode_t mode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RGBLED_MODE_BREATHE:
|
case RGBLED_MODE_BREATHE:
|
||||||
should_run = true;
|
_should_run = true;
|
||||||
_counter = 0;
|
_counter = 0;
|
||||||
_led_interval = 25;
|
_led_interval = 25;
|
||||||
send_led_enable(true);
|
send_led_enable(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RGBLED_MODE_PATTERN:
|
case RGBLED_MODE_PATTERN:
|
||||||
should_run = true;
|
_should_run = true;
|
||||||
_counter = 0;
|
_counter = 0;
|
||||||
_brightness = 1.0f;
|
_brightness = 1.0f;
|
||||||
send_led_enable(true);
|
send_led_enable(true);
|
||||||
@@ -466,16 +473,11 @@ RGBLED::set_mode(rgbled_mode_t mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if it should run now, start the workq */
|
/* if it should run now, start the workq */
|
||||||
if (should_run && !_running) {
|
if (_should_run && !_running) {
|
||||||
_running = true;
|
_running = true;
|
||||||
work_queue(LPWORK, &_work, (worker_t)&RGBLED::led_trampoline, this, 1);
|
work_queue(LPWORK, &_work, (worker_t)&RGBLED::led_trampoline, this, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if it should stop, then cancel the workq */
|
|
||||||
if (!should_run && _running) {
|
|
||||||
_running = false;
|
|
||||||
work_cancel(LPWORK, &_work);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,8 +130,12 @@ void ECL_L1_Pos_Controller::navigate_waypoints(const math::Vector2f &vector_A, c
|
|||||||
float alongTrackDist = vector_A_to_airplane * vector_AB;
|
float alongTrackDist = vector_A_to_airplane * vector_AB;
|
||||||
|
|
||||||
/* estimate airplane position WRT to B */
|
/* estimate airplane position WRT to B */
|
||||||
math::Vector2f vector_B_to_airplane_unit = get_local_planar_vector(vector_B, vector_curr_position).normalized();
|
math::Vector2f vector_B_to_P_unit = get_local_planar_vector(vector_B, vector_curr_position).normalized();
|
||||||
float bearing_wp_b = atan2f(-vector_B_to_airplane_unit.getY() , -vector_B_to_airplane_unit.getX());
|
|
||||||
|
/* calculate angle of airplane position vector relative to line) */
|
||||||
|
|
||||||
|
// XXX this could probably also be based solely on the dot product
|
||||||
|
float AB_to_BP_bearing = atan2f(vector_B_to_P_unit % vector_AB, vector_B_to_P_unit * vector_AB);
|
||||||
|
|
||||||
/* extension from [2], fly directly to A */
|
/* extension from [2], fly directly to A */
|
||||||
if (distance_A_to_airplane > _L1_distance && alongTrackDist / math::max(distance_A_to_airplane , 1.0f) < -0.7071f) {
|
if (distance_A_to_airplane > _L1_distance && alongTrackDist / math::max(distance_A_to_airplane , 1.0f) < -0.7071f) {
|
||||||
@@ -148,21 +152,30 @@ void ECL_L1_Pos_Controller::navigate_waypoints(const math::Vector2f &vector_A, c
|
|||||||
/* bearing from current position to L1 point */
|
/* bearing from current position to L1 point */
|
||||||
_nav_bearing = atan2f(-vector_A_to_airplane_unit.getY() , -vector_A_to_airplane_unit.getX());
|
_nav_bearing = atan2f(-vector_A_to_airplane_unit.getY() , -vector_A_to_airplane_unit.getX());
|
||||||
|
|
||||||
// XXX this can be useful as last-resort guard, but is currently not needed
|
/*
|
||||||
#if 0
|
* If the AB vector and the vector from B to airplane point in the same
|
||||||
} else if (absf(bearing_wp_b) > math::radians(80.0f)) {
|
* direction, we have missed the waypoint. At +- 90 degrees we are just passing it.
|
||||||
/* extension, fly back to waypoint */
|
*/
|
||||||
|
} else if (fabsf(AB_to_BP_bearing) < math::radians(100.0f)) {
|
||||||
|
/*
|
||||||
|
* Extension, fly back to waypoint.
|
||||||
|
*
|
||||||
|
* This corner case is possible if the system was following
|
||||||
|
* the AB line from waypoint A to waypoint B, then is
|
||||||
|
* switched to manual mode (or otherwise misses the waypoint)
|
||||||
|
* and behind the waypoint continues to follow the AB line.
|
||||||
|
*/
|
||||||
|
|
||||||
/* calculate eta to fly to waypoint B */
|
/* calculate eta to fly to waypoint B */
|
||||||
|
|
||||||
/* velocity across / orthogonal to line */
|
/* velocity across / orthogonal to line */
|
||||||
xtrack_vel = ground_speed_vector % (-vector_B_to_airplane_unit);
|
xtrack_vel = ground_speed_vector % (-vector_B_to_P_unit);
|
||||||
/* velocity along line */
|
/* velocity along line */
|
||||||
ltrack_vel = ground_speed_vector * (-vector_B_to_airplane_unit);
|
ltrack_vel = ground_speed_vector * (-vector_B_to_P_unit);
|
||||||
eta = atan2f(xtrack_vel, ltrack_vel);
|
eta = atan2f(xtrack_vel, ltrack_vel);
|
||||||
/* bearing from current position to L1 point */
|
/* bearing from current position to L1 point */
|
||||||
_nav_bearing = bearing_wp_b;
|
_nav_bearing = atan2f(-vector_B_to_P_unit.getY() , -vector_B_to_P_unit.getX());
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* calculate eta to fly along the line between A and B */
|
/* calculate eta to fly along the line between A and B */
|
||||||
|
|||||||
Reference in New Issue
Block a user