I'm working with a water vehicle that use four motors to move. They are placed at the corner and are fixed. Hence the movements are obtained changing the speed of each one.
The vehicle can move along three axes: Y (forward, backward), X (left, right), Z (yaw, CW and CCW). I receive the setpoint for each one, example:
- Y axis: 50%
- X axis: 0%
- Z axis: -20%
This mean the vehicle should go forward at 50% of the maximum allowable speed, and at the same time it must rotate CCW at %20.
My code assign to each motor a value based on the above value, using the superposition principle. Example:
- Y axis -> #1: 50%, #2: 50%, #3: 50%, #50%
- X axis -> #2: 0%, #2: 0%, #3: 0%, #4: 0%
- Z axis -> #3: -20%, #2: -20%, #3: 15%, #4: 15%
- Total: -> #1: 30%, #2: 30%, #3: 65%, #4: 65%
It works, but to improve the behavior we need to consider that the thrust exerted by the motor is not linear. And if it spins reversed the curve is different.
I've already measured and interpolated the curves and ended up with two functions that describe the behavior: f(x)_fwd and f(x)_bck.
Because the thrust depends on both speed and direction I don't understand how to compensate for that. I mean, I cannot simply put the final speed value into the 'x' variable because this value is the sum of different contribution (x, y, z axis) and each one require a different compensation.
I also cannot apply this correction at the beginning, before sum each contribution because I don't know yet the final speed and direction of the motor, hence I cannot know which equation to use.
One thought is the following:
- Do the math as described above and find the estimated working speed of each motor
- Repeat the calculation for each axis this time with the correction applied in function of the estimated working speed
It isn't optimal because it will end with different speeds (due to the correction) that will change again the working point and even the equation (i.e. if one motor initially was set to -5%, after the correction might be changed to +5%!).
What's the right approach in such a case? I'm sure it's a very common problem but I don't know the exact words to use to find literature about.
I add some details to improve the question. First, the vehicle is like a small platform (1 x 2 meters) with four motors on each corner. The motors are placed at 45° degrees in this way:
Where the arrow indicates the thrust exert when a positive voltage is applied to the motor.
What I'm not interested in
- I don't want to control speed, velocity or other navigation parameters of the vehicle
- the interface of the motors is not meaningful: I always think in term of ±100%. Then the interface may be voltage, 4-20 mA, PWM, serial line, etc... it doesn't matter at all
- The vehicle doesn't have any adequate sensor to measure its current speed or velocity
What I've already done
- I put the motor in a pool attached to a load-cell and I measured the thrust for over 50 values of setpoint (i.e. 0%, 10%, 20%, ..., -10%, -20%, ...)
- This values give two curves (positive and negative quadrants) in the form of Ax^P + Bx, where x is the control signal
What is the goal
I need to provide basic manual movements (forward/reverse, translate left/right, rotate CW/CCW) only.
Looking at the picture above it's clear that I have to control each motor in a different way to obtain the desired movement. For example, to go forward each motor should be set at the same X value. To rotate CW motors 1 and 2 (bottom-left, and top-left) should be negative while 3 and 4 (top-right and bottom-right) should be positive.
The problem is the thrust exerted from the motor is not linear with the control voltage and when reversed the thrust is much less. Hence if I want to rotate and apply the same ±X voltage to each one, it won't rotate on its center, because the ones that spin reversed provide too much less thrust.
A first correction is to control the ones that spin forward with 30% less that the ones that spin negative. This improve a lot the rotation but is not accurate because the ratio between positive and negative thrust depends on the control voltage.
With the equation I found I can now precisely set each control voltage taking in account the actual thrust, but the main problem is where to place this equation.
As said in the original question, if I put this equation on the final value of each motor it won't work, because it's the sum of all movements. Example: if I have only a rotational movement two motors will spin forward and two reversed. But if at the same time the vehicle must advance, all motors will spin forward, but some more than others (to provide also the rotation).
Hence, the final values of the control voltage haven't anymore the information about what were the axes commands, while the axis command haven't the final values of control voltage yet (to decide which equation to use: positive or negative).