Boe-Bot navigation algorithm
kingbp
Posts: 22
Hello I'm working on an navigation project with the Boe-Bot right now, I store all the paths that are taken in memory so I'm creating a replacement rules algorithm and Im trying to create certain conditions to replace paths stored in an array. I'm my algorithm there are 3 Directions stored in the array at a time. So if I have the 3 paths LUL in memory which stands for Left-U_Turn-Left, I want to chop off LUL and add S which stands for straight. I keep getting an error In the if statement for LUL it basic stamp editor keeps saying it was expecting an operator. Also I don't my turns(3) representing 3 chracters in the array can be done in pbasic can anyone give me an example of how i can fix my IF statement thanks!!
IF (turns(3) == "LUL") 'Look at the right three characters in the array
ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S
turns(ptr) = "S" 'Add the turn we should have taken (AND will take NEXT time) on to the array.
ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array.
IF (turns(3) == "LUL") 'Look at the right three characters in the array
ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S
turns(ptr) = "S" 'Add the turn we should have taken (AND will take NEXT time) on to the array.
ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array.
Comments
It looks like your program is written in something other than Stamp Basic and you're trying to convert it. Keep in mind that there's very limited variable storage on the Stamp (26 bytes to be exact) and arrays are limited to that. Often there's room in the program EEPROM to store tables containing things like path lists. If you replace your BS2 with something like a BS2pe, you'd have lots of room, but you'd want to store the paths as encoded binary values, maybe as lists of 2 bit values with 4 per byte or 8 per 16-bit word or something like that. Main problem is that you have to be careful not to write to the same location in EEPROM too often since EEPROM locations can be worn out from too many write cycles (around 100000 can do it sometimes).