Bonjour,
Je suis étudiant en électronique depuis peu et j ai recu le magnifique “ALLBOT - Four legs” pour m aider a apprendre.
Je vous écris car lorsque je veux téléverser le programme Allbot vers l aduino du robot la console me signale des erreurs de compilations…
N’étant pas très fort en programation, je suis incapable de comprendre le problème seul et c est après des heures de recherches en vain sur internet que j implore votre aide.
voici donc le programme suivit des erreurs signalées par la console:
#include <Servo.h>
#include <ALLBOT.h>
ALLBOT BOT(8); //number of motors
enum MotorName {
hipFrontLeft,
hipFrontRight,
hipRearLeft,
hipRearRight,
kneeFrontLeft,
kneeFrontRight,
kneeRearLeft,
kneeRearRight
};
int sounderPin = 13;
String rawcommand; // Global variable that stores the raw received IR command
String command; // Global variable that stores part of the decoded IR command
int times; // Global variable that stores part the received IR command
int speedms; // Global variable that stores part the received IR command
boolean IRreceive = true; // Set this to true if you want to use the IR remote
boolean receivelog = false; // Set this to true if you want to see the serial messages for debugging the IR commands
void setup() {
//NAME.attach(motorname, pin, init-angle, flipped, offset-angle);
BOT.attach(hipFrontLeft, A1, 45, 0, 0);
BOT.attach(hipFrontRight, A0, 45, 1, 0);
BOT.attach(hipRearLeft, 9, 45, 1, 0);
BOT.attach(hipRearRight, 4, 45, 0, 0);
BOT.attach(kneeFrontLeft, 11, 45, 1, 0);
BOT.attach(kneeFrontRight, 2, 45, 0, 0);
BOT.attach(kneeRearLeft, 10, 45, 1, 0);
BOT.attach(kneeRearRight, 3, 45, 0, 0);
//INIT sounder
pinMode(sounderPin, OUTPUT);
//wait for joints to be initialized
delay(500);
// Starting the hardware UART, necessary for receiving IR
if (IRreceive == true) // Check if required (when Serial is started servo1 connector will not work!)
{
Serial.begin(2400);
Serial.setTimeout(100);
Serial.println(“serial communication started”);
}
// Chirp for ready
chirp(1, 50);
chirp(1, 255);
chirp(3, 0);
}
void loop() {
if (IRreceive == true) // Choose between IR commands or random action
{
getcommand(); // Listen for IR command
executecommand(); // Execute any receveid commands
}
}
void leanright(int speedms){
BOT.move(kneeFrontRight, 90);
BOT.move(kneeRearRight, 90);
BOT.animate(speedms);
delay(speedms/2);
BOT.move(kneeFrontRight, 45);
BOT.move(kneeRearRight, 45);
BOT.animate(speedms);
}
void chirp(int beeps, int speedms){
for (int i = 0; i < beeps; i ){
for (int i = 0; i < 255; i ){
digitalWrite(sounderPin, HIGH);
delayMicroseconds((355-i)+ (speedms2));
digitalWrite(sounderPin, LOW);
delayMicroseconds((355-i)+ (speedms2));
}
delay(30);
}
}
void getcommand (void) // This is the routine that listens and decodes any IR commands. Decodes commands end up in the global vars.
{
int space1 = 0;
int space2 = 0;
if (Serial.available()) {
rawcommand = Serial.readString();
if (receivelog){
Serial.println(“START " + rawcommand + " END” + “\r\n” + "Received string length = " + rawcommand.length() + “\r\n” + "End character > at index = " + rawcommand.indexOf(’>’));
}
//checking and deleting rubbish data at start of received command
if ((rawcommand.indexOf('<') != 0) && (rawcommand.indexOf('<') != -1))
{
rawcommand.remove(0, rawcommand.indexOf('<'));
}
//check if received command is correct
if ((rawcommand.charAt(0) == '<') && (rawcommand.indexOf('>') <= 12) && (rawcommand.indexOf('>') != -1) && (rawcommand.length() > 7))
{
if (receivelog){
Serial.println("Command is VALID");
}
//breakdown into chunks
//command
command = rawcommand.substring(1, 3);
//finding the spaces to find the times and speedms
for (int i=0; i <= rawcommand.length(); i )
{
if ((rawcommand.charAt(i) == ' ') && (space1 == 0))
{
space1 = i;
}
else if ((rawcommand.charAt(i) == ' ') && (space2 == 0))
{
space2 = i;
}
}
//Setting the command variables and checking if they are indeed a number (toInt()).
//times
times = rawcommand.substring(space1+1, space2).toInt();
//speedms
speedms = rawcommand.substring(space2+1, rawcommand.indexOf('>')).toInt();
if (receivelog){
Serial.println("decoded commands are:");
Serial.flush();
Serial.println("command = " + command);
Serial.flush();
Serial.println("times = " + times);
Serial.flush();
Serial.println("speedms = " + speedms);
}
}
else
{
if (receivelog){
Serial.println("Command is NOT valid");
}
resetserial();
}
}
}
//--------------------------------------------------------------
void resetserial (void) // This clears any received IR commands that where received in the serial buffer while the robot was execution a command.
{
//resetting all variables
rawcommand = “”;
command = “”;
times = 0;
speedms = 0;
//flushing the serial buffer (64 byte) so there are no stored movements that need to be handled (annoying)…
while (Serial.available()) {
Serial.read();
}
}
//--------------------------------------------------------------
void executecommand (void) // Execute the commands that are stored in the global vars.
{
if (command == “LR”)
{
leanright(speedms*5);
resetserial();
}
}
ERREUR DE COMPILATION:
sketch_dec07a.ino: in function ‘void chirp(int, int)’:
sketch_dec07a.ino:82:30: warning: for increment expression has no effect [-Wunused-value]
sketch_dec07a.ino:82:30: warning: for increment expression has no effect [-Wunused-value]
sketch_dec07a.ino: In function ‘void getcommand()’:
sketch_dec07a.ino:107:20: error: ‘class String’ has no member named ‘remove’
sketch_dec07a.ino:121:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
sketch_dec07a.ino:121:48: warning: for increment expression has no effect [-Wunused-value]
voilà, j espère que vous pourrez m aider et attend vos réponces avec impatience
merci pour votre attention.
English traduction:
(excuse me but i am not good in English language)
Hello,
I am a student of electronics recently and I received the magnificent “ALLBOT - Four legs” to help me learn.
I am writing to you because when I want to upload the program Allbot to the robot aduino the console informs me of compilation errors …
Not being very strong in programming, I am unable to understand the problem alone and it is after hours of searching in vain on the internet that I implore your help.
Here is the program followed by errors reported by the console: (see above)