Browse Source

Copter: renaming functions after moving xy control

master
Randy Mackay 11 years ago committed by Andrew Tridgell
parent
commit
0a2adbac1b
  1. 2
      ArduCopter/ArduCopter.pde
  2. 7
      ArduCopter/Log.pde
  3. 16
      ArduCopter/commands_logic.pde
  4. 20
      ArduCopter/events.pde
  5. 4
      ArduCopter/navigation.pde

2
ArduCopter/ArduCopter.pde

@ -1773,7 +1773,7 @@ void update_roll_pitch_mode(void) @@ -1773,7 +1773,7 @@ void update_roll_pitch_mode(void)
update_simple_mode();
// update loiter target from user controls
wp_nav.move_loiter_target(g.rc_1.control_in, g.rc_2.control_in, 0.01f);
wp_nav.set_pilot_desired_acceleration(g.rc_1.control_in, g.rc_2.control_in);
// copy latest output from nav controller to stabilize controller
control_roll = wp_nav.get_roll();

7
ArduCopter/Log.pde

@ -280,9 +280,9 @@ struct PACKED log_Nav_Tuning { @@ -280,9 +280,9 @@ struct PACKED log_Nav_Tuning {
// Write an Nav Tuning packet
static void Log_Write_Nav_Tuning()
{
const Vector3f &pos_target = pos_controller.get_pos_target();
const Vector3f &vel_target = pos_controller.get_vel_target();
const Vector3f &accel_target = pos_controller.get_accel_target();
const Vector3f &pos_target = pos_control.get_pos_target();
const Vector3f &vel_target = pos_control.get_vel_target();
const Vector3f &accel_target = pos_control.get_accel_target();
const Vector3f &position = inertial_nav.get_position();
const Vector3f &velocity = inertial_nav.get_velocity();
@ -301,6 +301,7 @@ static void Log_Write_Nav_Tuning() @@ -301,6 +301,7 @@ static void Log_Write_Nav_Tuning()
desired_accel_y : accel_target.y
};
DataFlash.WriteBlock(&pkt, sizeof(pkt));
cliSerial->printf_P(PSTR("\nX:%4.2f Y:%4.2f\n"),(float)pos_target.x,(float)pos_target.y);
}
struct PACKED log_Control_Tuning {

16
ArduCopter/commands_logic.pde

@ -315,10 +315,10 @@ static void do_land(const struct Location *cmd) @@ -315,10 +315,10 @@ static void do_land(const struct Location *cmd)
// calculate and set desired location above landing target
Vector3f pos = pv_location_to_vector(*cmd);
pos.z = min(current_loc.alt, RTL_ALT_MAX);
wp_nav.set_destination(pos);
wp_nav.set_wp_destination(pos);
// initialise original_wp_bearing which is used to check if we have missed the waypoint
wp_bearing = wp_nav.get_bearing_to_destination();
wp_bearing = wp_nav.get_wp_bearing_to_destination();
original_wp_bearing = wp_bearing;
}else{
// set landing state
@ -368,7 +368,7 @@ static void do_loiter_unlimited() @@ -368,7 +368,7 @@ static void do_loiter_unlimited()
// use current location if not provided
if(command_nav_queue.lat == 0 && command_nav_queue.lng == 0) {
wp_nav.get_wp_stopping_point(target_pos);
wp_nav.get_wp_stopping_point_xy(target_pos);
}else{
// default to use position provided
target_pos = pv_location_to_vector(command_nav_queue);
@ -436,7 +436,7 @@ static void do_loiter_time() @@ -436,7 +436,7 @@ static void do_loiter_time()
// use current location if not provided
if(command_nav_queue.lat == 0 && command_nav_queue.lng == 0) {
wp_nav.get_wp_stopping_point(target_pos);
wp_nav.get_wp_stopping_point_xy(target_pos);
}else{
// default to use position provided
target_pos = pv_location_to_vector(command_nav_queue);
@ -478,7 +478,7 @@ static bool verify_land() @@ -478,7 +478,7 @@ static bool verify_land()
// check if we've reached the location
if (wp_nav.reached_wp_destination()) {
// get destination so we can use it for loiter target
Vector3f dest = wp_nav.get_destination();
Vector3f dest = wp_nav.get_wp_destination();
// switch into loiter nav mode
set_nav_mode(NAV_LOITER);
@ -591,7 +591,7 @@ static bool verify_RTL() @@ -591,7 +591,7 @@ static bool verify_RTL()
// use projection of safe stopping point based on current location and velocity
Vector3f origin, dest;
pos_control.get_stopping_point(origin);
wp_nav.get_wp_stopping_point_xy(origin);
dest.x = origin.x;
dest.y = origin.y;
dest.z = get_RTL_alt();
@ -607,7 +607,7 @@ static bool verify_RTL() @@ -607,7 +607,7 @@ static bool verify_RTL()
wp_nav.set_wp_destination(Vector3f(0,0,get_RTL_alt()));
// initialise original_wp_bearing which is used to point the nose home
wp_bearing = wp_nav.get_bearing_to_destination();
wp_bearing = wp_nav.get_wp_bearing_to_destination();
original_wp_bearing = wp_bearing;
// advance to next rtl state
@ -624,7 +624,7 @@ static bool verify_RTL() @@ -624,7 +624,7 @@ static bool verify_RTL()
wp_nav.set_wp_destination(Vector3f(0,0,get_RTL_alt()));
// initialise original_wp_bearing which is used to point the nose home
wp_bearing = wp_nav.get_bearing_to_destination();
wp_bearing = wp_nav.get_wp_bearing_to_destination();
original_wp_bearing = wp_bearing;
// point nose towards home (maybe)

20
ArduCopter/events.pde

@ -22,7 +22,7 @@ static void failsafe_radio_on_event() @@ -22,7 +22,7 @@ static void failsafe_radio_on_event()
}else if(g.failsafe_throttle == FS_THR_ENABLED_ALWAYS_LAND) {
// if failsafe_throttle is 3 (i.e. FS_THR_ENABLED_ALWAYS_LAND) land immediately
set_mode(LAND);
}else if(home_distance > wp_nav.get_waypoint_radius()) {
}else if(home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -34,7 +34,7 @@ static void failsafe_radio_on_event() @@ -34,7 +34,7 @@ static void failsafe_radio_on_event()
case AUTO:
// failsafe_throttle is 1 do RTL, 2 means continue with the mission
if (g.failsafe_throttle == FS_THR_ENABLED_ALWAYS_RTL) {
if(home_distance > wp_nav.get_waypoint_radius()) {
if(home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -56,7 +56,7 @@ static void failsafe_radio_on_event() @@ -56,7 +56,7 @@ static void failsafe_radio_on_event()
}else if(g.failsafe_throttle == FS_THR_ENABLED_ALWAYS_LAND) {
// if failsafe_throttle is 3 (i.e. FS_THR_ENABLED_ALWAYS_LAND) land immediately
set_mode(LAND);
}else if(home_distance > wp_nav.get_waypoint_radius()) {
}else if(home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -74,7 +74,7 @@ static void failsafe_radio_on_event() @@ -74,7 +74,7 @@ static void failsafe_radio_on_event()
if(g.failsafe_throttle == FS_THR_ENABLED_ALWAYS_LAND) {
// if failsafe_throttle is 3 (i.e. FS_THR_ENABLED_ALWAYS_LAND) land immediately
set_mode(LAND);
}else if(home_distance > wp_nav.get_waypoint_radius()) {
}else if(home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)){
set_mode(LAND);
}
@ -118,7 +118,7 @@ static void failsafe_battery_event(void) @@ -118,7 +118,7 @@ static void failsafe_battery_event(void)
init_disarm_motors();
}else{
// set mode to RTL or LAND
if (g.failsafe_battery_enabled == FS_BATT_RTL && home_distance > wp_nav.get_waypoint_radius()) {
if (g.failsafe_battery_enabled == FS_BATT_RTL && home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -129,7 +129,7 @@ static void failsafe_battery_event(void) @@ -129,7 +129,7 @@ static void failsafe_battery_event(void)
break;
case AUTO:
// set mode to RTL or LAND
if (home_distance > wp_nav.get_waypoint_radius()) {
if (home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -146,7 +146,7 @@ static void failsafe_battery_event(void) @@ -146,7 +146,7 @@ static void failsafe_battery_event(void)
}
default:
// set mode to RTL or LAND
if (g.failsafe_battery_enabled == FS_BATT_RTL && home_distance > wp_nav.get_waypoint_radius()) {
if (g.failsafe_battery_enabled == FS_BATT_RTL && home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -264,7 +264,7 @@ static void failsafe_gcs_check() @@ -264,7 +264,7 @@ static void failsafe_gcs_check()
// if throttle is zero disarm motors
if (g.rc_3.control_in == 0) {
init_disarm_motors();
}else if(home_distance > wp_nav.get_waypoint_radius()) {
}else if(home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -276,7 +276,7 @@ static void failsafe_gcs_check() @@ -276,7 +276,7 @@ static void failsafe_gcs_check()
case AUTO:
// if g.failsafe_gcs is 1 do RTL, 2 means continue with the mission
if (g.failsafe_gcs == FS_GCS_ENABLED_ALWAYS_RTL) {
if (home_distance > wp_nav.get_waypoint_radius()) {
if (home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}
@ -288,7 +288,7 @@ static void failsafe_gcs_check() @@ -288,7 +288,7 @@ static void failsafe_gcs_check()
// if failsafe_throttle is 2 (i.e. FS_THR_ENABLED_CONTINUE_MISSION) no need to do anything
break;
default:
if(home_distance > wp_nav.get_waypoint_radius()) {
if(home_distance > wp_nav.get_wp_radius()) {
if (!set_mode(RTL)) {
set_mode(LAND);
}

4
ArduCopter/navigation.pde

@ -92,7 +92,7 @@ static bool set_nav_mode(uint8_t new_nav_mode) @@ -92,7 +92,7 @@ static bool set_nav_mode(uint8_t new_nav_mode)
case NAV_CIRCLE:
// set center of circle to current position
pos_control.get_stopping_point(stopping_point);
wp_nav.get_loiter_stopping_point_xy(stopping_point);
circle_set_center(stopping_point,ahrs.yaw);
nav_initialised = true;
break;
@ -217,7 +217,7 @@ circle_set_center(const Vector3f current_position, float heading_in_radians) @@ -217,7 +217,7 @@ circle_set_center(const Vector3f current_position, float heading_in_radians)
circle_angular_velocity_max = constrain_float(ToRad(g.circle_rate),-circle_angular_velocity_max,circle_angular_velocity_max);
// angular_velocity in radians per second
circle_angular_acceleration = wp_nav.get_waypoint_acceleration()/((float)g.circle_radius * 100);
circle_angular_acceleration = wp_nav.get_wp_acceleration()/((float)g.circle_radius * 100);
if (g.circle_rate < 0.0f) {
circle_angular_acceleration = -circle_angular_acceleration;
}

Loading…
Cancel
Save