Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Clang Robot committed Mar 17, 2024
1 parent cc516d7 commit 361ca46
Showing 1 changed file with 48 additions and 46 deletions.
94 changes: 48 additions & 46 deletions motion/thruster_interface/src/thruster_interface_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using std::placeholders::_1;
constexpr double newton_to_gram_conversion_factor = 101.97162;

bool started = false;
//int8_t hardware_status = 0;
// int8_t hardware_status = 0;
uint8_t software_killswitch = 0;

class ThrusterInterface : public rclcpp::Node {
Expand All @@ -21,15 +21,20 @@ class ThrusterInterface : public rclcpp::Node {
std::bind(&ThrusterInterface::thrusterForcesCallback, this,
std::placeholders::_1));

publisher_ESC1 = this->create_publisher<std_msgs::msg::Float32>("/asv/temperature/ESC1", 10);
publisher_ESC2 = this->create_publisher<std_msgs::msg::Float32>("/asv/temperature/ESC2", 10);
publisher_ESC3 = this->create_publisher<std_msgs::msg::Float32>("/asv/temperature/ESC3", 10);
publisher_ESC4 = this->create_publisher<std_msgs::msg::Float32>("/asv/temperature/ESC4", 10);
publisher_status = this->create_publisher<std_msgs::msg::Int8>("/asv/status", 10);
publisher_ESC1 = this->create_publisher<std_msgs::msg::Float32>(
"/asv/temperature/ESC1", 10);
publisher_ESC2 = this->create_publisher<std_msgs::msg::Float32>(
"/asv/temperature/ESC2", 10);
publisher_ESC3 = this->create_publisher<std_msgs::msg::Float32>(
"/asv/temperature/ESC3", 10);
publisher_ESC4 = this->create_publisher<std_msgs::msg::Float32>(
"/asv/temperature/ESC4", 10);
publisher_status =
this->create_publisher<std_msgs::msg::Int8>("/asv/status", 10);

timer_ = this->create_wall_timer(
std::chrono::seconds(1),
std::bind(&ThrusterInterface::publish_temperature_and_status, this));
std::chrono::seconds(1),
std::bind(&ThrusterInterface::publish_temperature_and_status, this));
}

private:
Expand Down Expand Up @@ -59,64 +64,61 @@ class ThrusterInterface : public rclcpp::Node {
// SENDING
send_status(software_killswitch, file);
send_pwm(pwm_values, file);


}

void publish_temperature_and_status()
{
void publish_temperature_and_status() {

// RECEIVING
// RECEIVING

//int file;
//init(file);
// int file;
// init(file);

//TEMPERATURE
// TEMPERATURE

std::vector<float> temperature = {22.04, 43.04, 34.99, 49.66};
std::vector<float> temperature = {22.04, 43.04, 34.99, 49.66};

//temperature = readFloatsFromI2C(file);
// temperature = readFloatsFromI2C(file);

for (size_t i = 0; i < temperature.size(); i++) {
std::cout << i << "temperature value = " << temperature[i] << std::endl;
}
for (size_t i = 0; i < temperature.size(); i++) {
std::cout << i << "temperature value = " << temperature[i] << std::endl;
}

//hardware_status = read_hardware_statusFromI2C(file);
//cout << "hardware status = " << (uint16_t)(hardware_status) << endl;
// hardware_status = read_hardware_statusFromI2C(file);
// cout << "hardware status = " << (uint16_t)(hardware_status) << endl;


auto message_ESC1 = std_msgs::msg::Float32();
auto message_ESC2 = std_msgs::msg::Float32();
auto message_ESC3 = std_msgs::msg::Float32();
auto message_ESC4 = std_msgs::msg::Float32();
auto message_ESC1 = std_msgs::msg::Float32();
auto message_ESC2 = std_msgs::msg::Float32();
auto message_ESC3 = std_msgs::msg::Float32();
auto message_ESC4 = std_msgs::msg::Float32();

message_ESC1.data = temperature[0];
message_ESC2.data = temperature[1];
message_ESC3.data = temperature[2];
message_ESC4.data = temperature[3];
message_ESC1.data = temperature[0];
message_ESC2.data = temperature[1];
message_ESC3.data = temperature[2];
message_ESC4.data = temperature[3];

RCLCPP_INFO(this->get_logger(), "Publishing temperature");
publisher_ESC1->publish(message_ESC1);
publisher_ESC2->publish(message_ESC2);
publisher_ESC3->publish(message_ESC3);
publisher_ESC4->publish(message_ESC4);
RCLCPP_INFO(this->get_logger(), "Publishing temperature");
publisher_ESC1->publish(message_ESC1);
publisher_ESC2->publish(message_ESC2);
publisher_ESC3->publish(message_ESC3);
publisher_ESC4->publish(message_ESC4);

//HARDWARE STATUS
// HARDWARE STATUS

int8_t hardware_status = 0;
int8_t hardware_status = 0;

auto message_status = std_msgs::msg::Int8();
auto message_status = std_msgs::msg::Int8();

message_status.data = hardware_status;
message_status.data = hardware_status;

RCLCPP_INFO(this->get_logger(), "Publishing status");
RCLCPP_INFO(this->get_logger(), "Publishing status");

publisher_status->publish(message_status);
publisher_status->publish(message_status);

//close(file);
}
// close(file);
}

rclcpp::Subscription<vortex_msgs::msg::ThrusterForces>::SharedPtr subscription_;
rclcpp::Subscription<vortex_msgs::msg::ThrusterForces>::SharedPtr
subscription_;

rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr publisher_ESC1;
rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr publisher_ESC2;
Expand Down

0 comments on commit 361ca46

Please sign in to comment.