qt gui global variables
Hi,
I created a Qt gui with c++ and I'm compiling it with cmake. Below you can find my CMakeLists.
**CMakeLists**
#My CMakeLists.txt
cmake_minimum_required (VERSION 2.8) project (teste)
#---------------------------------
FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(teste_SOURCES main.cpp mainwindow.cpp) SET(teste_FORMS mainwindow.ui) SET(teste_HEADERS mainwindow.h globals.h) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON)
QT4_WRAP_CPP(teste_HEADERS_MOC ${SimpleProject_HEADERS}) QT4_WRAP_UI(teste_FORMS_HEADERS ${SimpleProject_FORMS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) ADD_EXECUTABLE(teste
${teste_SOURCES}
${teste_HEADERS_MOC}
${teste_FORMS_HEADERS} )
TARGET_LINK_LIBRARIES(teste ${QT_LIBRARIES})
In my Qt GUI I created some global variables (globals.h) and now I want my ROS node to get those variables.
**globals.h**
#ifndef GLOBALS_H
#define GLOBALS_H
// ALL THE GLOBAL DECLARATIONS
extern int numberOfMotors;
extern int intensidade[16];
extern int local[16];
#endif // GLOBALS_H
I assume that I have to include globals.h in my ROS node and then act conform it. However, I don't know how to make the globals.h available for ROS. I think I need to probably mix my cmake makefile and my catkin_make makefile, but I have no idea how. Here's my catkin_make CMakeLists:
cmake_minimum_required(VERSION 2.8.3)
project(tentativa)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
message_runtime
)
## Generate messages in the 'msg' folder
add_message_files(
FILES
Dados.msg
Dados2.msg
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs # Or other packages containing msgs
)
catkin_package(
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime #rwsua2017_msgs
)
# include_directories(include)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(publish_arduino src/publish_arduino.cpp)
target_link_libraries(publish_arduino ${catkin_LIBRARIES})
add_dependencies(publish_arduino tentativa_generate_message_cpp)
Does anyone know how to do it? Thanks in advance!