GELway - Self Balancing Robot with Self Reset

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

Postby iWitzand » Sat Nov 07, 2009 7:10 am

Hey everyone,

I've finally uploaded all my project work, source files and documentation. It can be found following this link.

http://code.google.com/p/gelway/

Any feedback let me know. I sort of threw the page together in an hour or so, didn't have much experience with Wiki's but should be easy enough to find everything.

Ohh and Atr, not yet haha, got one 30% exam to go, but should be pretty cruisey. Degrees get handed out on the 9th of December. At the moment I am just replacing my extra time from not having to do thesis work with Golf =)

Have fun all, and hope you enjoy programming the robot,

Steve
iWitzand
Novice
 
Posts: 30
Joined: Tue Jun 09, 2009 8:27 am

Postby gloomyandy » Sat Nov 07, 2009 9:02 am

Hi Steve,
That's great thanks for taking the time (away from your golf :D ) to put together the download page! I might even build another balancing robot... Good luck with the remaining 30%...

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

Postby kellogg » Mon Nov 09, 2009 3:28 am

Hi Steve and thanks for publishing the code and the thesis. The project is very impressive indeed. I ported the project into eclipse (project new, build from existing sources), but some JARs are not referenced, so I cannot compile the project. I will have to change the code as I don't have an EOPD sensor. There is a while loop that checks the distance to the ground, so I think this needs to be commented out if one doesn't want to use an EOPD sensor. I think you mentioned that you also used eclipse for this project. If so, could you please let me know your Java Build Path Libraries (JARs) for Gelway project. Did you use jeJOS plugin? Also I don't have a Symbian phone so is it possible to control the robot from jeJOS (PC) instead of a phone without a huge code changes.

thanks -- kellogg
kellogg
New User
 
Posts: 13
Joined: Fri Oct 23, 2009 7:07 pm

Postby iWitzand » Mon Nov 09, 2009 9:30 am

Hey kellog,

It doesn't actually matter what bluetooth connection you use with the robot. I have included a PC controller that should be able to be loaded with PCCOMM.jar file. I used leJOS 0.8, I don't think there will be any issues with leJOS 0.85, however I beleive some things maybe in differnet spots, like the Behaviour class files.

I followed a process I found on the web to add leJOS in with eclipse follow this link
http://www.bartneck.de/2008/03/04/java- ... -tutorial/

Once I did everything I was able to run the Hello World test program and all that. You can replace the EOPD sensor with the standard lightsensor if you like, should work, just be more susceptible to ambient light.

I am pretty sure I just ran everything with the .JAR file that came with leJOS 0.8. What JAR files or class files does it say you are actually missing.

Steve
iWitzand
Novice
 
Posts: 30
Joined: Tue Jun 09, 2009 8:27 am

Postby kellogg » Mon Nov 09, 2009 4:26 pm

Steve,

The errors I am getting were mostly to do with subsumption classes being moved under robotics folder in v0.85. I fixed that but there are lot of other errors that make me want to install leJOS 0.8 and re-compile the code with that version. There were too many changes made between 0.8 and 0.85, that make any 0.8 or earlier code to run under 0.85 difficult. It would be nice if the authors of leJOS 0.85 wrote a guide for porting code from 0.8 and older versions of leJOS to v0.85 indicating all the changes they've made. Instead, it is left to a code writer to figure it all out.

thanks

-- kellogg
kellogg
New User
 
Posts: 13
Joined: Fri Oct 23, 2009 7:07 pm

Postby kellogg » Mon Nov 09, 2009 5:26 pm

I compiled the code under leJOS 0.8, no major issues, except one small syntax error in GELwayFollower.java. The difference between Steve's GELway.nxj and my executable is that mine is 5KB smaller (22KB vs 27KB). Any idea why? I will try to run the program tonight on my NXT using the light sensor instead of EOPD. Does the code need any changes in case a Light Sensor is used instead of EOPD?

