Program a follower

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

Program a follower

Postby Londi » Sun Apr 27, 2014 4:35 pm

Hi guys,
How can i program a follower (Lego Car, that follows my remote controll)?
I think, the IR Code CENTRE/BEACON is the best for it...

Sorry for my bad english
User avatar
Londi
New User
 
Posts: 17
Joined: Sun Mar 23, 2014 12:22 am

Re: Program a follower

Postby lawrie » Sun Apr 27, 2014 8:59 pm

1. Create two regulated motors called left and right (or use Motor.A and Motor.B)
2. Create an EV3IRsensor and create a SensorMode called seek by calling getSeekMode().
3. Create a float[] sample for seek.
4. In a loop call fetchSample and if sample[0] < 0 move the right motor forward. If it is > 0, move the left motor forward. Stop the other motor.

I just tried this and it works. I will post the code if you want.

There seems to be a problem with seek mode that you cannot tell the difference between no beacon detected and the beacon directly in front.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Program a follower

Postby gloomyandy » Sun Apr 27, 2014 9:21 pm

Can you differentiate between no beacon and one in front by looking at the distance value? Each sample set contains 8 values (2 each for each of the possible beacon channels), one is the "direction" to the beacon the other is the distance.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4112
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Program a follower

Postby lawrie » Sun Apr 27, 2014 10:24 pm

OK, so a value of 128 means that no beacon is detected. So if direction is zero and distance (sample[1]) is 128 stop both motors, else set both motors to forward.

I should also have said that if you use sample[0] and sample[1], you should set the channel to 1, i.e. red slider to the top.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff