Skip to content

Commit 78b9821

Browse files
authored
v1.0 (#68)
* Revised readme.md, created low level control dir * fixes #16 * Updated README.md, shell script requires root * Initial commit of control * start future improvements lists * fix typo * Commit for work transfer to linux machine * #21 start dev guide * #9 configure usb_cam and add cv_camera, just in case * minor change commit * remove old version directory cv_camera * remove old version usb_cam directory * updated files from usb_cam * fix cv_camera, cleanup lanes-v1 * Implemented pathHeading Calc * cleanup and add debug code * launch views video1, does not display image (intentinoally) * Completed lat_controller core algo * Imported fix to GPS error * fixed error message. calculation likely still incorrect * reformat and add __future__ imports * Add debugger node to verify camera functionality * Fix typo in docstring * Reformat and add main() methods * Changed exception handler style * Add lane detection v2 source. Need to convert to python 2 * Built control core library * Update module README with credits * Added RAZOR 9DOF * Attempt to fix the repo link for razor * rm razor * Final IMU * Initial commit of the control node * Advanced Lanes work in python 2 * Added Interface and Common pkg * committing all changes * Added three ROS nodes. Lane offset data of a video feed can now be published * Removed swp, swn, swo files * Converting Vec3 to vector of cluster indices * Fixed some bugs * Fixed bugs * mm * Display label instead of intesnity * Maybe sped up gpf * missed semicolon * Edited params * this code is so bad :( * whoops * this is getting annoying * mm * Hopefully fixed * Implemented scanline wrapping * fix bug * mm * Maybe fixed scanline wrapping * moar bugs * mm * mm * mmm * ugh * sadasdfas * last time * Update README.md * Complete lane v2 node structure * Cleaned up lane v2 nodes * Add condition for no detected lane * Calibrate ELP camera * - Finished making Segmentation as stable as possible (for now). - Improved readability -Removed old files * Fixed gitignore * Delete .vscode files * revert to old gpf code * newest_steering_test.ino * Fixed over-segmentation of ground-plane * Add files via upload Initial low-level MCU node for low-level control. * Update redcar_control.ino Initial low-level control code for driving and steering control. * Add files via upload Initial commit of Control_Adapter_Arduino_node. * Delete low_lvl_mcu_node.py * Change no lane reading to "nan" Float32 * temp gpf fix * Implemented Point Filtering - NOT TESTED * Completed Rev1 Control node w/ custom message * Remove default test videos * Cleanup and refresh cached files * Added an IMU callback for control node to retrieve orientation * Updates after testing * #25 Add placeholder for face detector * #25 Add initial face detector * #25 Add haarcascade xml files * Add updated cache files * New point count based obstacle detection algorithm * #25 Altered CMakeLists to integrate cpp files * #25 Update face detector * Update control_node.cpp * Updated Object detection field * Change swiftnav to output vel_down * Fixed size_t error * fixed range to type float * Start launch file * Added control launch file * initial path interpolation file * Added launchfile, now publishing boolean * edited launch file * Fixed launch file ..again * Finished and tested lidar code * final parameter tweak * Fixed timer function bug, Added obstacle detection and driving mode mechanism * Add new arduino test code * Update path interpolation * Update new steering test * Fixed path heading check issue, placed CATKIN_IGNORE in localization pkg to prevent build error * Removed catkin_ignore from localization, planned to merge into ISS-29 * Added geodetic to ECEF conversion * Path interpolation publishes a path message * Set y position message to correct ouput * Path interpolation works with global reference frame * Add relative X and Y calculation * Improve interpolation function * Updated IMU Accel, Gyro Calibation * Fixed compilation error * Read locations from file * Fixed missing last point corner case in #42 * Hotfix commented out x_n * Fixed file parser #42 * Quick cleanup documentation #42 * Remove unnecessary globals * Modularize path interpolation * Add adaptive point density calculation * Add steering angle conversion * #42 debug in process for finePointsY equation * Fixed interpolation formula #42 * Cleanup #42 * Update launch file for path interpolation * Create geodesy package * Started real time position output node * Add mgrs library for UTM conversion * Remove mgrs library * Add geodetic to UTM calculation from utm pypy library * Update launch file * Add adaptive point density calc for UTM * Reorganize data #42 * Quick cleanup #42 * Cleanup Arduino and Python code * Cleanup Arduino Code * fix imu config * imu usb port change * Changed UTM to OOP implementation * Add OOP implementation for ECEF interpolation * Refactor ECEF path interpolation * Refactor UTM path interpolation * Update .gitignore * Start ENU converter * Stopped tracking cache files * Update manifest * Add live GPS position converter * Add velocity calculation * Hotfix debug message * Update geodesy launch * Including instructions at the topic for running code * Including instructions at the topic for running code * Added heading estimation into path cb * Fixed small struct bug * Fix for reseting prev_pos, added control debug layer * Added control files * Small update * Tuned PID parameters for 12 Volts and added timeout safety features * fixed rc, fixed control launch to include python node * Added rosserial launch * Added 2 new Paths * Fixed some low lvl python logic * removed old python low lvl node * launch files for path * updated joy installation * pip install * control bug fix * updated path * Obstacle detection fix * changed mitchell's code to reduce buffer size * Control Bug Fix * New student union path * Most updated Arduino code, tested some filtering at idle to lower oscillation * Control update * Arduino Fix * Preliminary error confirmation * Add point converter #53 * Fixed ENU data to ECEF data bug #53 * Update formatting for debugging #53 * Updated ardu_adapter.py and newest_steering_test.ino to remove magic numbers * Forgot an indent * working low level control code * Controller logic fix, fit was having error in having duplicated points * Start tf master node * Small fix * Fixed the wrapping angle issue where i forgot to remap the output to the right variable * Least squares gpf method w/ Eigen * Kalman Filter Core function implementationn * Fixed eigen compile errors * Update IMU message published * Move validation data to appropriate location * Note future TF msg improvements * Implemented SVD approach to groun plane fitting (NOT TESTED YET) * Fixed Eigen compilation bug * Verified that new CalculatePlaneNormal works as desired * fixed compilation bugs * Added include guards to all header files, tweaked gpf parameters * fixed z_min error * Gpf working commit * Update initial framework messages for tf * Update executable target * IMU Calibration, Control node update * Removed libuvc from util
1 parent 4c1bce0 commit 78b9821

File tree

268 files changed

+367768
-1417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+367768
-1417
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
11
build/
22
devel/
33

4+
.vscode*
5+
######################
6+
####### Python #######
7+
######################
8+
9+
# Byte-compiled / optimized / DLL files
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
14+
# Installer logs
15+
pip-log.txt
16+
pip-delete-this-directory.txt
17+
18+
# Unit test / coverage reports
19+
htmlcov/
20+
.tox/
21+
.coverage
22+
.coverage.*
23+
.cache
24+
nosetests.xml
25+
coverage.xml
26+
*.cover
27+
.hypothesis/
28+
.pytest_cache/
29+
30+
# pyenv
31+
.python-version
32+
33+
#####################
34+
35+
# Mac OSX Cache
36+
.DS_Store

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FusionAD is an autonomous driving software stack developed by engineering studen
55
#### **Run the ```ext_package_build.sh``` to ensure all the prerequisites of the external ROS packages used in this stack are met and installed**
66

77
```
8-
sh ext_package_build.sh
8+
sudo sh ext_package_build.sh
99
```
1010
### Development:
11-
Please pull from the branch "develop", not master.
11+
Please develop from the branch "develop", not master.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
/* HOW TO USE
2+
*
3+
* The Arduino is subscribed to ardu_adapter and receives steering + driving values from ardu_adapter
4+
* These values have already been translated to analog inputs that are applicable to steering and driving
5+
* To run this code, use the following command
6+
* $rosrun rosserial_python serial_node.py /dev/ttyACM0
7+
* Check the USB port and correct for these ^^^^ if needed
8+
*
9+
*/
10+
11+
12+
#include <ros.h>
13+
#include <std_msgs/Float64.h>
14+
ros::NodeHandle nh;
15+
16+
std_msgs::Float64 feedback;
17+
std_msgs::Float64 driving_feedback;
18+
std_msgs::Float64 steering_error_feedback;
19+
ros::Publisher steering_response("/control/steering_response", &feedback); // publish error instead
20+
ros::Publisher driving_response("/control/driving_response", &driving_feedback);
21+
ros::Publisher steering_error_response("/control/steering_error", &steering_error_feedback);
22+
23+
#include <PID_v1.h> // PID LIBRARY
24+
25+
#define R_EN 12 // ENABLE PIN steering
26+
#define L_EN 13
27+
28+
#define RPWM 6 // inward motion steering
29+
#define LPWM 5 // outward motion steering
30+
31+
#define Motor_R_EN 3 // ENABLE PIN DRIVE
32+
#define Motor_L_EN 4
33+
34+
#define Motor_RPWM 9 //
35+
#define Motor_LPWM 10
36+
37+
double left_setpoint = 0; // declare ALL the variables
38+
double right_setpoint = 0;
39+
double setpoint = 319;
40+
double input = 0;
41+
double right_output = 0;
42+
double left_output = 0;
43+
double wheel_angle = 0;
44+
double error = 0;
45+
double upper_steering_limit = 462;
46+
double lower_steering_limit = 182;
47+
double driving_limit = 100;
48+
double steering_tolerance = 13;
49+
50+
/* POTENTIOMETER VALUES!!!
51+
BOUNDS ARE 462 FULL LOCK RIGHT
52+
319 STRAIGHT
53+
182 FULL LOCK LEFT
54+
*/
55+
56+
unsigned int Kp = 120; // proportional gain
57+
unsigned int Ki = 1; // integral gain
58+
unsigned int Kd = 1; // derivative gain
59+
60+
PID left(&input, &left_output, &left_setpoint, Kp, Ki, Kd, REVERSE); // Turning left is more negative
61+
PID right(&input, &right_output, &right_setpoint, Kp, Ki, Kd, DIRECT); // Turning right is more positive (referencing the pot)
62+
63+
float steering_value = 319;
64+
float driving_value = 0;
65+
66+
unsigned long steering_timestamp = 0;
67+
unsigned long loop_timestamp = 0;
68+
unsigned long time_out = 200;
69+
70+
71+
void drivingcallback(const std_msgs::Float64& driving_msg)
72+
{
73+
driving_operation(driving_value);
74+
driving_value = driving_msg.data;
75+
}
76+
77+
void steeringcallback(const std_msgs::Float64& steering_msg)
78+
{
79+
steering_timestamp = millis();
80+
81+
if (steering_msg.data > upper_steering_limit)
82+
{
83+
steering_value = upper_steering_limit;
84+
}
85+
else if (steering_msg.data < lower_steering_limit)
86+
{
87+
steering_value = lower_steering_limit;
88+
}
89+
else
90+
{
91+
steering_value = steering_msg.data;
92+
if((abs(steering_value-(analogRead(0)) < steering_tolerance))) // need to rethink requirements of low lvl control on test platform
93+
{
94+
no_operation();
95+
}
96+
else
97+
{
98+
operation(steering_value);
99+
}
100+
}
101+
102+
feedback.data = analogRead(0); // feedback.data is equal to the input of the linear actuator
103+
steering_error_feedback.data = steering_value-feedback.data;
104+
driving_feedback.data = driving_value; // driving feedback is equal to the driving value (until we have motor feedback)
105+
driving_response.publish(&driving_feedback);
106+
steering_response.publish(&feedback);
107+
steering_error_response.publish(&steering_error_feedback);
108+
}
109+
110+
ros::Subscriber<std_msgs::Float64> steering_sub("/control/steering_channel", &steeringcallback); //subscriber initialization
111+
ros::Subscriber<std_msgs::Float64> driving_sub("/control/driving_channel", &drivingcallback);
112+
113+
void setup() {
114+
// put your setup code here, to run once:
115+
nh.initNode(); // initialize ROS node
116+
nh.subscribe(steering_sub); // subscriber to ardu_adapter for steering
117+
nh.subscribe(driving_sub); // subscriber to ardu_adapter for driving
118+
nh.advertise(steering_response); // publisher to ardu_adapter for steering
119+
nh.advertise(driving_response); // publisher to ardu_adapter for driving
120+
nh.advertise(steering_error_response); // publisher for error for PID tuning
121+
122+
pinMode(R_EN, OUTPUT); // initializing enable pins on linear actuator
123+
pinMode(L_EN, OUTPUT);
124+
125+
pinMode(RPWM, OUTPUT); // initializing PWM pins on linear actuator
126+
pinMode(LPWM, OUTPUT);
127+
128+
pinMode(Motor_R_EN, OUTPUT); // initializing enable pins on motor
129+
pinMode(Motor_L_EN, OUTPUT);
130+
131+
pinMode(Motor_RPWM, OUTPUT); // initializing PWM pins on motor
132+
pinMode(Motor_LPWM, OUTPUT);
133+
134+
left.SetMode(AUTOMATIC); // turning on the PID control
135+
right.SetMode(AUTOMATIC);
136+
137+
digitalWrite(R_EN, HIGH); // leave these as high to allow steering control operation
138+
digitalWrite(L_EN, HIGH);
139+
140+
digitalWrite(Motor_R_EN, HIGH); // leave these as high to allow the motor control operation
141+
digitalWrite(Motor_L_EN, HIGH);
142+
}
143+
144+
void loop() {
145+
// put your main code here, to run repeatedly:
146+
nh.spinOnce();
147+
148+
loop_timestamp = millis();
149+
150+
if (abs(loop_timestamp-steering_timestamp)>time_out)
151+
{
152+
no_operation();
153+
}
154+
155+
delay(20);
156+
}
157+
158+
void operation(double incoming_input)
159+
{
160+
input = analogRead(0);
161+
setpoint = incoming_input;
162+
error = setpoint - input;
163+
164+
if (error > 0)
165+
{
166+
right_operation(setpoint); // turn right
167+
steering_limits(input);
168+
}
169+
else if (error < 0)
170+
{
171+
left_operation(setpoint); // turn left
172+
steering_limits(input);
173+
}
174+
else if (error == 0)
175+
{
176+
no_operation(); // go straight
177+
}
178+
}
179+
180+
void right_operation(double right_side_setpoint)
181+
{
182+
right_setpoint = right_side_setpoint;
183+
input = analogRead(0);
184+
steering_limits(input);
185+
186+
if (input >= right_side_setpoint)
187+
{
188+
input = analogRead(0);
189+
right_setpoint = right_side_setpoint;
190+
left.SetMode(MANUAL);
191+
right.SetMode(MANUAL);
192+
analogWrite(LPWM, 0);
193+
analogWrite(RPWM, 0);
194+
}
195+
else if (input < right_side_setpoint)
196+
{
197+
input = analogRead(0);
198+
right_setpoint = right_side_setpoint;
199+
left.SetMode(MANUAL);
200+
right.SetMode(AUTOMATIC);
201+
right.Compute();
202+
analogWrite(LPWM, 0);
203+
analogWrite(RPWM, right_output);
204+
205+
if (input >= right_side_setpoint)
206+
{
207+
input = analogRead(0);
208+
right_setpoint = right_side_setpoint;
209+
left.SetMode(MANUAL);
210+
right.SetMode(MANUAL);
211+
analogWrite(LPWM, 0);
212+
analogWrite(RPWM, 0);
213+
}
214+
}
215+
}
216+
217+
void left_operation(double left_side_setpoint)
218+
{
219+
steering_limits(input);
220+
221+
if (input <= left_side_setpoint)
222+
{
223+
input = analogRead(0);
224+
left_setpoint = left_side_setpoint;
225+
right.SetMode(MANUAL);
226+
left.SetMode(MANUAL);
227+
analogWrite(RPWM, 0);
228+
analogWrite(LPWM, 0);
229+
}
230+
else if (input > left_side_setpoint)
231+
{
232+
input = analogRead(0);
233+
left_setpoint = left_side_setpoint;
234+
right.SetMode(MANUAL);
235+
left.SetMode(AUTOMATIC);
236+
left.Compute();
237+
analogWrite(RPWM, 0);
238+
analogWrite(LPWM, left_output);
239+
240+
if (input <= left_side_setpoint)
241+
{
242+
input = analogRead(0);
243+
left_setpoint = left_side_setpoint;
244+
right.SetMode(MANUAL);
245+
left.SetMode(MANUAL);
246+
analogWrite(RPWM, 0);
247+
analogWrite(LPWM, 0);
248+
}
249+
}
250+
}
251+
252+
void no_operation()
253+
{
254+
input = analogRead(0);
255+
right.SetMode(MANUAL);
256+
left.SetMode(MANUAL);
257+
analogWrite(RPWM, 0);
258+
analogWrite(LPWM, 0);
259+
}
260+
261+
void driving_operation(double incoming_driving_input)
262+
{
263+
if (incoming_driving_input > 0)
264+
{
265+
forward_drive(incoming_driving_input);
266+
}
267+
else if (incoming_driving_input < 0)
268+
{
269+
reverse_drive(incoming_driving_input);
270+
}
271+
else if (incoming_driving_input == 0)
272+
{
273+
braking();
274+
}
275+
}
276+
277+
void forward_drive(double driving_pwm)
278+
{
279+
if (driving_pwm <= driving_limit)
280+
{
281+
digitalWrite(Motor_R_EN, HIGH);
282+
digitalWrite(Motor_L_EN, HIGH);
283+
analogWrite(Motor_LPWM, 0);
284+
analogWrite(Motor_RPWM, driving_pwm);
285+
}
286+
else if (driving_pwm>driving_limit)
287+
{
288+
digitalWrite(Motor_R_EN, HIGH);
289+
digitalWrite(Motor_L_EN, HIGH);
290+
analogWrite(Motor_LPWM, 0);
291+
analogWrite(Motor_RPWM, 100);
292+
}
293+
}
294+
295+
void reverse_drive(double driving_pwm)
296+
{
297+
if (abs(driving_pwm <= driving_limit))
298+
{
299+
digitalWrite(Motor_R_EN, HIGH);
300+
digitalWrite(Motor_L_EN, HIGH);
301+
analogWrite(Motor_LPWM, abs(driving_pwm));
302+
analogWrite(Motor_RPWM, 0);
303+
}
304+
else if (abs(driving_pwm>driving_limit))
305+
{
306+
digitalWrite(Motor_R_EN, HIGH);
307+
digitalWrite(Motor_L_EN, HIGH);
308+
analogWrite(Motor_LPWM, abs(driving_pwm));
309+
analogWrite(Motor_RPWM, 0);
310+
}
311+
}
312+
void braking()
313+
{
314+
digitalWrite(Motor_R_EN, LOW);
315+
digitalWrite(Motor_L_EN, LOW);
316+
analogWrite(Motor_RPWM, 0);
317+
analogWrite(Motor_LPWM, 0);
318+
}
319+
320+
void steering_limits(double steering_input_limit)
321+
{
322+
if (steering_input_limit >= upper_steering_limit)
323+
{
324+
no_operation();
325+
}
326+
else if (steering_input_limit <= lower_steering_limit)
327+
{
328+
no_operation();
329+
}
330+
}

docs/standards/git/git_dev_guide.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
###==== FusionAD Git Dev Guide ====###
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
###==== FusionAD ROS Dev Guide ====###
2+

0 commit comments

Comments
 (0)