Follow Me 2D
Project 1 Activity
Instructions
In this activity you will implement two functions for finding the minimum value in a vector. The first will be a basic implementation and the second will ignore values of zero so that it can be used with the Lidar, which returns values of zero on bad readings. You will then implement follow me 2D by repeatedly finding the minimum value of the current Lidar scan, and then applying either bang-bang control or p-control to maintain a setpoint distance from the obstacle in the direction of the shortest Lidar scan. Complete the following:
- Implement
findMinDist()
inmbot_lib/mbot_lib/utils.cpp
according to the header filembot_lib/mbot_lib/utils.h
. - Implement
findMinNonzeroDist()
inmbot_lib/mbot_lib/utils.cpp
according to the header filembot_lib/mbot_lib/utils.h
. - Implement follow me 2D in
4_follow_2d.cpp
so that the robot performs the behavior specified below.
Feel free to look back at how you implemented follow me 1D.
- Hint: Remember to use the appropriate function for finding the minimum distance in a real Lidar scan.
- Hint: Driving in polar coordinates should look familiar.
Expected Behavior
The robot should follow the nearest obstacle without spinning, as shown in the video below. Be sure to demonstrate that following works in multiple directions, not just the forward / backward.
Testing
The functions can be tested by running the local unit tests. To test only the functions for this checkpoint run ctest -R FindMinDist --output-on-failure && ctest -R FindMinNonzeroDist --output-on-failure
in the /build
directory.
The robot behavior can be tested by running the follow_2d
executable.