HELP : Your program is too big for the memory model selected in the project
NicoHEI
Posts: 15
Hello everyone,
I need help,
I don't understand why my prog is too big...
#include "simpletools.h" // Include simple tools
#include "ping.h" // Include ping tools
#include "arlodrive.h"
int pingsRight = {1};
int pingsFront = {3};
int pingsLeft = {5};
char position;
char destination;
int rotR, rotL, L, R;
int L1 = 0;
int R1 = 0;
int distLeft = 0;
int distRight = 0;
int cmRight,cmLeft,cmFront;
int Normalspeed = 30;
int Maxspeed = 50;
int Minspeed = 20;
int DistanceDanger = 40;
int DistancePrudence = 40;
int distanceL[6], distanceR[6];
int main() // Main function
{
printf("Ou est le robot, entrez A, B ou C \n");
scanf("&s \n", &position);
printf("Ou voulez-vous allern entrez A, B ou C \n");
scanf("%s \n", &destination);
while(distanceL[0] <600 && distanceR[0]<600)
{
drive_speed(Normalspeed, Normalspeed);
drive_getTicksCalc(&distanceL[0], &distanceR[0]);
pause(100);
printf(" distanceL[0] %d \n distanceR[0] %d \n ", distanceL[0], distanceR[0]);
cmRight = ping_cm(pingsRight); // Ping sensors
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
// print(" Front %d \n", cmFront, " right %d \n", cmRight, " Left %d \n", cmLeft);
if(cmFront < DistancePrudence)
{
drive_speed(Minspeed, Minspeed);
if(cmFront < DistanceDanger)
{
//contournement par la gauche
/*
if(cmLeft > cmRight)
{
//il s'arrete
drive_speed(0,0);
pause(500);
drive_getTicks(&rotR, &rotL);
//il tourne 1 à droite
drive_goto(-23,23);
rotR = fabs(rotR);
rotL = fabs(rotL);
distLeft = distLeft-rotR;
distRight = distRight-rotL;
cmRight = ping_cm(pingsRight);
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
// print(" Front %d \n", cmFront, " right %d \n", cmRight, " Left %d \n", cmLeft);
while(cmRight < DistancePrudence)
{
//il avance 1 jusqu'a ce qu'il y a plus rien a droite
cmRight = ping_cm(pingsRight); // Ping sensors
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
L = 0;
R = 0;
drive_getTicks(&L, &R);
drive_speed(Minspeed, Minspeed);
}
//il avance 1 de distance de sécurité
drive_setMaxSpeed(Minspeed);
drive_goto(50, 50);
L1 = L;
R1 = R;
print("%d L \n %d R \n", L1, R1);
distRight = distRight - R1 + cos(45)*R1;
distLeft = distLeft - L1 + cos(45)*L1;
//il tourne 2 à droite
drive_getTicks(&rotR, &rotL);
drive_goto(23,-23);
rotR = fabs(rotR);
rotL = fabs(rotL);
distRight = distRight-rotR;
distLeft = distLeft-rotL;
drive_setMaxSpeed(Minspeed);
//il avance 2
drive_goto(70, 70);
distRight = distRight - R1 + cos(45)*R1;
distLeft = distLeft - L1 + cos(45)*L1;
drive_getTicks(&rotL, &rotR);
//il tourne 3 à droite
drive_goto(23,-23);
rotL = fabs(rotL);
rotR = fabs(rotR);
distLeft = distLeft-rotL;
distRight = distRight-rotR;
//il avance de la distance parcourue en avance 1
R = 0;
L = 0;
drive_getTicks(&R, &L);
drive_goto(L1, R1);
print("%d L \n %d R \n", L, R);
//il tourne 4 à gauche
drive_goto(-23, 23);
}
*/
if(cmLeft < cmRight)
{
//il s'arrete
drive_speed(0,0);
pause(500);
drive_getTicks(&distanceL[1], &distanceR[1]);
//il tourne 1 à droite
drive_goto(23,-23);
distanceL[1] = fabs(distanceL[1]);
distanceR[1] = fabs(distanceR[1]);
distanceL[0] = distanceL[0]-distanceL[1];
distanceR[0] = distanceR[0]-distanceL[1];
cmRight = ping_cm(pingsRight);
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
// print(" Front %d \n", cmFront, " right %d \n", cmRight, " Left %d \n", cmLeft);
while(cmLeft < DistancePrudence)
{
//il avance 1 jusqu'a ce qu'il y a plus rien a droite
cmRight = ping_cm(pingsRight); // Ping sensors
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
pause(500);
drive_speed(Minspeed, Minspeed);
}
drive_setMaxSpeed(Minspeed);
drive_goto(50, 50);
drive_getTicks(&distanceL[2], &distanceR[2]);
L1 = distanceL[2];
R1 = distanceR[2];
print("%d L1 \n %d R1 \n", L1, R1);
//il avance 1 de distance de sécurité
distanceL[0] = distanceL[1] - distanceL[1] + cos(45)*distanceL[2];
distanceR[0] = distanceR[1] - distanceR[1] + cos(45)*distanceR[2];
//il tourne 2 à droite
pause(500);
drive_goto(-23,23);
drive_getTicks(&distanceL[3], &distanceL[3]);
distanceL[3] = fabs(distanceL[3]);
distanceR[3] = fabs(distanceR[3]);
distanceL[0] = distanceL[0]-distanceL[3];
distanceR[0] = distanceR[0]-distanceR[3];
drive_setMaxSpeed(Minspeed);
//il avance 2
pause(500);
drive_goto(70, 70);
drive_getTicks(&distanceL[4], &distanceR[4]);
//il tourne 3 à droite
pause(500);
drive_goto(-23,23);
distanceL[4] = fabs(distanceL[4]);
distanceR[4] = fabs(distanceR[4]);
distanceL[0] = distanceL[0]-distanceL[4];
distanceR[0] = distanceR[0]-distanceR[4];
//il avance de la distance parcourue en avance 1
pause(500);
// drive_goto(L1, R1);
drive_getTicks(&distanceL[5], &distanceR[5]);
print("%d distanceL[5], %d distanceR[5] \n ", distanceL[5], distanceR[5]);
drive_goto(70, 70);
//il tourne 4 à gauche
pause(500);
drive_goto(23, -23);
}
}
}
}
drive_speed(0,0);
print("%d \n %d", L1, R1);
}
I need help,
I don't understand why my prog is too big...
#include "simpletools.h" // Include simple tools
#include "ping.h" // Include ping tools
#include "arlodrive.h"
int pingsRight = {1};
int pingsFront = {3};
int pingsLeft = {5};
char position;
char destination;
int rotR, rotL, L, R;
int L1 = 0;
int R1 = 0;
int distLeft = 0;
int distRight = 0;
int cmRight,cmLeft,cmFront;
int Normalspeed = 30;
int Maxspeed = 50;
int Minspeed = 20;
int DistanceDanger = 40;
int DistancePrudence = 40;
int distanceL[6], distanceR[6];
int main() // Main function
{
printf("Ou est le robot, entrez A, B ou C \n");
scanf("&s \n", &position);
printf("Ou voulez-vous allern entrez A, B ou C \n");
scanf("%s \n", &destination);
while(distanceL[0] <600 && distanceR[0]<600)
{
drive_speed(Normalspeed, Normalspeed);
drive_getTicksCalc(&distanceL[0], &distanceR[0]);
pause(100);
printf(" distanceL[0] %d \n distanceR[0] %d \n ", distanceL[0], distanceR[0]);
cmRight = ping_cm(pingsRight); // Ping sensors
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
// print(" Front %d \n", cmFront, " right %d \n", cmRight, " Left %d \n", cmLeft);
if(cmFront < DistancePrudence)
{
drive_speed(Minspeed, Minspeed);
if(cmFront < DistanceDanger)
{
//contournement par la gauche
/*
if(cmLeft > cmRight)
{
//il s'arrete
drive_speed(0,0);
pause(500);
drive_getTicks(&rotR, &rotL);
//il tourne 1 à droite
drive_goto(-23,23);
rotR = fabs(rotR);
rotL = fabs(rotL);
distLeft = distLeft-rotR;
distRight = distRight-rotL;
cmRight = ping_cm(pingsRight);
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
// print(" Front %d \n", cmFront, " right %d \n", cmRight, " Left %d \n", cmLeft);
while(cmRight < DistancePrudence)
{
//il avance 1 jusqu'a ce qu'il y a plus rien a droite
cmRight = ping_cm(pingsRight); // Ping sensors
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
L = 0;
R = 0;
drive_getTicks(&L, &R);
drive_speed(Minspeed, Minspeed);
}
//il avance 1 de distance de sécurité
drive_setMaxSpeed(Minspeed);
drive_goto(50, 50);
L1 = L;
R1 = R;
print("%d L \n %d R \n", L1, R1);
distRight = distRight - R1 + cos(45)*R1;
distLeft = distLeft - L1 + cos(45)*L1;
//il tourne 2 à droite
drive_getTicks(&rotR, &rotL);
drive_goto(23,-23);
rotR = fabs(rotR);
rotL = fabs(rotL);
distRight = distRight-rotR;
distLeft = distLeft-rotL;
drive_setMaxSpeed(Minspeed);
//il avance 2
drive_goto(70, 70);
distRight = distRight - R1 + cos(45)*R1;
distLeft = distLeft - L1 + cos(45)*L1;
drive_getTicks(&rotL, &rotR);
//il tourne 3 à droite
drive_goto(23,-23);
rotL = fabs(rotL);
rotR = fabs(rotR);
distLeft = distLeft-rotL;
distRight = distRight-rotR;
//il avance de la distance parcourue en avance 1
R = 0;
L = 0;
drive_getTicks(&R, &L);
drive_goto(L1, R1);
print("%d L \n %d R \n", L, R);
//il tourne 4 à gauche
drive_goto(-23, 23);
}
*/
if(cmLeft < cmRight)
{
//il s'arrete
drive_speed(0,0);
pause(500);
drive_getTicks(&distanceL[1], &distanceR[1]);
//il tourne 1 à droite
drive_goto(23,-23);
distanceL[1] = fabs(distanceL[1]);
distanceR[1] = fabs(distanceR[1]);
distanceL[0] = distanceL[0]-distanceL[1];
distanceR[0] = distanceR[0]-distanceL[1];
cmRight = ping_cm(pingsRight);
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
// print(" Front %d \n", cmFront, " right %d \n", cmRight, " Left %d \n", cmLeft);
while(cmLeft < DistancePrudence)
{
//il avance 1 jusqu'a ce qu'il y a plus rien a droite
cmRight = ping_cm(pingsRight); // Ping sensors
cmFront = ping_cm(pingsFront);
cmLeft = ping_cm(pingsLeft);
pause(500);
drive_speed(Minspeed, Minspeed);
}
drive_setMaxSpeed(Minspeed);
drive_goto(50, 50);
drive_getTicks(&distanceL[2], &distanceR[2]);
L1 = distanceL[2];
R1 = distanceR[2];
print("%d L1 \n %d R1 \n", L1, R1);
//il avance 1 de distance de sécurité
distanceL[0] = distanceL[1] - distanceL[1] + cos(45)*distanceL[2];
distanceR[0] = distanceR[1] - distanceR[1] + cos(45)*distanceR[2];
//il tourne 2 à droite
pause(500);
drive_goto(-23,23);
drive_getTicks(&distanceL[3], &distanceL[3]);
distanceL[3] = fabs(distanceL[3]);
distanceR[3] = fabs(distanceR[3]);
distanceL[0] = distanceL[0]-distanceL[3];
distanceR[0] = distanceR[0]-distanceR[3];
drive_setMaxSpeed(Minspeed);
//il avance 2
pause(500);
drive_goto(70, 70);
drive_getTicks(&distanceL[4], &distanceR[4]);
//il tourne 3 à droite
pause(500);
drive_goto(-23,23);
distanceL[4] = fabs(distanceL[4]);
distanceR[4] = fabs(distanceR[4]);
distanceL[0] = distanceL[0]-distanceL[4];
distanceR[0] = distanceR[0]-distanceR[4];
//il avance de la distance parcourue en avance 1
pause(500);
// drive_goto(L1, R1);
drive_getTicks(&distanceL[5], &distanceR[5]);
print("%d distanceL[5], %d distanceR[5] \n ", distanceL[5], distanceR[5]);
drive_goto(70, 70);
//il tourne 4 à gauche
pause(500);
drive_goto(23, -23);
}
}
}
}
drive_speed(0,0);
print("%d \n %d", L1, R1);
}
Comments
Also, and possibly more importantly, are you compiling this as C or C++? Check the Compiler Type option in Project Options. Since you're only using C features, make sure you are compiling it as C. If you need C++ features, you should disable exceptions ("-fno-exceptions" in compiler flags) and do a bunch of other stuff I can't remember.