Open
Conversation
| private: | ||
| void raw_packet_callback(const std_msgs::msg::Int32MultiArray::ConstSharedPtr& msg); | ||
|
|
||
| private: |
Member
There was a problem hiding this comment.
Добавь сюда
rclcpp::Node::SharedPtr node_;
| class AcousticModem : public rclcpp::Node | ||
| { | ||
| public: | ||
| AcousticModem(); |
Member
There was a problem hiding this comment.
Вместо AcousticModem(); используем другую конструкцию:
explicit AcousticModem(
rclcpp::NodeOptions options = rclcpp::NodeOptions());
void spin() {
rclcpp::spin(node_);
}
|
|
||
| namespace stingray_core::acoustic_modem | ||
| { | ||
| class AcousticModem : public rclcpp::Node |
Member
There was a problem hiding this comment.
Здесь пишешь просто class AcousticModem
| @@ -0,0 +1,14 @@ | |||
| from launch import LaunchDescription | |||
Member
There was a problem hiding this comment.
Давай сделаем одинавовые лаунчи. Вот пример:
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,
)
]
)
|
|
||
| namespace stingray_core::acoustic_modem | ||
| { | ||
| AcousticModem::AcousticModem() : Node("acoustic_modem") |
Member
There was a problem hiding this comment.
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);
}
| 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); | ||
| } |
Member
There was a problem hiding this comment.
что-то с отступами не так, надо настроить форматирование, он тогда будет и последнюю пустую строку автоматически ставить
| rclcpp::spin(std::make_shared<stingray_core::acoustic_modem::AcousticModem>()); | ||
| rclcpp::shutdown(); | ||
| return 0; | ||
| } No newline at end of file |
Member
There was a problem hiding this comment.
Давай вот так сделаем:
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;
}
|
|
||
| find_package(ament_cmake REQUIRED) | ||
| find_package(rclcpp REQUIRED) | ||
| find_package(sensor_msgs REQUIRED) |
Member
There was a problem hiding this comment.
в коде вроде не используется sensor_msgs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.