Convert circular motion and back and forward linear motion to sideways linear motion

262 Views Asked by At

i have a Mindstorms robot that has back/forward facing wheels and a motor in front that moves a stick left and right (circular motion) and i want the left and right motion of the end of the stick to be linear. i want to achieve this by correcting the circular motion using the back/forward motion. here is a picture for referencepicture If you knowany formulas or proceses let me know. thanx in adwance

1

There are 1 best solutions below

0
On BEST ANSWER

First, let's make a more mathematical drawing of the problem. The half of a circle is the possible path your stick can have, assuming that the robot is static. The radius of this circle, h, is the length of you stick. Point A is the starting position of the stick, point B is the ending position of the stick. Corner α is its starting angle and corner β is its ending angle, both measured from the x-axis.

mathematical drawing

In this picture, x is the difference in the x-axis between the two positions of the stick. It is thus the distance that the robot needs to compensate by driving backwards and so the target of our calculation.

In order to calculate x, we need the difference of the two x-coordinates of the stick's positions. In math language, this becomes:

x = |EC| - |ED|

Note that |EC| means the length of segment [EC].

Now we only need to calculate |EC| and |ED|. This can be done using the cosine function. The cosine function calculates the ratio of the apothema of a triangle and the side adjacent to the corner chosen in a right-angled triangle. For more information, see Wikipedia.

If you do know the angles already, its fairly simple from here. In triangle EDA, we can state that:

cos α = |ED| / h

In triangle ECB, we can state that:

cos β = |EC| / h

We can reform the equations to:

|EG| = h * cos α

and:

|EC| = h * cos β

Then, if we fill in the first equation, then we get:

x = h * cos β - h * cos α = h(cos β - cos α)

Note that you might have form the angles in the correct form, as they might not be measured from the x-axis.

But if we don't know the angles yet, we need to calculate them first. Then we need to know |AD| and |BC|, which is the distance between the center of the robot and the position we want to reach.

This time we will have to use the sine function, which is the ratio of the apothema of a triangle and the side opposite to the corner chosen in a right-angled triangle.

In triangle EDA, we can state that:

sin α = |AD| / h

And in triangle ECB, we can state that:

sin β = |BC| / h

This means that we can use the arcsine function, usually denoted as sin⁻¹ x. It calculates the angle which has cosine x.

If we reform the equations, we get:

α = sin⁻¹(|AD| / h)

And:

β = sin⁻¹(|BC| / h)

Using these values, we can uses the formula above to calculate x.