diff --git a/hri_safety_sense/CMakeLists.txt b/hri_safety_sense/CMakeLists.txt index 96ed888..f466fe1 100644 --- a/hri_safety_sense/CMakeLists.txt +++ b/hri_safety_sense/CMakeLists.txt @@ -1,36 +1,62 @@ -cmake_minimum_required(VERSION 2.4.6) -include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) - -# Set the build type. Options are: -# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage -# Debug : w/ debug symbols, w/o optimization -# Release : w/o debug symbols, w/ optimization -# RelWithDebInfo : w/ debug symbols, w/ optimization -# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries -#set(ROS_BUILD_TYPE RelWithDebInfo) - -rosbuild_init() - -#set the default path for built executables to the "bin" directory -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) -#set the default path for built libraries to the "lib" directory -set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) - -#uncomment if you have defined messages -#rosbuild_genmsg() -#uncomment if you have defined services -rosbuild_gensrv() - -#common commands for building c++ executables and libraries -#rosbuild_add_library(${PROJECT_NAME} src/example.cpp) -#target_link_libraries(${PROJECT_NAME} another_library) -#rosbuild_add_boost_directories() -#rosbuild_link_boost(${PROJECT_NAME} thread) -#rosbuild_add_executable(example examples/example.cpp) -#target_link_libraries(terex ${PROJECT_NAME}) -#rosbuild_add_executable(talker src/talker.cpp) -#rosbuild_add_executable(listener src/listener.cpp) -#target_link_libraries(terex hri_common) - -rosbuild_add_executable(safe_remote_control src/main.cpp src/VscProcess.cpp src/VehicleInterface.c src/JoystickHandler.cpp src/SerialInterface.c) +cmake_minimum_required(VERSION 2.8.3) +project(hri_safety_sense) + +find_package(catkin REQUIRED + roscpp + std_msgs + sensor_msgs + genmsg + message_runtime +) + +include_directories( + include + ${catkin_INCLUDE_DIRS} +) + +add_service_files( + DIRECTORY srv + FILES + EmergencyStop.srv + KeyString.srv + KeyValue.srv +) + +generate_messages( + DEPENDENCIES + std_msgs + sensor_msgs +) + +add_library(${PROJECT_NAME} + src/JoystickHandler.cpp + src/SerialInterface.c + src/VehicleInterface.c + src/VscProcess.cpp +) +target_link_libraries(${PROJECT_NAME} + ${catkin_LIBRARIES} + +) +add_dependencies(${PROJECT_NAME} + ${catkin_EXPORTED_TARGETS} +) + +catkin_package( + INCLUDE_DIRS include + LIBRARIES hri_safety_sense + CATKIN_DEPENDS + roscpp + std_msgs + sensor_msgs + genmsg + message_runtime +) + +add_executable(safe_remote_control src/main.cpp) +target_link_libraries(safe_remote_control + ${PROJECT_NAME} + ${catkin_LIBRARIES} +) + diff --git a/hri_safety_sense/ReadMe.md b/hri_safety_sense/ReadMe.md new file mode 100644 index 0000000..70b32a4 --- /dev/null +++ b/hri_safety_sense/ReadMe.md @@ -0,0 +1,57 @@ +## HRI Safety Sense +### Installing the ROS Node +This node is now compatible with ROS Melodic, and builds in catkin. It launches a wrapper node C Driver that +exposes a serial interface to the VSC. + +Installation requires either this folder (named hri_safety_sense) or the cloned git repo "hri-safe-remote-control-system" +to be in the 'src' directory of your ROS workspace. + +Build the package with either + +```bash +catkin_make +``` +or +```bash +catkin_build +``` +if you have catkin tools installed. Install with: `sudo apt-get install python-catkin-tools` + +## Launching the ROS Node +This package has an included launch file (located in hri_safety_sense/launch/) that can be used to launch +the node. The command to use this file is +```bash +roslaunch hri_safety_sense vsc_interface.launch safety_port:=${port} vsc_interface_enable:=${yN} +``` + +There are two arguments listed in the launch file: +* safety_port: the serial port that the device is on (default is /dev/ttyACM0) +* vsc_interface_enable: a predicate that stops the node from launching if set false (default is true). + +Another method of launching the ROS node is by using the command: +```bash +rosrun hri_safety_sense safe_remote_control +``` +Using the launch file is recommended, however, because it is setup to auto-restart the node should it die +unexpectedly. + +## ROS Topics: +Running this node exposes the following topics: +* /safety/emergency_stop + +## Updates to Build System +As of July 2019, this node is updated to be compatible with catkin. + +The functionality of this package is also +exported as a library that can be imported by other catkin packages in a ROS environment, enabling other nodes +to talk to the VSC. + +## Testing +This node has been tested with a point-to-point configuration with a wired EStop Button, as well as a Wireless EStop Device. + +Further testing with multi-point configurations, and configurations with a SRC are needed. + +####Authorship +In addition to [HRI/Fort Robotics](https://hriwiki.atlassian.net/wiki/spaces/DOC/overview) Robotics, this node was contributed to and maintained by [Jackson Stanhope](js@greenzie.co) with support from [Greenzie](www.greenzie.com). + + diff --git a/hri_safety_sense/src/JoystickHandler.h b/hri_safety_sense/include/JoystickHandler.h similarity index 100% rename from hri_safety_sense/src/JoystickHandler.h rename to hri_safety_sense/include/JoystickHandler.h diff --git a/hri_safety_sense/src/MsgHandler.h b/hri_safety_sense/include/MsgHandler.h similarity index 100% rename from hri_safety_sense/src/MsgHandler.h rename to hri_safety_sense/include/MsgHandler.h diff --git a/hri_safety_sense/src/VscProcess.h b/hri_safety_sense/include/VscProcess.h similarity index 100% rename from hri_safety_sense/src/VscProcess.h rename to hri_safety_sense/include/VscProcess.h diff --git a/hri_safety_sense/launch/vsc_interface.launch b/hri_safety_sense/launch/vsc_interface.launch new file mode 100644 index 0000000..2ad5fde --- /dev/null +++ b/hri_safety_sense/launch/vsc_interface.launch @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/hri_safety_sense/manifest.xml b/hri_safety_sense/manifest.xml deleted file mode 100644 index efae021..0000000 --- a/hri_safety_sense/manifest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - hri_safe_remote_system - - - hri - BSD - - - - - - - diff --git a/hri_safety_sense/package.xml b/hri_safety_sense/package.xml new file mode 100644 index 0000000..ee5a381 --- /dev/null +++ b/hri_safety_sense/package.xml @@ -0,0 +1,28 @@ + + + hri_safety_sense + 0.1.5 + HRI Library for Serial Communication in ROS + + + + + hri + Jackson Stanhope + + + + + + BSD + catkin + roscpp + sensor_msgs + std_msgs + roscpp + std_msgs + sensor_msgs + genmsg + message_runtime + + diff --git a/hri_safety_sense/src/JoystickHandler.cpp b/hri_safety_sense/src/JoystickHandler.cpp index 4b27c3e..f400fd9 100644 --- a/hri_safety_sense/src/JoystickHandler.cpp +++ b/hri_safety_sense/src/JoystickHandler.cpp @@ -18,8 +18,8 @@ #include "ros/ros.h" #include "sensor_msgs/Joy.h" -#include "VehicleMessages.h" -#include "JoystickHandler.h" +#include +#include using namespace hri_safety_sense; diff --git a/hri_safety_sense/src/SerialInterface.c b/hri_safety_sense/src/SerialInterface.c index 2999064..47b4dde 100644 --- a/hri_safety_sense/src/SerialInterface.c +++ b/hri_safety_sense/src/SerialInterface.c @@ -24,7 +24,7 @@ #include #include -#include "SerialInterface.h" +#include /** * Open a serial port diff --git a/hri_safety_sense/src/VscProcess.cpp b/hri_safety_sense/src/VscProcess.cpp index 700bd0b..8bbc3e5 100644 --- a/hri_safety_sense/src/VscProcess.cpp +++ b/hri_safety_sense/src/VscProcess.cpp @@ -31,10 +31,10 @@ /** * Includes */ -#include "VscProcess.h" -#include "JoystickHandler.h" -#include "VehicleInterface.h" -#include "VehicleMessages.h" +#include +#include +#include +#include using namespace hri_safety_sense; @@ -43,7 +43,7 @@ VscProcess::VscProcess() : { ros::NodeHandle nh("~"); std::string serialPort = "/dev/ttyACM0"; - if(nh.getParam("serial", serialPort)) { + if(nh.getParam("port", serialPort)) { ROS_INFO("Serial Port updated to: %s",serialPort.c_str()); }