Shop OBEX P1 Docs P2 Docs Learn Events
Boe-bot for arduino roaming with ping on servo turret — Parallax Forums

Boe-bot for arduino roaming with ping on servo turret

S_FlexS_Flex Posts: 3
edited 2013-02-15 06:07 in General Discussion
I have been trying to find out why the boe-bot jacks the turret to the left and starts turning in circles to the left. When the boe-bot encounters a corner. If I put an object in front of the sensor while its in its retard turn it snaps out of it and starts to move around like normal. Knowing C++ fairly well I can see in the sketch the author may have had a major lack of concentration because I see a lot of first grader mistakes and "WTF's?".

The bot has all fresh batteries, connections to the circuit are fine and everything works.

I know its programing.

Here is a link to the sketch:
http://learn.parallax.com/project/let-it-roam

I could point out a mass of issues with the sketch but I wanted to see what you all think.

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2013-02-13 08:07
    It looks like there's a minor bug with this line of code:

    const int elements = sizeof(sequence);

    It should be

    const int elements sizeof(sequence) / sizeof(int);

    But that shouldn't cause the problem you describe which is likely in the findOpening function. I imagine it does what you've seen because the greatest free space is always to the left. When you put an object in the path it snaps out of that mode and starts going straight.
  • Mike GMike G Posts: 2,702
    edited 2013-02-13 09:18
    The best obstacle avoidance robot I ever built had a bad solder joint on a sonic sensor. The bot would stop randomly and look around and change direction for no particular reason. This little bit of randomness stopped the bot from oscillating in a corner or getting stuck under a table.
  • S_FlexS_Flex Posts: 3
    edited 2013-02-14 05:30
    Let me point out a few things about the code.

    1) The code does not use any C++ Best Practices!
    2) The documentation does not explain what the code actually does.
    3) The code is overly complex for the simple tasks it has to do.
    4) There is no proper support or CVS for this code

    I don't want to rip into parallax to much even though its to easy for this issue. It is extremely disappointing to see a product named "Board of Education" and find a code like this associated with it.

    In the arduino tutorial for the maneuver() function please explain what a negative one to delay() will do! No that isn't part of this issue, but a big part of not understanding what was programed.

    I'm not sorry if I was to blatantly honest, but if this company wants to make money please rethink what your doing and remember the customer can make or brake you!
  • Mike GMike G Posts: 2,702
    edited 2013-02-14 05:56
    I checked out the code and read this in the code comments.
     * IMPORTANT: This is an early revision.  Please check back periodically, 
     * and if you find any bugs, please email me at alindsay@parallax.com.
    

    Did you send an email?
  • S_FlexS_Flex Posts: 3
    edited 2013-02-14 13:21
    Mike G wrote: »
    I checked out the code and read this in the code comments.
     * IMPORTANT: This is an early revision.  Please check back periodically, 
     * and if you find any bugs, please email me at alindsay@parallax.com.
    

    Did you send an email?
    But "Andy Lindsay" is a moderator of this forum. This is the company that the product came from. Most people would think to post on the forum before email some one that may or may not still work for the company. Also if you noticed in my first post I conveyed serious doubt of the authors competence.

    I just wanted to point out a few things that people will look for if you ever think about using C++.

    After dealing with this issue I personally have no confidence in parallax and its community. I don't care if you fix the code or clean it up, it doesn't matter anymore. I'm over it!
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2013-02-14 14:19
    @S_Flex welcome to the forums!

    I think you are judging Andy Lindsay a bit harshly by forming your opinion over one piece of code. Andy and Stephanie have created a mountainous body of sound educational materials for the Propeller over the years, all of which is solid material. Instead of posting public criticism which doesn't really solve the issues, avail yourself of the provided email address and report the issues which you feel are problematic. You'll find Andy to be inviting of the exchange and you'll help others who may come behind you with improvements and perhaps better code. All of the employees are approachable and happy to solve issues.

    Jeff
  • dgatelydgately Posts: 1,630
    edited 2013-02-14 17:10
    S_Flex wrote: »
    Let me point out a few things about the code.

    1) The code does not use any C++ Best Practices!
    2) The documentation does not explain what the code actually does.
    3) The code is overly complex for the simple tasks it has to do.
    4) There is no proper support or CVS for this code

    I don't want to rip into parallax to much even though its to easy for this issue. It is extremely disappointing to see a product named "Board of Education" and find a code like this associated with it.

    In the arduino tutorial for the maneuver() function please explain what a negative one to delay() will do! No that isn't part of this issue, but a big part of not understanding what was programed.

    I'm not sorry if I was to blatantly honest, but if this company wants to make money please rethink what your doing and remember the customer can make or brake you!

    1) The code does not use any C++ Best Practices!
    Looking for something else?
    See the libraries page for interfacing with particular types of hardware. Try the list of community-contributed code. The Arduino language is based on C/C++. It links against AVR Libc and allows the use of any of its functions; see its user manual for details.

    So, Arduino sketches are not really C/C++. The Arduino documentation webpages provide many sketch examples and the Roaming_with_Ping_on_Servo_Turret code follows typical examples as documented. Remember, this is example code to be used as a starting point for further development. This is NOT production-quality code (and it is documented as an early revision, at that).

    2) The documentation does not explain what the code actually does.
    Yes, seems that a paragraph or two of what actions the robot should attempt would really help. But, the code itself is well documented...

    Examples:
    [INDENT]/*[/INDENT]
    [INDENT] * Control BOE Shield-Bot servo direction, speed, set and forget version.[/INDENT]
    [INDENT] * Parameters: speedLeft - left servo speed[/INDENT]
    [INDENT] *             speedRight - right servo speed[/INDENT]
    [INDENT] *             Backward  Linear  Stop  Linear   Forward[/INDENT]
    [INDENT] *             -200      -100......0......100       200[/INDENT]
    [INDENT] */ [/INDENT]
    [INDENT]void maneuver(int speedLeft, int speedRight)[/INDENT]
    
    [INDENT]/*[/INDENT]
    [INDENT] * Initiate and capture Ping))) Ultrasonic Distance Sensor's round trip echo time.[/INDENT]
    [INDENT] * Parameter: pin - Digital I/O pin connected to Ping)))[/INDENT]
    [INDENT] * Returns:   duration - The echo time in microseconds [/INDENT]
    [INDENT] * Source:    Ping by David A. Mellis, located in File -> Examples -> Sensors[/INDENT]
    [INDENT] * To-Do:     Double check timing against datasheet[/INDENT]
    [INDENT] */ [/INDENT]
    [INDENT]long ping(int pin)[/INDENT]
    

    3) The code is overly complex for the simple tasks it has to do.
    Well, code complexity is "in the eye of the beholder", I guess... Do you have some suggestions for how the code could be simplified? I'm sure we'd all be interested in your review.


    4) There is no proper support or CVS for this code.
    Good suggestion for future example code. A git/cvs repository for example code as well as for the OBEX would be a welcome support feature!


    And, although not a direct answer to "please explain what a negative one to delay() will do", the following expresses what "-1" signifies to the maneuver(int,int,int) method. BTW: delay(int milliseconds) is an Ardiuino library method which is described at: http://arduino.cc/en/Reference/Delay. You may want to wander-over to the Arduino forums to ask what a negative parameter would mean for delay(). The delay() parameter is documented as an "unsigned int" so a "-1" could represent a very long delay...
    [LEFT][INDENT][COLOR=#333333][FONT=Verdana][URL]http://learn.parallax.com/ManeuverFunction[/URL]
    
    The rules for [FONT=Courier New][B]msTime [/B][/FONT]are:[/FONT][/COLOR][/INDENT]
    [INDENT]• Positive values for the number of ms to execute the maneuver
    • –1 to disable the servo signal
    
    [/INDENT]
    [INDENT][COLOR=#333333][FONT=Verdana]Here is what calls to this function will look like for the familiar forward-backward-left-right-stop sequence:[/FONT][/COLOR]
    
    maneuver(200, 200, 2000);           // Forward 2 seconds
    ...
    maneuver(0, 0, -1);                      // Disable servos[/INDENT]
    [/LEFT]
    
    
    
    
    

    You've made some valid points and it would be great to have them addressed! But I think you've been a bit harsh on Parallax support. Perhaps you just needed to vent a bit...

    dgately
  • Martin_HMartin_H Posts: 4,051
    edited 2013-02-15 06:07
    dgately wrote: »
    So, Arduino sketches are not really C/C++.

    That's really a bit of marketing talk. Arduino sketches really are C++ and the tool chain works fine with C++ code, as well as third party robotics class libraries.

    However, I agree the original poster was being a bit hard on Andy and Parallax. I would always prefer to have code I can improve now versus the promise of perfect code in the future. Besides, the BOE Shield is a hardware solution to allow the Arduino to be used with a BOE-bot. It doesn't require the use of Andy's code, and there's tons of Arduino, Ping))), and servo samples out there.
Sign In or Register to comment.