ROBOTC.net forums
http://robotc.net/forums/

Obstacle Course issues, please help.
http://robotc.net/forums/viewtopic.php?f=1&t=5037
Page 1 of 1

Author:  jbeagan [ Fri Oct 26, 2012 2:06 pm ]
Post subject:  Obstacle Course issues, please help.

Good afternoon. First time using RobotC and I have some grade 8 students that are doing the Obstacle Course challenge. They have successfully written the code to make the robot move to the first "wall", use the touch senor to back up, turn and begin to use the light sensor to complet the line following behavior. They used "time" as a variable to program the robot to stop at the end of the line but it does not seem to work at all.

Does anyone know of a way, or the code, to simultaneously run a time component during line following.

Thank you very much.

I appreciate it

Josh

Author:  magicode [ Fri Oct 26, 2012 2:17 pm ]
Post subject:  Re: Obstacle Course issues, please help.

Can you explain a little bit more about what you mean by "simultaneously run a time component during line following"? Perhapse you're thinking of timers: http://www.robotc.net/wiki/NXT_Functions_Timing

Author:  jbeagan [ Fri Oct 26, 2012 3:04 pm ]
Post subject:  Re: Obstacle Course issues, please help.

Thank you for replying. So the students are making the robot follow the line and they naturally want it to stop at the end of the line so they can continue the program. When it does not stop it ends up doing a 180 and then gets back on the line and follows it to the start. So they decided to time it and came up with 95000Msec (1min 30 sec) and then use the timer program. They are having issues with the timer program.

Thanks again.

Author:  MHTS [ Fri Oct 26, 2012 3:20 pm ]
Post subject:  Re: Obstacle Course issues, please help.

Is this what you are looking for?
Code:
void FollowLine(long time)
{
    time1[T1] = 0;
    while (time1[T1] < time)
    {
        int lightValue = SensorValue[lightSensor];
        if (lightValue < THRESHOLD)
        {
            //turn left
        }
        else if (lightValue > THRESHOLD)
        {
            //turn right
        }
        else
        {
            //go straight
        }
        wait1Msec(50);
    }
}

The problem I see with this is that timing is not precise. So you could stop prematurely or could have reached the end of the line then turn around starting to head to start before time runs out.

Author:  magicode [ Fri Oct 26, 2012 3:24 pm ]
Post subject:  Re: Obstacle Course issues, please help.

EDIT: The documentation says (well it says contradictory things really, but I'm going with what makes more sense) that the timer values are longs not ints, so the 95,000 milliseconds shouldn't be a problem.

Author:  MHTS [ Fri Oct 26, 2012 3:26 pm ]
Post subject:  Re: Obstacle Course issues, please help.

magicode wrote:
Since the maximum number values that the timer can count without overflowing is 32,768, using time1[timer] will not let you count to 95,000 milliseconds. There are a few ways to fix this, but using time10[timer] and counting to 9,500 seems to be the simplest way to me.

According to the documentation (http://www.robotc.net/wiki/NXT_Functions_Timing), time1 is returning long, so it is a lot more than 32K.

Author:  magicode [ Fri Oct 26, 2012 4:16 pm ]
Post subject:  Re: Obstacle Course issues, please help.anyhting

Well, I was looking at that as well, since it seemed wrong to me, but the text said signed int. It's probably a long as that's what the function prototype says. so I'll edit my post above to reflect that.

Author:  jbeagan [ Sat Oct 27, 2012 1:01 pm ]
Post subject:  Re: Obstacle Course issues, please help.

I will try both this weekend and have the kids try it on Monday. I will get back to you early next week.

Again, thank you for your input and responses. I really appreciate it.

Josh

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/