A doctor agent has information about 5 possible locations of 3 victims in a given area. Both agents have a map of the arena and know of the location of possible obstacles. The doctor directs the scout agent to look for the victims in these locations with the smallest number of moves possible. Once three victims have been found (and the severity of their injuries has been assessed), the mission ends, at which point the doctor reports back the location of the victims. However, a complicating factor is that the scout doesn’t know its starting position, and thus needs to figure this out.
I mostly focused on the robot movement and calibration by using the wall and the obstacles. Both were directly implemented in the
PilotRobot.java class for ease-of-access to all users.
Initially I planned on re-using the detailed code written by Jiafeng in the previous assignment, however after several days of testing and getting unexpected results in certain positions that I didn’t understand, I decided to revamp the entire code and wrote it again from scratch, optimised for the 6x6 square grid arena.
I wrote the
goTo() method, which uses the
MovePilot chassis to travel certain distances. Because each grid is very small on the 6x6 square version of the arena, I decided to have the robot move only 1/3 of the grid’s length (which is also equal to the width), check if any calibration was required, then move forward again for the remaining 2/3 of the grid’s length.
It’s a relatively straightforward implementation, with the robot moving in one of the 4 possible directions (front, right, back, and left). The direction for each step is individually given by the Jason via Wi-Fi. No direct diagonal movement was implemented. The robot rotates on it’s self according to the chosen direction before travelling forward.
This was slightly trickier. My code has the robot measure the left side distance against a wall or obstacle at each movement (using the ultrasound sensor), and if there is a substantial deviation from a straight path the should would normally take (ie the difference in the distances being bigger than 1 grid length + some margin), the robot corrects the deviation angle by going exactly back the same path it came from, and then correcting its angle by rotating itself by the calculated angle*.
I also updated the ultrasound sensor detection methods, and got 5 sample values each time, stored them in an
array, removed the highest and lowest values, and then got an average value of the 3 remaining samples. This was to avoid unintentional false or infinity values. I believe my updated methods were not used for the position detection implementation.