Skip to content

Acoustic modem node#26

Open
glebmih wants to merge 3 commits intofeat/hydrv_protocolfrom
acoustic_modem_node
Open

Acoustic modem node#26
glebmih wants to merge 3 commits intofeat/hydrv_protocolfrom
acoustic_modem_node

Conversation

@glebmih
Copy link
Copy Markdown

@glebmih glebmih commented Mar 18, 2026

No description provided.

@WaspishRaccoon WaspishRaccoon self-requested a review March 19, 2026 10:19
private:
void raw_packet_callback(const std_msgs::msg::Int32MultiArray::ConstSharedPtr& msg);

private:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавь сюда
rclcpp::Node::SharedPtr node_;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил

class AcousticModem : public rclcpp::Node
{
public:
AcousticModem();
Copy link
Copy Markdown
Member

@WaspishRaccoon WaspishRaccoon Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вместо AcousticModem(); используем другую конструкцию:

explicit AcousticModem(
        rclcpp::NodeOptions options = rclcpp::NodeOptions());

    void spin() { 
        rclcpp::spin(node_);
    }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделал


namespace stingray_core::acoustic_modem
{
class AcousticModem : public rclcpp::Node
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь пишешь просто class AcousticModem

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Готово

@@ -0,0 +1,14 @@
from launch import LaunchDescription
Copy link
Copy Markdown
Member

@WaspishRaccoon WaspishRaccoon Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай сделаем одинавовые лаунчи. Вот пример:

import os

from launch import LaunchDescription

from ament_index_python.packages import get_package_share_directory
from launch_ros.actions import Node

PRESSURE_SENSOR_PACKAGE = "pressure_sensor"
PRESSURE_SENSOR_NODE_NAME = "pressure_sensor"
PRESSURE_SENSOR_NAMESPACE = "stingray_core/pressure_sensor"


def generate_launch_description():
    package_dir = get_package_share_directory(PRESSURE_SENSOR_PACKAGE)
    config_file = os.path.join(package_dir, "config", "pressure_sensor.param.yaml")

    return LaunchDescription(
        [
            Node(
                package=PRESSURE_SENSOR_PACKAGE,
                executable=PRESSURE_SENSOR_NODE_NAME,
                name=PRESSURE_SENSOR_NODE_NAME,
                output="screen",
                namespace=PRESSURE_SENSOR_NAMESPACE,
                parameters=[config_file],
                emulate_tty=True,
            )
        ]
    )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено


namespace stingray_core::acoustic_modem
{
AcousticModem::AcousticModem() : Node("acoustic_modem")
Copy link
Copy Markdown
Member

@WaspishRaccoon WaspishRaccoon Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AcousticModem::AcousticModem(rclcpp::NodeOptions options)

Вот пример:

PressureSensor::PressureSensor(rclcpp::NodeOptions options)
    : node_(rclcpp::Node::make_shared("pressure_sensor",
                                      std::move(options))),
      config_(node_),
      depth_pub_(node_->create_publisher<std_msgs::msg::Float64>("depth", rclcpp::SensorDataQoS())),
      data_raw_sub_(node_->create_subscription<std_msgs::msg::String>(
          "/stingray_core/depth_link_node/data_raw", rclcpp::SensorDataQoS(),
          [this](const std_msgs::msg::String::ConstSharedPtr& msg) {
              this->data_raw_callback(msg);
          })) {

    RCLCPP_INFO(node_->get_logger(), "Pressure sensor node initialized");
    RCLCPP_INFO(node_->get_logger(), "dump_param: %.3f", config_.dump_param);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пофиксил

auto message_start_code = std_msgs::msg::Int8MultiArray();
message_start_code.data.assign(start_code, start_code + 3);
start_code_pub_->publish(message_start_code);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что-то с отступами не так, надо настроить форматирование, он тогда будет и последнюю пустую строку автоматически ставить

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

rclcpp::spin(std::make_shared<stingray_core::acoustic_modem::AcousticModem>());
rclcpp::shutdown();
return 0;
} No newline at end of file
Copy link
Copy Markdown
Member

@WaspishRaccoon WaspishRaccoon Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай вот так сделаем:

int main(int argc, char** argv) {
    rclcpp::init(argc, argv);
    auto sensor_node =
        std::make_shared<stingray_core::pressure_sensor::PressureSensor>();
    sensor_node->spin();
    rclcpp::shutdown();
    return 0;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Готово

Comment thread src/acoustic_modem/CMakeLists.txt Outdated

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в коде вроде не используется sensor_msgs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрал

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants