diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cc4fa3..65f5622 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ PROJECT(ut_automata) CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + MESSAGE(STATUS "Compilers found: ${CMAKE_CXX_COMPILER_LIST}") MESSAGE(STATUS "Using compiler: ${CMAKE_CXX_COMPILER}") MESSAGE(STATUS "Build Type: ${CMAKE_BUILD_TYPE}") @@ -85,6 +87,13 @@ IF(${CMAKE_BUILD_MODE} MATCHES "Hardware") TARGET_LINK_LIBRARIES(joystick ${libs}) ENDIF() +IF(${CMAKE_BUILD_MODE} MATCHES "Omega") + ROSBUILD_ADD_EXECUTABLE(radio_driver + src/radio_driver/radio_driver_node.cpp + src/radio_driver/radio_driver.cpp) + TARGET_LINK_LIBRARIES(radio_driver ${libs}) +ENDIF() + MESSAGE(STATUS "Building simulator") ROSBUILD_ADD_EXECUTABLE(simulator diff --git a/Makefile b/Makefile index 8264518..36dd1b3 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,12 @@ hardware: build build/CMakeLists.txt.copy $(info build_mode is [${build_mode}]) $(MAKE) --no-print-directory -C build +omega: build_mode=Omega +omega: build build/CMakeLists.txt.copy + $(info build_type is [${build_type}]) + $(info build_mode is [${build_mode}]) + $(MAKE) --no-print-directory -C build + clean: rm -rf build bin lib msg_gen src/ut_automata diff --git a/src/radio_driver/radio_driver.cpp b/src/radio_driver/radio_driver.cpp new file mode 100644 index 0000000..33c24e5 --- /dev/null +++ b/src/radio_driver/radio_driver.cpp @@ -0,0 +1,26 @@ +#include "radio_driver/radio_driver.h" + +static const bool kDebug = false; +static const float kCommandRate = 20; +static const float kCommandInterval = 1.0 / kCommandRate; + +namespace radio_driver { + +RadioDriver::RadioDriver(ros::NodeHandle nh) { + // TODO: init radio device + + joystick_sub_ = + nh.subscribe("/joystick", 10, &RadioDriver::joystickCallback, this); + timer_ = nh.createSteadyTimer(ros::WallDuration(kCommandInterval), + &RadioDriver::timerCallback, this); +} + +void RadioDriver::joystickCallback(const sensor_msgs::Joy& msg) { + // TODO: track this state +} + +void RadioDriver::timerCallback(const ros::SteadyTimerEvent& event) { + // TODO: publish commands +} + +} // namespace radio_driver diff --git a/src/radio_driver/radio_driver.h b/src/radio_driver/radio_driver.h new file mode 100644 index 0000000..83e6308 --- /dev/null +++ b/src/radio_driver/radio_driver.h @@ -0,0 +1,18 @@ +#include +#include + +namespace radio_driver { + +class RadioDriver { + public: + RadioDriver(ros::NodeHandle nh); + + private: + void joystickCallback(const sensor_msgs::Joy& msg); + void timerCallback(const ros::SteadyTimerEvent& event); + + ros::Subscriber joystick_sub_; + ros::SteadyTimer timer_; +}; + +} // namespace radio_driver \ No newline at end of file diff --git a/src/radio_driver/radio_driver_node.cpp b/src/radio_driver/radio_driver_node.cpp new file mode 100644 index 0000000..c8ee6e6 --- /dev/null +++ b/src/radio_driver/radio_driver_node.cpp @@ -0,0 +1,15 @@ +#include +#include + +#include "radio_driver/radio_driver.h" + +int main(int argc, char** argv) { + // Initialize ROS + ros::init(argc, argv, "radio_driver"); + ros::NodeHandle nh; + + radio_driver::RadioDriver radio_driver(nh); + + // Spin + ros::spin(); +}