I am currently testing out my NXT-Segway with an identical build based on the HTWay (http://www.hitechnic.com/blog/gyro-sensor/htway/). I'm still quite new to this and I couldn't find that many sample codes for the new leJos 0.9.0.
So this is the code I've got so far:
- Code: Select all
import lejos.nxt.*;
import lejos.robotics.*;
import lejos.nxt.Motor.*;
import lejos.nxt.Button.*;
import lejos.nxt.SensorPort.*;
import lejos.nxt.addon.GyroSensor;
import lejos.robotics.navigation.Segway;
class easyway
{
public static void main(String[] args) throws Exception
{
NXTMotor left = new NXTMotor(MotorPort.C);
NXTMotor right = new NXTMotor(MotorPort.A);
GyroSensor gyro = new GyroSensor (SensorPort.S2);
Segway a = new Segway(left, right, gyro, 4.9);
}
}
After compiling and transferring the code to the NXT it starts by prompting me to lay Segway flat for gyro calibration, then begins self-balancing thread. It just moves forward or backward, depending on how it is balanced, no matter what and ends it with a faceplant/falling on the back. I've tried balancing it against the wall but it moves forward/backward in the same way. The wheel diameter is written down in cm, but I've tried it with inches but to no avail.
It feels like it won't update itself as fast as it should? I don't know for sure, I'm still quite new to this. Any help? I can attach a video if necessary.
