Robot Bumper System

This is a discussion on Robot Bumper System within the C Programming forums, part of the General Programming Boards category; In my design class we have to build a functional robot. This robot must navigate the course by light sensors. ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    3

    Robot Bumper System

    In my design class we have to build a functional robot. This robot must navigate the course by light sensors. I am having an issue writting the code for the bumper system though. I've become pretty confused and could use some guidance. We were provided with the skeleton of the code, but filling in the missing pieces is proving to be a challenge. Any help is greatly appreciated. BTW: I am using high tide to write my program.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,676
    You couldn't have been much less specific if you tried. We have no code, no hardware description (I assume PIC?), no schematics, no description of how the bumper system is supposed to work and no description of how the bumper system is currently working incorrectly or not working at all. We're going to need lots more good, specific information to help you, so lets see it.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ummmmmmmmmmmmm.... ERRRRRRRRRRRRR.....ARGGGGGGGGGGGGG....

    Nope... crystal ball just isn't connecting....

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    position = getcurrentposition();
    if( position == lastposition && isdriving() )
    {
        /* we ran into something */
        reversedirection();
    }
    else
    {
        lastposition = position;
    }
    There. You didn't actually care if you smash into something right? What's the point of even having a bumper if you can't use it to bump into things?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    > reversedirection();

    Why not left or right ?

    Reverse would result in going to and forth between two obstacles, whereas left/right would make it able to navigate a 2d maze , without other controls .
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by manasij7479 View Post
    > reversedirection();

    Why not left or right ?

    Reverse would result in going to and forth between two obstacles, whereas left/right would make it able to navigate a 2d maze , without other controls .
    It depends if they have tank treads or not. A tank can independently control its treads, and while basically sitting still, can turn in a circle.

    A car can't.

    Also, it depends what they get stuck on:
    Code:
    ___
    |^
    If the car is the caret, and you drive right up to the corner, a left turn grinds you up against the corner, and a right turn backing up also runs you into the wall.


    Quzah.
    Last edited by quzah; 10-07-2011 at 05:08 PM.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    Quote Originally Posted by quzah View Post
    A car can't.
    Oh.. didn't consider that.

    Also, it depends what they get stuck on.
    Aren't the sensors supposed to stop it from making foolish decisions about which way to turn ?
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by manasij7479 View Post
    Aren't the sensors supposed to stop it from making foolish decisions about which way to turn ?
    Your guess is as good as mine.


    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    3

    bumper program

    hey, sorry for lack of information. I'm really knew to programming so this is all a bit hazy for me. I am operating on a  
    PIC16F877A microprocessor. The skeleton of the code:

    Code:
    
    
    void interrupt isr (void)
    // This function will be automatically called upon an interrupt
    { if (save_data ( ) ==0)
    // If interrupt was caused by real time clock, return. If
    {return;}
    // interrupt was caused by bumper, save function variables
    // being used by main() so they can be restored upon returning // from interrupt.
    pause (5);
    // Pause 5 msec to allow for bumper switch contact bounce
    if ((PORTB & 0x01) == 1)
    // Confirm valid bumper interrupt
    { INTF = 0; restore_data ( );
    //Restore function variables used in main()
    return; } output_low ('c', 0);
    //STOP the Motors! Iíve bumped into something.
    output_low ('c', 5); output_low ('c', 3); output_low ('c', 4); pause (50);
    //Always allow some time (50ms) for the motors to stop
    /*YOUR CODE GOES HERE - I.e., Check which bumper(s) hit and take evasive motor action. SEE IMPORTANT NOTES BELOW */
    if ((PORTB & 0x01) == 1)
    // If all bumpers have cleared their obstacles
    { INTF = 0;
    // Clear interrupt flag bit
    } restore_data ( );
    //Restore function variables used in main()
    return;
    }

    Photo of the pic board:
    Attachment 10976


    I'm not asking for you guys to completely write this program for me. I want to learn how to do this myself but would really appreciate some guidance. I have no programming experience so all imput would be great! so far i've figured out how to make the robot move and how to program led lights to blink. I'm stuck here on the bumpers though.

  10. #10
    Registered User
    Join Date
    Oct 2011
    Posts
    3
    the purpose of the bumpers is for the robot to be able to navigate through a course. For example: if the left bumper were to be hit, i'd want the robot to stop, reverse a bit, spin to the right, and continue forward. i've been attempting to figure this out for a few days now but have gotten nowhere

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I assume you have some code to make it go, or to make specific wheels get power or turn or the like? If not, get that first, so you can turn and drive. Once you can turn and drive, then you can figure out what bumper to check or trigger, and turn in response to bumper hits.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I, Robot -- It's a trick, and I'm mad.
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 07-15-2004, 02:57 PM
  2. Robot Programming?
    By Yaj in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-19-2002, 12:42 PM
  3. Bumper Stickers
    By MethodMan in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 06-19-2002, 11:41 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21