Skip to content

Commit

Permalink
remove verbose print from header
Browse files Browse the repository at this point in the history
  • Loading branch information
ErcBunny committed Mar 5, 2023
1 parent ba11659 commit 064386a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
13 changes: 10 additions & 3 deletions sw/airborne/modules/maze_runner/maze_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>.
*/

/** @file "modules/maze_runner/maze_runner.h"
/** @file "modules/maze_runner/maze_runner.c"
* @author Ryan Y. Liu <yueqianliu@outlook.com>
* A module for AE4317 Autonomous Flight of Micro Air Vehicles at the TU Delft.
* This module aims to provide a collision free navigation strategy for the Bebop in the Cyberzoo.
Expand All @@ -28,6 +28,13 @@
#include "modules/maze_runner/maze_runner.h"
#include "generated/flight_plan.h"

#define PRINT(string, ...) fprintf(stderr, "[maze_runner->%s()] " string, __FUNCTION__, ##__VA_ARGS__)
#if MAZE_RUNNER_VERBOSE
#define VERBOSE_PRINT PRINT
#else
#define VERBOSE_PRINT(...)
#endif

float oa_color_count_frac = 0.18f;
enum navigation_state_t navigation_state = SEARCH_FOR_SAFE_HEADING;
int32_t color_count = 0; // orange color count from color filter for obstacle detection
Expand Down Expand Up @@ -57,7 +64,7 @@ void maze_runner_init(void)

void maze_runner_loop(void)
{
// freq = 5.0 Hz
// loop frequency set in the module xml
// only evaluate our state machine if we are flying
if (!autopilot_in_flight())
{
Expand All @@ -67,7 +74,7 @@ void maze_runner_loop(void)
// compute current color thresholds
int32_t color_count_threshold = oa_color_count_frac * front_camera.output_size.w * front_camera.output_size.h;

VERBOSE_PRINT("Color_count: %d threshold: %d state: %d \n", color_count, color_count_threshold, navigation_state);
// VERBOSE_PRINT("Color_count: %d threshold: %d state: %d \n", color_count, color_count_threshold, navigation_state);

// update our safe confidence using color threshold
if (color_count < color_count_threshold)
Expand Down
7 changes: 1 addition & 6 deletions sw/airborne/modules/maze_runner/maze_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
#ifndef MAZE_RUNNER_VISUAL_DETECTION_ID
#define MAZE_RUNNER_VISUAL_DETECTION_ID ABI_BROADCAST
#endif
#define PRINT(string, ...) fprintf(stderr, "[maze_runner->%s()] " string, __FUNCTION__, ##__VA_ARGS__)
#if MAZE_RUNNER_VERBOSE
#define VERBOSE_PRINT PRINT
#else
#define VERBOSE_PRINT(...)
#endif

enum navigation_state_t
{
Expand All @@ -57,6 +51,7 @@ enum navigation_state_t
};

extern float oa_color_count_frac;
extern float heading_increment;

extern void maze_runner_init(void);
extern void maze_runner_loop(void);
Expand Down
26 changes: 16 additions & 10 deletions sw/airborne/modules/maze_runner/maze_runner_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* <http://www.gnu.org/licenses/>.
*/

/** @file "modules/maze_runner/maze_runner.h"
/** @file "modules/maze_runner/maze_runner_helper.c"
* @author Ryan Y. Liu <yueqianliu@outlook.com>
* A module for AE4317 Autonomous Flight of Micro Air Vehicles at the TU Delft.
* This module aims to provide a collision free navigation strategy for the Bebop in the Cyberzoo.
Expand All @@ -27,6 +27,13 @@

#include "modules/maze_runner/maze_runner.h"

#define PRINT(string, ...) fprintf(stderr, "[maze_runner->%s()] " string, __FUNCTION__, ##__VA_ARGS__)
#if MAZE_RUNNER_VERBOSE
#define VERBOSE_PRINT PRINT
#else
#define VERBOSE_PRINT(...)
#endif

/*
* Increases the NAV heading. Assumes heading is an INT32_ANGLE. It is bound in this function.
*/
Expand All @@ -41,7 +48,7 @@ uint8_t increase_nav_heading(float incrementDegrees)
// for performance reasons the navigation variables are stored and processed in Binary Fixed-Point format
nav_heading = ANGLE_BFP_OF_REAL(new_heading);

VERBOSE_PRINT("Increasing heading to %f\n", DegOfRad(new_heading));
// VERBOSE_PRINT("Increasing heading to %f\n", DegOfRad(new_heading));
return false;
}

Expand All @@ -66,9 +73,9 @@ uint8_t calculateForwards(struct EnuCoor_i *new_coor, float distanceMeters)
// Now determine where to place the waypoint you want to go to
new_coor->x = stateGetPositionEnu_i()->x + POS_BFP_OF_REAL(sinf(heading) * (distanceMeters));
new_coor->y = stateGetPositionEnu_i()->y + POS_BFP_OF_REAL(cosf(heading) * (distanceMeters));
VERBOSE_PRINT("Calculated %f m forward position. x: %f y: %f based on pos(%f, %f) and heading(%f)\n", distanceMeters,
POS_FLOAT_OF_BFP(new_coor->x), POS_FLOAT_OF_BFP(new_coor->y),
stateGetPositionEnu_f()->x, stateGetPositionEnu_f()->y, DegOfRad(heading));
// VERBOSE_PRINT("Calculated %f m forward position. x: %f y: %f based on pos(%f, %f) and heading(%f)\n", distanceMeters,
// POS_FLOAT_OF_BFP(new_coor->x), POS_FLOAT_OF_BFP(new_coor->y),
// stateGetPositionEnu_f()->x, stateGetPositionEnu_f()->y, DegOfRad(heading));
return false;
}

Expand All @@ -77,8 +84,8 @@ uint8_t calculateForwards(struct EnuCoor_i *new_coor, float distanceMeters)
*/
uint8_t moveWaypoint(uint8_t waypoint, struct EnuCoor_i *new_coor)
{
VERBOSE_PRINT("Moving waypoint %d to x:%f y:%f\n", waypoint, POS_FLOAT_OF_BFP(new_coor->x),
POS_FLOAT_OF_BFP(new_coor->y));
// VERBOSE_PRINT("Moving waypoint %d to x:%f y:%f\n", waypoint, POS_FLOAT_OF_BFP(new_coor->x),
// POS_FLOAT_OF_BFP(new_coor->y));
waypoint_move_xy_i(waypoint, new_coor->x, new_coor->y);
return false;
}
Expand All @@ -88,17 +95,16 @@ uint8_t moveWaypoint(uint8_t waypoint, struct EnuCoor_i *new_coor)
*/
uint8_t chooseRandomIncrementAvoidance(void)
{
float heading_increment;
// Randomly choose CW or CCW avoiding direction
if (rand() % 2 == 0)
{
heading_increment = 5.f;
VERBOSE_PRINT("Set avoidance increment to: %f\n", heading_increment);
// VERBOSE_PRINT("Set avoidance increment to: %f\n", heading_increment);
}
else
{
heading_increment = -5.f;
VERBOSE_PRINT("Set avoidance increment to: %f\n", heading_increment);
// VERBOSE_PRINT("Set avoidance increment to: %f\n", heading_increment);
}
return false;
}

0 comments on commit 064386a

Please sign in to comment.