Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to HRI Safety Sense ROS node #4

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 61 additions & 35 deletions hri_safety_sense/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
)


57 changes: 57 additions & 0 deletions hri_safety_sense/ReadMe.md
Original file line number Diff line number Diff line change
@@ -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).


15 changes: 15 additions & 0 deletions hri_safety_sense/launch/vsc_interface.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<launch>

<!-- Start a serial interface with the vsc on "safety_port" -->
<arg name="safety_port" default="/dev/ttyACM0"/>
<arg name="vsc_interface_enable" default="true"/>
<group if="$(arg vsc_interface_enable)">
<!-- Start a serial interface to vsc on 'safety_port' -->
<node name="vsc_serial_interface"
pkg="hri_safety_sense"
type="safe_remote_control"
respawn="true">
<param name="port" value="$(arg safety_port)"/>
</node>
</group>
</launch>
15 changes: 0 additions & 15 deletions hri_safety_sense/manifest.xml

This file was deleted.

28 changes: 28 additions & 0 deletions hri_safety_sense/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<package format="2">
<name>hri_safety_sense</name>
<version>0.1.5</version>
<description>HRI Library for Serial Communication in ROS</description>

<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<author>hri</author>
<maintainer email="js@greenzie.co">Jackson Stanhope</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<depend>genmsg</depend>
<depend>message_runtime</depend>
</package>

4 changes: 2 additions & 2 deletions hri_safety_sense/src/JoystickHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "ros/ros.h"
#include "sensor_msgs/Joy.h"

#include "VehicleMessages.h"
#include "JoystickHandler.h"
#include <VehicleMessages.h>
#include <JoystickHandler.h>

using namespace hri_safety_sense;

Expand Down
2 changes: 1 addition & 1 deletion hri_safety_sense/src/SerialInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <string.h>
#include <fcntl.h>

#include "SerialInterface.h"
#include <SerialInterface.h>

/**
* Open a serial port
Expand Down
10 changes: 5 additions & 5 deletions hri_safety_sense/src/VscProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
/**
* Includes
*/
#include "VscProcess.h"
#include "JoystickHandler.h"
#include "VehicleInterface.h"
#include "VehicleMessages.h"
#include <VscProcess.h>
#include <JoystickHandler.h>
#include <VehicleInterface.h>
#include <VehicleMessages.h>

using namespace hri_safety_sense;

Expand All @@ -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());
}

Expand Down