Skip to content

Commit

Permalink
WIP #8 removed rosmod dependency from rosmod_actor so it only uses ro…
Browse files Browse the repository at this point in the history
…s. updated rosmod_actor CMakeLists to better follow package and install conventions.
  • Loading branch information
finger563 committed Apr 4, 2018
1 parent f5135f7 commit f2d0d8f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 150 deletions.
129 changes: 12 additions & 117 deletions src/rosmod_actor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,14 @@ else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()


ADD_DEFINITIONS(-DNAMESPACE=rosmod)
find_package(catkin REQUIRED COMPONENTS std_msgs rosmod)
ADD_DEFINITIONS(-DUSE_ROSMOD)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

#
## Declare ROS messages, services and actions
#

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependencies might have been
## pulled in transitively but can be declared for certainty nonetheless:
## * add a build_depend tag for "message_generation"
## * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

# Generate messages in the 'msg' folder
#add_message_files(
# FILES
#)

# Generate services in the 'srv' folder
#add_service_files(
# FILES
#)

## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )

# Generate added messages and services with any dependencies listed here
#generate_messages(
# DEPENDENCIES
# std_msgs
#)
find_package(catkin REQUIRED COMPONENTS roscpp)

#
## catkin specific configuration
#
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# CATKIN_DEPENDS roscpp std_msgs
CATKIN_DEPENDS rosmod message_runtime
# DEPENDS system_lib
CATKIN_DEPENDS roscpp message_runtime
INCLUDE_DIRS include
)

#
Expand All @@ -101,22 +35,16 @@ include_directories(
include
)

## Declare a cpp library
# add_library(node
# src/${PROJECT_NAME}/node.cpp
# )

## Declare a cpp executable
# add_executable(node_node src/node_node.cpp)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
# add_dependencies(node_node node_generate_messages_cpp)

## Specify libraries to link a library or executable target against
# target_link_libraries(node_node
# ${catkin_LIBRARIES}
# )
# make rosmod_actor executable
add_executable(rosmod_actor
src/rosmod_actor/jsoncpp.cpp
src/rosmod_actor/component.cpp
src/rosmod_actor/main.cpp)
target_link_libraries(rosmod_actor dl ${catkin_LIBRARIES})

#
## Install
Expand All @@ -125,13 +53,6 @@ include_directories(
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
# install(TARGETS node node_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
Expand All @@ -146,38 +67,12 @@ include_directories(
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#
## Testing
#

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_node.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)

# make rosmod_actor executable
add_executable(rosmod_actor
src/rosmod_actor/jsoncpp.cpp
src/rosmod_actor/component.cpp
src/rosmod_actor/main.cpp)
target_link_libraries(rosmod_actor dl ${catkin_LIBRARIES})
# install rosmod_actor executable
install(TARGETS rosmod_actor
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp")

20 changes: 10 additions & 10 deletions src/rosmod_actor/include/rosmod_actor/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "rosmod_actor/logger.hpp"
#include "rosmod_actor/json.hpp"

#include "rosmod/rosmod_ros.h"
#include "rosmod/rosmod_callback_queue.h"
#include "ros/ros.h"
#include "ros/callback_queue.h"

/**
* @brief Component class
Expand All @@ -28,6 +28,11 @@ class Component {
*/
Component(Json::Value& _config);

/**
* @brief Component Destructor
*/
virtual ~Component();

/**
* @brief Component startup function
*
Expand All @@ -41,22 +46,17 @@ class Component {
* @param[in] event a oneshot timer event
* @see startUp()
*/
virtual void init_timer_operation(const rosmod::TimerEvent& event);
virtual void init_timer_operation(const ros::TimerEvent& event) = 0;

/**
* @brief Component Message Queue handler
*/
void process_queue();

/**
* @brief Component Destructor
*/
virtual ~Component();

protected:
Json::Value config; /*!< Component Configuration */
rosmod::Timer init_timer; /*!< Initialization timer */
rosmod::CallbackQueue comp_queue; /*!< Component Message Queue */
ros::Timer init_timer; /*!< Initialization timer */
ros::CallbackQueue comp_queue; /*!< Component Message Queue */
std::unique_ptr<Logger> logger; /*!< Component logger object */
std::string workingDir; /*!< Working directory of the process */
};
Expand Down
23 changes: 7 additions & 16 deletions src/rosmod_actor/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<package>
<package format="2">
<name>rosmod_actor</name>
<version>0.0.0</version>
<description>The rosmod actor package</description>
Expand Down Expand Up @@ -33,22 +33,13 @@
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<build_depend>message_generation</build_depend>
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<run_depend>message_runtime</run_depend>
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rosmod_jsoncpp</build_depend>
<build_depend>rosmod_component</build_depend>
<build_depend>rosmod</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>rosmod_jsoncpp</run_depend>
<run_depend>rosmod_component</run_depend>
<run_depend>rosmod</run_depend>
<run_depend>std_msgs</run_depend>

<depend>rosmod_jsoncpp</depend>
<depend>rosmod_component</depend>
<depend>rosmod</depend>
<depend>roscpp</depend>
<depend>std_msgs</depend>
<depend>message_runtime</depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
Expand Down
5 changes: 1 addition & 4 deletions src/rosmod_actor/src/rosmod_actor/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ Component::~Component() {
init_timer.stop();
}

// Initialization
void Component::init_timer_operation(const rosmod::TimerEvent& event) {}

// Component Operation Queue Handler
void Component::process_queue() {
rosmod::NodeHandle nh;
ros::NodeHandle nh;
while (nh.ok())
this->comp_queue.callAvailable(ros::WallDuration(0.01));
}
6 changes: 3 additions & 3 deletions src/rosmod_actor/src/rosmod_actor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <iostream>
#include <fstream>

#include "rosmod/rosmod_ros.h"
#include "ros/ros.h"

#include <signal.h>
#include <ros/ros.h>
Expand Down Expand Up @@ -119,10 +119,10 @@ int main(int argc, char **argv)
ROS_INFO_STREAM("Thread priority is " << params.sched_priority << std::endl);

nodeName = root["Name"].asString();
rosmod::init(argc, argv, nodeName.c_str(), ros::init_options::NoSigintHandler);
ros::init(argc, argv, nodeName.c_str(), ros::init_options::NoSigintHandler);
signal(SIGINT, rosmod_actor_SigInt_handler);
// Create Node Handle
rosmod::NodeHandle n;
ros::NodeHandle n;

ROS_INFO_STREAM(nodeName << " thread id = " << boost::this_thread::get_id());

Expand Down

0 comments on commit f2d0d8f

Please sign in to comment.