Commit 66921fc2 authored by bucyril's avatar bucyril
Browse files

PPSClient can establish connection to CentralManager

parent 8cc10520
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<node pkg="d_fall_pps" name="PPSClient" output="screen" type="PPSClient"> <node pkg="d_fall_pps" name="PPSClient" output="screen" type="PPSClient">
<rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" /> <rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" />
<param name="studentID" value="$(optenv ROS_NAMESPACE)" />
</node> </node>
<node pkg="d_fall_pps" name="SafeControllerService" output="screen" type="SafeControllerService"> <node pkg="d_fall_pps" name="SafeControllerService" output="screen" type="SafeControllerService">
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <ros/package.h> #include <ros/package.h>
#include "d_fall_pps/Controller.h" #include "d_fall_pps/Controller.h"
#include "d_fall_pps/CentralManager.h" #include "d_fall_pps/CMQuery.h"
#include "d_fall_pps/ViconData.h" #include "d_fall_pps/ViconData.h"
#include "d_fall_pps/CrazyflieData.h" #include "d_fall_pps/CrazyflieData.h"
...@@ -43,6 +43,8 @@ using namespace d_fall_pps; ...@@ -43,6 +43,8 @@ using namespace d_fall_pps;
std::string teamName; std::string teamName;
//name of the crazyflie, as specified in Vicon //name of the crazyflie, as specified in Vicon
std::string crazyflieName; std::string crazyflieName;
//studentID, gives namespace and identifier in CentralManagerService
int studentID;
//the safe controller specified in the ClientConfig.yaml, is considered trusted //the safe controller specified in the ClientConfig.yaml, is considered trusted
ros::ServiceClient safeController; ros::ServiceClient safeController;
...@@ -140,15 +142,23 @@ void loadParameters(ros::NodeHandle& nodeHandle) { ...@@ -140,15 +142,23 @@ void loadParameters(ros::NodeHandle& nodeHandle) {
if(!nodeHandle.getParam("crazyFlieName", crazyflieName)) { if(!nodeHandle.getParam("crazyFlieName", crazyflieName)) {
ROS_ERROR("Failed to get crazyFlieName"); ROS_ERROR("Failed to get crazyFlieName");
} }
if(!nodeHandle.getParam("studentID", studentID)) {
ROS_ERROR("Failed to get studentID");
}
} }
void loadCrazyflieContext() { void loadCrazyflieContext() {
CentralManager centralManagerCall; CMQuery contextCall;
if(centralManager.call(centralManagerCall)) { contextCall.request.studentID = studentID;
context = centralManagerCall.response.context;
ROS_INFO("CrazyflieContext obtained"); centralManager.waitForExistence(ros::Duration(-1));
if(centralManager.call(contextCall)) {
context = contextCall.response.crazyflieContext;
ROS_INFO_STREAM("CrazyflieContext:" << context);
} else { } else {
ROS_ERROR("Failed to call CentralManagerService"); ROS_ERROR("Failed to load context");
} }
} }
...@@ -213,7 +223,7 @@ int main(int argc, char* argv[]){ ...@@ -213,7 +223,7 @@ int main(int argc, char* argv[]){
//ros::service::waitForService("/CentralManagerService/CentralManager"); //ros::service::waitForService("/CentralManagerService/CentralManager");
centralManager = nodeHandle.serviceClient<CentralManager>("/CentralManagerService/CentralManager"); centralManager = nodeHandle.serviceClient<CMQuery>("/CentralManagerService/Query", false);
loadCrazyflieContext(); loadCrazyflieContext();
//keeps 100 messages because otherwise ViconDataPublisher would override the data immediately //keeps 100 messages because otherwise ViconDataPublisher would override the data immediately
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "d_fall_pps/ViconData.h" #include "d_fall_pps/ViconData.h"
#include "d_fall_pps/UnlabeledMarker.h" #include "d_fall_pps/UnlabeledMarker.h"
#define TESTING_FAKE_DATA
// notice that unit here are in milimeters // notice that unit here are in milimeters
using namespace ViconDataStreamSDK::CPP; using namespace ViconDataStreamSDK::CPP;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment