-
-
Save cwyark/ecec75775e20451b4d496599937808b0 to your computer and use it in GitHub Desktop.
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 <cinttypes> | |
#include <cstdio> | |
#include <memory> | |
#include <string> | |
#include "rclcpp/rclcpp.hpp" | |
#include "rcl_interfaces/srv/describe_parameters.hpp" | |
#include "rcl_interfaces/srv/get_parameter_types.hpp" | |
#include "rcl_interfaces/srv/get_parameters.hpp" | |
#include "rcl_interfaces/srv/list_parameters.hpp" | |
#include "rcl_interfaces/srv/set_parameters.hpp" | |
#include "rcl_interfaces/srv/set_parameters_atomically.hpp" | |
class ServerNode : public rclcpp::Node | |
{ | |
public: | |
explicit ServerNode() | |
: Node("param_server") | |
{ | |
// Create a callback function for when service requests are received. | |
auto callback_ = | |
[this](const std::shared_ptr<rmw_request_id_t> request_header, | |
const std::shared_ptr<rcl_interfaces::srv::GetParameters::Request> request, | |
std::shared_ptr<rcl_interfaces::srv::GetParameters::Response> response) -> void | |
{ | |
(void)this; | |
(void)request_header; | |
(void)request; | |
(void)response; | |
}; | |
// Create a service that will use the callback function to handle requests. | |
srv_ = create_service<rcl_interfaces::srv::GetParameters>("get_parameters", callback_); | |
} | |
private: | |
rclcpp::Service<rcl_interfaces::srv::GetParameters>::SharedPtr srv_; | |
}; | |
int main(int argc, char * argv[]) | |
{ | |
setvbuf(stdout, NULL, _IONBF, BUFSIZ); | |
rclcpp::init(argc, argv); | |
auto node = std::make_shared<ServerNode>(); | |
rclcpp::spin(node); | |
rclcpp::shutdown(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment