Shop OBEX P1 Docs P2 Docs Learn Events
Peguin program error — Parallax Forums

Peguin program error

InteractInteract Posts: 79
edited 2007-08-31 19:19 in Robotics
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

Comments

  • David CarrierDavid Carrier Posts: 294
    edited 2007-08-24 23:37
    Robert,
    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
  • InteractInteract Posts: 79
    edited 2007-08-25 16:27
    Yes, well, working on a few things:
    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
  • GrievousfishGrievousfish Posts: 54
    edited 2007-08-27 17:14
    Thanks for the code fixes!

    Code is always welcome!

    smilewinkgrin.gif
  • MinimumWageMinimumWage Posts: 72
    edited 2007-08-31 19:19
    Hi all,

    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:
    ReadLDR:
      RCTIME 0, 1, RightLDR                       ' Read R/C time for each
      HIGH 0                                     ' photoresitor then recharge
                                                 ' their capacitors
      RCTIME 1, 1, LeftLDR
      HIGH 1
    RETURN
    

    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
Sign In or Register to comment.