Part 0: Map configuration
First of all, you need to understand the 2D space that describes a robotic arm, a goal, and obstacles.
The following example map, named 'Test1', would help you to understand map configuration specifications.
[BasicMap]
Window : (300, 200) # (width, height)
ArmBase : (150, 200) # (x-coordinate, y-coordinate)
ArmLinks : [
(100, 95, 5, (0, 180)), # (length, initial angle, padding distance, (min angle, max angle)
(50, 60, 5, (-150, 150)),
]
Obstacles : [
(125, 70, 10), # (x-coordinate, y-coordinate, radius)
(80, 90, 10),
(165, 30, 10),
(185, 60, 10)
]
Goals : [
(150, 50, 10), # (x-coordinate, y-coordinate, radius)
(100, 50, 10)
]
- Window: The window size for the given example map is 300x200 pixel. Note that (0, 0) is the top-left corner and (300, 200) is the bottom-right corner .
- ArmBase: The arm base is placed at (150, 200).
- ArmLinks: There are two arm links.
- length: The length of the first arm link is 100.
- initial angle: its initial angle (\(\alpha\)) is 95.
- padding distance: The minimum distance between the arm link and the obstacle is 5.
- The arm link should be at least 5 units away from the obstacles (goal and window boundary from the arm link do not apply this rule). This sample output helps you visualize the padding distance.
- You do not need to consider padding distance when computing if the arm links touch the window boundary or the goal.
- You will need to compute distance between a point and a line segment.
- (min angle, max angle): The minimum and maximum angle for this arm link is 0 and 180.
The second arm link can be explained in the same manner.
- Obstacles: There are 4 obstacles with specified coordinates and radius
- There are two goals with specified coordinates and radius.
Look carefully at the conventions for \(\alpha\) and \(\beta \) in the
diagram at the top of this page. Both angles are measured counter-clockwise.
\(\alpha\) is relative to the ground and
\(\beta \) is relative to the direction of link-1.
There are four obstacles, each of them is described in tuple (x-coordinate, y-coordinate, radius).
Goals can be described in the same convention. Multiple goals are given;
however, you only need to reach one goal with the fewest steps.
The generated 2D map for above configuration is shown in the following:
You can play with the maps (stored in config file "test_config.txt") with the following command if your geometry functions are correctly implemented:
python3 mp2.py --human --map Test1 --config test_config.txt
Feel free to modify the config file to do more self test.
Once the window pops up, you can rotate the arm using the following keys:
- z / x: increase / decrease \(\alpha\)
- a / s: increase / decrease \(\beta\)
- q / w: increase / decrease \(\gamma\) (if you have 3 arm links)