Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix advanced perimeter tracking #120

Merged
merged 4 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions code/ardumower/motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void Robot::motorControlPerimeter() {
//Control the perimeter motor only each 30ms
if (millis() < nextTimeMotorPerimeterControl) return;
nextTimeMotorPerimeterControl = millis() + 30; //possible 15ms with the DUE
//PerimeterMagMaxValue=2000; //need to change in the future
//tell to the pid where is the mower (Pid.x)
perimeterPID.x = 5 * (double(perimeterMag) / perimeterMagMaxValue);
//tell to the Pid where to go (Pid.w)
Expand All @@ -161,9 +162,9 @@ void Robot::motorControlPerimeter() {
perimeterPID.w = 0.5;
}
//parameter the PID
perimeterPID.y_min = -motorSpeedMaxPwm ;
perimeterPID.y_max = motorSpeedMaxPwm ;
perimeterPID.max_output = motorSpeedMaxPwm ;
perimeterPID.y_min = -MaxSpeedperiPwm ;
perimeterPID.y_max = MaxSpeedperiPwm ;
perimeterPID.max_output = MaxSpeedperiPwm ;
//and compute
perimeterPID.compute();

Expand Down Expand Up @@ -202,8 +203,7 @@ void Robot::motorControlPerimeter() {
// we record The time at which the last wire loss occurred
lastTimeForgetWire = millis();
// if we have lost the wire from too long time (the robot is running in a circle outside the wire we stop everything)
if (millis() > perimeterLastTransitionTime + trackingErrorTimeOut) {
if ((trackingErrorTimeOut != 0) && (millis() > perimeterLastTransitionTime + trackingErrorTimeOut)){
if (millis() > perimeterLastTransitionTime + trackingErrorTimeOut) {
Console.println(F("Error: tracking error"));
addErrorCounter(ERR_TRACKING);
//setNextState(STATE_ERROR,0);
Expand Down Expand Up @@ -235,7 +235,6 @@ void Robot::motorControlPerimeter() {
if (abs(perimeterMag ) < perimeterMagMaxValue/4) {
perimeterLastTransitionTime = millis(); //initialise perimeterLastTransitionTime in perfect sthraith line
}
}
}


Expand Down
6 changes: 3 additions & 3 deletions code/ardumower/mower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ Mower::Mower(){
perimeterTrackRollTime = 1500; // roll time during perimeter tracking
perimeterTrackRevTime = 2200; // reverse time during perimeter tracking
#if defined (ROBOT_ARDUMOWER)
perimeterPID.Kp = 51.0; // perimeter PID controller
perimeterPID.Ki = 12.5;
perimeterPID.Kp = 16; // perimeter PID controller
perimeterPID.Ki = 8;
perimeterPID.Kd = 0.8;
#else // ROBOT_MINI
perimeterPID.Kp = 24.0; // perimeter PID controller
perimeterPID.Ki = 7.0;
perimeterPID.Kd = 9.0;
#endif

trackingPerimeterTransitionTimeOut = 0; // 0=disable
trackingPerimeterTransitionTimeOut = 2500; // never<500 ms
trackingErrorTimeOut = 10000; // 0=disable
trackingBlockInnerWheelWhilePerimeterStruggling = 1;
MaxSpeedperiPwm = 200; // speed max in PWM while perimeter tracking
Expand Down