Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,650 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,170 people online right now. Registration is fast and FREE... Join Now!




Going to Uni

 
Reply to this topicStart new topic

Going to Uni

sms123
post 13 Sep, 2008 - 01:37 AM
Post #1


D.I.C Head

**
Joined: 15 Aug, 2008
Posts: 54


My Contributions


hey guys, i am going to Sheffield uni on the 21st to do a Mcomp in computer science, and i have just got a pack from the department, and it says that as an introductory exercise, we will be making football playing robots out of lego, but instead of using lego's language, they use Java. there are some introductory exercises they want me to do just thought i would share them with you lol.

//note i dont need help with this btw, just showing you guys lol
Motor b controls left wheel, motor c controls right wheel
Motors can rotate up to 999 (degrees per second)
to set speed - Motor.B.setSpeed(50); //rotates wheel at 50d/s
to set direction - Motor.B.forward(); // or Motor.B.backward();

then it asks;
write statements to make the robot
1.)move slowly backwards
2.)turn gradually to the right
3.)turn gradually to the left
4.)Spin rapidly on the spot

then it goes on to say
//writing short hand, its a long para
robot has 2 distance sensors = leftDistanceSensor + rightDistanceSensor
if robot is closer to object on left, turn right visa versa
write script to achieve this

robot has touch sensor on front = touchSensor
isPressed() returns true if touching something
write script to make robot reverse if hits obstacle

ultrasonic distance sensor is not accurate (be noisy cause of electrical interference) how would you deal with this?
int distance = distanceSensor.getDistance();

i think this will be fun hahahha, but i think they will get a bit annoyed if i make my robot like the ones you see on Robot Wars lol with axes and flippers lol
User is offlineProfile CardPM

Go to the top of the page

abgorn
post 13 Sep, 2008 - 01:55 AM
Post #2


Hello Crap for Brains

Group Icon
Joined: 5 Jun, 2008
Posts: 863



Thanked 4 times

Dream Kudos: 25
My Contributions


Lol, do you actually have to make a physical lego robot?
User is online!Profile CardPM

Go to the top of the page

sms123
post 13 Sep, 2008 - 02:02 AM
Post #3


D.I.C Head

**
Joined: 15 Aug, 2008
Posts: 54


My Contributions


QUOTE(abgorn @ 13 Sep, 2008 - 02:55 AM) *

Lol, do you actually have to make a physical lego robot?

lol i guess so, i loved lego when i was a kid lol
heres what i have done, what do you think;
//btw not sure what to do about the last one, the one about interference, was thinking, using two sensors???
CODE

Ex1
(i)
Motor.B.setSpeed(25);
Motor.C.setSpeed(25);
Motor.B.backward();
Motor.C.backward();

(ii)
Motor.B.stop();
Motor.C.setSpeed(25);
Motor.C.forward();

(iii)
Motor.C.stop();
Motor.B.setSpeed(25);
Motor.B.forward();

(iv)
Motor.B.setSpeed(999);
Motor.B.forward();
Motor.C.setSpeed(999);
Motor.C.backward();

Ex2

int leftDist;
int rightDist;
boolean tooClose = false;
do{
    if((leftDist<10)||(rightDist<10)){
        if((leftDist<2)&&(rightDist<2)){
            Motor.B.setSpeed(25);
            Motor.C.setSpeed(25);
            Motor.B.backward();
            Motor.C.backward();
            tooClose = true;
        }
        if(leftDist<rightDist){
            Motor.c.stop();
            Motor.B.setSpeed(100);
            Motor.B.forward();
        }else{
            Motor.c.stop();
            Motor.B.setSpeed(100);
            Motor.B.forward();
        }
    }
}while(!tooClose);

Ex3

boolean hasntHit = true;
do{
    if(touchSensor.isPressed){
        Motor.B.setSpeed(25);
        Motor.C.setSpeed(25);
        Motor.B.backward();
        Motor.C.backward();
        hasntHit = false;
    }
}while(hasntHit);
User is offlineProfile CardPM

Go to the top of the page

abgorn
post 13 Sep, 2008 - 02:56 AM
Post #4


Hello Crap for Brains

Group Icon
Joined: 5 Jun, 2008
Posts: 863



Thanked 4 times

Dream Kudos: 25
My Contributions


Your doing a good job so far, but where did you get the methods from?

This post has been edited by abgorn: 13 Sep, 2008 - 03:06 AM
User is online!Profile CardPM

Go to the top of the page

sms123
post 13 Sep, 2008 - 08:51 AM
Post #5


D.I.C Head

**
Joined: 15 Aug, 2008
Posts: 54


My Contributions


QUOTE(abgorn @ 13 Sep, 2008 - 03:56 AM) *

Your doing a good job so far, but where did you get the methods from?

oh they gave examples, lol, they just said, like if you want to know if the touch sensor was activated, use .isPressed() etc
User is offlineProfile CardPM

Go to the top of the page

RedSonja
post 30 Sep, 2008 - 04:25 AM
Post #6


D.I.C Head

Group Icon
Joined: 4 Sep, 2008
Posts: 170



Thanked 3 times

Dream Kudos: 25
My Contributions


Well, I am so jealous. It was never this much fun when I was a student. There must still be lots of Lego at home from when the kids were little, maybe I could have a go...

Actually since most of what I do has to do with rockets, I wondered about getting one of those little USB desktop missile launchers.

User is offlineProfile CardPM

Go to the top of the page

homemade-jam
post 30 Sep, 2008 - 05:22 AM
Post #7


eeeAddict

Group Icon
Joined: 17 Mar, 2008
Posts: 1,044



Thanked 1 times

Dream Kudos: 25
My Contributions


I'm looking forward to going to uni in less that 10 months biggrin.gif
User is offlineProfile CardPM

Go to the top of the page

William_Wilson
post 30 Sep, 2008 - 05:34 AM
Post #8


lost in compilation

Group Icon
Joined: 23 Dec, 2005
Posts: 3,970



Thanked 15 times

Dream Kudos: 3275

Expert In: Java, C, Javascript

My Contributions


I had a robotics course a while back using the BOE robot.

It is amazing what you can learn from trial and error, fault tolerances, random errors, etc. Though we used basic to code these things and the code loading app didn't have syntax highlighting, so there was a lot of copy and paste tongue.gif

It can be frustrating, but I'm sure you'll have fun doing it smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:15AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month