/* This is pseudocode for the mapping algorithm of the group project. Essentially the plan is to map a small area with many bots acting concurrently and automously. -Jim and Trevor */ Functions: (basic) forward backward turn_left turn_right (sensor functions) left_sensor right_sensor top_sensor - for polarized light front_sensor - for unpolarized light bottom_sensor - for colored tile ir_in - infrared in ir_out - infrared out left_bumper right_bumper (specialized functions) smart_avoid - to manage obstacle avoidance with bumpers light_distance - figure out distance from the light ir_distance - figure out distance from obstacles get_position - figure out the polar coordinates of our current position map - move around the area return_to_drop_point (vars) bytes type_of_obstacle - 0 = obstacle, 1 = bad spot int distance_from_light - distance from light source at position int angle_from_light - angle of polarized light from N-S light byte left_or_right - 0 = left quarter, 1 = right quarter. drop_angle - angle from pol. light at drop point drop_distance - distance from unpol. light at drop point floor_tile_size main() { /* the getting there group will drop us off at the outside edge of the hemisphere, directly underneath the polarized light.*/ /* ideally the smart_avoid thread is already running */ move forward() following the N-S light. if within x distance from normal light source, { and if left_or_right is 0, turn left begin mapping(0) - turn left else if left_or_right is 1, turn right begin mapping(1) - turn right } return_to_drop_point() /* at this point the getting there group code takes over again. */ } map(int direction) { /* the idea is to zig-zag through the area, recording the positions of bad spots and obstacles as we go. we will maintain a costant distance from the unpol. light source, which increases each time we complete a pass. */ move forward for floor_tile_size turn the opposite way as (direction) move forward until the pol. light is at 0 (or whatever the value is when the bot is underneath) { /* keeping track of distance from unpol. light*/ if direction is left, { right_sensor get_distance() } if direction is right, { left_sensor get_distance() } if a bad spot is found, { get_position; record position; } if an obstacle is found, { get_position; if position of obstacle = position of wall, map(opposite direction) /* should we record the wall as an obstacle? prob. not.*/ record position } } }