Shop OBEX P1 Docs P2 Docs Learn Events
New Penguin code — Parallax Forums

New Penguin code

David CarrierDavid Carrier Posts: 294
edited 2012-02-16 05:53 in Robotics
A new version of the Penguin code, 1.1, will be released soon. I am attaching a preliminary release of the autonomous navigation and servo calibrating programs. I still need to do some final checking, then I will port all changes to the compass versions of the Penguin code.
To use this code you will need to run Preliminary-Penguin-ServoCalibration-v1.1.bpx and calibrate the servos again. I rearranged some of the constants in EEPROM to simplify the program. There are also more settings stored in EEPROM. You can now adjust the stride and tilt angles as well as the tilting and stepping speed. This does increase the program length by a marginal amount, but RAM usage has not increased. By adjusting the step and tilt speeds independently, the Penguin can be programed to walk smoother and run faster.
Most of the enhancements are in the servo calibration program itself. The menu has been expended and is now easier to use. Because of its larger size, the text of the menu is now stored in a separate program slot and a separate file. Preliminary-Penguin-Menu-v1.1.bpx must be in the same directory as Preliminary-Penguin-ServoCalibration-v1.1.bpx in order to run the calibration program. Some of the menu options and shortcut keys have change to be more intuitive, and settings can be adjusted while the the Penguin is walking.
I have also changed some of the variable names in Preliminary-Penguin-AutonomousNavigation-v1.1.bpx, so some modifications might break , but program flow should be easier to understand.
I always welcome comments, criticisms, and requests, but even though everything is considered, I cannot implement everything everyone wants. My goal is to provide the most features and controls possible, then allow everyone else to write there own navigation code and remove whatever they are not using.

Let me know what you think,
David Carrier

P.S. If there is enough interest and I have enough time, I could write a simple program that will run through a list of movements and commands that are stored in EEPROM. I have noticed that robot dancing seems to be very popular, and the Penguin could easily have every movement synchronized to a particular song. Also, NewStrideValue and NewTiltValue can be changed simultaneously to create more complex movements.

