Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/connect_bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class Bulebule(cmd.Cmd):
'angular_speed_profile',
'linear_speed_profile',
'static_turn_right_profile',
'micrometers_per_count_calibration ',
'front_sensors_calibration',
]
SET_SUBCOMMANDS = [
Expand Down Expand Up @@ -287,10 +288,10 @@ def do_plot(self, extra):
else:
print('Please, specify what to plot!')

def do_run(self, extra):
def do_run(self, line):
"""Run different procedures on the mouse."""
if extra in self.RUN_SUBCOMMANDS:
self.proxy.send_bt('run %s\0' % extra)
if any(line.startswith(x) for x in self.RUN_SUBCOMMANDS):
self.proxy.send_bt('run %s\0' % line)
else:
print('Please, specify what to run!')

Expand Down
42 changes: 42 additions & 0 deletions src/calibration.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,48 @@ void run_static_turn_right_profile(void)
reset_motion();
}

/**
* @brief Micrometers per count calibration.
*
* Assumes the robot is positioned at the start of a cell, with its tail
* touching the back wall. It will accelerate in a straight line and will stop
* touching its nose with last cell's front wall.
*
* Side walls control is activated so it is recommended to always have side
* walls when running this test.
*
* @param[in] cells Number of cells to run across before stopping.
*/
void run_micrometers_per_count_calibration(unsigned int cells)
{
float linear_acceleration = get_linear_acceleration();
float linear_deceleration = get_linear_deceleration();
float max_linear_speed = get_max_linear_speed();

set_linear_acceleration(4.);
set_linear_deceleration(4.);
set_max_linear_speed(0.4);

reset_motion();
side_sensors_calibration();
enable_motor_control();

side_sensors_control(true);
front_sensors_control(false);

accelerate(get_encoder_average_micrometers(),
CELL_DIMENSION * cells - WALL_WIDTH / 2. - MOUSE_TAIL);
disable_walls_control();
decelerate(get_encoder_average_micrometers(),
CELL_DIMENSION - WALL_WIDTH / 2. - MOUSE_HEAD, 0.);

reset_motion();

set_linear_acceleration(linear_acceleration);
set_linear_deceleration(linear_deceleration);
set_max_linear_speed(max_linear_speed);
}

/**
* @brief Front sensors calibration funtion.
*
Expand Down
1 change: 1 addition & 0 deletions src/calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void run_linear_speed_profile(void);
void run_angular_speed_profile(void);
void run_distances_profiling(void);
void run_static_turn_right_profile(void);
void run_micrometers_per_count_calibration(unsigned int cells);
void run_front_sensors_calibration(void);

#endif /* __CALIBRATION_H */
8 changes: 8 additions & 0 deletions src/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static bool run_angular_speed_profile_signal;
static bool run_linear_speed_profile_signal;
static bool run_static_turn_right_profile_signal;
static bool run_front_sensors_calibration_signal;
static unsigned int run_micrometers_per_count_calibration_signal;

/**
* @brief Push a single char to the serial received buffer.
Expand Down Expand Up @@ -97,6 +98,9 @@ static void process_command(void)
run_angular_speed_profile_signal = true;
else if (!strcmp(buffer.data, "run static_turn_right_profile"))
run_static_turn_right_profile_signal = true;
else if (starts_with("run micrometers_per_count_calibration "))
run_micrometers_per_count_calibration_signal =
(unsigned int)parse_spaced_float(2);
else if (!strcmp(buffer.data, "run front_sensors_calibration"))
run_front_sensors_calibration_signal = true;
else if (starts_with("set micrometers_per_count "))
Expand Down Expand Up @@ -167,6 +171,10 @@ void execute_commands(void)
} else if (run_static_turn_right_profile_signal) {
run_static_turn_right_profile_signal = false;
run_static_turn_right_profile();
} else if (run_micrometers_per_count_calibration_signal) {
run_micrometers_per_count_calibration(
run_micrometers_per_count_calibration_signal);
run_micrometers_per_count_calibration_signal = 0;
} else if (run_front_sensors_calibration_signal) {
run_front_sensors_calibration_signal = false;
run_front_sensors_calibration();
Expand Down