-- kellogg
kellogg
New User
 
Posts: 13
Joined: Fri Oct 23, 2009 7:07 pm

Postby iWitzand » Mon Nov 09, 2009 10:05 pm

Hey kellog,

Not sure about the 5kb smaller. It's probably to do with what behaviours I had active when I compiled.

In regards to the Leight Sensor and EOPD sensor, you will need to pay attention to this value

private final int eopdThresh = 1022;

I haven't use the lightsensor. What you will want to do is set to just off the maximum read value on the LightSensor. The EOPD was around 1024. Basically if it reads the max value it assumes it has fallen over. So just find the max light sensor value and minus about 5. Also with the light sensor, it may be dependant on the room light, so try it in a dark or well lit room.

You mentioned a small error in GELwayFollower.java, I assume you have fixed it :). You can try commenting out the Behaviours to start off with. Also make sure you are compiling that in the main just file you are running the loadNormal(); method.

// loadMaster(); // Load the Master GELway settings
// loadSlave(); // Load the Slave GELway settings
loadNormal(); // Load the normal GELway settings

Slave and Master are used generally when you have two robots. Hope this helps,

Steve
iWitzand
Novice
 
Posts: 30
Joined: Tue Jun 09, 2009 8:27 am

Postby kellogg » Wed Nov 11, 2009 2:42 pm

Hi Steve,

Well I spent a good portion of last night trying to get my GELway working, without much luck. I tried both Normal and Master modes with a PC controlling the NXT. I made the following changes to the code:

- commented out a while loop in BalanceController.java, so the GELway runs without EOPD sensor check: while (eopd.readRawValue() < eopdThresh && upright)
- uncommented PC control in Normal() mode in GELway.java:
conn.setIOMode(0);

Here are my observations.

1. I connected a PC to the NXT via BT.
2. I executed GELway in Normal mode on the NXT.
3. NXT LCD says Waiting ... for about 2-3 min.
4. NXT goes to gyro calibration mode and stays there forever.
5. Pressing ENTER key doesn't terminate this method, I had to reset the NXT to get out of that loop.
6. NXT never gets to BT Connected mode.
7. I executed PCConnect.jar on the PC, but this program would not take my NXT MAC address, although there is on option to change it. So I couldn't Connect from PCConnect.jar. I need to re-compile PCController.java with my NXT MAC address. Please help me figure out how you created this JAR file (need javac and jar arguments).

I repeated the test in Master mode with connectMasterSlave() method commented out but the result is the same. Perhaps it is just matter of re-compiling PCConnect.jar to match my NXT MAC address. The thesis says that you use arrow keys for PC control and the PCController.java shows you used same keys as in phone controlled code 2468. Any comment?

Oh, and at one time I had NXT crashing with this codes:

Java Exception
Class: 8
Method: 27
PC: 7426

This is leJOS 0.8.

- k
kellogg
New User
 
Posts: 13
Joined: Fri Oct 23, 2009 7:07 pm

Postby iWitzand » Wed Nov 11, 2009 11:49 pm

Hey kellog,

My first suggestion is to comment out the Bluetooth connection. You don't need it to actually run, just to see if you can actually balance the robot. You should go straight into the gyro calibration, and enter should start the balance (also if your gyro calibration returning an actual value, should be around 620ish) if it says 1024, its not working, or the gyro is in the wrong port.

In regards to the Bluetooth connection, if you want to use it you will have to connect with a Bluetooth device somehow. I haven't had much experience with MACs so can't help to much. With the key presses, if the PCController detects say an up arrow, it sends a 2, a left sends a 4 to the GELway. This just to conform with the mobile keys.

Let us know if it is balancing without the Bluetooth, if so we can work from there,

Steve
iWitzand
Novice
 
Posts: 30
Joined: Tue Jun 09, 2009 8:27 am

Postby kellogg » Thu Nov 12, 2009 3:49 pm

