This file contains 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
template<typename DurationT, typename CallbackT> | |
typename rclcpp::WallTimer<CallbackT>::SharedPtr | |
Node::create_wall_timer( | |
std::chrono::duration<int64_t, DurationT> period, | |
CallbackT callback, | |
rclcpp::callback_group::CallbackGroup::SharedPtr group) | |
{ | |
auto timer = rclcpp::WallTimer<CallbackT>::make_shared( | |
std::chrono::duration_cast<std::chrono::nanoseconds>(period), | |
std::move(callback)); |
This file contains 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
Node::Node( | |
const std::string & node_name, | |
const std::string & namespace_, | |
rclcpp::Context::SharedPtr context, | |
bool use_intra_process_comms) | |
: node_base_(new rclcpp::node_interfaces::NodeBase(node_name, namespace_, context)), | |
node_graph_(new rclcpp::node_interfaces::NodeGraph(node_base_.get())), | |
node_logging_(new rclcpp::node_interfaces::NodeLogging(node_base_.get())), | |
node_timers_(new rclcpp::node_interfaces::NodeTimers(node_base_.get())), | |
node_topics_(new rclcpp::node_interfaces::NodeTopics(node_base_.get())), |
This file contains 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
uint32_t serialize_std_msgs__string(void *_msg, uint8_t *_buf, uint32_t _buf_size) | |
{ | |
struct std_msgs__string *_s = (struct std_msgs__string *)_msg; | |
uint8_t *_p = _buf; | |
if ((uintptr_t)_p & 3) | |
_p += 4 - ((uintptr_t)_p & 3); | |
uint32_t _data_len = (uint32_t)strlen(_s->data) + 1; | |
*((uint32_t *)_p) = _data_len; | |
_p += 4; | |
memcpy(_p, _s->data, _data_len); |
This file contains 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
bool frudp_publish_user_msg(frudp_pub_t *pub, | |
const uint8_t *payload, const uint32_t payload_len) | |
{ | |
if (pub->reliable) | |
{ | |
// 高信頼通信は未対応 | |
FREERTPS_ERROR("user reliable publishing not quite done yet.\n"); | |
return false; | |
} |
This file contains 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
#include <stdio.h> | |
#include "freertps/freertps.h" | |
// コールバック関数 | |
void chatter_cb(const void *msg) | |
{ | |
// str_lenの型は32ビットなのに、forループの中では8ビット受け渡しなのが解せない | |
uint32_t str_len = *((uint32_t *)msg); | |
char buf[128] = {0}; | |
for (int i = 0; i < str_len && i < sizeof(buf)-1; i++) |
This file contains 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
auto parameters = parameters_client->get_parameters({"parameter_number", "parameter_string", "parameter_boolean"}); | |
if (rclcpp::spin_until_future_complete(node, parameters) != rclcpp::executor::FutureReturnCode::SUCCESS) | |
{ | |
std::cerr << "Failed to set parameter: " << result.reason << std::endl; | |
return -1; | |
} | |
for (auto & parameter : parameters.get()) { | |
std::cout << "Parameter name: " << parameter.get_name() << std::endl; | |
std::cout << "Parameter value (" << parameter.get_type_name() << "): " << | |
parameter.value_to_string() << std::endl; |
This file contains 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
int main(int argc, char ** argv) | |
{ | |
rclcpp::init(argc, argv); | |
auto node = rclcpp::Node::make_shared("get_parameters"); | |
auto parameter_service = std::make_shared<rclcpp::parameter_service::ParameterService>(node); | |
auto parameters_client = std::make_shared<rclcpp::parameter_client::SyncParametersClient>(node); | |
// パラメータの設定 | |
auto set_parameters_results = parameters_client->set_parameters({ | |
rclcpp::parameter::ParameterVariant("parameter_number", 1), | |
rclcpp::parameter::ParameterVariant("parameter_string", "hello"), |
This file contains 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
explicit ParameterVariant(const std::string & name, const bool bool_value); | |
explicit ParameterVariant(const std::string & name, const int int_value); | |
explicit ParameterVariant(const std::string & name, const int64_t int_value); | |
explicit ParameterVariant(const std::string & name, const float double_value); | |
explicit ParameterVariant(const std::string & name, const double double_value); |
This file contains 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
void | |
add_subscription(const rclcpp::subscription::SubscriptionBase::SharedPtr subscription_ptr); | |
void | |
add_timer(const rclcpp::timer::TimerBase::SharedPtr timer_ptr); | |
void | |
add_service(const rclcpp::service::ServiceBase::SharedPtr service_ptr); | |
void |
This file contains 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
enum class CallbackGroupType | |
{ | |
MutuallyExclusive, | |
Reentrant | |
}; |
NewerOlder