Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
#include "sensors/distance/sharp/GP2.h"#include "sensors/distance/ping/PingSonar.h"#include "actuators.h"#include "servos.h"#include "sys/axon.h"#include "a2d.h"#include "uart.h"#include "rprintf.h"#include "pwm.h"// Define two servos SERVO left = MAKE_SERVO(FALSE, E3,1500, 500); SERVO right = MAKE_SERVO(FALSE , E4,1500, 500); SERVO top = MAKE_SERVO(FALSE, E2,1500, 500); SERVO bottom = MAKE_SERVO(FALSE , E1,1500, 500); // Create the list - remember to place an & at the // start of each servo name SERVO_LIST servos[] = {&left,&right, &top, &bottom}; // Create a driver for the list of servos SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(servos); Sharp_GP2D12 IR1 = MAKE_Sharp_GP2D12(ADC0); PingSonar PINGsensor = MAKE_PingSonar(F0); int IR1read; int PINGread;void away_from_wall(void){//move away from wallact_setSpeed(&left, DRIVE_SPEED_MAX);act_setSpeed(&right, DRIVE_SPEED_MAX);act_setSpeed(&top, DRIVE_SPEED_MAX);act_setSpeed(&bottom, DRIVE_SPEED_MAX);}void towards_wall(void){//move towards the wallact_setSpeed(&left, DRIVE_SPEED_MAX);act_setSpeed(&right, DRIVE_SPEED_MAX);act_setSpeed(&top, DRIVE_SPEED_MIN);act_setSpeed(&bottom, DRIVE_SPEED_MIN);}void forward(void){act_setSpeed(&left, DRIVE_SPEED_MAX);act_setSpeed(&right, DRIVE_SPEED_MIN);}void rotate(void){act_setSpeed(&left, DRIVE_SPEED_MAX);act_setSpeed(&right, DRIVE_SPEED_MAX);act_setSpeed(&top, DRIVE_SPEED_MAX);act_setSpeed(&bottom, DRIVE_SPEED_MAX);}void appInitHardware(void){ distanceInit(IR1); distanceInit(PINGsensor); }// This routine is called once to allow you to set up any other variables in your// You can use 'clock' function here.// The loopStart parameter has the current clock value in ?STICK_COUNT appInitSoftware(TICK_COUNT loopStart){return 0; // dont pause after}TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){distanceRead(IR1);IR1.distance.cm(IR1read);distanceRead(PINGsensor);PINGsensor.distance.cm(PINGread); {if (IR1read > 4) {do distanceRead(sensor); IR1.distance.cm(IR1read); away_from_wall(); while (IR1read > 4 && PINGread < 4);}} {if (IR1read < 4) {do distanceRead(sensor); IR1.distance.cm(IR1read); towards_wall(); while (IR1read < 4 && PINGread < 4);}} {if (IR1read == 4) {do distanceRead(sensor); IR1.distance.cm(IR1read); forward(); while (IR1read == 4 && PINGread < 4);}} {if (PINGread < 4) {do distanceRead(PINGsensor); PINGsensor.distance.cm(PINGread); rotate(); while (PINGread < 100);}} return (10); // wait for 1 second before calling me again. 1000000us = 1}
################################################################################ Makefile for the project omnibot_wall_follow################################################################################# General FlagsPROJECT = omnibot_wall_followMCU = atmega640TARGET = omnibot_wall_follow.elfCC = avr-gcc.exe## Options common to compile, link and assembly rulesCOMMON = -mmcu=$(MCU)## Compile options common for all C compilation units.CFLAGS = $(COMMON)CFLAGS += -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsCFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d ## Assembly specific flagsASMFLAGS = $(COMMON)ASMFLAGS += $(CFLAGS)ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2## Linker flagsLDFLAGS = $(COMMON)LDFLAGS += -Wl,-Map=omnibot_wall_follow.map## Intel Hex file production flagsHEX_FLASH_FLAGS = -R .eepromHEX_EEPROM_FLAGS = -j .eepromHEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings## Objects that must be built in order to linkOBJECTS = omnibot_wall_follow.o PingSonar.o GP2D120.o ## Objects explicitly added by the userLINKONLYOBJECTS = ## Buildall: $(TARGET) omnibot_wall_follow.hex omnibot_wall_follow.eep omnibot_wall_follow.lss size## Compileomnibot_wall_follow.o: ../omnibot_wall_follow.c $(CC) $(INCLUDES) $(CFLAGS) -c $<PingSonar.o: ../webbotavrclib-1.14a/Sensors/Distance/Ping/PingSonar.c $(CC) $(INCLUDES) $(CFLAGS) -c $<GP2D120.o: ../webbotavrclib-1.14a/Sensors/Distance/Sharp/GP2D120.c $(CC) $(INCLUDES) $(CFLAGS) -c $<##Link$(TARGET): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)%.hex: $(TARGET) avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@%.eep: $(TARGET) -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0%.lss: $(TARGET) avr-objdump -h -S $< > $@size: ${TARGET} @echo @avr-size -C --mcu=${MCU} ${TARGET}## Clean target.PHONY: cleanclean: -rm -rf $(OBJECTS) omnibot_wall_follow.elf dep/* omnibot_wall_follow.hex omnibot_wall_follow.eep omnibot_wall_follow.lss omnibot_wall_follow.map## Other dependencies-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
Build started 16.2.2010 at 09:45:18avr-gcc.exe -mmcu=atmega640 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT omnibot_wall_follow.o -MF dep/omnibot_wall_follow.o.d -c ../omnibot_wall_follow.c../omnibot_wall_follow.c:18: error: 'FLASE' undeclared here (not in a function)../omnibot_wall_follow.c: In function 'appControl':../omnibot_wall_follow.c:50: error: 'sensor' undeclared (first use in this function)../omnibot_wall_follow.c:50: error: (Each undeclared identifier is reported only once../omnibot_wall_follow.c:50: error: for each function it appears in.)../omnibot_wall_follow.c:52: error: called object 'PINGsensor.distance.cm' is not a function../omnibot_wall_follow.c:56: error: expected 'while' before 'IR1'../omnibot_wall_follow.c:57: warning: implicit declaration of function 'away_from_wall'../omnibot_wall_follow.c:63: error: expected 'while' before 'IR1'../omnibot_wall_follow.c:64: warning: implicit declaration of function 'towards_wall'../omnibot_wall_follow.c:70: error: expected 'while' before 'IR1'../omnibot_wall_follow.c:71: warning: implicit declaration of function 'forward'../omnibot_wall_follow.c:77: error: expected 'while' before 'PINGsensor'../omnibot_wall_follow.c:78: warning: implicit declaration of function 'rotate'../omnibot_wall_follow.c: At top level:../omnibot_wall_follow.c:86: warning: conflicting types for 'away_from_wall'../omnibot_wall_follow.c:57: warning: previous implicit declaration of 'away_from_wall' was here../omnibot_wall_follow.c:94: warning: conflicting types for 'towards_wall'../omnibot_wall_follow.c:64: warning: previous implicit declaration of 'towards_wall' was here../omnibot_wall_follow.c:101: warning: conflicting types for 'forward'../omnibot_wall_follow.c:71: warning: previous implicit declaration of 'forward' was here../omnibot_wall_follow.c:106: warning: conflicting types for 'rotate'../omnibot_wall_follow.c:78: warning: previous implicit declaration of 'rotate' was heremake: *** [omnibot_wall_follow.o] Error 1Build failed with 9 errors and 12 warnings...
Build started 16.2.2010 at 10:30:35avr-gcc.exe -mmcu=atmega640 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT omnibot_wall_follow.o -MF dep/omnibot_wall_follow.o.d -c ../omnibot_wall_follow.c../omnibot_wall_follow.c: In function 'appControl':../omnibot_wall_follow.c:76: error: called object 'IR1.distance.cm' is not a function../omnibot_wall_follow.c:78: error: called object 'PINGsensor.distance.cm' is not a function../omnibot_wall_follow.c:81: error: 'sensor' undeclared (first use in this function)../omnibot_wall_follow.c:81: error: (Each undeclared identifier is reported only once../omnibot_wall_follow.c:81: error: for each function it appears in.)../omnibot_wall_follow.c:82: error: expected 'while' before 'IR1'../omnibot_wall_follow.c:89: error: expected 'while' before 'IR1'../omnibot_wall_follow.c:96: error: expected 'while' before 'IR1'../omnibot_wall_follow.c:103: error: expected 'while' before 'PINGsensor'make: *** [omnibot_wall_follow.o] Error 1Build failed with 9 errors and 0 warnings...
PingSonar sensor = MAKE_PingSonar(F0);//declaredistanceInit(sensor);//initializewhile(1){distanceRead(sensor);//update value (do often)do_something_useful(sensor.distance.cm);//use the sensor value to do something useful}
Build started 16.2.2010 at 11:31:39avr-gcc.exe -mmcu=atmega640 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT omnibot_wall_follow.o -MF dep/omnibot_wall_follow.o.d -c ../omnibot_wall_follow.c../omnibot_wall_follow.c: In function 'set_integerIR1':../omnibot_wall_follow.c:33: warning: type of 'IR1read1' defaults to 'int'../omnibot_wall_follow.c: In function 'set_integerPING':../omnibot_wall_follow.c:36: warning: type of 'PINGread1' defaults to 'int'../omnibot_wall_follow.c: In function 'appControl':../omnibot_wall_follow.c:88: error: expected 'while' before 'set_integerIR1'../omnibot_wall_follow.c:95: error: expected 'while' before 'set_integerIR1'../omnibot_wall_follow.c:102: error: expected 'while' before 'set_integerIR1'../omnibot_wall_follow.c:109: error: expected 'while' before 'set_integerPING'make: *** [omnibot_wall_follow.o] Error 1
gcc plug-in: Error: Object file not found on expected location C:\Documents and Settings\Griffin\My Documents\Robo stuff\ODEE\default\omnibot_wall_follow.elf
Note: A common error you may get is"gcc plug-in: Error: Object file not found on expected location C:\Documents and Settings\User\My Documents\My_Robots\[your project name]\[your project name].elfMake sure your makefile specifies the output .elf file as [your project name].elf"If you get that error, it means you made a mistake naming your files. Start at the beginning, and read instructions more carefully.
yes I am sure. There are no spaces in the name.could someone plz download the project and try it on their pc? I really have no idea what is wrong and it might be obious once one of u try it
LIBDIRS = -L"C:\Documents and Settings\Griffin\My Documents\Robo stuff\webbotavrclib-1.14a"
void set_integerIR1(IR1read1){IR1read = IR1read1;}
I will change that filepath in the makefile for you, but I'm not sure thats the problem, but its a new thing to try
SERVO left = MAKE_SERVO(FALSE, E3,1500, 500); SERVO right = MAKE_SERVO(FALSE , E4,1500, 500); SERVO top = MAKE_SERVO(FALSE, E2,1500, 500); SERVO bottom = MAKE_SERVO(FALSE , E1,1500, 500); // Create the list - remember to place an & at the // start of each servo name SERVO_LIST servos[] = {&left,&right, &top, &bottom}; // Create a driver for the list of servos SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(servos); Sharp_GP2D12 IR1 = MAKE_Sharp_GP2D12(ADC0); PingSonar PINGsensor = MAKE_PingSonar(F0); int IR1read int PINGreadvoid set_integerIR1(int IR1read1){IR1read = IR1read1;}void set_integerPING(int PINGread1){PINGread = PINGread1; }