Revision 1802
| branches/16299_s10/Makefile (revision 1802) | ||
|---|---|---|
| 1 |
# This is the root makefile |
|
| 2 |
# |
|
| 3 |
# Make global makefile changes here |
|
| 4 |
# |
|
| 5 |
################################### |
|
| 6 |
|
|
| 7 |
# Relative path to the root directory (containing lib directory) |
|
| 8 |
ifndef COLONYROOT |
|
| 9 |
COLONYROOT := .. |
|
| 10 |
else |
|
| 11 |
COLONYROOT := ../$(COLONYROOT) |
|
| 12 |
endif |
|
| 13 |
|
|
| 14 |
# Hey Emacs, this is a -*- makefile -*- |
|
| 15 |
#---------------------------------------------------------------------------- |
|
| 16 |
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. |
|
| 17 |
# |
|
| 18 |
# Released to the Public Domain |
|
| 19 |
# |
|
| 20 |
# Additional material for this makefile was written by: |
|
| 21 |
# Peter Fleury |
|
| 22 |
# Tim Henigan |
|
| 23 |
# Colin O'Flynn |
|
| 24 |
# Reiner Patommel |
|
| 25 |
# Markus Pfaff |
|
| 26 |
# Sander Pool |
|
| 27 |
# Frederik Rouleau |
|
| 28 |
# |
|
| 29 |
#---------------------------------------------------------------------------- |
|
| 30 |
# On command line: |
|
| 31 |
# |
|
| 32 |
# make all = Make software. |
|
| 33 |
# |
|
| 34 |
# make clean = Clean out built project files. |
|
| 35 |
# |
|
| 36 |
# make coff = Convert ELF to AVR COFF. |
|
| 37 |
# |
|
| 38 |
# make extcoff = Convert ELF to AVR Extended COFF. |
|
| 39 |
# |
|
| 40 |
# make program = Download the hex file to the device, using avrdude. |
|
| 41 |
# Please customize the avrdude settings below first! |
|
| 42 |
# |
|
| 43 |
# make debug = Start either simulavr or avarice as specified for debugging, |
|
| 44 |
# with avr-gdb or avr-insight as the front end for debugging. |
|
| 45 |
# |
|
| 46 |
# make library = Build the library, then make software |
|
| 47 |
# |
|
| 48 |
# make demo = copy this directory and all subdirectories to the demos folder |
|
| 49 |
# |
|
| 50 |
# make filename.s = Just compile filename.c into the assembler code only. |
|
| 51 |
# |
|
| 52 |
# make filename.i = Create a preprocessed source file for use in submitting |
|
| 53 |
# bug reports to the GCC project. |
|
| 54 |
# |
|
| 55 |
# To rebuild project do "make clean" then "make all". |
|
| 56 |
#---------------------------------------------------------------------------- |
|
| 57 |
|
|
| 58 |
#if you want your code to work on the Firefly++ and not Firefly+ |
|
| 59 |
#then add the -DFFPP line to CDEFS |
|
| 60 |
CDEFS = |
|
| 61 |
#-DFFPP |
|
| 62 |
|
|
| 63 |
# MCU name |
|
| 64 |
MCU = atmega128 |
|
| 65 |
|
|
| 66 |
# Processor frequency. |
|
| 67 |
# This will define a symbol, F_CPU, in all source code files equal to the |
|
| 68 |
# processor frequency. You can then use this symbol in your source code to |
|
| 69 |
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done |
|
| 70 |
# automatically to create a 32-bit value in your source code. |
|
| 71 |
F_CPU = 8000000 |
|
| 72 |
|
|
| 73 |
# Output format. (can be srec, ihex, binary) |
|
| 74 |
FORMAT = ihex |
|
| 75 |
|
|
| 76 |
# List C source files here. (C dependencies are automatically generated.) |
|
| 77 |
SRC = $(wildcard *.c) |
|
| 78 |
|
|
| 79 |
# List Assembler source files here. |
|
| 80 |
# Make them always end in a capital .S. Files ending in a lowercase .s |
|
| 81 |
# will not be considered source files but generated files (assembler |
|
| 82 |
# output from the compiler), and will be deleted upon "make clean"! |
|
| 83 |
# Even though the DOS/Win* filesystem matches both .s and .S the same, |
|
| 84 |
# it will preserve the spelling of the filenames, and gcc itself does |
|
| 85 |
# care about how the name is spelled on its command-line. |
|
| 86 |
ASRC = |
|
| 87 |
|
|
| 88 |
# Optimization level, can be [0, 1, 2, 3, s]. |
|
| 89 |
# 0 = turn off optimization. s = optimize for size. |
|
| 90 |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
|
| 91 |
OPT = s |
|
| 92 |
|
|
| 93 |
# Debugging format. |
|
| 94 |
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. |
|
| 95 |
# AVR Studio 4.10 requires dwarf-2. |
|
| 96 |
# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. |
|
| 97 |
DEBUG = |
|
| 98 |
|
|
| 99 |
# Compiler flag to set the C Standard level. |
|
| 100 |
# c89 = "ANSI" C |
|
| 101 |
# gnu89 = c89 plus GCC extensions |
|
| 102 |
# c99 = ISO C99 standard (not yet fully implemented) |
|
| 103 |
# gnu99 = c99 plus GCC extensions |
|
| 104 |
CSTANDARD = -std=gnu99 |
|
| 105 |
|
|
| 106 |
# Place -D or -U options here |
|
| 107 |
CDEFS += -DF_CPU=$(F_CPU)UL |
|
| 108 |
CDEFS += -DFFP |
|
| 109 |
# for wireless library |
|
| 110 |
ifdef USE_WIRELESS |
|
| 111 |
CDEFS += -DROBOT |
|
| 112 |
endif |
|
| 113 |
|
|
| 114 |
# Place -I, -L options here |
|
| 115 |
CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly |
|
| 116 |
CINCS += -L$(COLONYROOT)/code/lib/bin |
|
| 117 |
ifdef USE_WIRELESS |
|
| 118 |
CINCS += -I$(COLONYROOT)/code/lib/include/libwireless |
|
| 119 |
endif |
|
| 120 |
|
|
| 121 |
#---------------- Compiler Options ---------------- |
|
| 122 |
# -g*: generate debugging information |
|
| 123 |
# -O*: optimization level |
|
| 124 |
# -f...: tuning, see GCC manual and avr-libc documentation |
|
| 125 |
# -Wall...: warning level |
|
| 126 |
# -Wa,...: tell GCC to pass this to the assembler. |
|
| 127 |
# -adhlns...: create assembler listing |
|
| 128 |
CFLAGS = |
|
| 129 |
# CFLAGS = -g$(DEBUG) |
|
| 130 |
CFLAGS += $(CDEFS) $(CINCS) |
|
| 131 |
CFLAGS += -O$(OPT) |
|
| 132 |
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
|
| 133 |
CFLAGS += -Wall -Wstrict-prototypes |
|
| 134 |
CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
|
| 135 |
CFLAGS += $(CSTANDARD) |
|
| 136 |
|
|
| 137 |
#---------------- Assembler Options ---------------- |
|
| 138 |
# -Wa,...: tell GCC to pass this to the assembler. |
|
| 139 |
# -ahlms: create listing |
|
| 140 |
# -gstabs: have the assembler create line number information; note that |
|
| 141 |
# for use in COFF files, additional information about filenames |
|
| 142 |
# and function names needs to be present in the assembler source |
|
| 143 |
# files -- see avr-libc docs [FIXME: not yet described there] |
|
| 144 |
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
|
| 145 |
|
|
| 146 |
|
|
| 147 |
#---------------- Library Options ---------------- |
|
| 148 |
# Minimalistic printf version |
|
| 149 |
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
|
| 150 |
|
|
| 151 |
# Floating point printf version (requires MATH_LIB = -lm below) |
|
| 152 |
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
|
| 153 |
|
|
| 154 |
# If this is left blank, then it will use the Standard printf version. |
|
| 155 |
PRINTF_LIB = |
|
| 156 |
#PRINTF_LIB = $(PRINTF_LIB_MIN) |
|
| 157 |
#PRINTF_LIB = $(PRINTF_LIB_FLOAT) |
|
| 158 |
|
|
| 159 |
|
|
| 160 |
# Minimalistic scanf version |
|
| 161 |
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
|
| 162 |
|
|
| 163 |
# Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
|
| 164 |
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
|
| 165 |
|
|
| 166 |
# If this is left blank, then it will use the Standard scanf version. |
|
| 167 |
SCANF_LIB = |
|
| 168 |
#SCANF_LIB = $(SCANF_LIB_MIN) |
|
| 169 |
#SCANF_LIB = $(SCANF_LIB_FLOAT) |
|
| 170 |
|
|
| 171 |
MATH_LIB = -lm |
|
| 172 |
|
|
| 173 |
#---------------- External Memory Options ---------------- |
|
| 174 |
|
|
| 175 |
# 64 KB of external RAM, starting after internal RAM (ATmega128!), |
|
| 176 |
# used for variables (.data/.bss) and heap (malloc()). |
|
| 177 |
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
|
| 178 |
|
|
| 179 |
# 64 KB of external RAM, starting after internal RAM (ATmega128!), |
|
| 180 |
# only used for heap (malloc()). |
|
| 181 |
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff |
|
| 182 |
|
|
| 183 |
EXTMEMOPTS = |
|
| 184 |
|
|
| 185 |
#---------------- Linker Options ---------------- |
|
| 186 |
# -Wl,...: tell GCC to pass this to linker. |
|
| 187 |
# -Map: create map file |
|
| 188 |
# --cref: add cross reference to map file |
|
| 189 |
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
|
| 190 |
LDFLAGS += $(EXTMEMOPTS) |
|
| 191 |
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
|
| 192 |
ifdef USE_WIRELESS |
|
| 193 |
LDFLAGS += -lwireless |
|
| 194 |
endif |
|
| 195 |
LDFLAGS += -ldragonfly |
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
#---------------- Programming Options (avrdude) ---------------- |
|
| 200 |
|
|
| 201 |
# Programming hardware: alf avr910 avrisp bascom bsd |
|
| 202 |
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
|
| 203 |
# |
|
| 204 |
# Type: avrdude -c ? |
|
| 205 |
# to get a full listing. |
|
| 206 |
# |
|
| 207 |
AVRDUDE_PROGRAMMER = avrisp |
|
| 208 |
|
|
| 209 |
# programmer connected to serial device |
|
| 210 |
|
|
| 211 |
AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex |
|
| 212 |
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
|
| 213 |
|
|
| 214 |
|
|
| 215 |
# Uncomment the following if you want avrdude's erase cycle counter. |
|
| 216 |
# Note that this counter needs to be initialized first using -Yn, |
|
| 217 |
# see avrdude manual. |
|
| 218 |
#AVRDUDE_ERASE_COUNTER = -y |
|
| 219 |
|
|
| 220 |
# Uncomment the following if you do /not/ wish a verification to be |
|
| 221 |
# performed after programming the device. |
|
| 222 |
#AVRDUDE_NO_VERIFY = -V |
|
| 223 |
|
|
| 224 |
# Increase verbosity level. Please use this when submitting bug |
|
| 225 |
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
|
| 226 |
# to submit bug reports. |
|
| 227 |
#AVRDUDE_VERBOSE = -v -v |
|
| 228 |
|
|
| 229 |
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
|
| 230 |
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) |
|
| 231 |
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) |
|
| 232 |
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) |
|
| 233 |
|
|
| 234 |
#don't check for device signature |
|
| 235 |
AVRDUDE_FLAGS += -F |
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
#---------------- Debugging Options ---------------- |
|
| 240 |
|
|
| 241 |
# For simulavr only - target MCU frequency. |
|
| 242 |
DEBUG_MFREQ = $(F_CPU) |
|
| 243 |
|
|
| 244 |
# Set the DEBUG_UI to either gdb or insight. |
|
| 245 |
# DEBUG_UI = gdb |
|
| 246 |
DEBUG_UI = insight |
|
| 247 |
|
|
| 248 |
# Set the debugging back-end to either avarice, simulavr. |
|
| 249 |
DEBUG_BACKEND = avarice |
|
| 250 |
#DEBUG_BACKEND = simulavr |
|
| 251 |
|
|
| 252 |
# GDB Init Filename. |
|
| 253 |
GDBINIT_FILE = __avr_gdbinit |
|
| 254 |
|
|
| 255 |
# When using avarice settings for the JTAG |
|
| 256 |
JTAG_DEV = /dev/com1 |
|
| 257 |
|
|
| 258 |
# Debugging port used to communicate between GDB / avarice / simulavr. |
|
| 259 |
DEBUG_PORT = 4242 |
|
| 260 |
|
|
| 261 |
# Debugging host used to communicate between GDB / avarice / simulavr, normally |
|
| 262 |
# just set to localhost unless doing some sort of crazy debugging when |
|
| 263 |
# avarice is running on a different computer. |
|
| 264 |
DEBUG_HOST = localhost |
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
#============================================================================ |
|
| 269 |
|
|
| 270 |
|
|
| 271 |
# Define programs and commands. |
|
| 272 |
SHELL = sh |
|
| 273 |
CC = avr-gcc |
|
| 274 |
OBJCOPY = avr-objcopy |
|
| 275 |
OBJDUMP = avr-objdump |
|
| 276 |
SIZE = avr-size |
|
| 277 |
NM = avr-nm |
|
| 278 |
AVRDUDE = avrdude |
|
| 279 |
REMOVE = rm -f |
|
| 280 |
REMOVEDIR = rm -rf |
|
| 281 |
COPY = cp |
|
| 282 |
WINSHELL = cmd |
|
| 283 |
|
|
| 284 |
|
|
| 285 |
# Define Messages |
|
| 286 |
# English |
|
| 287 |
MSG_ERRORS_NONE = Errors: none |
|
| 288 |
MSG_BEGIN = -------- begin -------- |
|
| 289 |
MSG_END = -------- end -------- |
|
| 290 |
MSG_SIZE_BEFORE = Size before: |
|
| 291 |
MSG_SIZE_AFTER = Size after: |
|
| 292 |
MSG_COFF = Converting to AVR COFF: |
|
| 293 |
MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
|
| 294 |
MSG_FLASH = Creating load file for Flash: |
|
| 295 |
MSG_EEPROM = Creating load file for EEPROM: |
|
| 296 |
MSG_EXTENDED_LISTING = Creating Extended Listing: |
|
| 297 |
MSG_SYMBOL_TABLE = Creating Symbol Table: |
|
| 298 |
MSG_LINKING = Linking: |
|
| 299 |
MSG_COMPILING = Compiling: |
|
| 300 |
MSG_ASSEMBLING = Assembling: |
|
| 301 |
MSG_CLEANING = Cleaning project: |
|
| 302 |
MSG_LIBRARY_BUILD = Building library: |
|
| 303 |
MSG_LIBRARY_CHECK = Checking if we need to rebuild the library: |
|
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
# Define all object files. |
|
| 308 |
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
|
| 309 |
|
|
| 310 |
# Define all listing files. |
|
| 311 |
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) |
|
| 312 |
|
|
| 313 |
|
|
| 314 |
# Compiler flags to generate dependency files. |
|
| 315 |
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d |
|
| 316 |
|
|
| 317 |
|
|
| 318 |
# Combine all necessary flags and optional flags. |
|
| 319 |
# Add target processor to flags. |
|
| 320 |
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) |
|
| 321 |
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
# Default target. |
|
| 328 |
all: begin gccversion lib sizebefore build sizeafter checksize end |
|
| 329 |
|
|
| 330 |
build: elf hex eep lss sym |
|
| 331 |
|
|
| 332 |
elf: $(TARGET).elf |
|
| 333 |
hex: $(TARGET).hex |
|
| 334 |
eep: $(TARGET).eep |
|
| 335 |
lss: $(TARGET).lss |
|
| 336 |
sym: $(TARGET).sym |
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
|
| 340 |
# Eye candy. |
|
| 341 |
# AVR Studio 3.x does not check make's exit code but relies on |
|
| 342 |
# the following magic strings to be generated by the compile job. |
|
| 343 |
begin: |
|
| 344 |
@echo |
|
| 345 |
@echo $(MSG_BEGIN) |
|
| 346 |
|
|
| 347 |
end: |
|
| 348 |
@echo $(MSG_END) |
|
| 349 |
@echo |
|
| 350 |
|
|
| 351 |
|
|
| 352 |
# Display size of file. |
|
| 353 |
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
|
| 354 |
ELFSIZE = $(SIZE) -A $(TARGET).elf |
|
| 355 |
AVRMEM = avr-mem.sh $(TARGET).elf $(MCU) |
|
| 356 |
|
|
| 357 |
# Check RAM size (make sure under 4 kB) |
|
| 358 |
AWK = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'gawk'; else echo 'awk'; fi) |
|
| 359 |
DATASIZE = avr-size -A main.elf | grep 'data' | $(AWK) '{ print $$2 }' > 1.tmp
|
|
| 360 |
BSSSIZE = avr-size -A main.elf | grep 'bss' | $(AWK) '{ print $$2 }' > 2.tmp
|
|
| 361 |
ADD = expr `cat 1.tmp` + `cat 2.tmp` > 3.tmp |
|
| 362 |
CLEANSIZE = rm 1.tmp 2.tmp 3.tmp |
|
| 363 |
checksize: |
|
| 364 |
@$(DATASIZE) |
|
| 365 |
@$(BSSSIZE) |
|
| 366 |
@$(ADD) |
|
| 367 |
@if test `cat 3.tmp` -gt 4096; \ |
|
| 368 |
then echo "RAM size exceeded. Make .data or .bss smaller.";echo;exit 1; \ |
|
| 369 |
else echo ".data and .bss size fine";echo; fi |
|
| 370 |
@$(CLEANSIZE) |
|
| 371 |
|
|
| 372 |
# Display size before |
|
| 373 |
sizebefore: |
|
| 374 |
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ |
|
| 375 |
$(AVRMEM) 2>/dev/null; echo; fi |
|
| 376 |
|
|
| 377 |
# Display size after |
|
| 378 |
sizeafter: |
|
| 379 |
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ |
|
| 380 |
$(AVRMEM) 2>/dev/null; echo; fi |
|
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
# Display compiler version information. |
|
| 385 |
gccversion : |
|
| 386 |
@$(CC) --version |
|
| 387 |
|
|
| 388 |
|
|
| 389 |
# Build the library |
|
| 390 |
library: |
|
| 391 |
@echo $(MSG_LIBRARY_BUILD) |
|
| 392 |
make clean -C $(COLONYROOT)/code/projects/libdragonfly |
|
| 393 |
make dist -C $(COLONYROOT)/code/projects/libdragonfly |
|
| 394 |
ifdef USE_WIRELESS |
|
| 395 |
make clean -C $(COLONYROOT)/code/projects/libwireless/lib |
|
| 396 |
make dist -C $(COLONYROOT)/code/projects/libwireless/lib |
|
| 397 |
endif |
|
| 398 |
|
|
| 399 |
# Check if library needs to be built |
|
| 400 |
lib: |
|
| 401 |
@echo $(MSG_LIBRARY_CHECK) |
|
| 402 |
make dist -C $(COLONYROOT)/code/projects/libdragonfly |
|
| 403 |
ifdef USE_WIRELESS |
|
| 404 |
make dist -C $(COLONYROOT)/code/projects/libwireless/lib |
|
| 405 |
endif |
|
| 406 |
|
|
| 407 |
|
|
| 408 |
# Program the device. |
|
| 409 |
program: $(TARGET).hex $(TARGET).eep |
|
| 410 |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
|
| 411 |
|
|
| 412 |
|
|
| 413 |
# Generate avr-gdb config/init file which does the following: |
|
| 414 |
# define the reset signal, load the target file, connect to target, and set |
|
| 415 |
# a breakpoint at main(). |
|
| 416 |
gdb-config: |
|
| 417 |
@$(REMOVE) $(GDBINIT_FILE) |
|
| 418 |
@echo define reset >> $(GDBINIT_FILE) |
|
| 419 |
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE) |
|
| 420 |
@echo end >> $(GDBINIT_FILE) |
|
| 421 |
@echo file $(TARGET).elf >> $(GDBINIT_FILE) |
|
| 422 |
@echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) |
|
| 423 |
ifeq ($(DEBUG_BACKEND),simulavr) |
|
| 424 |
@echo load >> $(GDBINIT_FILE) |
|
| 425 |
endif |
|
| 426 |
@echo break main >> $(GDBINIT_FILE) |
|
| 427 |
|
|
| 428 |
debug: gdb-config $(TARGET).elf |
|
| 429 |
ifeq ($(DEBUG_BACKEND), avarice) |
|
| 430 |
@echo Starting AVaRICE - Press enter when "waiting to connect" message displays. |
|
| 431 |
@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ |
|
| 432 |
$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) |
|
| 433 |
@$(WINSHELL) /c pause |
|
| 434 |
|
|
| 435 |
else |
|
| 436 |
@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ |
|
| 437 |
$(DEBUG_MFREQ) --port $(DEBUG_PORT) |
|
| 438 |
endif |
|
| 439 |
@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) |
|
| 440 |
|
|
| 441 |
|
|
| 442 |
|
|
| 443 |
|
|
| 444 |
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
|
| 445 |
COFFCONVERT=$(OBJCOPY) --debugging \ |
|
| 446 |
--change-section-address .data-0x800000 \ |
|
| 447 |
--change-section-address .bss-0x800000 \ |
|
| 448 |
--change-section-address .noinit-0x800000 \ |
|
| 449 |
--change-section-address .eeprom-0x810000 |
|
| 450 |
|
|
| 451 |
|
|
| 452 |
coff: $(TARGET).elf |
|
| 453 |
@echo |
|
| 454 |
@echo $(MSG_COFF) $(TARGET).cof |
|
| 455 |
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
|
| 456 |
|
|
| 457 |
|
|
| 458 |
extcoff: $(TARGET).elf |
|
| 459 |
@echo |
|
| 460 |
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
|
| 461 |
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
|
| 462 |
|
|
| 463 |
|
|
| 464 |
|
|
| 465 |
# Create final output files (.hex, .eep) from ELF output file. |
|
| 466 |
%.hex: %.elf |
|
| 467 |
@echo |
|
| 468 |
@echo $(MSG_FLASH) $@ |
|
| 469 |
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
|
| 470 |
|
|
| 471 |
%.eep: %.elf |
|
| 472 |
@echo |
|
| 473 |
@echo $(MSG_EEPROM) $@ |
|
| 474 |
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
|
| 475 |
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
|
| 476 |
|
|
| 477 |
# Create extended listing file from ELF output file. |
|
| 478 |
%.lss: %.elf |
|
| 479 |
@echo |
|
| 480 |
@echo $(MSG_EXTENDED_LISTING) $@ |
|
| 481 |
$(OBJDUMP) -h -S $< > $@ |
|
| 482 |
|
|
| 483 |
# Create a symbol table from ELF output file. |
|
| 484 |
%.sym: %.elf |
|
| 485 |
@echo |
|
| 486 |
@echo $(MSG_SYMBOL_TABLE) $@ |
|
| 487 |
$(NM) -n $< > $@ |
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
|
| 491 |
# Link: create ELF output file from object files. |
|
| 492 |
.SECONDARY : $(TARGET).elf |
|
| 493 |
.PRECIOUS : $(OBJ) |
|
| 494 |
%.elf: $(OBJ) |
|
| 495 |
@echo |
|
| 496 |
@echo $(MSG_LINKING) $@ |
|
| 497 |
$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) |
|
| 498 |
|
|
| 499 |
|
|
| 500 |
# Compile: create object files from C source files. |
|
| 501 |
%.o : %.c |
|
| 502 |
@echo |
|
| 503 |
@echo $(MSG_COMPILING) $< |
|
| 504 |
$(CC) -c $(ALL_CFLAGS) $< -o $@ |
|
| 505 |
|
|
| 506 |
|
|
| 507 |
# Compile: create assembler files from C source files. |
|
| 508 |
%.s : %.c |
|
| 509 |
$(CC) -S $(ALL_CFLAGS) $< -o $@ |
|
| 510 |
|
|
| 511 |
|
|
| 512 |
# Assemble: create object files from assembler source files. |
|
| 513 |
%.o : %.S |
|
| 514 |
@echo |
|
| 515 |
@echo $(MSG_ASSEMBLING) $< |
|
| 516 |
$(CC) -c $(ALL_ASFLAGS) $< -o $@ |
|
| 517 |
|
|
| 518 |
# Create preprocessed source for use in sending a bug report. |
|
| 519 |
%.i : %.c |
|
| 520 |
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ |
|
| 521 |
|
|
| 522 |
|
|
| 523 |
# Target: clean project. |
|
| 524 |
clean: begin clean_list end |
|
| 525 |
|
|
| 526 |
clean_list : |
|
| 527 |
@echo |
|
| 528 |
@echo $(MSG_CLEANING) |
|
| 529 |
$(REMOVE) $(TARGET).hex |
|
| 530 |
$(REMOVE) $(TARGET).eep |
|
| 531 |
$(REMOVE) $(TARGET).cof |
|
| 532 |
$(REMOVE) $(TARGET).elf |
|
| 533 |
$(REMOVE) $(TARGET).map |
|
| 534 |
$(REMOVE) $(TARGET).sym |
|
| 535 |
$(REMOVE) $(TARGET).lss |
|
| 536 |
$(REMOVE) $(OBJ) |
|
| 537 |
$(REMOVE) $(LST) |
|
| 538 |
$(REMOVE) $(SRC:.c=.s) |
|
| 539 |
$(REMOVE) $(SRC:.c=.d) |
|
| 540 |
$(REMOVEDIR) .dep |
|
| 541 |
|
|
| 542 |
|
|
| 543 |
|
|
| 544 |
# Include the dependency files. |
|
| 545 |
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) |
|
| 546 |
|
|
| 547 |
|
|
| 548 |
# Listing of phony targets. |
|
| 549 |
.PHONY : all begin finish end sizebefore sizeafter gccversion \ |
|
| 550 |
build elf hex eep lss sym coff extcoff \ |
|
| 551 |
clean clean_list program debug gdb-config |
|
| 552 |
|
|
| 553 |
# copy to demo folder |
|
| 554 |
DEMO_NAME := $(shell sh -c 'echo $${PWD\#\#*/}')
|
|
| 555 |
demo: |
|
| 556 |
@echo "Copying to demo folder..." |
|
| 557 |
@echo "$(DEMO_NAME)" |
|
| 558 |
@make clean |
|
| 559 |
@svn mkdir $(COLONYROOT)/../demos/$(DEMO_NAME) |
|
| 560 |
@svn mkdir $(COLONYROOT)/../demos/$(DEMO_NAME)/behavior |
|
| 561 |
@svn mkdir $(COLONYROOT)/../demos/$(DEMO_NAME)/projects |
|
| 562 |
@svn copy * $(COLONYROOT)/../demos/$(DEMO_NAME)/behavior/ |
|
| 563 |
@svn copy $(COLONYROOT)/code/projects/libdragonfly $(COLONYROOT)/../demos/$(DEMO_NAME)/projects/ |
|
| 564 |
@svn mkdir $(COLONYROOT)/../demos/$(DEMO_NAME)/projects/libwireless |
|
| 565 |
@svn copy $(COLONYROOT)/code/projects/libwireless/lib $(COLONYROOT)/../demos/$(DEMO_NAME)/projects/libwireless/ |
|
| 566 |
@svn copy $(COLONYROOT)/code/lib $(COLONYROOT)/../demos/$(DEMO_NAME) |
|
| 567 |
@svn copy $(COLONYROOT)/../demos/innerMakefile $(COLONYROOT)/../demos/$(DEMO_NAME)/Makefile |
|
| 568 |
@cp -f $(COLONYROOT)/../demos/dragonflyMakefile $(COLONYROOT)/../demos/$(DEMO_NAME)/projects/libdragonfly/Makefile |
|
| 569 |
@cp -f $(COLONYROOT)/../demos/wirelessMakefile $(COLONYROOT)/../demos/$(DEMO_NAME)/projects/libwireless/lib/Makefile |
|
| 570 |
@echo "Don't forget to commit your new demo folder!" |
|
| branches/16299_s10/matlab/motionModel.m (revision 1802) | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
for i=1:numRobots, |
| 15 | 15 |
|
| 16 |
wheels = inverseTransform * [v(i); omega(i)]; |
|
| 17 |
wheels = min(wheels, wheelMax); |
|
| 16 |
wheels = inverseTransform * [v(i); omega(i)]; |
|
| 17 |
wheels = min(wheels, wheelMax); |
|
| 18 | 18 |
wheels = max(wheels, wheelMin); |
| 19 | 19 |
q = transform * wheels; |
| 20 | 20 |
v(i) = q(1); |
| branches/16299_s10/code/tools/eeprom/program_eeprom.c (revision 1802) | ||
|---|---|---|
| 1 |
#include <dragonfly_lib.h> |
|
| 2 |
#include <eeprom.h> |
|
| 3 |
|
|
| 4 |
int main() |
|
| 5 |
{
|
|
| 6 |
char str[5]; |
|
| 7 |
int i=0,id; |
|
| 8 |
char c; |
|
| 9 |
|
|
| 10 |
dragonfly_init(ALL_ON); |
|
| 11 |
|
|
| 12 |
usb_puts("Here is the current setup:\r\n ID: ");
|
|
| 13 |
itoa(get_robotid(), str, 10); |
|
| 14 |
usb_puts(str); |
|
| 15 |
usb_puts("\r\n BOM type: ");
|
|
| 16 |
itoa(get_bom_type(), str, 10); |
|
| 17 |
usb_puts(str); |
|
| 18 |
usb_puts("\r\n\r\nEnter new ID:");
|
|
| 19 |
|
|
| 20 |
while((c = usb_getc()) != '\n' && c != '\r') |
|
| 21 |
{
|
|
| 22 |
usb_putc(c); |
|
| 23 |
if(i>=4) |
|
| 24 |
{
|
|
| 25 |
usb_puts("ERROR: filled buffer\n");
|
|
| 26 |
while(1); |
|
| 27 |
} |
|
| 28 |
str[i++] = c; |
|
| 29 |
} |
|
| 30 |
while(i<5) |
|
| 31 |
str[i++] = 0; |
|
| 32 |
|
|
| 33 |
id = atoi(str); |
|
| 34 |
|
|
| 35 |
usb_puts("\r\nsetting new id to: ");
|
|
| 36 |
usb_puti(id); |
|
| 37 |
|
|
| 38 |
|
|
| 39 |
eeprom_put_byte(EEPROM_ROBOT_ID_ADDR, 'I'); |
|
| 40 |
eeprom_put_byte(EEPROM_ROBOT_ID_ADDR+1, 'D'); |
|
| 41 |
eeprom_put_byte(EEPROM_ROBOT_ID_ADDR+2, id); |
|
| 42 |
|
|
| 43 |
|
|
| 44 |
usb_puts("\r\nEnter BOM type:\r\b"
|
|
| 45 |
"1 for BOM 1.0\r\n" |
|
| 46 |
"5 for BOM 1.5\r\n" |
|
| 47 |
"r for RBOM\r\n>"); |
|
| 48 |
|
|
| 49 |
c = usb_getc(); |
|
| 50 |
usb_putc(c); |
|
| 51 |
|
|
| 52 |
switch(c) |
|
| 53 |
{
|
|
| 54 |
case '1': id = BOM10; break; |
|
| 55 |
case '5': id = BOM15; break; |
|
| 56 |
case 'r': id = RBOM; break; |
|
| 57 |
default: |
|
| 58 |
usb_puts("ERROR: invalid input");
|
|
| 59 |
while(1); |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
eeprom_put_byte(EEPROM_BOM_TYPE_ADDR, 'B'); |
|
| 63 |
eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+1, 'O'); |
|
| 64 |
eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+2, 'M'); |
|
| 65 |
eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+3, id); |
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
usb_puts("\r\ndone! have a nice day\r\n");
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
while(1); |
|
| 73 |
|
|
| 74 |
return 0; |
|
| 75 |
} |
|
| 76 |
|
|
| branches/16299_s10/code/tools/eeprom/Makefile (revision 1802) | ||
|---|---|---|
| 1 |
# this is a local makefile |
|
| 2 |
|
|
| 3 |
# Relative path to the root directory (containing lib directory) |
|
| 4 |
#ifndef COLONYROOT |
|
| 5 |
COLONYROOT = .. |
|
| 6 |
|
|
| 7 |
# Target file name (without extension). |
|
| 8 |
TARGET = main |
|
| 9 |
|
|
| 10 |
# Uncomment this to use the wireless library |
|
| 11 |
#USE_WIRELESS = 1 |
|
| 12 |
|
|
| 13 |
# com1 = serial port. Use lpt1 to connect to parallel port. |
|
| 14 |
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi) |
|
| 15 |
|
|
| 16 |
#else |
|
| 17 |
COLONYROOT := ../$(COLONYROOT) |
|
| 18 |
#endif |
|
| 19 |
|
|
| 20 |
include $(COLONYROOT)/Makefile |
|
| branches/16299_s10/code/tools/rangefinders/robot/testIRcycle.c (revision 1802) | ||
|---|---|---|
| 1 |
#include <dragonfly_lib.h> |
|
| 2 |
|
|
| 3 |
int main(void) |
|
| 4 |
{
|
|
| 5 |
/* initialize components, set wireless channel */ |
|
| 6 |
dragonfly_init(ALL_ON); |
|
| 7 |
|
|
| 8 |
//Replace the next two lines with your own code |
|
| 9 |
//You can add as many lines as you want |
|
| 10 |
|
|
| 11 |
uint8_t rangeNumber[] = {IR1,IR2,IR3,IR4,IR5}; //0 indexed
|
|
| 12 |
uint8_t cIndex; |
|
| 13 |
|
|
| 14 |
//initial setup (IR1) |
|
| 15 |
cIndex=0; |
|
| 16 |
orb1_set_color(BLUE); |
|
| 17 |
orb2_set_color(GREEN); |
|
| 18 |
|
|
| 19 |
while(1) {
|
|
| 20 |
|
|
| 21 |
usb_puti(range_read_distance(rangeNumber[cIndex])); |
|
| 22 |
usb_putc('\r');
|
|
| 23 |
|
|
| 24 |
if (button1_click()) {
|
|
| 25 |
switch (cIndex){ //button1 chooses a color channel
|
|
| 26 |
case 0: //IR1 |
|
| 27 |
orb1_set_color(RED); |
|
| 28 |
orb2_set_color(RED); |
|
| 29 |
cIndex=1; |
|
| 30 |
break; |
|
| 31 |
case 1: //IR2 |
|
| 32 |
|
|
| 33 |
orb1_set_color(GREEN); |
|
| 34 |
orb2_set_color(GREEN); |
|
| 35 |
cIndex=2; |
|
| 36 |
break; |
|
| 37 |
case 2: //IR3 |
|
| 38 |
|
|
| 39 |
orb1_set_color(BLUE); |
|
| 40 |
orb2_set_color(BLUE); |
|
| 41 |
cIndex=3; |
|
| 42 |
break; |
|
| 43 |
case 3: //IR4 |
|
| 44 |
orb1_set_color(YELLOW); |
|
| 45 |
orb2_set_color(YELLOW); |
|
| 46 |
cIndex=4; |
|
| 47 |
break; |
|
| 48 |
case 4: //IR5 |
|
| 49 |
orb1_set_color(BLUE); |
|
| 50 |
orb2_set_color(GREEN); |
|
| 51 |
cIndex=0; |
|
| 52 |
break; |
|
| 53 |
default: //undefined |
|
| 54 |
return 0; |
|
| 55 |
break; |
|
| 56 |
} |
|
| 57 |
delay_ms(50); //allows button press to release |
|
| 58 |
} |
|
| 59 |
delay_ms(50); //refresh frequency: 1000/(50ms) refresh rate |
|
| 60 |
|
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
//this tell the robot to just chill out forever. don't put anything after this |
|
| 66 |
while(1); |
|
| 67 |
return 0; |
|
| 68 |
} |
|
| branches/16299_s10/code/tools/rangefinders/robot/Makefile (revision 1802) | ||
|---|---|---|
| 1 |
# this is a local makefile |
|
| 2 |
|
|
| 3 |
# Relative path to the root directory (containing lib directory) |
|
| 4 |
ifndef COLONYROOT |
|
| 5 |
COLONYROOT := .. |
|
| 6 |
|
|
| 7 |
# Target file name (without extension). |
|
| 8 |
TARGET = testIRcycle |
|
| 9 |
|
|
| 10 |
# Uncomment this to use the wireless library |
|
| 11 |
USE_WIRELESS = 1 |
|
| 12 |
|
|
| 13 |
# com1 = serial port. Use lpt1 to connect to parallel port. |
|
| 14 |
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi) |
|
| 15 |
|
|
| 16 |
else |
|
| 17 |
COLONYROOT := ../$(COLONYROOT) |
|
| 18 |
endif |
|
| 19 |
|
|
| 20 |
include $(COLONYROOT)/Makefile |
|
| branches/16299_s10/code/tools/rangefinders/Makefile (revision 1802) | ||
|---|---|---|
| 1 |
# this is a local makefile |
|
| 2 |
|
|
| 3 |
# Relative path to the root directory (containing lib directory) |
|
| 4 |
ifndef COLONYROOT |
|
| 5 |
COLONYROOT := .. |
|
| 6 |
|
|
| 7 |
# Target file name (without extension). |
|
| 8 |
TARGET = |
|
| 9 |
|
|
| 10 |
# Uncomment this to use the wireless library |
|
| 11 |
USE_WIRELESS = 1 |
|
| 12 |
|
|
| 13 |
# com1 = serial port. Use lpt1 to connect to parallel port. |
|
| 14 |
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi) |
|
| 15 |
|
|
| 16 |
else |
|
| 17 |
COLONYROOT := ../$(COLONYROOT) |
|
| 18 |
endif |
|
| 19 |
|
|
| 20 |
include $(COLONYROOT)/Makefile |
|
| branches/16299_s10/code/tools/Makefile (revision 1802) | ||
|---|---|---|
| 1 |
# this is a local makefile |
|
| 2 |
|
|
| 3 |
# Relative path to the root directory (containing lib directory) |
|
| 4 |
ifndef COLONYROOT |
|
| 5 |
COLONYROOT := .. |
|
| 6 |
|
|
| 7 |
# Target file name (without extension). |
|
| 8 |
TARGET = main |
|
| 9 |
|
|
| 10 |
# Uncomment this to use the wireless library |
|
| 11 |
USE_WIRELESS = 1 |
|
| 12 |
|
|
| 13 |
# com1 = serial port. Use lpt1 to connect to parallel port. |
|
| 14 |
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi) |
|
| 15 |
|
|
| 16 |
else |
|
| 17 |
COLONYROOT := ../$(COLONYROOT) |
|
| 18 |
endif |
|
| 19 |
|
|
| 20 |
include $(COLONYROOT)/Makefile |
|
| branches/16299_s10/code/behaviors/bfs_fsm/bfs_fsm.c (revision 1802) | ||
|---|---|---|
| 1 |
#include <dragonfly_lib.h> |
|
| 2 |
#include <wireless.h> |
|
| 3 |
#include <wl_token_ring.h> |
|
| 4 |
#include "queue.h" |
|
| 5 |
#include <string.h> |
|
| 6 |
#include "bfs_fsm.h" |
|
| 7 |
#include "smart_run_around_fsm.h" |
|
| 8 |
#include "orbit_fsm.h" |
|
| 9 |
|
|
| 10 |
/* Used to find a robot (or other object) |
|
| 11 |
|
|
| 12 |
Uses bom and token ring and rangefinders |
|
| 13 |
|
|
| 14 |
Assumes: |
|
| 15 |
robots are already in a token ring |
|
| 16 |
*/ |
|
| 17 |
|
|
| 18 |
|
|
| 19 |
/* private function prototypes */ |
|
| 20 |
void bfs_evaluate_state(void); |
|
| 21 |
int bfs_follow(void); |
|
| 22 |
|
|
| 23 |
|
|
| 24 |
/* init */ |
|
| 25 |
void bfs_init(int robot) {
|
|
| 26 |
range_init(); |
|
| 27 |
analog_init(1); |
|
| 28 |
motors_init(); |
|
| 29 |
orb_init(); |
|
| 30 |
orb_enable(); |
|
| 31 |
usb_init(); |
|
| 32 |
run_around_init(); |
|
| 33 |
|
|
| 34 |
/*Start in the start state, BFS_SEEK */ |
|
| 35 |
bfs_state = BFS_SEEK; |
|
| 36 |
|
|
| 37 |
bfs_otherRobot = robot; // set which robot to seek |
|
| 38 |
bfs_my_id = wl_get_xbee_id(); |
|
| 39 |
bfs_follow_id = -1; |
|
| 40 |
|
|
| 41 |
bfs_pControl=0; |
|
| 42 |
bfs_bom = 0; |
|
| 43 |
bfs_bom_count = 0; |
|
| 44 |
|
|
| 45 |
|
|
| 46 |
/*Initialize distances to zero.*/ |
|
| 47 |
bfs_d1=1000; bfs_d2=1000; bfs_d3=1000; bfs_d4=1000; bfs_d5=1000; |
|
| 48 |
|
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/*The main function, call this to update states as frequently as possible.*/ |
|
| 52 |
void bfs_fsm(void) {
|
|
| 53 |
|
|
| 54 |
/* reset some values */ |
|
| 55 |
bfs_speed = BFS_STRAIGHT_SPEED; |
|
| 56 |
|
|
| 57 |
/*The following lines ensure that undefined (-1) values |
|
| 58 |
will not update the distances.*/ |
|
| 59 |
int temp; |
|
| 60 |
|
|
| 61 |
wl_do(); // update wireless |
|
| 62 |
usb_puts("\n\rwl_do");
|
|
| 63 |
usb_puts("|state=");
|
|
| 64 |
usb_puti(bfs_state); |
|
| 65 |
usb_puts("|bfs_follow=");
|
|
| 66 |
usb_puti(bfs_follow_id); |
|
| 67 |
usb_puts("|");
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
if (bfs_state == BFS_SEEK) {
|
|
| 71 |
bfs_follow_id = bfs_follow(); |
|
| 72 |
wl_do(); // update wireless |
|
| 73 |
usb_puti(bfs_follow_id); |
|
| 74 |
if (bfs_follow_id != BFS_NO_VAL && bfs_follow_id < BFS_MAX_ROBOTS) {
|
|
| 75 |
bfs_state = BFS_FOLLOW; // move to follow state |
|
| 76 |
bfs_d2=1000; |
|
| 77 |
bfs_check_id=0; |
|
| 78 |
} |
|
| 79 |
} |
|
| 80 |
if (bfs_state == BFS_FOLLOW) {
|
|
| 81 |
/* check robot to follow */ |
|
| 82 |
if (++bfs_check_id > BFS_CHECK_ID_TIME) {
|
|
| 83 |
bfs_check_id=0; |
|
| 84 |
temp = bfs_follow(); |
|
| 85 |
wl_do(); |
|
| 86 |
if (temp == BFS_NO_VAL) {
|
|
| 87 |
bfs_state = BFS_SEEK; |
|
| 88 |
return; |
|
| 89 |
} else if (temp != bfs_follow_id) |
|
| 90 |
bfs_follow_id = temp; |
|
| 91 |
} |
|
| 92 |
// get bom reading |
|
| 93 |
temp = wl_token_get_my_sensor_reading(bfs_follow_id); |
|
| 94 |
if (temp == -1 || temp > 16) {
|
|
| 95 |
bfs_bom_count++; |
|
| 96 |
if (bfs_bom_count > BFS_MAX_BOM_COUNT) {
|
|
| 97 |
bfs_state = BFS_SEEK; |
|
| 98 |
bfs_bom = 255; |
|
| 99 |
bfs_bom_count = 0; |
|
| 100 |
} |
|
| 101 |
} |
|
| 102 |
else {
|
|
| 103 |
bfs_bom = temp; |
|
| 104 |
|
|
| 105 |
// modify bom reading so right is negative, left is positive |
|
| 106 |
if (bfs_bom <= 12) |
|
| 107 |
bfs_bom -= 4; |
|
| 108 |
else |
|
| 109 |
bfs_bom -= 20; |
|
| 110 |
|
|
| 111 |
bfs_pControl = bfs_bom*4; |
|
| 112 |
usb_puti(bfs_bom); |
|
| 113 |
|
|
| 114 |
|
|
| 115 |
// get range reading for front |
|
| 116 |
temp=range_read_distance(IR2); |
|
| 117 |
bfs_d2=(temp == -1) ? bfs_d2 : temp; |
|
| 118 |
usb_puti(bfs_d2); |
|
| 119 |
|
|
| 120 |
if (bfs_d2 < BFS_SLOW_DISTANCE) |
|
| 121 |
bfs_speed = BFS_SLOW_SPEED; |
|
| 122 |
|
|
| 123 |
if (bfs_d2 < BFS_ORBIT_DISTANCE) {
|
|
| 124 |
if (bfs_follow_id != bfs_otherRobot) {
|
|
| 125 |
// check if we can now see a robot that's closer to our goal |
|
| 126 |
temp = bfs_follow(); |
|
| 127 |
wl_do(); |
|
| 128 |
if (temp == BFS_NO_VAL || temp == bfs_follow_id) |
|
| 129 |
bfs_state = BFS_SEEK; |
|
| 130 |
else if (temp != bfs_follow_id) |
|
| 131 |
bfs_follow_id = temp; |
|
| 132 |
return; // redo this function in light of the state changes |
|
| 133 |
} else {
|
|
| 134 |
// orbit the robot |
|
| 135 |
bfs_state = BFS_ORBIT; // move to orbit state |
|
| 136 |
orbit_init(bfs_follow_id); |
|
| 137 |
bfs_d2=1000; |
|
| 138 |
} |
|
| 139 |
} |
|
| 140 |
} |
|
| 141 |
} |
|
| 142 |
if (bfs_state == BFS_ORBIT) {
|
|
| 143 |
usb_puts("orbiting\n");
|
|
| 144 |
orbit_state = ORBIT_INSERTION; |
|
| 145 |
while(orbit_state != ORBIT_STOP) |
|
| 146 |
{ orbit_fsm(); }
|
|
| 147 |
bfs_state = BFS_STOP; // move to stop state |
|
| 148 |
} |
|
| 149 |
if (bfs_state == BFS_STOP && bfs_follow_id != bfs_otherRobot) {
|
|
| 150 |
bfs_state = BFS_SEEK; // seek the otherRobot |
|
| 151 |
return; |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
// evaluate state |
|
| 155 |
bfs_evaluate_state(); |
|
| 156 |
} |
|
| 157 |
|
|
| 158 |
|
|
| 159 |
//Acts on state change. |
|
| 160 |
void bfs_evaluate_state(){
|
|
| 161 |
switch(bfs_state){
|
|
| 162 |
case(BFS_SEEK): orb_set_color(RED); |
|
| 163 |
// move around |
|
| 164 |
run_around_FSM(); // note: better to just incorporate into this file later one |
|
| 165 |
break; |
|
| 166 |
|
|
| 167 |
case(BFS_FOLLOW): orb_set_color(GREEN); |
|
| 168 |
// follow another robot |
|
| 169 |
move(bfs_speed,bfs_pControl); |
|
| 170 |
break; |
|
| 171 |
|
|
| 172 |
case(BFS_ORBIT): //orb_set_color(BLUE); |
|
| 173 |
// orbit a robot |
|
| 174 |
//orbit_fsm(); |
|
| 175 |
//move(0,0); |
|
| 176 |
break; |
|
| 177 |
|
|
| 178 |
case(BFS_STOP): orb_set_color(YELLOW); |
|
| 179 |
// stop |
|
| 180 |
move(0,0); |
|
| 181 |
break; |
|
| 182 |
|
|
| 183 |
default: orb_set_color(MAGENTA); |
|
| 184 |
/*Should never get here, so stop.*/ |
|
| 185 |
move(0,0); |
|
| 186 |
break; |
|
| 187 |
} |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
/* find a robot to follow using BFS |
|
| 191 |
ported from colonybfs by Felix |
|
| 192 |
*/ |
|
| 193 |
int bfs_follow() |
|
| 194 |
{
|
|
| 195 |
|
|
| 196 |
/* pseudocode for BFS |
|
| 197 |
|
|
| 198 |
procedure bfs(v) |
|
| 199 |
q := make_queue() |
|
| 200 |
enqueue(q,v) |
|
| 201 |
mark v as visited |
|
| 202 |
while q is not empty |
|
| 203 |
v = dequeue(q) |
|
| 204 |
process v |
|
| 205 |
for all unvisited vertices v' adjacent to v |
|
| 206 |
mark v' as visited |
|
| 207 |
enqueue(q,v') |
|
| 208 |
*/ |
|
| 209 |
|
|
| 210 |
Queue* q = queue_create(); |
|
| 211 |
|
|
| 212 |
//int num_current_robots = wl_token_get_robots_in_ring(); |
|
| 213 |
|
|
| 214 |
// keep track of which nodes you have visited. Indexed by robot # |
|
| 215 |
// 1 if visited, 0 if not |
|
| 216 |
unsigned char visited_nodes[BFS_MAX_ROBOTS]; |
|
| 217 |
// keep track of the distance from the start robot to other robots |
|
| 218 |
// also indexed by robot# |
|
| 219 |
unsigned char node_distances[BFS_MAX_ROBOTS]; |
|
| 220 |
// this is the path you take |
|
| 221 |
unsigned char path[BFS_MAX_ROBOTS]; |
|
| 222 |
|
|
| 223 |
//variables you will need |
|
| 224 |
unsigned char current_node; //current node |
|
| 225 |
unsigned char current_neighbour_node; //neighbor to the current node |
|
| 226 |
unsigned char current_neighbour_val; //value of that neighbour's sensors |
|
| 227 |
unsigned char current_distance; //keep track of current distance to the start |
|
| 228 |
|
|
| 229 |
unsigned char large_number = 255; |
|
| 230 |
|
|
| 231 |
unsigned char* add_value; |
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
//set visited nodes to all 0 |
|
| 236 |
memset(visited_nodes, 0, BFS_MAX_ROBOTS); |
|
| 237 |
|
|
| 238 |
//set all the distances to a very large number |
|
| 239 |
//this isn't technically necessary, but it's probably a good thing -- just in case |
|
| 240 |
memset(node_distances, large_number, BFS_MAX_ROBOTS); |
|
| 241 |
|
|
| 242 |
//set the path to all LARGE_NUMBER as well |
|
| 243 |
memset(path, BFS_NO_VAL, BFS_MAX_ROBOTS); |
|
| 244 |
|
|
| 245 |
//queue_remove_all(q); |
|
| 246 |
|
|
| 247 |
//add the start node |
|
| 248 |
add_value = (unsigned char*)malloc(sizeof(char)); |
|
| 249 |
(*add_value) = bfs_my_id; |
|
| 250 |
queue_add(q, add_value); |
|
| 251 |
visited_nodes[bfs_my_id] = 1; |
|
| 252 |
node_distances[bfs_my_id] = 0; |
|
| 253 |
|
|
| 254 |
while(!queue_is_empty(q)){
|
|
| 255 |
add_value = queue_remove(q); |
|
| 256 |
current_node = (*add_value); |
|
| 257 |
|
|
| 258 |
//get the current distance from you to the start |
|
| 259 |
current_distance = node_distances[current_node]; |
|
| 260 |
|
|
| 261 |
//this node is on your 'path' |
|
| 262 |
path[current_distance] = current_node; |
|
| 263 |
//note: it's OK if this path leads nowhere -- the path will be |
|
| 264 |
//overwritten by a node that does lead to the goal |
|
| 265 |
//(if there is no path, we set path to null anyways) |
|
| 266 |
|
|
| 267 |
//from now on, all further nodes will be one further away -- increment |
|
| 268 |
current_distance++; |
|
| 269 |
|
|
| 270 |
|
|
| 271 |
//process node -- basically check if it's the goal |
|
| 272 |
if(current_node == bfs_otherRobot) {
|
|
| 273 |
//you reach the goal |
|
| 274 |
//return the first robot in the path, which is the one |
|
| 275 |
//to follow |
|
| 276 |
/* |
|
| 277 |
lcd_putchar('.');
|
|
| 278 |
lcd_putchar('.');
|
|
| 279 |
for(i = 0; i < MAX_ROBOTS; i++) |
|
| 280 |
lcd_putchar(path[i] +48); //print out the path for fun -- remove this later |
|
| 281 |
lcd_putchar('.');
|
|
| 282 |
lcd_putchar('.');
|
|
| 283 |
*/ |
|
| 284 |
return path[1]; //path[0] is you. path[1] is who you want to follow |
|
| 285 |
} |
|
| 286 |
|
|
| 287 |
// go through all nodes adjacent to current |
|
| 288 |
// in effect, this means going through the current node's row in the matrix |
|
| 289 |
|
|
| 290 |
wl_token_iterator_begin(); |
|
| 291 |
while(wl_token_iterator_has_next()) {
|
|
| 292 |
//the robot # is actually just the index |
|
| 293 |
current_neighbour_node = wl_token_iterator_next(); |
|
| 294 |
//the value is what is stored in the matrix (this is important) |
|
| 295 |
current_neighbour_val = wl_token_get_sensor_reading(current_node,current_neighbour_node); |
|
| 296 |
|
|
| 297 |
//check for connected-ness and that it was not visited |
|
| 298 |
// unconnected visited |
|
| 299 |
if( (current_neighbour_val == BFS_NO_VAL) || (visited_nodes[current_neighbour_node]) ) {
|
|
| 300 |
//if it is either unconnected or previously visited, exit |
|
| 301 |
continue; //go to the next node |
|
| 302 |
} |
|
| 303 |
|
|
| 304 |
//update the distance from the start node to this node |
|
| 305 |
node_distances[current_neighbour_node] = current_distance; |
|
| 306 |
//also mark it as visited |
|
| 307 |
visited_nodes[current_neighbour_node] = 1; |
|
| 308 |
|
|
| 309 |
//also enqueue each neighbour |
|
| 310 |
add_value = (unsigned char*)malloc(sizeof(char)); |
|
| 311 |
(*add_value) = current_neighbour_node; |
|
| 312 |
queue_add(q, add_value); |
|
| 313 |
|
|
| 314 |
} |
|
| 315 |
} |
|
| 316 |
|
|
| 317 |
//if we get to here, there is no path |
|
| 318 |
memset(path, 0, BFS_MAX_ROBOTS); |
|
| 319 |
return BFS_NO_VAL; |
|
| 320 |
|
|
| 321 |
} |
|
| 322 |
|
|
| 323 |
|
|
| branches/16299_s10/code/behaviors/bfs_fsm/test_decoy/decoy.c (revision 1802) | ||
|---|---|---|
| 1 |
/** driver for orbit code |
|
| 2 |
sit and activate bom, let other robot orbit this |
|
| 3 |
*/ |
|
| 4 |
|
|
| 5 |
#include <dragonfly_lib.h> |
|
| 6 |
#include <wireless.h> |
|
| 7 |
#include <wl_token_ring.h> |
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
int main(void) {
|
|
| 12 |
// enable everything |
|
| 13 |
dragonfly_init(ALL_ON); |
|
| 14 |
orb_enable(); |
|
| 15 |
orb_init(); |
|
| 16 |
orb_set_color(PURPLE); |
|
| 17 |
wl_init(); |
|
| 18 |
wl_set_channel(0xF); |
|
| 19 |
wl_token_ring_register(); |
|
| 20 |
wl_token_ring_join(); // join token ring |
|
| 21 |
usb_init(); |
|
| 22 |
usb_puts("start");
|
|
| 23 |
usb_puti(wl_get_xbee_id()); |
|
| 24 |
|
|
| 25 |
|
|
| 26 |
while(1) {
|
|
| 27 |
wl_do(); /* do wireless */ |
|
| 28 |
} |
|
| 29 |
|
|
| 30 |
orb_set_color(RED); |
|
| 31 |
usb_puts("end");
|
|
| 32 |
|
|
| 33 |
return 0; |
|
| 34 |
} |
|
| branches/16299_s10/code/behaviors/bfs_fsm/test_decoy/Makefile (revision 1802) | ||
|---|---|---|
| 1 |
# this is a local makefile |
|
| 2 |
|
|
| 3 |
# Relative path to the root directory (containing lib directory) |
|
| 4 |
ifndef COLONYROOT |
|
| 5 |
COLONYROOT := .. |
|
| 6 |
|
|
| 7 |
# Target file name (without extension). |
|
| 8 |
TARGET = main |
|
| 9 |
|
|
| 10 |
# Uncomment this to use the wireless library |
|
| 11 |
USE_WIRELESS = 1 |
|
| 12 |
|
|
| 13 |
# com1 = serial port. Use lpt1 to connect to parallel port. |
|
| 14 |
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi) |
|
| 15 |
|
|
| 16 |
else |
|
| 17 |
COLONYROOT := ../$(COLONYROOT) |
|
| 18 |
endif |
|
| 19 |
|
|
| 20 |
include $(COLONYROOT)/Makefile |
|
| branches/16299_s10/code/behaviors/bfs_fsm/bfs_fsm.h (revision 1802) | ||
|---|---|---|
| 1 |
// BFS FSM header file |
|
| 2 |
|
|
| 3 |
|
|
| 4 |
#ifndef _BFS_FSM_H_ |
|
| 5 |
#define _BFS_FSM_H_ |
|
| 6 |
|
|
| 7 |
//The States: |
|
| 8 |
#define BFS_SEEK 12 //do run around |
|
| 9 |
#define BFS_FOLLOW 13 //follow other robots to location |
|
| 10 |
#define BFS_ORBIT 15 //Orbit robot |
|
| 11 |
#define BFS_STOP 16 //Stop. The default and ending state |
|
| 12 |
|
|
| 13 |
|
|
| 14 |
#define BFS_STRAIGHT_SPEED 170 |
|
| 15 |
|
|
| 16 |
#define BFS_SLOW_DISTANCE 250 |
|
| 17 |
#define BFS_SLOW_SPEED 160 |
|
| 18 |
|
|
| 19 |
#define BFS_ORBIT_DISTANCE 175 /* distance to start orbit around robot */ |
|
| 20 |
|
|
| 21 |
#define BFS_STOP_DISTANCE 120 /* distance to stop for object */ |
|
| 22 |
|
|
| 23 |
#define BFS_MAX_ROBOTS 20 /* max id of robot in project */ |
|
| 24 |
|
|
| 25 |
#define BFS_NO_VAL 255 |
|
| 26 |
|
|
| 27 |
#define BFS_CHECK_ID_TIME 100 |
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
int bfs_state; /*State machine variable.*/ |
|
| 32 |
int bfs_speed; |
|
| 33 |
|
|
| 34 |
int bfs_otherRobot; /* the robot we are seeking */ |
|
| 35 |
int bfs_my_id; /* my wireless id */ |
|
| 36 |
int bfs_follow_id; /* robot to follow */ |
|
| 37 |
int bfs_check_id; /* timer to check robot id to follow */ |
|
| 38 |
|
|
| 39 |
|
|
| 40 |
int bfs_pControl; /*Proportional control variable, determines turn direction.*/ |
|
| 41 |
int bfs_d1,bfs_d2,bfs_d3,bfs_d4,bfs_d5; /*The five distances taken in by IR.*/ |
|
| 42 |
int bfs_bom; /* bom data */ |
|
| 43 |
int bfs_bom_count; |
|
| 44 |
|
|
| 45 |
#define BFS_MAX_BOM_COUNT 5 /* number of missing bom packets before reverting to seek state */ |
|
| 46 |
|
|
| 47 |
/* bfs_init |
|
| 48 |
argument: robot_id that you want to find |
|
| 49 |
notes: must call before bfs_fsm |
|
| 50 |
*/ |
|
| 51 |
void bfs_init(int robot); |
|
| 52 |
|
|
| 53 |
|
|
| 54 |
/* bfs_fsm |
|
| 55 |
argument: none |
|
| 56 |
notes: call in a while loop to perform FSM action |
|
| 57 |
*/ |
|
| 58 |
void bfs_fsm(void); |
|
| 59 |
|
|
| 60 |
#endif |
|
| branches/16299_s10/code/behaviors/bfs_fsm/orbit_fsm.c (revision 1802) | ||
|---|---|---|
| 1 |
#include <dragonfly_lib.h> |
|
| 2 |
#include <wireless.h> |
|
| 3 |
#include <wl_token_ring.h> |
|
| 4 |
#include "orbit_fsm.h" |
|
| 5 |
#include "bfs_fsm.h" |
|
| 6 |
|
|
| 7 |
/* Used to orbit a robot |
|
| 8 |
|
|
| 9 |
Must be within BOM range of robot before activating |
|
| 10 |
|
|
| 11 |
orbit_theta_stop requires encoders, and is incomplete |
|
| 12 |
|
|
| 13 |
Assumes: |
|
| 14 |
both robots are already in a token ring |
|
| 15 |
*/ |
|
| 16 |
|
|
| 17 |
|
|
| 18 |
/* private function prototype */ |
|
| 19 |
void orbit_evaluate_state(void); |
|
| 20 |
|
|
| 21 |
|
|
| 22 |
/* primary init */ |
|
| 23 |
void orbit_init(int robot) {
|
|
| 24 |
//range_init(); |
|
| 25 |
//analog_init(1); |
|
| 26 |
//motors_init(); |
|
| 27 |
//orb_init(); |
|
| 28 |
//orb_enable(); |
|
| 29 |
//usb_init(); |
|
| 30 |
|
|
| 31 |
/*Start in the start state, ORBIT_SEEK */ |
|
| 32 |
orbit_state = ORBIT_INSERTION; |
|
| 33 |
|
|
| 34 |
orbit_otherRobot = robot; // set which robot to seek and orbit |
|
| 35 |
|
|
| 36 |
orbit_pControl=0; |
|
| 37 |
orbit_bom = bfs_bom; |
|
| 38 |
orbit_theta = 0; |
|
| 39 |
orbit_theta_stop = 1000; |
|
| 40 |
|
|
| 41 |
/*Initialize distances to zero.*/ |
|
| 42 |
orbit_d1=1000; orbit_d2=1000; orbit_d3=1000; orbit_d4=1000; orbit_d5=1000; |
|
| 43 |
|
|
| 44 |
} |
|
| 45 |
/* secondary init */ |
|
| 46 |
void orbit_init_theta(int robot,int theta) {
|
|
| 47 |
//range_init(); |
|
| 48 |
//analog_init(1); |
|
| 49 |
//motors_init(); |
|
| 50 |
//orb_init(); |
|
| 51 |
//orb_enable(); |
|
| 52 |
//usb_init(); |
|
| 53 |
|
|
| 54 |
/*Start in the start state, ORBIT_INSERTION */ |
|
| 55 |
orbit_state = ORBIT_INSERTION; |
|
| 56 |
|
|
| 57 |
orbit_otherRobot = robot; // set which robot to seek and orbit |
|
| 58 |
|
|
| 59 |
orbit_pControl=0; |
|
| 60 |
orbit_bom = bfs_bom; |
|
| 61 |
orbit_theta = 0; |
|
| 62 |
orbit_theta_stop = (theta>0)?theta:-1; // check theta_stop |
|
| 63 |
|
|
| 64 |
/*Initialize distances to zero.*/ |
|
| 65 |
orbit_d1=1000; orbit_d2=1000; orbit_d3=1000; orbit_d4=1000; orbit_d5=1000; |
|
| 66 |
|
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
/*The main function, call this to update states as frequently as possible.*/ |
|
| 70 |
void orbit_fsm(void) {
|
|
| 71 |
|
|
| 72 |
/*The following lines ensure that undefined (-1) values |
|
| 73 |
will not update the distances.*/ |
|
| 74 |
int temp; |
|
| 75 |
|
|
| 76 |
//temp=range_read_distance(IR1); |
|
| 77 |
//orbit_d1=(temp == -1) ? orbit_d1 : temp; |
|
| 78 |
|
|
| 79 |
temp=range_read_distance(IR2); |
|
| 80 |
orbit_d2=(temp == -1) ? orbit_d2 : temp; |
|
| 81 |
|
|
| 82 |
//temp=range_read_distance(IR3); |
|
| 83 |
//orbit_d3=(temp == -1) ? orbit_d3 : temp; |
|
| 84 |
|
|
| 85 |
//temp=range_read_distance(IR4); |
|
| 86 |
//orbit_d4=(temp == -1) ? orbit_d4 : temp; |
|
| 87 |
|
|
| 88 |
//temp=range_read_distance(IR5); |
|
| 89 |
//orbit_d5=(temp == -1) ? orbit_d5 : temp; |
|
| 90 |
|
|
| 91 |
wl_do(); // update wireless |
|
| 92 |
|
|
| 93 |
// get bom reading |
|
| 94 |
temp = wl_token_get_my_sensor_reading(orbit_otherRobot); |
|
| 95 |
orbit_bom = (temp == -1) ? orbit_bom : temp; |
|
| 96 |
|
|
| 97 |
// modify bom reading so right is negative, left is positive |
|
| 98 |
if (orbit_bom <= 12) |
|
| 99 |
orbit_bom -= 4; |
|
| 100 |
else |
|
| 101 |
orbit_bom -= 20; |
|
| 102 |
|
|
| 103 |
|
|
| 104 |
if (orbit_state == ORBIT_SEEK && orbit_d2 < ORBIT_DISTANCE) |
|
| 105 |
orbit_state = ORBIT_INSERTION; // begin to orbit |
|
| 106 |
if (orbit_state == ORBIT_INSERTION && |
|
| 107 |
(orbit_bom == ORBIT_DIRECTION || (orbit_bom + 1) == ORBIT_DIRECTION || (orbit_bom - 1) == ORBIT_DIRECTION)) |
|
| 108 |
orbit_state = ORBIT_ORBITING; // orbit achieved |
|
| 109 |
if (orbit_state == ORBIT_ORBITING && ((orbit_d2 < ORBIT_STOP_DISTANCE) |
|
| 110 |
|| (orbit_theta >= orbit_theta_stop))) |
|
| 111 |
orbit_state = ORBIT_STOP; // orbit obstructed |
|
| 112 |
|
|
| 113 |
// evaluate state |
|
| 114 |
orbit_evaluate_state(); |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
|
|
| 118 |
//Acts on state change. |
|
| 119 |
void orbit_evaluate_state(){
|
|
| 120 |
switch(orbit_state){
|
|
| 121 |
case(ORBIT_SEEK): orb_set_color(RED); |
|
| 122 |
// move towards robot |
|
| 123 |
orbit_pControl = orbit_bom*10; |
|
| 124 |
move(ORBIT_STRAIGHT_SPEED,orbit_pControl); |
|
| 125 |
break; |
|
| 126 |
|
|
| 127 |
case(ORBIT_INSERTION): orb_set_color(GREEN); |
|
| 128 |
// rotate into orbit, perpendicular to other robot |
|
| 129 |
orbit_pControl = -ORBIT_DIRECTION*10; |
|
| 130 |
move(ORBIT_STRAIGHT_SPEED/2,orbit_pControl); |
|
| 131 |
break; |
|
| 132 |
|
|
| 133 |
case(ORBIT_ORBITING): orb_set_color(BLUE); |
|
| 134 |
// go straight with slight rotation |
|
| 135 |
if (orbit_bom == ORBIT_DIRECTION) |
|
| 136 |
orbit_pControl = ORBIT_DIRECTION; |
|
| 137 |
else if (orbit_bom < ORBIT_DIRECTION) |
|
| 138 |
orbit_pControl = ORBIT_DIRECTION-ORBIT_CORRECTION; |
|
| 139 |
else |
|
| 140 |
orbit_pControl = ORBIT_DIRECTION+ORBIT_CORRECTION; |
|
| 141 |
|
|
| 142 |
move(ORBIT_STRAIGHT_SPEED,orbit_pControl); |
|
| 143 |
break; |
|
| 144 |
|
|
| 145 |
case(ORBIT_STOP): orb_set_color(YELLOW); |
|
| 146 |
move(0,0); |
|
| 147 |
break; |
|
| 148 |
|
|
| 149 |
default: orb_set_color(YELLOW); |
|
| 150 |
/*Should never get here, so stop.*/ |
|
| 151 |
move(0,0); |
|
| 152 |
break; |
|
| 153 |
} |
|
| 154 |
} |
|
| 155 |
|
|
| 156 |
|
|
Also available in: Unified diff