LeJos: all robot classes and methods in 1?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

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

Post 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
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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)
schodet
Posts: 139
Joined: 29 Sep 2010, 11:21
Contact:

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

Post 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.
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post by HaWe »

I'm too old for learning new things.
Sad but true.
I won't have a long time to live anymore.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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...
schodet
Posts: 139
Joined: 29 Sep 2010, 11:21
Contact:

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

Post 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?
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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)
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

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

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Locked

Who is online

Users browsing this forum: No registered users and 1 guest