Hello! So I have a tech demo tomorrow with my robot PROTO. I was tweaking his code tonight and i got these errors.
obstacleEvasion.cpp:22:12: error: no matching function for call to ‘AF_DCMotor::AF_DCMotor()’
obstacleEvasion.cpp:22:12: note: candidates are:
In file included from obstacleEvasion.cpp:10:0:
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:156:3: note: AF_DCMotor::AF_DCMotor(uint8_t, uint8_t)
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:156:3: note: candidate expects 2 arguments, 0 provided
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:153:7: note: AF_DCMotor::AF_DCMotor(const AF_DCMotor&)
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:153:7: note: candidate expects 1 argument, 0 provided
obstacleEvasion.cpp:23:12: error: no matching function for call to ‘AF_DCMotor::AF_DCMotor()’
obstacleEvasion.cpp:23:12: note: candidates are:
In file included from obstacleEvasion.cpp:10:0:
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:156:3: note: AF_DCMotor::AF_DCMotor(uint8_t, uint8_t)
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:156:3: note: candidate expects 2 arguments, 0 provided
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:153:7: note: AF_DCMotor::AF_DCMotor(const AF_DCMotor&)
/home/pi/sketchbook/libraries/AFmotor/AFMotor.h:153:7: note: candidate expects 1 argument, 0 provided
Could someone help me debug? Here’s the actual code.
</*MAEP 2.0 Navigation
by Noah Moroze, aka GeneralGeek
This code has been released under a Attribution-NonCommercial-ShareAlike license, more info at http://creativecommons.org/licenses/
PING))) code by David A. Mellis and Tom Igoe http://www.arduino.cc/en/Tutorial/Ping
*/
/Altered by Dominique M. Alzate for DC Motor support and raspberry pi control brain. PROTOmetheus/
#include <Servo.h> //include Servo library
#include <AFMotor.h> //include DC Motor library
const int pingPin = 7;
const int irPin = 0; //Sharp infrared sensor pin
const int dangerThresh = 10; //threshold for obstacles (in cm)
int leftDistance, rightDistance; //distances on either side
Servo panMotor;
AF_DCMotor leftMotor;
AF_DCMotor rightMotor; //declare motors
long duration; //time it takes to recieve PING))) signal
void setup()
{
panMotor.attach(6); //attach motors to proper pins
panMotor.write(90); //set PING))) pan to center
leftMotor.setSpeed(105); //set the speed of the motors, between 0-255
rightMotor.setSpeed (105);
}
void loop()
{
int distanceFwd = ping();
if (distanceFwd>dangerThresh) //if path is clear
{
delay (500);
leftMotor.run(FORWARD); //if there’s no obstacle ahead, Go Forward!
rightMotor.run(FORWARD); //move forward
}
else //if path is blocked
{
leftMotor.run(FORWARD); // Turn as long as there’s an obstacle ahead.
rightMotor.run (BACKWARD);
panMotor.write(0);
delay(500);
rightDistance = ping(); //scan to the right
delay(500);
panMotor.write(180);
delay(700);
leftDistance = ping(); //scan to the left
delay(500);
panMotor.write(90); //return to center
delay(100);
compareDistance();
}
}
void compareDistance()
{
if (leftDistance>rightDistance) //if left is less obstructed
{
leftMotor.run(BACKWARD);
rightMotor.run(FORWARD); //turn left
delay(500);
}
else if (rightDistance>leftDistance) //if right is less obstructed
{
leftMotor.run(FORWARD);
rightMotor.run(BACKWARD); //turn right
delay(500);
}
else //if they are equally obstructed
{
leftMotor.run(FORWARD);
rightMotor.run(BACKWARD); //turn 180 degrees
delay(1000);
}
}
long ping()
{
// Send out PING))) signal pulse
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
//Get duration it takes to receive echo
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
//Convert duration into distance
return duration / 29 / 2;
}>
I’d really appreciate any help I can get.