On the note of a previous post I put up (T100 Analog Joystick Issues), I am planning on disassembling that setup and starting anew with different connections. My current plans are to create a code that can run 4 vectored thrusters, each with left, right, and strafe commands, as well as 2 vertical thrusters for vertical movement. I do have the Arduino IDE for Windows, as well as an Arduino Uno and the motors necessary. I also have multiple Analog joysticks for control. I am starting a fresh line of code, so any starter lines of code or possibly any prewritten lines of code would be extremely helpful, as well as schematics for motor hookups. Possibly the most specific request I have when it comes to the coding is how to create a command that allows one joystick to control 2 or more motors. Any help would be greatly appreciated.
You need to design some mixing algorithm.
For example imagine a vehicle with only two forward facing thrusters. The code to control it would be something like:
turn_command = x forward_command = y motor1 output = forward_command + turn_command motor2 output = forward_command - turn_command
Similarly, performing some mixing for a more complex arrangement like vectored thrusters would go something like this:
lateral_command = x forward_command = y turn_command = z motor1 output = forward_command + lateral command - turn_command motor2 output = forward_command - lateral command + turn_command motor3 output = -forward_command + lateral command + turn_command motor4 output = -forward_command - lateral_command - turn_command
These are just examples, the algorithm that works will depend on how you have everything hooked up and mounted. You should break it down into what each motor should do for a given axis. Start with only forward command, which way should each motor spin? Do lateral next, then add turning.
Is this something I could use the github example code (https://github.com/bluerobotics/br-esc-examples/blob/master/arduino/AnalogJoystickControl/AnalogJoystickControl.ino) for? It only runs three motors but maybe I can use another Arduino Uno to use the for the other 3 motors on our ROV.