Skip to content

Commit 37043b3

Browse files
author
jschlind411
committed
Saving current tuning progress, debugging and extraniouse changes are present
do not use at this commit
1 parent 662c5ac commit 37043b3

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

src/abridge/src/abridge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void driveCommandHandler(const geometry_msgs::Twist::ConstPtr& message) {
163163

164164
// Cap motor commands at 120. Experimentally determined that high values (tested 180 and 255) can cause
165165
// the hardware to fail when the robot moves itself too violently.
166-
int max_motor_cmd = 180;
166+
int max_motor_cmd = 255;
167167

168168
if (currentMode == 1)
169169
{

src/behaviours/src/DriveController.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void DriveController::ProcessData()
220220

221221
void DriveController::fastPID(float errorVel, float errorYaw , float setPointVel, float setPointYaw) {
222222

223-
float velOut = fastVelPID.PIDOut(errorVel, setPointVel);
223+
float velOut = 0;//fastVelPID.PIDOut(errorVel, setPointVel);
224224
float yawOut = fastYawPID.PIDOut(errorYaw, setPointYaw);
225225

226226
int left = velOut - yawOut;
@@ -238,7 +238,7 @@ void DriveController::fastPID(float errorVel, float errorYaw , float setPointVel
238238

239239
void DriveController::slowPID(float errorVel,float errorYaw, float setPointVel, float setPointYaw) {
240240

241-
float velOut = slowVelPID.PIDOut(errorVel, setPointVel);
241+
float velOut = 0;//slowVelPID.PIDOut(errorVel, setPointVel);
242242
float yawOut = slowYawPID.PIDOut(errorYaw, setPointYaw);
243243

244244
int left = velOut - yawOut;
@@ -306,9 +306,9 @@ PIDConfig DriveController::fastVelConfig() {
306306
PIDConfig DriveController::fastYawConfig() {
307307
PIDConfig config;
308308

309-
config.Kp = 240;
310-
config.Ki = 25;
311-
config.Kd = 0.5;
309+
config.Kp = 100;
310+
config.Ki = 10;
311+
config.Kd = 14;
312312
config.satUpper = 255;
313313
config.satLower = -255;
314314
config.antiWindup = config.satUpper/2;
@@ -350,9 +350,9 @@ PIDConfig DriveController::slowVelConfig() {
350350
PIDConfig DriveController::slowYawConfig() {
351351
PIDConfig config;
352352

353-
config.Kp = 80;
354-
config.Ki = 15;
355-
config.Kd = 1.7;
353+
config.Kp = 70;
354+
config.Ki = 16;
355+
config.Kd = 10;
356356
config.satUpper = 255;
357357
config.satLower = -255;
358358
config.antiWindup = config.satUpper/4;

src/behaviours/src/LogicController.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ Result LogicController::DoWork() {
154154
//used for precision driving pass through
155155
case LOGIC_STATE_PRECISION_COMMAND: {
156156

157+
// cout << "I MADE IT HERE!" << endl;
158+
157159
//unlike waypoints precision commands change every update tick so we ask the
158160
//controller for new commands on every update tick.
159161
result = control_queue.top().controller->DoWork();
160162

163+
// cout << result.pd.cmdAngularError;
164+
161165
//pass the driving commands to the drive controller so it can interpret them
162166
driveController.SetResultData(result);
163167

@@ -191,7 +195,7 @@ void LogicController::ProcessData() {
191195
if (processState == PROCCESS_STATE_SEARCHING) {
192196
prioritizedControllers = {
193197
PrioritizedController{0, (Controller*)(&searchController)},
194-
PrioritizedController{10, (Controller*)(&obstacleController)},
198+
PrioritizedController{-1, (Controller*)(&obstacleController)},
195199
PrioritizedController{15, (Controller*)(&pickUpController)},
196200
PrioritizedController{5, (Controller*)(&range_controller)},
197201
PrioritizedController{-1, (Controller*)(&dropOffController)}

src/behaviours/src/PID.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,25 @@ float PID::PIDOut(float calculatedError, float setPoint) {
105105
if (fabs(P) < config.antiWindup)
106106
{
107107
float avgPrevError = 0;
108-
for (int i = 1; i < Error.size(); i++) {
108+
for (int i = 1; i < Error.size(); i++)
109+
{
109110
avgPrevError += Error[i];
110111
}
111-
if (Error.size() > 1) {
112+
if (Error.size() > 1)
113+
{
112114
avgPrevError /= Error.size()-1;
113115
}
114-
else {
116+
else
117+
{
115118
avgPrevError = Error[0];
116119
}
117120

118-
D = config.Kd * (((1-config.derivativeAlpha)*Error[0]) - (config.derivativeAlpha * avgPrevError));
121+
D = config.Kd * (Error[0] - Error[1]) * hz;
119122
}
120123

121124
float PIDOut = P + I + D + FF;
125+
126+
cout << "PID: " << "P:" << P << " I:" << I << " D:" << D << endl;
122127
if (PIDOut > config.satUpper) //cap vel command
123128
{
124129
PIDOut = config.satUpper;

src/behaviours/src/PID.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class PID
4444
float prevSetPoint = std::numeric_limits<float>::min();
4545
vector<float> integralErrorHistArray;
4646
int step = 0;
47-
float hz = 10;
47+
float hz = 10; //Rate that PID is running at
4848

4949
};
5050

src/behaviours/src/SearchController.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "SearchController.h"
2+
#include <angles/angles.h>
23

34
SearchController::SearchController() {
45
rng = new random_numbers::RandomNumberGenerator();
@@ -24,7 +25,14 @@ void SearchController::Reset() {
2425
*/
2526
Result SearchController::DoWork() {
2627

27-
if (!result.wpts.waypoints.empty()) {
28+
result.type = precisionDriving;
29+
result.pd.cmdAngularError = angles::shortest_angular_distance(currentLocation.theta, 0);
30+
result.pd.cmdVel = 0;
31+
result.PIDMode = SLOW_PID;
32+
33+
cout << "PID: " << result.pd.cmdAngularError << endl;
34+
35+
/* if (!result.wpts.waypoints.empty()) {
2836
if (hypot(result.wpts.waypoints[0].x-currentLocation.x, result.wpts.waypoints[0].y-currentLocation.y) < 0.10) {
2937
attemptCount = 0;
3038
}
@@ -63,9 +71,9 @@ Result SearchController::DoWork() {
6371
6472
result.wpts.waypoints.clear();
6573
result.wpts.waypoints.insert(result.wpts.waypoints.begin(), searchLocation);
66-
74+
*/
6775
return result;
68-
}
76+
//}
6977

7078
}
7179

0 commit comments

Comments
 (0)