1. Get familiar with Python development
2. Implement and test proportional control
1. A personal computer
Define a series of waypoints (position and direction), your simulated robot should navigate through those points one by one using P control.
For Module 1.0, you need to:
Submit a video, showing the performance of your "a controller". (Do not attach your video on Canvas as they might be excessively large; instead, please put your video online and share the link on Canvas)
Submit a working package on Canvas (Alternatively, you may set up your own Github or bitbucket page. Put the page link in your lab report, see below)
From Module 1.5, we will require a full report. See Module 1.5 page for submission requirement.
The lab report and program files should be done in pairs of 2 or 3. Between groups, you are allowed to collectively interpret material and understand the course package; sharing code or lab reports will be considered a violation of course policy.
1. 100% Working code can be demonstrated
1. Install Python compiler for Windows (for OS X, for Linux) The given package is debugged on Python 3.
2. Install PIP. For some Windows computers, to run a python file, you need to call `py` instead of `python`.
3. Download our course package (git clone may be better) here
4. Install missing packages, most commonly you need to install numpy, Pillow, Open-CV, and maybe something else.
Numpy installation: in Command Prompt/Terminal, try `python -m pip install numpy`
Pillow installation: in Command Prompt/Terminal, try `python -m pip install Pillow`
Pillow installation: in Command Prompt/Terminal, try `python -m pip install opencv-python ` (read more here)
1. Run E160_gui.py
(If you use python IDLE, simply go File->open->E160_gui.py; then click run (F5))
(If you use Command Prompt/Terminal, navigate to the directory you extracted your course package (Windows, Linux), (mostly you will use `cd Folder_Name`), type `python E160_gui.py` or `py E160_gui.py`).
2. You may see a dialogue window as in Fig. 1. Move the slider bar at bottom, you can manually control the robot.
3. Click any point on the dialogue window, on the command prompt/terminal, and you should be able to see "New desired robot state [x][x].
4. Click "track point" button, you should see your robot is rotating like crazy. This is because "track point" function should be developed by you!
5. Now the slider bar will not function anymore until you click "stop"
1. This is the file you will modify to achieve a controller. We defined a class called "controller". The __init__() function will be called only once when the dialogue window pops-up. The track_point() function will be called every 0.1 second.
2. Understand goal points:
Goal points is stored as a list in `self.robot.state_des` object of E160_des_state (defined in `E160_state.py`). Each element is in the form of (x, y, theta) in global frame
Modify set_goal_points(self) for points you are going to track. The robot should go to the first destination. For instance:
In the above case, you added way points (100, 20, 1.06), then (110, 30, 1.57)
Internally, object `self.robot.state_des` of `E160_des_state` class stores way points as a list.
When you use mouse to left click a point, the way points you defined in the above python program will be cleared. `self.robot.state_des` will only have the one goal point: the point you clicked.
3. Retrieve destination configurations
Read `track_point(self)` function. There are examples on how to get destination position, current position, current velocity in global and local frame, etc. Note `self.robot.state_des.get_des_state()` will return you the goal position you should navigate to, not the whole way point list that self.robot.state_des internally stored.
Keep in mind, `track_point(self)` is called every 0.1s.
4. Define the criteria for "reaching the vicinity" of the goal position, as proportional control, strictly speaking, will never let your robot reach its destination.
In the above code: if abs(c_posX - d_posX) is a wrong example of criteria for you to determine whether the robot has reached its way point. You need to re-define it.
`self.robot.state_des.reach_destination()` serve as a function to internally report a way point is reached. After this function is called, the `self.robot.state_des.get_des_state()` will return the next way point. Therefore, `self.robot.state_des.reach_destination()` must be called once (and only once) when a way point is reached.
`self.robot.state_des.reach_destination()` will return `True` if you have reached the last point of the the way point list (and thus the motors should stop); the function returns `False` if it only reaches a midway point.
5. `self.robot.set_motor_control(c_v, c_w)` will result in motor to move. You only need to specify x-direction velocity and angular velocity. You do NOT need to specify the wheel speed.
6. `self.robot.send_wheel_speed(phi_l = 6.0,phi_r = 6.0)` allows you to update the wheel rotation velocity (unit in rad/s). You must calculate the wheel speed yourself. (The robot chassis diameter is 2L=24cm, the wheel radius is r=3cm). Please try to calibrate your wheel speed to be less than 16 rad/s. The simulator will function normally if the wheel speed is beyond 16 rad/s. However, the counter for "wrong frame" will be added.
1. In`__init__(self,robot)`, you can define whether you want to log your navigation data or not. If logging == True, your logging file will be in "log" folder. The file name should be date_time.csv.
2. In `__init__(self,robot)`, define the name of parameters you want to log, and call function: (note the input is a list in [], each element should be of string type.)
3. To log a variable, in track_point(self), call function: (note the input is a list in [], each element should be of float type.)
4. Every time when you restart the main dialogue window, your data will be logged in another file in 'log' folder
5. You may use MS Excel, LibreOffice Calc, Google sheet, or MATLAB to read the saved log file. You can plot whatever you want using these tools!
1. This controller is simply to kick-off our course modules.
2. "A controller" work in this way:
a. Firstly, the robot will turn in place to face the goal position
b. Then, the robot will move in a straight-line to reach the goal position
c. Finally, the robot will turn in place again to reach the goal orientation
3. Feel free to define more functions and use more classes
4. It is not recommended to modify other .py files; because updates may be provided on these files
Figure 1. Main dialogue window, use slider bars to control robot simulation