Results 1 to 14 of 14
Like Tree1Likes
  • 1 Post By quad64bit

Thread: Following a black line with an NXT Mindstorm Lego Robot

  1. #1
    Hazza is offline Member
    Join Date
    Oct 2012
    Posts
    64
    Rep Power
    0

    Default Following a black line with an NXT Mindstorm Lego Robot

    I have managed to make it follow the straight long black line, but the line terminates in a big black blob (imagine a lollypop etc.) and I need it to stop at this black blob. I was wondering what sensors an NXT has that can distinguish between a long straight black line and a big black blob?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    What's a 'NXT'?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    I like likes!

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Yeah, this isn't really a java question at all. As far as sensors, I have an NXT kit myself - there are many, but there is no sensors that magically does what you ask. There are light sensors, color sensors, touch sensors, range finders, etc etc...

    How would one look at a long line vs a blob? It's not the sensors job to do that, it's your code's job. For example, what sensor do you have in your body that distinguishes between a car and a house? In that case, the same sensor is getting the input (your eye) but it's your brain and it's software that makes the distinction.

    So, you have some sensor that is capable of reading some kind of input, like the light sensor which in a well lit room works well for black vs white, and a set of software that can look at the other characteristics of the input. Since the sensor is very basic and only reads simple values, you will have to combine the input of the sensor with a motor that can sweep the sensor around. The first thing that comes to mind is that a blob has essentially 4 edges in close proximity, where as a a line has 2 edges, and then 2 unknown boundaries. Your code can make this distinction.
    Sierra likes this.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Quote Originally Posted by Sierra View Post
    That stuff doesn't look much like the Lego I had when I was a kid; I only had those little 2x1 bricks. I wasn't even allowed to play with those 1x1 bricks because my little brother used to stick them up his nose ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Sometimes I wish I was back in those times... when building a vast spaceship did not cost millions of euros but only the imagination of a child... :/
    I like likes!

  7. #7
    Hazza is offline Member
    Join Date
    Oct 2012
    Posts
    64
    Rep Power
    0

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Thank you for your help guys I have another question that is on a different topic but related to the program I am building. I know a constructor method has the same name as the class, and is used to create an instance of that class. But if that thing already exists in the real world, like the black line, then in my BlackLine class would I not need a BlackLine() method, because I would not need to create something that already exists?

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Quote Originally Posted by Hazza View Post
    I know a constructor method has the same name as the class
    A constructor is not a method.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    Hazza is offline Member
    Join Date
    Oct 2012
    Posts
    64
    Rep Power
    0

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Yeah I understand how it is not a method now, thanks to Understanding constructors - JavaWorld but the real question is, would I need one in my class?

  10. #10
    Hazza is offline Member
    Join Date
    Oct 2012
    Posts
    64
    Rep Power
    0

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    So does every class that you write need a constructor even if that class is a real world entity?

  11. #11
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    A real world entity relates to a java class like an aircraft to an apple. Your question makes that much sense as to ask why an aircraft needs a service crew though apples grow everywhere. At least to my limited mind.
    A generic answer is: Yes every class has a constructor and no, you do not write the default, empty constructor as it is usually implicitly created by Java.
    Last edited by Sierra; 01-13-2013 at 07:22 PM.
    I like likes!

  12. #12
    Hazza is offline Member
    Join Date
    Oct 2012
    Posts
    64
    Rep Power
    0

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Thank you Sierra that was very helpful. Another question (on a different topic but still related to my program) are you allowed to have if statements in set methods? I know the compiler sees no problem with it, but is it considered acceptable by convention?

  13. #13
    Russd772 is offline Member
    Join Date
    Dec 2012
    Posts
    42
    Rep Power
    0

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    as far as your OP question goes, what i would do is use 4 IR sensors that bounce the IR beam back to judge distances. the IR sensors cant bounce off of the black so you will have a high resistance when on the black line, use two to follow the lines then when you get to the blob, all four will read high resistance because all 4 will be on black instead of just the two. i dont know much about the lego kit but i did something similar with a handyboard and some motors. hope this helps with that question.

    Russ

  14. #14
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Following a black line with an NXT Mindstorm Lego Robot

    Quote Originally Posted by Hazza View Post
    Thank you Sierra that was very helpful. Another question (on a different topic but still related to my program) are you allowed to have if statements in set methods? I know the compiler sees no problem with it, but is it considered acceptable by convention?
    Of course that is acceptable and you are allowed to do that...
    I like likes!

Similar Threads

  1. Robot screen capture returns black image
    By Jaeela in forum New To Java
    Replies: 1
    Last Post: 11-30-2012, 10:51 AM
  2. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  3. compare sensorvalue leJOS, java for LEGO NXT
    By reinout91 in forum New To Java
    Replies: 0
    Last Post: 06-22-2011, 12:53 AM
  4. Red/Black Trees
    By f1gh in forum New To Java
    Replies: 4
    Last Post: 12-12-2010, 03:30 AM
  5. red black tree
    By ahmakki in forum New To Java
    Replies: 1
    Last Post: 03-21-2010, 07:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •