|
Explore TEAMS!
|
Student /
MatthewFrykenbergsCode/*Matthew Frykenberg Wimp mode lab*/ // Include the Command Module API
// Pointer to the Sensor Data structure cr8_t *cr8; // Main function uint8_t safe(void); int main(void) { // Allocate memory for sensor data structure cr8 = cr8_alloc(); // Initialize the Create and Command Module // Sync communications settings. cr8_init(cr8); // Start Robot Code Here // | // \|/ //while safe {
cr8_set_leds(1,1,255,255);
cr8_delay(20);
cr8_update(cr8);
if(cr8->dist_mm!=0)
{
while(cr8->bumper_right==0 && cr8->bumper_left==0 && cr8->dist_mm<560)
{
cr8_drive_direct(500,500);
cr8_delay(20);
cr8_update(cr8);
}
cr8_drive_direct(0,0);
cr8->dist_mm=0;
cr8_delay(20);
cr8_update(cr8);
}
if(cr8->bumper_right==1)
{
cr8_drive_direct(-100,100);
cr8_set_leds(1,0,255,255);
cr8_delay(20);
cr8_update(cr8);
if(cr8->bumper_right==0 && cr8->bumper_left==0)
{
cr8_update(cr8);
while(cr8->bumper_right==0 && cr8->bumper_left==0 && cr8->angle<90)
{
cr8_drive_direct(-100,100);
cr8_delay(20);
cr8_update(cr8);
}
cr8->dist_mm=0;
cr8_delay(20);
cr8_update(cr8);
while(cr8->bumper_right==0 && cr8->bumper_left==0 && cr8->dist_mm<560)
{
cr8_drive_direct(500,500);
cr8_delay(20);
cr8_update(cr8);
}
cr8_drive_direct(0,0);
cr8->dist_mm=0;
cr8->angle=0;
cr8_delay(20);
cr8_update(cr8);
}
}
if(cr8->bumper_left==1)
{
cr8_drive_direct(100,-100);
cr8_set_leds(0,1,255,255);
cr8_delay(20);
cr8_update(cr8);
if(cr8->bumper_right==0 && cr8->bumper_left==0)
{
cr8_update(cr8);
while(cr8->bumper_right==0 && cr8->bumper_left==0 && cr8->angle<90)
{
cr8_drive_direct(100,-100);
cr8_delay(20);
cr8_update(cr8);
}
cr8->dist_mm=0;
cr8_delay(20);
cr8_update(cr8);
while(cr8->bumper_right==0 && cr8->bumper_left==0 && cr8->dist_mm<560)
{
cr8_drive_direct(500,500);
cr8_delay(20);
cr8_update(cr8);
}
cr8_drive_direct(0,0);
cr8->dist_mm=0;
cr8->angle=0;
cr8_delay(20);
cr8_update(cr8);
}
}
}
// release the sensor data strucutre memory and exit the program
cr8_free(cr8);
return 0;
uint8_t safe(void) { cr8_update(cr8);
// Check for unsafe conditions:
// Wheel Drops
// Cliff Detection
if(cr8->wheeldrop_left || cr8->wheeldrop_right ||
cr8->wheeldrop_caster ||
cr8->cliff_right || cr8->cliff_left ||
cr8->cliff_frontright || cr8->cliff_frontleft)
{
cr8_drive_direct(0,0);
cr8_beep_error();
cr8_set_leds(off,off,255,255);
return 0;
}
else {
// No unsafe conditions found
return 1;
}}
} Make All: > "make.exe" all begin -------- avr-gcc (GCC) 4.1.2 (WinAVR 20070525) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiling C: main.c avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=18432000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=obj/main.lst -std=gnu99 -Wundef -MD -MP -MF .dep/main.o.d main.c -o obj/main.o Linking: main.elf avr-gcc -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=18432000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=obj/create.o -std=gnu99 -Wundef -MD -MP -MF .dep/main.elf.d obj/create.o obj/main.o --output main.elf -Wl,-Map=main.map,--cref -lm Creating load file for Flash: main.hex avr-objcopy -O ihex -R .eeprom main.elf main.hex Creating load file for EEPROM: main.eep avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex main.elf main.eep c:\WinAVR-20070525\bin\avr-objcopy.exe: there are no sections to be copied! c:\WinAVR-20070525\bin\avr-objcopy.exe: --change-section-lma .eeprom=0x00000000 never used make.exe: [main.eep] Error 1 (ignored) Creating Extended Listing: main.lss avr-objdump -h -S main.elf > main.lss Creating Symbol Table: main.sym avr-nm -n main.elf > main.sym Size after: main.elf : section size addr .data 6 8388864 .text 5882 0 .bss 18 8388870 .stab 888 0 .stabstr 113 0 .debug_aranges 64 0 .debug_pubnames 758 0 .debug_info 5265 0 .debug_abbrev 803 0 .debug_line 4635 0 .debug_frame 544 0 .debug_str 1577 0 .debug_loc 943 0 Total 21496 end -------- > Process Exit Code: 0 > Time Taken: 00:03 Make Program: > "make.exe" program Creating load file for EEPROM: main.eep avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex main.elf main.eep c:\WinAVR-20070525\bin\avr-objcopy.exe: there are no sections to be copied! c:\WinAVR-20070525\bin\avr-objcopy.exe: --change-section-lma .eeprom=0x00000000 never used make.exe: [main.eep] Error 1 (ignored) avrdude -p atmega168 -P com4 -c stk500 -U flash:w:main.hex avrdude: successfully opened stk500v1 device -- please use -c stk500v1 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.05s avrdude: Device signature = 0x1e9406 avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "main.hex" avrdude: input file main.hex auto detected as Intel Hex avrdude: writing flash (5888 bytes): Writing | ################################################## | 100% 2.22s avrdude: 5888 bytes of flash written avrdude: verifying flash memory against main.hex: avrdude: load data flash data from input file main.hex: avrdude: input file main.hex auto detected as Intel Hex avrdude: input file main.hex contains 5888 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 1.98s avrdude: verifying ... avrdude: 5888 bytes of flash verified avrdude done. Thank you. > Process Exit Code: 0 > Time Taken: 00:09 |