talker.cpp
Go to the documentation of this file.
1 
29 
30 #include "ros/ros.h"
31 
32 int main(int argc, char **argv)
33 {
34  ros::init(argc, argv, "json_talker");
35 
36  ros::NodeHandle nh;
37 
38  auto publisher = nh.advertise<json_transport::json_t>("json", 1000, true);
39 
40  std::string data_string;
41  nh.getParam("test_data", data_string);
42  auto data = json_transport::json_t::parse(data_string);
43 
44  ROS_INFO_STREAM("Publishing " << data);
45 
46  publisher.publish(data);
47 
48  ros::spin();
49 
50  return 0;
51 }
a class to store JSON values
Definition: json.hpp:85
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
Definition: talker.cpp:32
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ROSCPP_DECL void spin()
static basic_json parse(detail::input_adapter i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true)
deserialize from a compatible input
Definition: json.hpp:15605
#define ROS_INFO_STREAM(args)
bool getParam(const std::string &key, std::string &s) const


json_transport
Author(s): Paul Bovbel
autogenerated on Wed Jan 27 2021 03:58:48