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