Skip to content

Example 2: Creating an SA Reader explicitly in CPP

jmessias edited this page Jun 29, 2015 · 1 revision
//Necessary includes
#include <monarch_situational_awareness/CreateReader.h>

//Reader Creation:
//Explicit style - without using helpers----------------------------
ros::NodeHandle n;
ros::service::waitForService("create_reader");    
monarch_situational_awareness::CreateReader cr;
string topic_name;
ros::Duration d(5.0);
while(!cr.response.success)
{
  cr.request.properties.slot_name = "Slot B";
  //you can also set the agent name here if needed.
  cr.request.properties.agent_name = "";
  service::call("create_reader",cr);
  d.sleep();
}
ros::Subscriber sub = n.subscribe(cr.response.topic_name,1,callback);