Robocup Soccer

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

Robocup Soccer

Postby ChrisB01 » Tue Mar 18, 2008 5:19 pm

Has anyone used the NXT and lejos to enter robocup junior soccer competitions. I’ve used it twice and came 2nd and it seams to work very well the only problem is the size restrictions of 18cm diameter and 22cm height.

Thanks
ChrisB01
Advanced Member
 
Posts: 189
Joined: Sat Mar 15, 2008 12:19 pm
Location: UK

hi

Postby chika_E » Wed Mar 19, 2008 5:41 pm

Hi do you have some code about robocup or follow ir ball to help me??? i want to do nxt for robocup and i dont understand so much in lejos for nxt, i programmed for lejos RCX but is new for me the NXT java program :S i hope you can help me ... please... answer me!!
chika_E
New User
 
Posts: 2
Joined: Wed Mar 07, 2007 3:32 am

Postby ChrisB01 » Fri Mar 21, 2008 4:50 pm

To play robocup with the ir ball the basic principle is to spin around on the spot until you see the ball then go forward. You can pick up the balls light using a normal light sensor. To make your program accurate you have to have a calibration phase. I normally draw the light reading on the screen and then move the ball as far away as possible while it’s still registering then take a reading and store that in a variable. Then you check if the light reading you’re getting when you’re playing is above or equal to this value and that’s how you find the ball.

This some sample code that should do the job:

import lejos.nxt.*;

public class tinyRobocup {

static LightSensor LSensor = new LightSensor(SensorPort.S1);
// Change S1 to the sensor port your using

static int lowLightValue = 0;
// The varible to hold the calabrated light value

public static void main(String[] args) {
calabrate();
play();
}

static void calabrate() {
while (Button.ESCAPE.isPressed() == false && lowLightValue == 0) {
// Loop while escape isnt pressed and you havent calabrated lowLightValue
LCD.clear();
LCD.drawInt(LSensor.readNormalizedValue(),0,0);
if (Button.ENTER.isPressed() == true) {
lowLightValue = LSensor.readNormalizedValue();
}
}
}

static void play() {
while (Button.ESCAPE.isPressed() == false) { // Play while the escape button isnt pressed
if (LSensor.readNormalizedValue() < lowLightValue) { // Can I see the ball?
// Spin to find the ball
} else { // I can see it!
// Go forward
}
}
}
}
ChrisB01
Advanced Member
 
Posts: 189
Joined: Sat Mar 15, 2008 12:19 pm
Location: UK

Postby Xpyd3r » Mon Mar 24, 2008 12:59 pm

Yea, for the past 3 years I have been working with an Incompetent domineering and worst of all always wrong teammate. So this year I'm working alone, and almost done with both robots by myself and i have about 3 weeks to program an offense and defense program haha, defense being the complex one of the two, but I'm hoping I retained enough java from my course last year to write it, and hoping that lejos is pretty reliable and simple to use, haha. So yea, good luck man! btw where are you competing?
Xpyd3r
Novice
 
Posts: 50
Joined: Tue Aug 07, 2007 5:58 am


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 10 guests

more stuff