|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
lejos.robotics.navigation.Segway
public class Segway
This class balances a two-wheeled Segway-like robot. It works with almost any construction (tall or short) such as the Anyway or the HTWay. Wheel diameter is the most important construction variable, which is specified in the constructor.
To start the robot balancing:
Alternately you can lean the robot against a wall and run the program. After the gyro calibration, the robot backs up against the wall until it falls forward. When it detects the forward fall, it start the balance loop.
NOTE: In order to make the Segway move and navigate, use the SegwayPilot class.
This code is based on the HTWay by HiTechnic.
Field Summary | |
---|---|
protected EncoderMotor |
left_motor
|
protected EncoderMotor |
right_motor
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Segway(EncoderMotor left,
EncoderMotor right,
GyroSensor gyro,
double wheelDiameter)
Creates an instance of the Segway, prompts the user to lay Segway flat for gyro calibration, then begins self-balancing thread. |
Method Summary | |
---|---|
void |
run()
When an object implementing interface Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread. |
void |
wheelDriver(int left_wheel,
int right_wheel)
This method allows the robot to move forward/backward and make in-spot rotations as well as arcs by varying the power to each wheel. |
Methods inherited from class java.lang.Thread |
---|
currentThread, getName, getPriority, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, setDaemon, setName, setPriority, sleep, start, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected EncoderMotor left_motor
protected EncoderMotor right_motor
Constructor Detail |
---|
public Segway(EncoderMotor left, EncoderMotor right, GyroSensor gyro, double wheelDiameter)
left
- The left motor. An unregulated motor.right
- The right motor. An unregulated motor.gyro
- A HiTechnic gyro sensorwheelDiameter
- diameter of wheel, preferably use cm (printed on side of LEGO tires in mm)Method Detail |
---|
public void run()
Runnable
Runnable
is used
to create a thread, starting the thread causes the object's
run
method to be called in that separately executing
thread.
public void wheelDriver(int left_wheel, int right_wheel)
left_wheel
- The relative control power to the left wheel. -200 to 200 are good numbers.right_wheel
- The relative control power to the right wheel. -200 to 200 are good numbers.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |