test_intent_event.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <dialogflow_ros/DialogflowEvent.h>
3 #include <dialogflow_ros/DialogflowParameter.h>
4 
5 int main(int argc, char **argv)
6 {
7  ros::init(argc, argv, "test_intent_event");
9  ros::Rate poll_rate(100);
10  ros::Publisher pub = n.advertise<dialogflow_ros::DialogflowEvent>("/dialogflow_client/requests/df_event", 10);
11  while(pub.getNumSubscribers() == 0) poll_rate.sleep();
12  ros::Duration(1).sleep();
13 
14  dialogflow_ros::DialogflowEvent event;
15  event.event_name = "objects_found";
16  dialogflow_ros::DialogflowParameter parameter;
17  parameter.param_name = "objects";
18  std::string milk = "milk";
19  std::string snack = "snack";
20  std::vector<std::string> object_list = {milk, snack};
21  // parameter.value.resize(2);
22  parameter.value = object_list;
23  // parameter.value.push_back(milk);
24  // parameter.value = object_list;
25  event.parameters.push_back(parameter);
26 
27  // std::cout << "Event: " << event << std::endl;
28  std::cout << "Parameter: " << parameter << std::endl;
29  std::cout << "Values" << std::endl;
30  for (auto val : parameter.value)
31  std::cout << val << std::endl;
32 
33 
34  pub.publish(event);
35  ros::Duration(1).sleep();
36  return 0;
37 }
void publish(const boost::shared_ptr< M > &message) const
int main(int argc, char **argv)
bool sleep() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool sleep()
uint32_t getNumSubscribers() const


dialogflow_ros
Author(s): Anas Abou Allaban
autogenerated on Mon Jun 10 2019 13:02:59