Commit fd9a13f7 authored by roangel's avatar roangel
Browse files

Not able to subscribe yet to the publisher, dont know why, but compiling all ros stuff

parent 6eeaa41f
......@@ -10,6 +10,7 @@
#ifdef CATKIN_MAKE
#include "ros/callback_queue.h"
#include "ros/ros.h"
#include "d_fall_pps/ViconData.h"
#endif
#include "ui_mainguiwindow.h"
......@@ -61,7 +62,11 @@ class MainGUIWindow : public QMainWindow
Q_OBJECT
public:
#ifdef CATKIN_MAKE
explicit MainGUIWindow(ros::NodeHandle* pNodeHandle, QWidget *parent = 0);
#else
explicit MainGUIWindow(QWidget *parent = 0);
#endif
~MainGUIWindow();
public slots:
......@@ -106,6 +111,8 @@ private:
Marker* marker;
#ifdef CATKIN_MAKE
ros::NodeHandle* _pNodeHandle;
ros::Subscriber* ViconSubscriber;
#endif
};
......
......@@ -5,6 +5,14 @@
#ifdef CATKIN_MAKE
#endif
#ifdef CATKIN_MAKE
using namespace d_fall_pps;
#endif
int main(int argc, char *argv[])
{
#ifdef CATKIN_MAKE
......@@ -13,8 +21,11 @@ int main(int argc, char *argv[])
#endif
QApplication applicationGUI(argc, argv);
#ifdef CATKIN_MAKE
MainGUIWindow mainWindow(&nodeHandle);
#else
MainGUIWindow mainWindow;
#endif
mainWindow.show();
applicationGUI.exec();
......
......@@ -11,13 +11,32 @@
#include <string>
#ifdef CATKIN_MAKE
using namespace d_fall_pps;
void viconCallback(const ViconData& data)
{
ROS_INFO("in viconCallback");
qDebug("in viconCallback");
}
#endif
#define N_MAX_CRAZYFLIES 20 // protection number
#ifdef CATKIN_MAKE
#else
MainGUIWindow::MainGUIWindow(ros::NodeHandle* pNodeHandle, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainGUIWindow),
_pNodeHandle(pNodeHandle)
{
ui->setupUi(this);
_init();
}
#endif
#else
MainGUIWindow::MainGUIWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainGUIWindow)
......@@ -27,6 +46,9 @@ MainGUIWindow::MainGUIWindow(QWidget *parent) :
_init();
}
#endif
MainGUIWindow::~MainGUIWindow()
{
delete ui;
......@@ -47,6 +69,12 @@ void MainGUIWindow::set_tabs(int n)
void MainGUIWindow::_init()
{
sleep(1000);
#ifdef CATKIN_MAKE
ViconSubscriber = new ros::Subscriber(_pNodeHandle->subscribe("/ViconDataPublisher/ViconData", 1, viconCallback));
ROS_INFO("successfully subscribed to ViconData from GUI");
qDebug("successfully subscribed to ViconData from GUI");
#endif
ui->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
......
<launch>
<node pkg="d_fall_pps" name="CentralManagerService" output="screen" type="CentralManagerService">
</node>
<!-- <node pkg="d_fall_pps" name="CentralManagerService" output="screen" type="CentralManagerService"> -->
<!-- </node> -->
<node pkg="d_fall_pps" name="CrazyRadio" output="screen" type="CrazyRadio.py">
<rosparam command="load" file="$(find d_fall_pps)/launch/studentParams.yaml" />
</node>
<!-- <node pkg="d_fall_pps" name="CrazyRadio" output="screen" type="CrazyRadio.py"> -->
<!-- <rosparam command="load" file="$(find d_fall_pps)/launch/studentParams.yaml" /> -->
<!-- </node> -->
<node pkg="d_fall_pps" name="ViconDataPublisher" output="screen" type="ViconDataPublisher">
</node>
<node pkg="d_fall_pps" name="PPSClient" output="screen" type="PPSClient">
<rosparam command="load" file="$(find d_fall_pps)/launch/studentParams.yaml" />
</node>
<!-- <node pkg="d_fall_pps" name="PPSClient" output="screen" type="PPSClient"> -->
<!-- <rosparam command="load" file="$(find d_fall_pps)/launch/studentParams.yaml" /> -->
<!-- </node> -->
<node pkg="d_fall_pps" name="SafeControllerService" output="screen" type="SafeControllerService">
</node>
<!-- <node pkg="d_fall_pps" name="SafeControllerService" output="screen" type="SafeControllerService"> -->
<!-- </node> -->
<!-- When we have a GUI, this has to be adapted and included
<node pkg="d_fall_pps" name="GUI" output="screen" type="GUI">
<rosparam command="load" file="$(find d_fall_pps)/launch/ControlParams.yaml" />
<!-- When we have a GUI, this has to be adapted and included -->
<node pkg="d_fall_pps" name="my_GUI" output="screen" type="my_GUI">
<!-- <rosparam command="load" file="$(find d_fall_pps)/launch/ControlParams.yaml" /> -->
</node>
-->
</launch>
......@@ -126,7 +126,7 @@ bool safetyCheck(ViconData data){
//is called upon every new arrival of data in main
void viconCallback(const ViconData& data){
ROS_INFO("in viconCallback");
ROS_INFO("in viconCallback PPSClient");
//ROS_INFO_STREAM(data);
//ROS_INFO("My teamname is:"); ROS_INFO_STREAM(team);
//ROS_INFO("My crazyflie is:"); ROS_INFO_STREAM(cflie);
......
......@@ -44,17 +44,21 @@ int main(int argc, char* argv[]) {
nodeHandle.advertise<ViconData>("ViconData", 1);
//publish something random if no viconData is available for testing
/*
ViconData viconData;
double i = 1;
while(true)
int i = 1;
while(ros::ok())
{
if(i % 1000 == 0)
{
ROS_INFO("iteration #%d",i);
}
viconData.roll = i;
viconDataPublisher.publish(viconData);
ros::Duration(0.001).sleep();
++i;
}
//the code will not go further than here if testing without real ViconData
*/
Client client;
......
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