44// license that can be found in the LICENSE file or at
55// https://opensource.org/licenses/MIT.
66
7- // #include <arpa/inet.h>
8- // #include <netinet/in.h>
9- // #include <stdio.h>
10- // #include <stdlib.h>
11- // #include <string.h>
12- // #include <sys/socket.h>
13- // #include <sys/types.h>
14- // #include <time.h>
15-
16- // #include <atomic>
177#include < boost/asio.hpp>
188#include < boost/thread.hpp>
199#include < crane_msgs/msg/robot_feedback.hpp>
@@ -33,7 +23,7 @@ struct RobotInterfaceConfig
3323auto makeConfig (uint8_t id) -> RobotInterfaceConfig
3424{
3525 RobotInterfaceConfig config;
36- config.ip = " 224.5.20.10 " + std::to_string (id);
26+ config.ip = " 224.5.20." + std::to_string (id + 100 );
3727 config.port = 50100 + id;
3828 return config;
3929}
@@ -293,40 +283,5 @@ int main(int argc, char * argv[])
293283 exe.add_node (node->get_node_base_interface ());
294284 exe.spin ();
295285 rclcpp::shutdown ();
296- // try {
297- // boost::asio::io_service io_service;
298- //
299- // // ローカルホストの指定したポートでUDPソケットを開く
300- // udp::socket socket(io_service);
301- // auto listen_address = boost::asio::ip::address::from_string("224.5.20.100");
302- // boost::asio::ip::udp::endpoint listen_endpoint(listen_address, 50100);
303- //
304- // socket.open(listen_endpoint.protocol());
305- //
306- // if (socket.is_open()) {
307- // std::cout << "socket opened" << std::endl;
308- // } else {
309- // std::cout << "socket not opened" << std::endl;
310- // }
311- // socket.set_option(boost::asio::ip::udp::socket::reuse_address(true));
312- // socket.bind(listen_endpoint);
313- //
314- // // Join the multicast group.
315- // socket.set_option(boost::asio::ip::multicast::join_group(listen_address));
316- //
317- //
318- // std::cout << "joined multicast group" << std::endl;
319- //
320- // for (;;) { // 無限ループでパケットを待ち受ける
321- // char data[1024];
322- // udp::endpoint sender_endpoint;
323- // size_t length = socket.receive_from(boost::asio::buffer(data), sender_endpoint);
324- //
325- // std::cout << "Received packet: " << std::string(data, length) << std::endl;
326- // }
327- // } catch (std::exception & e) {
328- // std::cerr << "Exception: " << e.what() << "\n";
329- // }
330-
331286 return 0 ;
332287}
0 commit comments