BotDogs4645 / SY2023-CORE-A

Robot programming for CORE A
Other
1 stars 1 forks source link

Elevator State Space Control #21

Closed davidmuchow closed 1 year ago

davidmuchow commented 1 year ago

This might be a bit of a ramble because I am still trying to fill in all the blanks.

To remove complexity from the driver, we have opted to completely remove lower level controls from them. That means they will have no direct motor control or pnuematics control. To accomplish this successfully, we are going to have to model the entire system in state space and then have preset positions that the driver can request in button form.
First step is to identify the states, ins and outs of the system.

The states are represented here:

$x =$ the current x position in the robot's cartesian map $Vx =$ the current velocity in x in the cartesian map $E{mv} =$ the voltage into the elevator motor $y =$ the current y position in the robot's cartesian map $Vy =$ the current velocity in the y in the cartesian map $T{mv} =$ the voltage in the telescoping arm motor


What about $\theta$ positioning?

We have decided to enumerate different $\theta$ positions. The actual $\theta$ of the elevator does not matter from a controller perspective, and neither do the enumerations. The driver should not have direct control of the elevator's selected enumeration because we can control that logic for them. From where we are right now, there would be three enumerated elevator $\theta s$:

$x$ is equal to the requested position of the $x$ coordinate, in meters. This essentially represents the extension of the arm.

$y$ is equal to the requested position of the $y$ coordinate, in meters. This essentially represents the height of the arm.

$\theta_e$ is equal to the enumerated rotation of the elevator, and therefore the transformation of the end affector coordinate by a rotation matrix:

$$\Large \begin{bmatrix} cos{\theta} & -sin{\theta} \ sin{\theta} & cos{\theta} \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix} $$

This comes out to be equal to:

  $\Large x^{\prime} = xcos{\theta} - ysin{\theta}$
  $\Large y^{\prime} = xsin{\theta} + ycos{\theta}$

However, in actuality, there is a more complex underlying control request. There is also velocity control that is bundled with the position requests.

$V_x$ is equal to the velocity the telescoping arm should be traveling.

$V_y$ is equal to the velocity the elevator should be traveling.

Another important part to mention is the control loop power one like this offers. You can apply an easing to the interpolation of the requested position vs the current position, and slow down the arm as it reaches the requested position.


Deriving a position

How we want to set this up is important. I would rather have transformations from an AprilTag to the low, middle and high nodes that are automatically translated into x,y,theta coords usable in the state space controllers. However, whenever we place something, we need to account for two rotations that intefere with our axises. The robot has to be given coordinates WITHOUT rotation, because the rotations will be given seperately. It is essentially like thinking the axises are rotated, but the coordinates themselves aren't because relatively they are just on an axis. First, let me define some terms. Whenever "absolute" is used, it's refering to field relative. Bottom right corner is 0,0 and X+ is facing towards the opposing alliance. Theta increases counterclockwise, as defined by general convention.

$$\Large \begin{bmatrix} R{px} \ R{py} \ R{pz} \end{bmatrix} = ((\begin{bmatrix} A{rx} \ A{ry} \ A{rz} \end{bmatrix} \circ \begin{bmatrix} T_x \ T_y \ Tz \end{bmatrix}) - \begin{bmatrix} A{px} \ A{py} \ A{pz} \end{bmatrix}) - \begin{bmatrix} c \ 0 \ 0 \end{bmatrix}) $$

$$\Large \begin{bmatrix} x^{\prime} \ z^{\prime} \ \end{bmatrix} = \begin{bmatrix} cos{\phi} & -sin{\phi} \ sin{\phi} & cos{\phi} \end{bmatrix} \begin{bmatrix} x \ z \ \end{bmatrix} $$

$$\Large \begin{bmatrix} x^{\prime\prime} \ z^{\prime\prime} \ \end{bmatrix} = (\begin{bmatrix} cos{\theta} & -sin{\theta} \ sin{\theta} & cos{\theta} \end{bmatrix} \begin{bmatrix} x^{\prime} \ z^{\prime} + z \ \end{bmatrix}) - \begin{bmatrix} 0 \ z \ \end{bmatrix} $$

$$\Large \begin{bmatrix} X \ Z \ \end{bmatrix} = (\begin{bmatrix} x^{\prime\prime} \ z^{\prime\prime} \ \end{bmatrix} \circ \begin{bmatrix} T{fx} \ T{fz} \end{bmatrix} $$

davidmuchow commented 1 year ago