CBCJava - Java on the CBC

17 replies [Last post]
catron
catron's picture
Title: ZoomBot
Joined: 06/02/2009
Posts:
BotPoints: 98
User offline. Last seen 5 years 39 weeks ago.

Hey guys,
CBCJava is a project that allows easy development with Java. This will be a paper at GCER, so any ideas or suggestions before then would be great.
CBCJava Website

Pros:
Object-Oriented
Java is taught at many schools
Faster downloading through network

Cons:
Does not yet support USB downloading like KISS-C

Requirements:
Eclipse
Java Runtime
Ethernet adapter for networked downloading
Flash Drive for Project Installer

Once the KISS-C source is released, I hope to support usb downloading.

Email me or post here with questions or comments: My Email

Example:

  1. public class Main {
  2. public static void main(String[] args) {
  3. // Very important
  4. CBC.init();
  5. System.out.println("CBC Example!");
  6. // Create motor objects
  7. MotorController leftMotor = new MotorController(0);
  8. MotorController rightMotor = new MotorController(3);
  9. // Start motors at full percentage
  10. leftMotor.moveAtPercent(100);
  11. rightMotor.moveAtPercent(100);
  12. System.out.println("Press A to stop motors.");
  13. // Create button object representing A
  14. Button aButton = new Button("a");
  15. // Wait until A is Pressed
  16. aButton.waitUntilPressed();
  17. // CBC.type.function provides all C-like functions
  18. CBC.motor.ao();
  19. }
  20. }

Again, this is still very much a work in progress, do not expect everything to work.

DISCLAIMER:
CBCJava adds files to the CBC's file system. There is absolutely NO WARRANTY. Do not try if you are scared of the liability involved.

"When you do things right, people won't know you've done anything at all."

tmac721
tmac721's picture
Title: NooBot+
Joined: 04/14/2009
Posts:
BotPoints: 16
User offline. Last seen 7 years 38 weeks ago.

Awesome work. I can't wait to read the paper.

catron
catron's picture
Title: ZoomBot
Joined: 06/02/2009
Posts:
BotPoints: 98
User offline. Last seen 5 years 39 weeks ago.

Updated the above information. Now supports flash drive downloading for all OSes. Camera is also now supported.

"When you do things right, people won't know you've done anything at all."

catron
catron's picture
Title: ZoomBot
Joined: 06/02/2009
Posts:
BotPoints: 98
User offline. Last seen 5 years 39 weeks ago.

w00t! I knew if I stared at that source file long enough it would magically start working! Windows networked downloading is now complete!

"When you do things right, people won't know you've done anything at all."

catron
catron's picture
Title: ZoomBot
Joined: 06/02/2009
Posts:
BotPoints: 98
User offline. Last seen 5 years 39 weeks ago.

I have added interaction support to CBCJava as a new tool in the suite. It supports commands from System.out and all of the CBC low-level methods. Other things *may* work, but this is uncertain. It runs alongside your program in a thread. Interaction can only call methods at this time, but should support varaibles in the future. If you want to use Interaction, you cannot do it from a static object. To change this in a main class, do the following:

  1. class Main {
  2. public Main() {
  3. }
  4. public void run(String[] args) {
  5. // CBC init takes two params, The current object (this), and whether or not to run interaction.
  6. CBC.init(this, true);
  7. }
  8. public static void main(String[] args) {
  9. Main main = new Main();
  10. main.run(args);
  11. }
  12. }

If you don't want to run interaction, pass null for the main object and false for interaction.
Usage of Interaction:

> doSomethingInMainClass();
Any errors/return value will be displayed here
> CBC.motor.motor(0,100);
Same as with the other command
> interaction:version
Prints version of the interaction server running on the CBC
> interaction:close
Stops the interaction thread

One more feature I think that people do not know about is that CBCJava passes you the current executing directory, This is usually /mnt/user/code/projectName/bin. If you copy files into your bin path, they will be downloaded into this folder. You may then use them in your code.

@tmac721: Check your gmail for info about writing the create jni wrapper

Happy coding,
Braden (Beta) McDorman

"When you do things right, people won't know you've done anything at all."

PiPeep
PiPeep's picture
Title: RocketBot
Joined: 07/19/2009
Posts:
BotPoints: 170
User offline. Last seen 3 years 37 weeks ago.

Wow! This is great!

However... I am on a mac (which has poor Java 6 support), and I was wondering if there was any hope at getting a port of the tools to Java 5? I will try to do it myself, but I hate downloading the eclipse SDK.

catron
catron's picture
Title: ZoomBot
Joined: 06/02/2009
Posts:
BotPoints: 98
User offline. Last seen 5 years 39 weeks ago.

Hey.. Sorry, didn't see your message for a while. I do not currently have Java 5 installed, and have a plethora of other commitments right now. I will get to it eventually, but that may be a while.

"When you do things right, people won't know you've done anything at all."

PiPeep
PiPeep's picture
Title: RocketBot
Joined: 07/19/2009
Posts:
BotPoints: 170
User offline. Last seen 3 years 37 weeks ago.

In javac you can use the -target argument to specify a JVM version. Not sure how to do this via Eclipse though.

PiPeep
PiPeep's picture
Title: RocketBot
Joined: 07/19/2009
Posts:
BotPoints: 170
User offline. Last seen 3 years 37 weeks ago.

Nevermind. I switched to Ubuntu. (However a java-1.5 version might be useful to mac users)

PiPeep
PiPeep's picture
Title: RocketBot
Joined: 07/19/2009
Posts:
BotPoints: 170
User offline. Last seen 3 years 37 weeks ago.

I uploaded a fix to the Google Code site with a new installer with create support and some simulator support! We're going to try to use CBCJava for the competition this year. It's a lot cleaner than working in C. Thank You!

PiPeep
PiPeep's picture
Title: RocketBot
Joined: 07/19/2009
Posts:
BotPoints: 170
User offline. Last seen 3 years 37 weeks ago.