Skip to content

Commit ad6f8d8

Browse files
committed
first push
0 parents  commit ad6f8d8

38 files changed

+2173
-0
lines changed

.catkin_workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file currently only serves to mark the location of a catkin workspace for tool integration

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.pyo
2+
*.pyc
3+
*.mp4
4+
/rec1_dataset/IMG
5+
/rec2_dataset/IMG
6+
/rec3_dataset/IMG
7+
/test_dataset/IMG
8+
.ipynb_checkpoints
9+
.DS_Store
10+
__pycache__
11+
/devel
12+
/build
13+
src/CMakeLists.txt

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Udacity
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
[![Udacity - Robotics NanoDegree Program](https://s3-us-west-1.amazonaws.com/udacity-robotics/Extra+Images/RoboND_flag.png)](https://www.udacity.com/robotics)
2+
3+
# Table of Contents #
4+
5+
- [Hover Controller](#hover-controller)
6+
- [Attitude Controller](#attitude-controller)
7+
- [Position Controller](#position-controller)
8+
- [Additional Helpful Tools](#additional-helpful-tools)
9+
- [Using the Simulator](#using-the-simulator)
10+
11+
# Hover Controller #
12+
### Step 1: Writing the PID Class ###
13+
14+
Add the PID class you wrote to `quad_controller/src/quad_controller/pid_controller.py`
15+
16+
### Step 2: Running the Hover Controller ###
17+
18+
**NOTE: Launch `roscore` first, then Unity**
19+
20+
After you have added the PID class, you can launch the hover controller.
21+
To do so, run the following commands in your terminal:
22+
```
23+
$ cd ~/catkin_ws/
24+
$ catkin_make
25+
$ source devel/setup.bash
26+
$ roslaunch quad_controller hover_controller.launch
27+
```
28+
Now, with the hover controller launched, you can launch the quad simulator on your host platform.
29+
The details surrounding this process will be be different for each host platform (Win/Mac/Linux).
30+
please see "Using the Simulator" below.
31+
32+
### Step 3: Tuning Parameters ###
33+
Now that Unity has been launched, verify that you can see poses being published by the simulator
34+
on the `/quad_rotor/pose` topic:
35+
```
36+
$ rostopic echo /quad_rotor/pose
37+
```
38+
If you see messages being published, you're golden! If you don't see messages being published,
39+
then you might want to check your firewall settings on your host VM, or try restarting
40+
the simulator (at the moment there's an infrequent bug where comunications with the simulator does not work).
41+
42+
Now that you've verified poses are being published, you can use `rqt_reconfigure` to adjust the setpoints
43+
and PID parameters for the hover controller!
44+
45+
You should tune the parameters using rqt_reconfigure until you are happy with the result.
46+
For more information about how to tune PID parameters, head back into the classroom.
47+
48+
If manually adjusting the PID parameters is not your thing, feel free to try out the
49+
Ziegler–Nichols tuning method using either `hover_zn_tuner_node`, or `hover_twiddle_tuner_node`.
50+
These nodes both implement tuning methods that were discussed in the classroom.
51+
52+
You might find that these tuner helpers only get you part way to a good tune.
53+
There's a reason for this! Do you know?
54+
55+
To run `hover_zn_tuner_node`:
56+
```
57+
$ rosrun quad_controller hover_zn_tuner_node
58+
```
59+
60+
To run `twiddle_tuner_node`:
61+
```
62+
$ rosrun quad_controller hover_twiddle_tuner_node
63+
```
64+
65+
Write down the parameters you came up with, as you will need them later, for the full positional controller!
66+
67+
**Bonus Quesion:**
68+
69+
Why does the quad overshoot more frequently when heading to a set point at a lower altitude?
70+
How can you modify the code to overcome this issue?
71+
72+
# Attitude Controller #
73+
The attitude controller is responsible for controlling the roll, pitch, and yaw angle of the quad rotor.
74+
You can tune it very similarly to how you tuned the hover controller!
75+
Note: ZN/Twiddle Tuner nodes only work with the Hover controller.
76+
77+
### Step 1: Launch the Attitude Controller ###
78+
```
79+
$ roslaunch quad_controller attitude_controller.launch
80+
```
81+
82+
### Step 2: Launch the Attitude Controller ###
83+
84+
Tune roll and pitch PID parmaeters until things look good.
85+
You'll also need to write down these PID parameters.
86+
As mentioned previously, you'll be using them in the positional controller!
87+
88+
89+
# Position Controller #
90+
91+
Finally, now that you have tuned the attitude controller and positional controllers
92+
you can begin to work on the positional controller. The positional controller is
93+
responsible for commanding the attitude and thrust vectors in order to acheive a
94+
goal orientation in three dimensional space.
95+
96+
Luckily, you've likely found some pretty decent PID parameters in your previous exploration.
97+
If you're fortunate, these parameters will work for you... However, even if they don't
98+
we've got you covered. There's all sorts of additional tooling that you can use to
99+
troubleshoot and tune positional control of your quad!
100+
101+
### Step 1: Launch the Positional Controller ###
102+
```
103+
$roslaunch quad_controller position_controller.launch
104+
```
105+
106+
### Step 2: Tuning Parameters ###
107+
108+
Tune parameters until the controller is well-behaved.
109+
This should not be a very familiar, albeit potentially more difficult problem.
110+
111+
# Additional Helpful Tools #
112+
With so many degrees of freedom, debugging and troubleshooting can be a painful process.
113+
In order to make things a little bit simpler, we've provided some tools that might make
114+
life a little bit easier.
115+
116+
### Constraining Forces and Torques ###
117+
118+
It is possible to constrain forces and torques on the quad rotor's body frame.
119+
This can be useful if you're trying to debug only a single degree of freedom.
120+
121+
Example: Disallow movement along the quad's X axis
122+
```
123+
$ rosservice call /quad_rotor/x_force_constrained "data: true"
124+
```
125+
Example: Disallow rotation about the quad's X axis
126+
```
127+
$ rosservice call /quad_rotor/x_torque_constrained "data: true"
128+
```
129+
130+
### Setting the Camera Pose ###
131+
132+
To set the camera pose you can either, right click in the simulator, and drag
133+
or you can use the following service call, where the data parameter may take on the following
134+
values:
135+
0: Orthogonal to the inertial frame's YZ plane, facing the positive X direction.
136+
1: Orthogonal to the inertial frame's XZ plane, facing the positive Y direction.
137+
2: Orthogonal to the intertial frame's XY plane, facing the negative Z direction.
138+
3: Perspective view, facing the quad's body frame origin from the -X,-Y, +Z quadrant.
139+
140+
```
141+
$ rosservice call /quad_rotor/camera_pose_type "data: 0"
142+
```
143+
To reset the camera pose, to the default pose, you can use the service call, or right click.
144+
145+
### Setting the Camera Distance ###
146+
147+
To set the distance between the camera and the quad's body frame, you can use the
148+
`/quad_rotor/camera_distance` service. For example, to set the camera distance to be
149+
20 meters, you would call the service as follows:
150+
```
151+
$ rosservice call /quad_rotor/camera_distance "data: 20.0"
152+
```
153+
154+
To reset the camera distance to the default, simply right click in the simulator.
155+
156+
### Disabling Gravity ###
157+
158+
Gravity can be a harsh reality. Particularly when you're dealing with attitude tuning.
159+
Fortunately, we can disable gravity in the simulator for the purposes of debugging.
160+
To do so, call the `/quad_rotor/gravity` service as follows:
161+
```
162+
$ rosservice call /quad_rotor/gravity "data: false"
163+
```
164+
165+
### Setting Pose ###
166+
167+
To set the quad pose, use the `/quad_rotor/set_pose` service. The following service call
168+
will place the quad at the origin:
169+
```
170+
$ rosservice call /quad_rotor/set_pose "pose:
171+
position:
172+
x: 0.0
173+
y: 0.0
174+
z: 0.0
175+
orientation:
176+
x: 0.0
177+
y: 0.0
178+
z: 0.0
179+
w: 0.0"
180+
```
181+
182+
### Plotting using `quad_plotter_node` ###
183+
184+
The `quad_plotter_node` is a handy tool which allows you to capture and plot quad movements.
185+
This might be useful to you while you are tuning the quad rotor in simulation.
186+
187+
**Services:**
188+
- `/quad_plotter/start_recording` - Begins recording plot data (poses)
189+
- `/quad_plotter/stop_recording` - Stops recording plot data (poses)
190+
- `/quad_plotter/clear_path_history` - Clear plot history (poses)
191+
- `/quad_plotter/clear_waypoints` - Clear waypoints
192+
- `/quad_plotter/load_waypoints_from_sim` - Gets waypoints from the drone simulator
193+
- `/quad_plotter/get_path_history` - Returns path history as pose array
194+
- `/quad_plotter/plot_one` - Plots a 2D path on a given plane (*plane selection coming soon!*)
195+
- `/quad_plotter/plot_3d` - Create a 3D plot depicting path in perspective
196+
- `/quad_plotter/plot_grid` - Create a grid plot, showing 4 different views
197+
198+
**Example: Capturing a Grid Plot**
199+
1. Load waypoints from the simulator (optional) `$ rosservice call /quad_plotter/load_waypoints_from_sim`
200+
2. Begin recording poses `$ rosservice call /quad_plotter/start_recording "{}"`
201+
3. Perform the behavior that you wish to capture in the simulator.
202+
4. Stop recording poses `$ rosservice call /quad_plotter/stop_recording "{}"`
203+
5. Generate the plot `$ rosservice call /quad_plotter/plot_gird "{}"`
204+
205+
After performing the above steps, a new timestamped PNG image should be generated and placed in the `/quad_controller/output_data` directory.
206+
207+
# Using the Simulator #
208+
209+
First be sure to grab the newest version of the simulator for your host computer OS [here](https://github.com/udacity/RoboND-Controls-Lab/releases). **Please note that you cannot use the simulator inside of the Udacity supplied course VM (Virtual Machine). You have to use the simulator for your host operating system and connect it to your VM.**
210+
211+
If using the VM, inside the simulator's `_data` or `/Contents` folder, edit `ros_settings.txt` and set `vm-ip` to the VM’s IP address and set `vm-override` to `true`. If not using a VM, no edit is necessary.
212+
213+
To find the ip of your VM, type `echo $(hostname -I)` into a terminal of your choice. **Be aware that the ip address of your VM can change. If you are experiencing problems, be sure to check that the VM's ip matches that of which you have in ros_settings.txt**
214+
215+
**Note: Be sure to use at least V2.1.0 of the Udacity provided VM for this lab**

0 commit comments

Comments
 (0)