Peguin program error
There is a error in the Penguin sample code. (Penguin-AutonomousNavigation & Penguin - Migrate North)
I noticed it when I was adding a "stand still and waddle" ability as a response.
In the:
'
[noparse][[/noparse] Memory initialization ]
section.
there is a line :
PUT DataOffset, Word NewTiltValue, Word Word_1
That should read:
PUT DataOffset, Word NewStrideValue, Word NewTiltValue
The error put the wrong values for stepcenter and tiltcenter into mem. These values are never used in the program so it didn't cause a problem. But I needed them for the waddle.
Robert
Post Edited (Interact) : 8/24/2007 10:27:35 PM GMT
I noticed it when I was adding a "stand still and waddle" ability as a response.
In the:
'
[noparse][[/noparse] Memory initialization ]
section.
there is a line :
PUT DataOffset, Word NewTiltValue, Word Word_1
That should read:
PUT DataOffset, Word NewStrideValue, Word NewTiltValue
The error put the wrong values for stepcenter and tiltcenter into mem. These values are never used in the program so it didn't cause a problem. But I needed them for the waddle.
Robert
Post Edited (Interact) : 8/24/2007 10:27:35 PM GMT
Comments
Good catch; I think the error occurred when I was switching between the Word_x variables and the aliases, like NewTiltValue, that are used for readability. I should never have been using the Word_x variables anywhere in the program. You also helped me notice that, in a similar manner, lines 135 and 136 should be changed from:
IF Word_1 > 2500 OR NewStrideValue < 1250 THEN END
IF Word_0 > 2500 OR NewTiltValue < 1250 THEN END
to:
IF NewStrideValue > 2500 OR NewStrideValue < 1250 THEN END
IF NewTiltValue > 2500 OR NewTiltValue < 1250 THEN END
I think I accidentally swapped NewStrideValue and NewTiltValue while I was writing the code, and remnants of that error were still there. It would have been a lot easier to catch if I weren't using Word_0 and Word_1 in the first place. Sometimes the most difficult step when writing a new program is deciding on variable names that are short, concise, and easy to differentiate; the worst thing you can do is just use numbers.
It is good to know that you are working with the code I wrote for the Penguin. I had written it with hopes that it would be easily integrated into new code.
I am in the process of documenting how the Penguin's code works and how to add to it. Unfortunately I have not been able to dedicate too much time to it recently, but if you have any comments, bugs, or questions in the meantime, feel free to post them on this forum, and I will get to them as soon as I can.
Thank you,
David Carrier
The "Stand still and waddle" was to help decide which way to turn when encountering an object. The sensors on the head move left and right of the object during the "waddle".
Also getting the feet to slow down at the ends of their stroke, and faster in mid-step, so there is less jerking. And I found I needed the feet a little higher off the ground to walk better, and by getting the tilt and stride to slow down before changing directions, this didn't cause any undo wiggle/flop/jerk.
Also got a little dance going - stand on one foot while kicking the other etc. [noparse]:)[/noparse]
Robert
Code is always welcome!
I found another small error last night playing around with the sample code for testing the penguin sensors. In the Penguin-PhotoresistorTest.bpx program the left and right·variables are reversed in the ReadLDR subroutine. If you want the correct left/right values to display in the debug window you need to change the RCTIME statements so that Pin 0 corresponds to the right detector, and Pin 1 to the left, like so:
There are also some pin and variable declarations in the program header that appear to be carried over from the Penguin-IRTest.bpx program. They could probably be removed to make the code more readable if you wanted.
Regards,
Mike