Skip to content

Commit

Permalink
setup omega target with radio driver skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeno12 committed Sep 15, 2023
1 parent c7acf37 commit 22bbd61
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions src/radio_driver/radio_driver.cpp
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions src/radio_driver/radio_driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <ros/ros.h>
#include <sensor_msgs/Joy.h>

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
15 changes: 15 additions & 0 deletions src/radio_driver/radio_driver_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <ros/ros.h>
#include <sensor_msgs/Joy.h>

#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();
}

0 comments on commit 22bbd61

Please sign in to comment.