Page 4 of 4

Re: LeJos: all robot classes and methods in 1?

Posted: 02 Nov 2010, 11:03
by HaWe
andy,
the point is not just to understand OO but 1st to have all classes in 1.
something like a super class SuperRobot.class
And I just want to have 1 instance for all of my programs like
public class MyRobot implements SuperRobot

in order to have all objects and methods in 1 and so may access them all at once
- all motors
- all sensors
- all comm
- all behavior
- all navigator
- all HID BT keyboards

Re: LeJos: all robot classes and methods in 1?

Posted: 02 Nov 2010, 11:43
by gloomyandy
Doc,
I know that is what you want, but I've already tried to explain that...
1. I don't think it makes any sense to try and do this. Java class libraries (like the one with leJOS) assume that you will be using OO after all that's what Java is mainly about. You may be able with a lot of work to wrap things like call backs, threads, enumerators, interfaces etc. in more procedural code but really you are trying to push water uphill.
2. That you will struggle to find anyone that has both the capability and the interest to do this for you. Anyone that is familiar enough with something like leJOS is likely to also like using OO and so will most likely share my views above. But you never know perhaps there is someone out there willing to help... good luck to them!

So for me this leaves you the following options...
1. Try and get to grips with the current version of leJOS (OO and all).
2. Write your own version of the one ultimate class that wraps/hides the OO leJOS class libs.
3. Write your own procedurally based set of robotics libraries, but which use a sub-set of Java and run on the leJOS firmware. You can also think of this as using something like a C front end, but you would still need a set of robotics library functions...

I've been trying to encourage you to try option one by pointing out that not all leJOS code has to be that OO (the subsumption code is probably a very bad example, if you have the time take a look at some of the other samples, they really are not that OO). But you will eventually have to deal a little with OO (you may even get to like it). The good news is that there are lots of resources out on the web that can help (this is one of the advantages of using a standard programming language like Java).

You could do number 2, the problem is that you almost certainly need to be a good Java programmer already to do this, and given that no-one else is likely to be interested, that means that you would have to learn Java in which case I think option one is a better way to go.

Option 3 is interesting but it will be a huge task. You would have to re-create a big chunk of the existing leJOS class libs in procedural code. It might be an interesting project though...

Sorry I know this is not the answer you want but it's the best I can offer.

Good luck

Andy

Re: LeJos: all robot classes and methods in 1?

Posted: 02 Nov 2010, 11:50
by HaWe
well, I can't do because I have not enough experience in Java.
In that case "the cat bites into it's own tail" as we say.

Either there will be someone else who is building that whole chunk, and I'd give it a try, or this Java approach has died before it's been started.

I'm sure a whole lot of hobby programmers will appreciate to have Java unleashed with a simple access like NXC to all drivers and procedures and 1 chunk- API "all in one".

But for beginners OOP with hundreds of classes sucks - and frustrates.

(ps: BTW - all of my mobile robot programs have a subsumption architecture)

Re: LeJos: all robot classes and methods in 1?

Posted: 03 Nov 2010, 22:01
by schodet
doc-helmut wrote:well, I can't do because I have not enough experience in Java.
You would have gained sufficient experience if you used the time you spent on this forum thread to learn Java.

I just can not understand what you find so complicated in the current LeJOS API.

Re: LeJos: all robot classes and methods in 1?

Posted: 03 Nov 2010, 22:52
by HaWe
I'm too old for learning new things.
Sad but true.
I won't have a long time to live anymore.

Re: LeJos: all robot classes and methods in 1?

Posted: 03 Nov 2010, 23:39
by HaWe
ps:
if I read something like...

Code: Select all

public class RemoteProgramm {
   public static void main(String[] args) throws Exception {
      RemoteNXT nxt = null;   
        NXTCommConnector connector = Bluetooth.getConnector();
        try {
           nxt = new RemoteNXT("NXT", connector);
            Thread.sleep(2000);
        } catch (IOException e) { ... }
Image
...I suffer from persistent vomiting...

Re: LeJos: all robot classes and methods in 1?

Posted: 04 Nov 2010, 00:08
by schodet
Did you read the tutorial, you can read much simpler example, for example:

Code: Select all

 2 import lejos.nxt.*; // this is required for all programs that run on the NXT
 3 
 4 
 5 /**
 6  *Motor runs forward then backward as button is pressed.
 7  * @author Roger
 8  */
 9 public class BasicMotorTest
10 {
11 
12     public static void main(String[] args)
13     {
14 
15         Motor.A.forward();
16         LCD.drawString("FORWARD", 0, 0);
17         Button.waitForPress();
18         Motor.A.backward(); // you could use  Motor.A.reverseDirection  instead
19         LCD.drawString("BACKWARD", 0, 1);
20         Button.waitForPress();
21         Motor.A.reverseDirection();
22         LCD.drawString("FORWARD", 0, 2);
23         Button.waitForPress();
24         Motor.A.stop();
25     }
26 }
Do you really find this unreadable?

Re: LeJos: all robot classes and methods in 1?

Posted: 04 Nov 2010, 07:50
by HaWe
oh yes, this is much simpler indeed.
No vomiting ;)

but why do I need both
public class BasicMotorTest
and
public static void main(String[] args)
?
I mean: what do I need a class for if I just want to run a main program without any subroutine or function?
and what is public, static, and String[] args for (I never understood THAT)

Re: LeJos: all robot classes and methods in 1?

Posted: 04 Nov 2010, 09:33
by mightor
Helmut,

Because that's the design of the language. Why do you need a task main in NXC? Why do you need a void main in a C program?

You never understood it because you never took the time to learn it properly.

This thread is now locked.

- Xander