From 27a2c7946def2e29ab67a88b4054a8716ad1c638 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Tue, 15 Feb 2011 16:44:07 +0100 Subject: [PATCH] cleanup whitespaces --- conf/modules/digital_cam.xml | 13 +- sw/airborne/modules/digital_cam/dc.c | 77 +++---- sw/airborne/modules/digital_cam/dc.h | 114 +++++------ .../subsystems/navigation/poly_survey_adv.c | 190 +++++++++--------- 4 files changed, 197 insertions(+), 197 deletions(-) diff --git a/conf/modules/digital_cam.xml b/conf/modules/digital_cam.xml index e190c57f90c..627061410c6 100644 --- a/conf/modules/digital_cam.xml +++ b/conf/modules/digital_cam.xml @@ -1,8 +1,8 @@ - @@ -33,10 +33,9 @@ - + - diff --git a/sw/airborne/modules/digital_cam/dc.c b/sw/airborne/modules/digital_cam/dc.c index d010c133bb8..a96fe9fff9d 100644 --- a/sw/airborne/modules/digital_cam/dc.c +++ b/sw/airborne/modules/digital_cam/dc.c @@ -58,17 +58,17 @@ uint16_t dc_buffer = 0; #include "estimator.h" #include "latlong.h" - void dc_send_shot_position(void) - { - int16_t phi = DegOfRad(estimator_phi*10.0f); - int16_t theta = DegOfRad(estimator_theta*10.0f); - float gps_z = ((float)gps_alt) / 100.0f; - int16_t photo_nr = -1; +void dc_send_shot_position(void) +{ + int16_t phi = DegOfRad(estimator_phi*10.0f); + int16_t theta = DegOfRad(estimator_theta*10.0f); + float gps_z = ((float)gps_alt) / 100.0f; + int16_t photo_nr = -1; - latlong_of_utm(gps_utm_east/100, gps_utm_north/100, gps_utm_zone); + latlong_of_utm(gps_utm_east/100, gps_utm_north/100, gps_utm_zone); -// float gps_lat_send = DegOfRad(latlong_lat); -// float gps_lon_send = DegOfRad(latlong_lon); + // float gps_lat_send = DegOfRad(latlong_lat); + // float gps_lon_send = DegOfRad(latlong_lon); if (dc_buffer < DC_IMAGE_BUFFER) { dc_buffer++; @@ -77,38 +77,38 @@ uint16_t dc_buffer = 0; } - DOWNLINK_SEND_DC_SHOT(DefaultChannel, - &photo_nr, - &gps_utm_east, - &gps_utm_north, - &gps_z, - &gps_utm_zone, - &phi, - &theta, - &gps_course, - &gps_gspeed, - &gps_itow); - } -#endif -uint8_t dc_info(void) { + DOWNLINK_SEND_DC_SHOT(DefaultChannel, + &photo_nr, + &gps_utm_east, + &gps_utm_north, + &gps_z, + &gps_utm_zone, + &phi, + &theta, + &gps_course, + &gps_gspeed, + &gps_itow); +} +#endif /* SENSOR_SYNC_SEND */ +uint8_t dc_info(void) { #ifdef DOWNLINK_SEND_DC_INFO float course = DegOfRad(estimator_psi); DOWNLINK_SEND_DC_INFO(DefaultChannel, - &dc_autoshoot, - &estimator_x, - &estimator_y, - &course, - &dc_buffer, - &dc_gps_dist, - &dc_gps_next_dist, - &dc_gps_x, - &dc_gps_y, - &dc_circle_start_angle, - &dc_circle_interval, - &dc_circle_last_block, - &dc_gps_count, - &dc_autoshoot_quartersec_period); + &dc_autoshoot, + &estimator_x, + &estimator_y, + &course, + &dc_buffer, + &dc_gps_dist, + &dc_gps_next_dist, + &dc_gps_x, + &dc_gps_y, + &dc_circle_start_angle, + &dc_circle_interval, + &dc_circle_last_block, + &dc_gps_count, + &dc_autoshoot_quartersec_period); #endif return 0; } @@ -133,6 +133,7 @@ uint8_t dc_circle(float interval, float start) { dc_info(); return 0; } + /* shoot on survey */ uint8_t dc_survey(float interval, float x, float y) { dc_autoshoot = DC_AUTOSHOOT_SURVEY; @@ -153,6 +154,7 @@ uint8_t dc_survey(float interval, float x, float y) { dc_info(); return 0; } + uint8_t dc_stop(void) { dc_autoshoot = DC_AUTOSHOOT_STOP; dc_info(); @@ -192,4 +194,3 @@ static inline void dc_shoot_on_gps( void ) { } } */ - diff --git a/sw/airborne/modules/digital_cam/dc.h b/sw/airborne/modules/digital_cam/dc.h index 74b90c3c138..1746a25b3e1 100644 --- a/sw/airborne/modules/digital_cam/dc.h +++ b/sw/airborne/modules/digital_cam/dc.h @@ -24,8 +24,8 @@ /** \file dc.h * \brief Standard Digital Camera Control Interface * - * -Standard IO - * -I2C Control + * -Standard IO + * -I2C Control * * Usage: (from the flight plan, the settings or any airborne code): * - dc_send_command( ) @@ -76,26 +76,26 @@ extern uint8_t dc_cam_tracing; /* Generic Set of Digital Camera Commands */ typedef enum { - DC_GET_STATUS = 0, + DC_GET_STATUS = 0, - DC_HOLD = 13, - DC_SHOOT = 32, + DC_HOLD = 13, + DC_SHOOT = 32, - DC_WIDER = 'w', - DC_TALLER = 't', + DC_WIDER = 'w', + DC_TALLER = 't', - DC_UP = 'u', - DC_DOWN = 'd', - DC_CENTER = 'c', - DC_LEFT = 'l', - DC_RIGHT = 'r', + DC_UP = 'u', + DC_DOWN = 'd', + DC_CENTER = 'c', + DC_LEFT = 'l', + DC_RIGHT = 'r', - DC_MENU = 'm', - DC_HOME = 'h', - DC_PLAY = 'p', + DC_MENU = 'm', + DC_HOME = 'h', + DC_PLAY = 'p', - DC_ON = 'O', - DC_OFF = 'o', + DC_ON = 'O', + DC_OFF = 'o', } dc_command_type; @@ -104,12 +104,12 @@ static inline void dc_send_command(uint8_t cmd); /* Auotmatic Digital Camera Photo Triggering */ typedef enum { - DC_AUTOSHOOT_STOP = 0, - DC_AUTOSHOOT_PERIODIC = 1, - DC_AUTOSHOOT_DISTANCE = 2, - DC_AUTOSHOOT_EXT_TRIG = 3, - DC_AUTOSHOOT_SURVEY = 4, - DC_AUTOSHOOT_CIRCLE = 5 + DC_AUTOSHOOT_STOP = 0, + DC_AUTOSHOOT_PERIODIC = 1, + DC_AUTOSHOOT_DISTANCE = 2, + DC_AUTOSHOOT_EXT_TRIG = 3, + DC_AUTOSHOOT_SURVEY = 4, + DC_AUTOSHOOT_CIRCLE = 5 } dc_autoshoot_type; extern dc_autoshoot_type dc_autoshoot; @@ -198,7 +198,7 @@ static inline void dc_init(void) #endif } -/* shoot on grid +/* shoot on grid static inline void dc_shot_on_utm_north_close_to_100m_grid( void ) { uint32_t dist_to_100m_grid = (gps_utm_north / 100) % 100; @@ -221,10 +221,10 @@ static float dim_mod(float a, float b, float m) { static inline void dc_periodic_4Hz( void ) { static uint8_t dc_shutter_timer = 0; - + switch (dc_autoshoot) { - case DC_AUTOSHOOT_PERIODIC: + case DC_AUTOSHOOT_PERIODIC: if (dc_shutter_timer) { dc_shutter_timer--; } else { @@ -244,43 +244,43 @@ static uint8_t dc_shutter_timer = 0; break; case DC_AUTOSHOOT_CIRCLE: { - float course = DegOfRad(estimator_psi) - dc_circle_start_angle; - if (course < 0.) - course += 360.; - float current_block = floorf(course/dc_circle_interval); - - if (dc_probing) { - if (current_block == dc_circle_last_block) { - dc_probing = FALSE; - } - } - - if (dim_mod(current_block, dc_circle_last_block, dc_circle_max_blocks) == 1) { - dc_gps_count++; - dc_circle_last_block = current_block; - dc_send_command(DC_SHOOT); - } + float course = DegOfRad(estimator_psi) - dc_circle_start_angle; + if (course < 0.) + course += 360.; + float current_block = floorf(course/dc_circle_interval); + + if (dc_probing) { + if (current_block == dc_circle_last_block) { + dc_probing = FALSE; + } + } + + if (dim_mod(current_block, dc_circle_last_block, dc_circle_max_blocks) == 1) { + dc_gps_count++; + dc_circle_last_block = current_block; + dc_send_command(DC_SHOOT); + } } break; case DC_AUTOSHOOT_SURVEY : { - float dist_x = dc_gps_x - estimator_x; - float dist_y = dc_gps_y - estimator_y; - - if (dc_probing) { - if (dist_x*dist_x + dist_y*dist_y < dc_gps_dist*dc_gps_dist) { - dc_probing = FALSE; - } - } - - if (dist_x*dist_x + dist_y*dist_y >= dc_gps_next_dist*dc_gps_next_dist) { - dc_gps_next_dist += dc_gps_dist; - dc_gps_count++; - dc_send_command(DC_SHOOT); - } + float dist_x = dc_gps_x - estimator_x; + float dist_y = dc_gps_y - estimator_y; + + if (dc_probing) { + if (dist_x*dist_x + dist_y*dist_y < dc_gps_dist*dc_gps_dist) { + dc_probing = FALSE; + } + } + + if (dist_x*dist_x + dist_y*dist_y >= dc_gps_next_dist*dc_gps_next_dist) { + dc_gps_next_dist += dc_gps_dist; + dc_gps_count++; + dc_send_command(DC_SHOOT); + } } break; - + default : dc_autoshoot = DC_AUTOSHOOT_STOP; } diff --git a/sw/airborne/subsystems/navigation/poly_survey_adv.c b/sw/airborne/subsystems/navigation/poly_survey_adv.c index b798c2cc808..3f5979304de 100644 --- a/sw/airborne/subsystems/navigation/poly_survey_adv.c +++ b/sw/airborne/subsystems/navigation/poly_survey_adv.c @@ -109,41 +109,41 @@ static bool_t get_two_intersects(point2d *x, point2d *y, point2d a, point2d b) point2d tmp; for (i=0;i fabs(dir_vec.y)) { - if ((y->x - x->x) / dir_vec.x < 0.0){ - tmp = *x; - *x = *y; - *y = tmp; - } + if ((y->x - x->x) / dir_vec.x < 0.0){ + tmp = *x; + *x = *y; + *y = tmp; + } } else - if ((y->y - x->y) / dir_vec.y < 0.0) { - tmp = *x; - *x = *y; - *y = tmp; - } + if ((y->y - x->y) / dir_vec.y < 0.0) { + tmp = *x; + *x = *y; + *y = tmp; + } return TRUE; } @@ -180,32 +180,32 @@ bool_t init_poly_survey_adv(uint8_t first_wp, uint8_t size, float angle, float s if (return_angle > 359) return_angle -= 360; if (angle <= 45.0 || angle >= 315.0) { - //north - dir_vec.y = 1.0; - dir_vec.x = 1.0*tanf(angle_rad); - sweep.x = 1.0; - sweep.y = - dir_vec.x / dir_vec.y; + //north + dir_vec.y = 1.0; + dir_vec.x = 1.0*tanf(angle_rad); + sweep.x = 1.0; + sweep.y = - dir_vec.x / dir_vec.y; } else if (angle <= 135.0) { - //east - dir_vec.x = 1.0; - dir_vec.y = 1.0/tanf(angle_rad); - sweep.y = - 1.0; - sweep.x = dir_vec.y / dir_vec.x; + //east + dir_vec.x = 1.0; + dir_vec.y = 1.0/tanf(angle_rad); + sweep.y = - 1.0; + sweep.x = dir_vec.y / dir_vec.x; } else if (angle <= 225.0) { - //south - dir_vec.y = -1.0; - dir_vec.x = -1.0*tanf(angle_rad); - sweep.x = -1.0; - sweep.y = dir_vec.x / dir_vec.y; + //south + dir_vec.y = -1.0; + dir_vec.x = -1.0*tanf(angle_rad); + sweep.x = -1.0; + sweep.y = dir_vec.x / dir_vec.y; } else { - //west - dir_vec.x = -1.0; - dir_vec.y = -1.0/tanf(angle_rad); - sweep.y = 1.0; - sweep.x = - dir_vec.y / dir_vec.x; + //west + dir_vec.x = -1.0; + dir_vec.y = -1.0/tanf(angle_rad); + sweep.y = 1.0; + sweep.x = - dir_vec.y / dir_vec.x; } //normalize @@ -226,18 +226,18 @@ bool_t init_poly_survey_adv(uint8_t first_wp, uint8_t size, float angle, float s //cacluate the leftmost point if one sees the dir vec as going "up" and the sweep vec as going right if (div < 0.0) { - for(i=1;i 0.0) { - small.x = waypoints[poly_first+i].x; - small.y = waypoints[poly_first+i].y; - } + for(i=1;i 0.0) { + small.x = waypoints[poly_first+i].x; + small.y = waypoints[poly_first+i].y; + } } else - for(i=1;i 0.0) { - small.x = waypoints[poly_first+i].x; - small.y = waypoints[poly_first+i].y; - } + for(i=1;i 0.0) { + small.x = waypoints[poly_first+i].x; + small.y = waypoints[poly_first+i].y; + } //calculate the line the defines the first flyover seg_start.x = small.x + 0.5*sweep_vec.x; @@ -245,8 +245,8 @@ bool_t init_poly_survey_adv(uint8_t first_wp, uint8_t size, float angle, float s VEC_CALC(seg_end, seg_start, dir_vec, +); if (!get_two_intersects(&seg_start, &seg_end, seg_start, seg_end)) { - psa_stage = ERR; - return FALSE; + psa_stage = ERR; + return FALSE; } //center of the entry circle @@ -271,65 +271,65 @@ bool_t poly_survey_adv(void) { //entry circle around entry-center until the desired altitude is reached if (psa_stage == ENTRY) { - nav_circle_XY(entry_center.x, entry_center.y, -psa_min_rad); - if (NavCourseCloseTo(segment_angle) - && nav_approaching_xy(seg_start.x, seg_start.y, last_x, last_y, CARROT) - && fabs(estimator_z - psa_altitude) <= 20) { - psa_stage = SEG; - NavVerticalAutoThrottleMode(0.0); - nav_init_stage(); + nav_circle_XY(entry_center.x, entry_center.y, -psa_min_rad); + if (NavCourseCloseTo(segment_angle) + && nav_approaching_xy(seg_start.x, seg_start.y, last_x, last_y, CARROT) + && fabs(estimator_z - psa_altitude) <= 20) { + psa_stage = SEG; + NavVerticalAutoThrottleMode(0.0); + nav_init_stage(); //uncomment following line for use with digital_cam module - //dc_survey(psa_shot_dist, seg_start.x - dir_vec.x*psa_shot_dist*0.5, seg_start.y - dir_vec.y*psa_shot_dist*0.5); - } + //dc_survey(psa_shot_dist, seg_start.x - dir_vec.x*psa_shot_dist*0.5, seg_start.y - dir_vec.y*psa_shot_dist*0.5); + } } //fly the segment until seg_end is reached if (psa_stage == SEG) { - nav_points(seg_start, seg_end); - //calculate all needed points for the next flyover - if (nav_approaching_xy(seg_end.x, seg_end.y, seg_start.x, seg_start.y, 0)) { + nav_points(seg_start, seg_end); + //calculate all needed points for the next flyover + if (nav_approaching_xy(seg_end.x, seg_end.y, seg_start.x, seg_start.y, 0)) { //uncomment following line for use with digital_cam module - //dc_stop(); - VEC_CALC(seg_center1, seg_end, rad_vec, -); - ret_start.x = seg_end.x - 2*rad_vec.x; - ret_start.y = seg_end.y - 2*rad_vec.y; + //dc_stop(); + VEC_CALC(seg_center1, seg_end, rad_vec, -); + ret_start.x = seg_end.x - 2*rad_vec.x; + ret_start.y = seg_end.y - 2*rad_vec.y; - //if we get no intersection the survey is finished - if (!get_two_intersects(&seg_start, &seg_end, vec_add(seg_start, sweep_vec), vec_add(seg_end, sweep_vec))) - return FALSE; + //if we get no intersection the survey is finished + if (!get_two_intersects(&seg_start, &seg_end, vec_add(seg_start, sweep_vec), vec_add(seg_end, sweep_vec))) + return FALSE; - ret_end.x = seg_start.x - sweep_vec.x - 2*rad_vec.x; - ret_end.y = seg_start.y - sweep_vec.y - 2*rad_vec.y; + ret_end.x = seg_start.x - sweep_vec.x - 2*rad_vec.x; + ret_end.y = seg_start.y - sweep_vec.y - 2*rad_vec.y; - seg_center2.x = seg_start.x - 0.5*(2.0*rad_vec.x+sweep_vec.x); - seg_center2.y = seg_start.y - 0.5*(2.0*rad_vec.y+sweep_vec.y); + seg_center2.x = seg_start.x - 0.5*(2.0*rad_vec.x+sweep_vec.x); + seg_center2.y = seg_start.y - 0.5*(2.0*rad_vec.y+sweep_vec.y); - psa_stage = TURN1; - nav_init_stage(); - } + psa_stage = TURN1; + nav_init_stage(); + } } //turn from stage to return else if (psa_stage == TURN1) { - nav_circle_XY(seg_center1.x, seg_center1.y, -psa_min_rad); - if (NavCourseCloseTo(return_angle)) { - psa_stage = RET; - nav_init_stage(); - } - //return + nav_circle_XY(seg_center1.x, seg_center1.y, -psa_min_rad); + if (NavCourseCloseTo(return_angle)) { + psa_stage = RET; + nav_init_stage(); + } + //return } else if (psa_stage == RET) { - nav_points(ret_start, ret_end); - if (nav_approaching_xy(ret_end.x, ret_end.y, ret_start.x, ret_start.y, 0)) { - psa_stage = TURN2; - nav_init_stage(); - } - //turn from return to stage + nav_points(ret_start, ret_end); + if (nav_approaching_xy(ret_end.x, ret_end.y, ret_start.x, ret_start.y, 0)) { + psa_stage = TURN2; + nav_init_stage(); + } + //turn from return to stage } else if (psa_stage == TURN2) { - nav_circle_XY(seg_center2.x, seg_center2.y, -(2*psa_min_rad+psa_sweep_width)*0.5); - if (NavCourseCloseTo(segment_angle)) { - psa_stage = SEG; - nav_init_stage(); + nav_circle_XY(seg_center2.x, seg_center2.y, -(2*psa_min_rad+psa_sweep_width)*0.5); + if (NavCourseCloseTo(segment_angle)) { + psa_stage = SEG; + nav_init_stage(); //uncomment following line for use with digital_cam module - //dc_survey(psa_shot_dist, seg_start.x - dir_vec.x*psa_shot_dist*0.5, seg_start.y - dir_vec.y*psa_shot_dist*0.5); - } + //dc_survey(psa_shot_dist, seg_start.x - dir_vec.x*psa_shot_dist*0.5, seg_start.y - dir_vec.y*psa_shot_dist*0.5); + } } return TRUE;