Thanks Steve. Could you be more specific as to how to disable BT in order to get the robot to balance. My gyro calibration reads 594 or 606 depending on how the GELway is positioned straight up or slightly tilted.

thanks - k
kellogg
New User
 
Posts: 13
Joined: Fri Oct 23, 2009 7:07 pm

Postby iWitzand » Fri Nov 13, 2009 6:45 am

Kellogg,

Just to clarify, when you run the gyro calibration make sure the robot is perfectly still, i usually leave it flat on the ground. You should get similar gyro readings each time.

In the GELway.java class file all you have to do is comment out the Bluetooth lines. You will also need to remove the GELwayDriver behaviour since it uses Bluetooth. Your normal method should look like this

Code: Select all
   /**
    * Loads operator settings for GELway when only one robot is used
    */
   public static void loadNormal() {
      //LCD.drawString("Waiting...", 2, 1);
      //BTConnection conn = Bluetooth.waitForConnection();
      // conn.setIOMode(0); // Used when a pc connection is made
      //conn.setIOMode(NXTConnection.RAW); // Used when a phone connection is made
      LCD.clear();
      // Start Bluetooth reader thread
     // br = new BluetoothReader(conn);
      //br.start();
      // Start Balance control thread
      // BalanceController bc = new BalanceController(ctrl);
      BalanceController bc = new BalanceController(ctrl);
      bc.start();
      LCD.clear();
      //Behavior b1 = new GELwayDriver(ctrl, br); // Needed to drive robot and slave
      // Behavior b1 = new GELwayFollower(ctrl);
      Behavior b2 = new DetectObstacle(ctrl); // Needed to avoid obstacles
      // Behavior b3 = new KeepStraight(ctrl); // Needed to keep straight
      Behavior[] bArray = { b2 };
      Arbitrator arby = new Arbitrator(bArray);
      arby.start();
   }
iWitzand
Novice
 
Posts: 30
Joined: Tue Jun 09, 2009 8:27 am

GELway thread - leJOS balbot + BT with a Symbian phone

Postby kellogg » Thu Nov 19, 2009 7:21 pm

Hi Steve,

I did manage to get the program enter the balancing routine, but I was disappointed to see that the NXT doesn't actually balance. It is not reading gyro values fast enough and the motors don't move fast enough to make it balance. I also noticed quite a big drift in gyro readings. Of course it could be a matter of adjusting the PID parameters but I suspect it may be more that that to make it work like the one you filmed.

comments???

- k
kellogg
New User
 
Posts: 13
Joined: Fri Oct 23, 2009 7:07 pm

Postby harold » Sat Nov 21, 2009 11:18 am

Hi Steve,

Very nice work indeed!
Downloaded your code and got it working with minor changes (e.g. disabling the eopd which I don't have and adding a button listener for the escape key instead).
The balance is very good without any changes to the PID constants.
Thanks!
Harold
harold
New User
 
Posts: 1
Joined: Sat Nov 21, 2009 11:04 am

Postby iWitzand » Wed Nov 25, 2009 10:03 pm

Hey kellogg,

I am really unsure as to what the problem is now. I have had a few people load my code now and they haven't had too much trouble getting it to balance. It is true that every motor is slightly different but they shouldn't be so different that they are not getting enough power sent to them.

My gyro readings do drift, this can be fixed with a Kalman filter using the tilt sensor (I didn't look into this however, so you would have to find another project), but the drift is not significant enough to make it not balance, over time it would just slightly move backwards.

I wish I could be of more help, but I am not sure where to pinpoint the actual problem,

Steve
iWitzand
Novice
 
Posts: 30
Joined: Tue Jun 09, 2009 8:27 am

Postby gloomyandy » Wed Nov 25, 2009 10:50 pm

Hi Kellog/Steve,
Just a thought...

Is your robot the same as the one used in the project? In particular are you using the same wheels? What about power supply? Are you using batteries or the rechargeable pack? Steve what did your robot use?

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

PreviousNext

Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff