Working with the source code

A place to discus the development of leJOS for the EV3. Please do not use this section to post questions about how to use leJOS or to report problems etc.
int1
New User
Posts: 3
Joined: Thu Feb 08, 2018 8:17 am

Working with the source code

Postby int1 » Thu Feb 08, 2018 8:39 am

Hi :D ! As you may know, the method steer() from DifferentialPilot, has a "problem": every time you call this method it first stops the robot and then changes directions, which is not I'm looking for.

I searched for a solution, and saw a thread in this forum saying that this a problem that only happens because of a few lines of the source code. And since I was already interested in adding some new methods, I thought "Hey, why not myself do the changes that I need?". Turns out that this was reaaaaally hard for me atleast. Because of all of this, I'd like to know the correct way of dealing with the source code of LeJOS.

What I have tried so far: Opening the source code as a project in eclipse and fixing some errors that for some reason appeared, going in the DifferentialPilot class and adding a new simple method just to tried it out, then making that into a .jar file, moving this new .jar to the correct location and naming it "ev3class.jar" and removing the old one of the "official LeJOS", then using the modified LeJOS in Eclipse, but what happened is even Eclipse while I was typing the name of the method auto-completed for me. No errors. But when I tried to run that in my EV3, it gave me an error: "No such method". Not only that, but also when I change the steer method to something totally different it simply does not change in "action in the EV3" :( .

User avatar
gloomyandy
leJOS Team Member
Posts: 6054
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Working with the source code

Postby gloomyandy » Thu Feb 08, 2018 9:17 am

If you build a new ev3class.jar file then you need to update the copy of this file that is on your ev3. Otherwise you will be compiling against one version but running with a different one. You will also need to restart the EV3 (or at least the menu as that will be using the "old" ev3classes.jar).

You should probably learn about the leJOS snapshot, once you have one you can point your leJOS projects at that rather than at the isntalled version of leJOS, this means you can develop within the snapshot and have your projects reference the snapshot files (which means you only have to update the files on the EV3). Or you can simply update your leJOS project to reference "your" copy of ev3classes.jar. The following link may help
https://sourceforge.net/p/lejos/wiki/Wo ... ith%20GIT/
You will also need to understand how to use ANT build files!

Good luck!

BTW if you want continuous movement I would strongly suggest using the Chassis class rather then DifferentialPilot, if you are tracking your Pose I would also strongly suggest using the PoseProvider built into the Chassis. This works much better for continuous movement.


There is a reason the DifferentialPilot stops and starts movement that way. Many other parts of the leJOS Robotics API rely on this movement model. If you want continuous movement, you really need to move away from the older code.
leJOS news https://lejosnews.wordpress.com/

int1
New User
Posts: 3
Joined: Thu Feb 08, 2018 8:17 am

Re: Working with the source code

Postby int1 » Thu Feb 08, 2018 3:16 pm

Wow, such a fast reply, thank you sir :o ! I'll certainly gonna read that article of the wiki, but for now, I still have one more question: How can I locate and change the ev3class.jar in the EV3? Is this something I have to do through ant files? When I open de SD Card on my PC I can't seem to find the ev3classes in there.

User avatar
gloomyandy
leJOS Team Member
Posts: 6054
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Working with the source code

Postby gloomyandy » Thu Feb 08, 2018 3:59 pm

You won't be able to see the Linux file system on the SD card from a PC. The easy way is probably to transfer the file when the EV3 is running. There are various ways to do this (the ant files show one way). Do you know anything about Linux? If you are going to do anything serious with the EV3 you really should. If you do then you can ssh into the EV3 and have a look around the file system.
leJOS news https://lejosnews.wordpress.com/

int1
New User
Posts: 3
Joined: Thu Feb 08, 2018 8:17 am

Re: Working with the source code

Postby int1 » Thu Feb 08, 2018 4:10 pm

I can't believe I actually forgot that, but you're right ahahah.

I used ssh and it works just fine. Thank you for your time! :D


Return to “leJOS EV3 Development”

Who is online

Users browsing this forum: No registered users and 1 guest