 # Programming fsolve for arduino?

I am building a submarine with two thrusters each of which is connected to two servos allowing 360 degrees of motion. I have used the fsolve function in octave to solve the nonlinear system of equations to get the servo angles and thrust needed to create my desired motion. I want the Arduino to take a string input <(x,y,z,roll,pitch,yaw> and run those inputs through fsolve and output the angles and thrusts to be sent to the respective servos and motor controllers. Unfortunately fsolve does not exist in Arduino so I will be trying to program it in based on the source code provided by octave. I am very new to programming in Arduino so any help will be very appreciated. Is this goal achievable?

fsolve source code - fsolve.m | searchcode

That code calls functions that are not defined. You'll need ALL of the functions if you hope to implement that on an Arduino.

Where are you getting the x, y, z, yaw, pitch, roll values to send to the Arduino?

Paul the inputs will be given as a string. Attached is the current code I have commented where I want to add the fsolve to get the correct outputs to send to the motors and servos.

sketch_apr13a.ino (6.29 KB)

PaulS:
Where are you getting the x, y, z, yaw, pitch, roll values to send to the Arduino?

Paul the inputs will be given as a string.

What is the source for the x, y, z, yaw, pitch, roll values?

From the serial monitor, the values are given to us as a string. For example:

100,0,0,0,0,100

That would mean full speed in the X direction and Yaw full speed in a positive direction.

These numbers are user generated and can range from -100 to 100.

Just a guess here. But, I’m thinking on a low-end microcontroller you’re going to have to come up with a different method than a brute force numerical equation solver.

I want the Arduino to take a string input <(x,y,z,roll,pitch,yaw> and run those inputs through fsolve and output the angles and thrusts to be sent to the respective servos and motor controllers.

Here is a novel idea: the computer that is supposed to send the strings to the Arduino could run Octave, and

output the angles and thrusts to be sent to the respective servos and motor controllers.