Skip to content

updating my branch #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Propulsion_2024/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ struct pwm_array {
int pwm_signals[8];

};

struct Command {
pwm_array thruster_pwms; // PWM values for each thruster
float duration; // Duration of the command in seconds
};
struct Sequence {
std::vector<Command> commands;
};

51 changes: 39 additions & 12 deletions Propulsion_2024/Thruster_Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Thruster_Commander::Thruster_Commander()
angular_velocity = Eigen::Matrix<float, 1, 3>::Zero();
acceleration = Eigen::Matrix<float, 1, 3>::Zero();
angular_acceleration = Eigen::Matrix<float, 1, 3>::Zero();

}

Thruster_Commander::~Thruster_Commander()
Expand Down Expand Up @@ -117,7 +116,7 @@ int Thruster_Commander::get_pwm(int thruster_num, float force) {
return 1500;
}

//

Eigen::Matrix<float, 1, 3> Thruster_Commander::compute_forces(force_array forces)
{
Eigen::Matrix<float, 1, 3> total_force = Eigen::Matrix<float, 1, 3>::Zero();
Expand Down Expand Up @@ -171,63 +170,91 @@ force_array Thruster_Commander::thrust_compute_fz(float z_force)
}
return forces;
}
force_array Thruster_Commander::thrust_compute_fy(float y_force){
force_array Thruster_Commander::thrust_compute_fy(float y_force)
{

// fx, fz and mz should be zero
// my and mz should be small enough to keep the vehicle stable

force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fx(float x_force){
force_array Thruster_Commander::thrust_compute_fx(float x_force)
{
// fy, fz and mz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;

}
force_array Thruster_Commander::thrust_compute_fx_fy(float x_force, float y_force)
{
// fz and mz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_mz(float z_torque)
{
// fx, fy and fz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fz_mz(float z_force, float z_torque)
{
// fx and fy should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fy_mz(float force, float torque)
force_array Thruster_Commander::thrust_compute_fy_mz(float y_force, float z_torque)
{
// fx and fz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fx_mz(float force, float torque)
force_array Thruster_Commander::thrust_compute_fx_mz(float x_force, float z_torque)
{
// fy and fz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fx_fy_mz(float x_force, float y_force, float torque)
force_array Thruster_Commander::thrust_compute_fx_fy_mz(float x_force, float y_force, float z_torque)
{
// fz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fx_fy_fz(float x_force, float y_force)
{
// mz should be zero
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fx_fy_fz_mz(float x_distance, float y_force, float z_force, float torque)
force_array Thruster_Commander::thrust_compute_fx_fy_fz_mz(float x_distance, float y_force, float z_force, float z_torque)
{
// mx and my should be small enough to keep the vehicle stable
force_array forces;
return forces;
}
force_array Thruster_Commander::thrust_compute_fx_fy_fz_mx_my_mz(float x_force, float y_force, float z_force, float, float x_torque, float y_torque, float z_torque)
{
// this is the most general case
// all forces and torques are specified
force_array forces;
return forces;
}

Command Thruster_Commander::simple_vertical_travel(float z_distance)
force_array Thruster_Commander::thrust_compute(Eigen::Matrix<float, 1, 6> force_torque, bool simple=true)
{
Command command;
return command;
}
// this is a general case force function
// it will call other force functions depending on what forces and torques are specified
// if simple=true, mz and my will be neglected
force_array forces;
return forces;
}
18 changes: 12 additions & 6 deletions Propulsion_2024/Thruster_Commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Thruster_Commander
bool simple_is_it_possible(float x_force, float y_force, float z_force, float z_torque);
bool is_it_possible(float x_force, float y_force, float z_force, float x_torque, float y_torque, float z_torque);

// force-torque commands
// force-torque computations
// these functions compute the forces from each thruster necessary to acheive a given force or torque on the sub
// these functions do not condier drag, or any other forces not produced directly by the thruster
// suffixes state which forces and torques are being driven by the thrusters
Expand All @@ -104,20 +104,26 @@ class Thruster_Commander
force_array thrust_compute_fy(float y_force);
force_array thrust_compute_fx(float x_force);
force_array thrust_compute_fx_fy(float x_force, float y_force);

force_array thrust_compute_mz(float z_torque);
force_array thrust_compute_fz_mz(float z_force, float z_torque);
force_array thrust_compute_fy_mz(float y_force, float z_torque);
force_array thrust_compute_fx_mz(float force, float torque);
force_array thrust_compute_fx_fy_mz(float x_force, float y_force, float torque);

force_array thrust_compute_fx_fy_fz(float x_force, float y_force);
force_array thrust_compute_fx_fy_fz_mz(float x_distance, float y_force, float z_force, float torque);

force_array thrust_compute_fx_fy_fz_mx_my_mz(float x_force, float y_force, float z_force, float, float x_torque, float y_torque, float z_torque);

// distance commands
Command simple_vertical_travel(float z_distance);
// this is a general case force function
// it will call other force functions depending on what forces and torques are specified
// if simple=true, mz and my will be neglected
force_array thrust_compute(Eigen::Matrix<float, 1, 6> force_torque, bool simple=true);

// computes a force array from an acceleration vector (surge, sway, heave) in m/s^2, and (roll, pitch, yaw) in rad/s^2
force_array acceleration_compute(Eigen::Matrix<float, 1, 6> acceleration, bool simple=true);

// generates a command to a target velocity
// target velocity is a 1x6 matrix with (sway, surge, heave) linear velocities in m/s and (roll, pitch, yaw) angular velocities in r/s
Command accelerate_to(Eigen::Matrix<float, 1, 6> target_velocity);

};

8 changes: 8 additions & 0 deletions Propulsion_2024/UnitTesting.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ int thruster_commander_test_0()
thruster_commander.thrust_compute_fz(5);
return 0;
}
int thrust_commander_constructor_tests()
{
return 0;
}
int pwm_lookup_test()
{
return 0;
}


// TODO:
Expand Down