View unanswered posts | View active topics It is currently Sun Apr 20, 2014 5:20 pm






Reply to topic  [ 8 posts ] 
Obstacle Course issues, please help. 
Author Message
Rookie

Joined: Fri Oct 26, 2012 2:01 pm
Posts: 6
Post 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


Fri Oct 26, 2012 2:06 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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

_________________
sudo rm -rf /


Fri Oct 26, 2012 2:17 pm
Profile
Rookie

Joined: Fri Oct 26, 2012 2:01 pm
Posts: 6
Post 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.


Fri Oct 26, 2012 3:04 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1343
Post 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.


Fri Oct 26, 2012 3:20 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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.

_________________
sudo rm -rf /


Fri Oct 26, 2012 3:24 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1343
Post 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.


Fri Oct 26, 2012 3:26 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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.

_________________
sudo rm -rf /


Fri Oct 26, 2012 4:16 pm
Profile
Rookie

Joined: Fri Oct 26, 2012 2:01 pm
Posts: 6
Post 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


Sat Oct 27, 2012 1:01 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.