LeJOS NXT movement in centimeters

579 Views Asked by At

I just started learning LeJOS programming and have a small probelm. I understand that I can measure movement distance in seconds and degrees. Is it possible to measure distance in centimeters, for instance. If yes, then how?

2

There are 2 best solutions below

0
On

I am assuming that your robot uses wheels to enable it to move. If you can obtain the amount of degrees that your wheel turns, you can use the Arc Length Formula to obtain the linear distance that your wheel moved.

0
On

Assuming you are using wheels it depends on the radius of your wheels. The distance a wheel travels is directly related to the circumference of the wheel.

Say we have 2 wheels, one with a 2cm radius and the other with a 4cm radius. If we allow each wheel to do a complete (360degrees) rotation the robot will have traveled the complete circumference of the wheel.

@2cm radius distance=12.6cm @4cm radius distance=25.1cm

But then how do we calculate the distance if we only move a fraction of a complete rotation or more then 1 rotation?

Use the formula Distance = 2 * PI * Radius * (Degrees / 360)

You could also use the

import lejos.robotics.navigation.Move;
...
float distance = Move.convertAngleToDistance(/*float*/angle,/*float*/turnRadius);