Skip to content
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

Thruster 2025 #21

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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 include/thruster_info.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef SENSIING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_INFO_HPP
#define SENSIING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_INFO_HPP
const int kThrusterCount = 6;
#endif // SENSIING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_INFO_HPP
const int kThrusterNeutralPWM = 1500;
const int kThrusterPins[]={2,3,4,5,6,7};
#endif // SENSIING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_INFO_HPP
6 changes: 3 additions & 3 deletions src/communication/communication.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SENSING_AND_CONTROL_UNIT_SRC_COMMUNICATION_COMMUNICATION_HPP
#define SENSING_AND_CONTROL_UNIT_SRC_COMMUNICATION_COMMUNICATION_HPP
#ifndef SENSIING_AND_CONTROL_UNIT_SRC_COMMUNICATION_COMMUNICATION_HPP
#define SENSIING_AND_CONTROL_UNIT_SRC_COMMUNICATION_COMMUNICATION_HPP
#include "error.hpp"
#include "vec3.hpp"
#include "thruster_info.hpp"
Expand Down Expand Up @@ -38,4 +38,4 @@ class Communication {
void recieveCommands();
};
} // namespace sensing_and_control_unit
#endif // SENSING_AND_CONTROL_UNIT_SRC_COMMUNICATION_COMMUNICATION_HPP
#endif // SENSING_AND_CONTROL_UNIT_SRC_COMMUNICATION_COMMUNICATION_HPP
21 changes: 18 additions & 3 deletions src/thruster/thruster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@

namespace sensing_and_control_unit {
Thrusters::Thrusters() {}

Thrusters::~Thrusters() {}

void Thrusters::initialize() {}
void Thrusters::initialize()
{
for(int thruster_index=0;thruster_index<kThrusterCount;thruster_index++)
{
thrusters_[thruster_index].attach(kThrusterPins[thruster_index]);
thrusters_[thruster_index].writeMicroseconds(kThrusterNeutralPWM);
}
}

void Thrusters::setPWMs(int pwm_values[kThrusterCount])
{
int pwm_value;
for(int thruster_index=0;thruster_index<kThrusterCount;thruster_index++)
{
pwm_value = pwm_values[thruster_index];
thrusters_[thruster_index].writeMicroseconds(pwm_value);
}

void Thrusters::setPWMs(int pwm_values[kThrusterCount]) {}
}

} // namespace sensing_and_control_unit
13 changes: 11 additions & 2 deletions src/thruster/thruster.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
#ifndef SENSING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_HPP
#define SENSING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_HPP

#include "thruster_info.hpp"
#include <Servo.h>
#include <std_msgs/Int32MultiArray.h>
#include <ros.h>
#include "Arduino.h"

namespace sensing_and_control_unit
{
class Thrusters
{
private:
Servo thrusters_[kThrusterCount];
ros::Subscriber<std_msgs::Int32MultiArray> pwm_sub_;
void pwmCallback(const std_msgs::Int32MultiArray &msg);

public:
Thrusters();
~Thrusters();
void initialize();
void initialize();
void setPWMs(int pwm_values[kThrusterCount]);
};
} // namespace sensing_and_control_unit
#endif // SENSING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_HPP

#endif // SENSING_AND_CONTROL_UNIT_SRC_THRUSTER_THRUSTER_HPP