Comments

  • InteractInteract Posts: 79
    edited 2007-09-15 18:19
    File Attached is the latest.
    ·
    Ok, I tried your new code and the Penguin still gets stuck and hits object etc.
    I had posted this a while back . And my penguin now can negotiate a kitchen full of 20 coffee cups (8" or more apart) all night with out getting stuck or hitting them. I even got it to go through a maze trying to go north. although the maze needed the walls to be far enough apart so the guy could turn around.. The key was to get it to back up while turning and then walk away from that spot before testing for the lighter direction again.
    All this additional function takes up LESS memory.
    ·
    Improvements to the Move routine:
    ·
    It saves 102 bytes of· EEPROM space, and eliminates 4 , word length variables. This is about one third the size. ·No there is no down side to this, walking is still just as hilarious as it always was. Basically instead of trying to integrate the remainder of signed division slowly into the move., It just adds one smaller pulse at the end of the step or tilt, making for a possible improvement of a softer landing, depending stride distance etc. The only down side is that if you use a speed of 1 (Really too fast) it will still use two steps of time. Other than that a speed of fifteen will now be the same as a speed of fourteen.
    This is a drop-in to the sample code. If you use the move routine as-is in your own programs it will copy-paste in with no problems.
    ·
    Improvments to the Sensor Procesing and additional movements added.
    ·
    ' Additional functions have been added to the penguin. It can now move in 6 directions:
    ' Forward, Forward-Left, Forward-Right, Backwards, Backwards-Left AND Backwards-Right.
    ' The penguin now makes much better decisions and sticks to them. Since it can now turn
    ' left or right while backing up, its object avoidance has been greatly improved.
    ' The penguin now takes several steps to avoid an object while ignoring the light but not the IR.
    ‘ It tends to not get stuck trying to figure out where to go and what to do. There is a step counter that is used for
    ' events, in this case it chirps after 11 unblocked steps. The step counter can be used
    ' for many other creative events like "stop an waddle" after 15 then play a song after 20 etc.
    ' The penguin will try to go toward the light. if it needs to turn to accomplish this,
    ' it will turn while still moving forward and indicate a “1” for a right turn and a 2 for
    ' a left turn decision on the LED display. IF the penguin makes it 11 steps without encountering
    ' an object in its way, it will chirp, and continue.
    ' if an object is in its way, It will indicate this on the LED (as before) and it will
    ' back-away left, or back-away right from the object, depending on which side the object is on.
    ' If the object is directly in front of it, then it will back-away so the penguin is
    ' facing the lighter direction.
    ·

    Maby you could integrate some of this with the EEPROM mods you have done?
    ·
    Link to Move: subroutine disscusion - http://forums.parallax.com/showthread.php?p=670670


    Post Edited (Interact) : 9/16/2007 12:28:52 AM GMT
  • InteractInteract Posts: 79
    edited 2007-09-18 16:38
    I did forget to mention an important addition to the above code.·( ·Penguin-AutonomousNavigation_NEW.bpx ) The movements now take into account which foot is already forward. This improved the smoothness of the transitions from one direction to another. Also routines for moving to a “feet together straight up” and a basic “waddle” are in there, as he does take a rest after walking for a while. All the movements that are in a forward direction are in one subroutine and the movements that are in the backwards direction are in another. I had it coded in one routine but it really came out quite a bit larger, and the logic for this choice was already done in the calling loop. I couldn’t think of a situation where the logic wouldn’t already have been done, so I kept them separate.
  • HumanoidoHumanoido Posts: 5,770
    edited 2007-09-18 17:12
    David, how would you synchronize the steps to music?
    Your code is remarkable. You have the most amazing
    skill and talent in creating the smooth motion engine.
    I would like you to continue using your talent to make
    a more compact program, with the motion code only.

    humanoido
  • fredobedofredobedo Posts: 4
    edited 2012-02-12 12:56
    Hello!

    I took out my old penguin and I install the code "Penguin-AutonomousNavigation_NEW". This is by far the best program to move the penguin but I have a little problem:

    Despite several attempts to calibrate the servos, the servo to "tilt" only moves left. I have to change the position of the servo arm so that the robot walks approximately well.

    During the calibration, however, if I walk the penguin, the servo moves correctly from right to left.

    I have no problem with other programs like "Penguin-AutonomousNavigation-v1.1, v1.2 and v1.3.

    This is unfortunate because "Penguin-AutonomousNavigation_NEW" works really well!

    What's going on?

    Sorry for my little English from a translator!

    Thank you!
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-02-15 06:45
    fredobedo: Interact is the person to answer this question as he is the modifier of the program. However, he has not posted on the Parallax Forum for 3 years and is not active and will probably not see this post. That leaves the option of troubleshooting the program if you really want to make it work. As a first step, I suggest going back to the original program by David Carrier and see if you can get that working. Then go from there. Keep in mind there are now earlier version Penguins and newer Penguins that have differences. Which version do you have?
  • fredobedofredobedo Posts: 4
    edited 2012-02-15 10:02
    Humanoido wrote: »
    fredobedo: Interact is the person to answer this question as he is the modifier of the program. However, he has not posted on the Parallax Forum for 3 years and is not active and will probably not see this post. That leaves the option of troubleshooting the program if you really want to make it work. As a first step, I suggest going back to the original program by David Carrier and see if you can get that working. Then go from there. Keep in mind there are now earlier version Penguins and newer Penguins that have differences. Which version do you have?

    Hello Humanoido ! Thanks for your answer!

    This post is very old indeed I know!

    As mentioned in my post, other programs from David Carrier work fine .

    When I calibrate the servos with the program above, everything went very well, walking too.

    I write the value into the EEPROM, but when I load and then launches the "Penguin-AutonomousNavigation_NEW.bpx", the robot is not able to walk because the Sevo "tilt" only works one way :/

    I believe strongly in a problem reading or writing of stored value, but my poor skills do not allow me to check these values​​ :/

    I think it's just a little mistake , so some help would be welcome :D This program is great and I am surprised that the routines were not used in the V1.3 from David ,with the original program the robot is often stuck!

    Oh I forgot, my penguin is the first released.

    Thanks you !
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-02-16 05:53
    fredobedo wrote: »
    ...the servo to "tilt" only moves left. I have no problem with other programs like "Penguin-AutonomousNavigation-v1.1, v1.2 and v1.3.

    First and foremost, put new batteries in Penguin.

    Make sure everthing mechanical is consistent and not binding with the power off.

    If the anomaly persists, it could be due to the modified program,
    but as you say, it could be related to the storage or non storage of a variable.

    So the code in question could involve the tilt right routines.

    Does any part of the failed program do a proper tilt to the right?
    Check the routines for main, walk forward, walk backward, and move.

    These are some variables and constants to start checking in the program...
    TiltRange      CON     240
    TiltRight      CON     DataOffset + 10
    OldTiltValue   VAR     Word_3                ' Main , Move
    Word NewTiltValue - TiltRange      ' TiltRight
    

    Also run the program that allows comparison between two
    programs to show the changes and study the differences for a lead.
Sign In or Register to comment.