I am attaching two bloxter programs to this message.
a. This program causes the 'bot to drive forward to within a certain distance of an object and then stop. If the object gets too close, the GoPiGo backs away from it. If the object moves away, the GoPiGo moves forward until it is a certain distance away again.
b. The “eyes” color indicate status:
White is the initial state while it’s setting itself up and waiting to start.
Green is “moving forward”
Blue is “moving backward”
Red is “stopped”.
a. This program uses logic from the first program to move toward an object and, when it gets within a certain distance it stops, looks to the right and left to find an “escape route”, and when it finds it it turns in that direction, centers the servo, and continues moving until it confronts another object.
When I try the second program, it fails to run and reports that “Local Variable ‘gpg’ referenced before assignment” (See attached .jpg)
- Where? I don’t see anything that tells me at what part of the program it stopped. I suspect it’s early on because the color of the “eyes” doesn’t change.
This may be related to two possible “bugs” I discovered while using the advanced bloxter editor:
- Once a variable is created, it cannot be deleted even if you select “delete variable” with it selected in the left-hand tools pane.
- Having created a function, you cannot delete it if you need to change it for some reason. (i.e. You need to change it to a function that returns a value, etc.) Likewise, you cannot change the type of function (i.e. change it from one that returns a value, or dosen’t, to the other.)
Avoid_Object-1.blox.txt (11.0 KB)
Distance_Sensor_Test.blox.txt (4.6 KB)