Skip to content

Commit

Permalink
adjustment to backward_until_inside function..
Browse files Browse the repository at this point in the history
Added slopreadnings defininition angle will be read this number of times, to get an avarage.
  • Loading branch information
PalmOla authored and sm6yvr committed Jul 14, 2017
1 parent 775090c commit bb5338d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
7 changes: 2 additions & 5 deletions Liam/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,12 @@ int CONTROLLER::GoBackwardUntilInside (BWFSENSOR *Sensor) {
int counter = MAX_GO_BACKWARD_TIME;
// Check if tiltAngle is greater then slopeangle, if not return directly.
int angle = 0;
int timesToCheck = 10;
for (int i = 0; i < timesToCheck; i++)
for (int i = 0; i < SLOPEREADINGS; i++)
{
angle += compass->getTiltAngle();

delay(100);
}
Serial.print("\nbackwards active. angle is :");Serial.print(angle/10);
if (abs(angle / timesToCheck) <= SLOPEANGLE)
if (abs(angle / SLOPEREADINGS) <= SLOPEANGLE)
return 0;

while (Sensor->isInside() == false)
Expand Down
12 changes: 8 additions & 4 deletions Liam/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
You can also see some values reported by the sensors. You need probably to tweek some
of the parameters in this file and when you are done remove or comment out this line to
run your mover in real mode. */
#define __SETUP_AND_DEBUG_MODE__ true
#define __SETUP_AND_DEBUG_MODE__ false

/******************************************************************
User specific settings depends on how you have built your mover.
Expand All @@ -54,7 +54,7 @@
BRUSHLESS 0 (for all hobbyking motors with external ESC)
BRUSHED: 1 (for all brushed motors, A3620 and NIDEC 22)
NIDEC 2 (for NIDEC 24 or NIDEC 22 connected to morgan shield without any modifications) */
const int MY_CUTTERMOTOR = 2;
const int MY_CUTTERMOTOR = 1;

/* Configure which type of battery you have.
Types availible:
Expand Down Expand Up @@ -121,8 +121,12 @@ const int NUMBER_OF_SENSORS = 2;
If mower is not inside within x seconds mower will stop. */
#define GO_BACKWARD_UNTIL_INSIDE true
#define MAX_GO_BACKWARD_TIME 5
/* Slopeangle. Mower will not go backwards if slope is less then slopeangle.*/
#define SLOPEANGLE 20
// The amount of times to check and sum angle, sum will be divided by this value to get avrage angle of slopereadings number of time read.
#define SLOPEREADINGS 1
/* Slopeangle. Mower will not go backwards if slope is less then slopeangle.
if you have no angle-sensor and still want mower to go backwards until it's inside, then set SLOPEANGLE to -1
*/
#define SLOPEANGLE -1

/******************************************************************
Common settings that should be same for the most of us.
Expand Down
2 changes: 0 additions & 2 deletions Liam/Liam.ino
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ void loop() {

#if GO_BACKWARD_UNTIL_INSIDE
err = Mower.GoBackwardUntilInside(&Sensor);
if (err == 0)
return;
#endif

// Tries to turn, but if timeout then reverse and try again
Expand Down
4 changes: 2 additions & 2 deletions Liam/MMA_7455.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void MMA_7455::autoupdate()
int16_t xc = 0, yc = 0, zc = 0;
float lpratio = 0.2; /* between 0 and 1 */
/* Set serial baud rate */
//Serial.begin(115200);
Serial.begin(115200);
/* Set accelerometer sensibility to 2g */
setSensitivity(2);
/* Verify sensibility - optional */
Expand Down Expand Up @@ -106,7 +106,7 @@ void MMA_7455::autoupdate()
}
boolean MMA_7455::initialize() {
Wire.begin();
//Serial.begin(115200);
Serial.begin(115200);
setSensitivity(2);
setMode(measure);
setAxisOffset(X_ANGLE_NORMAL, Y_ANGLE_NORMAL, Z_ANGLE_NORMAL);
Expand Down

0 comments on commit bb5338d

Please sign in to comment.