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

Alternative Update to ROS 1 Melodic #6

Open
wants to merge 18 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
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
<h3><a href="http://humanisticrobotics.com/products/safe-remote-control" target="_blank">Safe Remote Control System (SRCS)</a></h3>


#### Tutorial Instructions: [Running_Tutorials] (Running_Tutorials.md)
#### C Drivers: [/drivers] (/drivers)
#### ROS Drivers: [/hri_safety_sense] (/hri_safety_sense)

#### C Drivers tutorial instructions: [hri_c_driver](hri_c_driver/README.md)
#### ROS Drivers: [hri_safety_sense](hri_safety_sense/README.md)
25 changes: 0 additions & 25 deletions Running_Tutorials.txt

This file was deleted.

57 changes: 57 additions & 0 deletions hri_c_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 2.8.3)
project(hri_c_driver)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
)

###################################
## 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 your 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(
INCLUDE_DIRS include
LIBRARIES hri_c_driver
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
include
${catkin_INCLUDE_DIRS}
)

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_library(hri_c_driver src/SerialInterface.c src/VehicleInterface.c)

## Specify libraries to link a library or executable target against
target_link_libraries(hri_c_driver
${catkin_LIBRARIES}
)

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executables and/or libraries for installation
install(TARGETS hri_c_driver
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
6 changes: 1 addition & 5 deletions drivers/C/Makefile → hri_c_driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VERSION = 1.1

TARGET = lib/hri_vsc_interface.$(VERSION).so
SOURCES = $(shell echo src/*.c)
HEADERS = $(shell echo include/*.h)
HEADERS = $(shell echo include/hri_c_driver/*.h)
OBJECTS = $(SOURCES:.c=.o)
TUTORIAL_SRC = $(shell echo tutorials/*.c)

Expand All @@ -42,7 +42,3 @@ $(TARGET): $(OBJECTS)

clean:
rm $(OBJECTS) $(TARGET) $(TUTORIAL_SRC:.c=)




16 changes: 10 additions & 6 deletions Running_Tutorials.md → hri_c_driver/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Tutorials Provided at:
####[Tutorials](/drivers/C/tutorials)
####[Tutorials](tutorials)

####Tutorial Descriptions (Refer to Source for Details):
* vsc_tutorial_1: A message of type UserHeartbeatMsgType containing the EStopStatus is sent at a rate of 20Hz to the VSC. This is a basic example where the joystick and button values can be seen as received by the VSC.
Expand All @@ -12,13 +12,17 @@ on the first tutorial and expands it by settings three default display lines, an
* vsc_tutorial_4: The fourth example shows how to switch the SRC into the user value displa mode. The example shows how to constantly update user feedback values and also send motor control commands to the SRC.

####Basic Instructions:

To compile:
```
make
```

To run vsc_tutorial_1, ensure that the SRC and VSC are on the same network.
Under the cloned directory /driver/C execute the following command in your terminal:
./tutorials/vsc_tutorial_1 /ttyACM* 115200
```
./tutorials/vsc_tutorial_1 /ttyACM* 115200
```
where * replaces the serial port being used for the VSC.
Note: This example assumes the VSC is connected via USB to a user computer. Ports used
can be found under /dev directory in Mac and Linux systems. Usually, ttyACM0/1, tty.usbserial.




Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
typedef struct {
uint32_t front;
uint32_t back;
int32_t fd;
int fd;
uint8_t recvbuffer[SIZE_RECEIVE_BUFFER];
} VscInterfaceType;

Expand Down
19 changes: 19 additions & 0 deletions hri_c_driver/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<package format="2">
<name>hri_c_driver</name>
<version>1.1.0</version>
<description>

hri_c_driver

</description>

<maintainer email="contact@fortrobotics.com">hri</maintainer>
<license>BSD</license>
<author>hri</author>

<buildtool_depend>catkin</buildtool_depend>

<export>
</export>
</package>
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 "hri_c_driver/SerialInterface.h"

/**
* Open a serial port
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include <unistd.h>
#include <sys/types.h>

#include "VehicleMessages.h"
#include "VehicleInterface.h"
#include "SerialInterface.h"
#include "hri_c_driver/VehicleMessages.h"
#include "hri_c_driver/VehicleInterface.h"
#include "hri_c_driver/SerialInterface.h"

/**
* Calculate the Fletcher 16 Checksum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include <sys/time.h>
#include <sys/select.h>

#include "VehicleMessages.h"
#include "VehicleInterface.h"
#include "hri_c_driver/VehicleMessages.h"
#include "hri_c_driver/VehicleInterface.h"

/* File descriptor for VSC Interface */
VscInterfaceType* vscInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include <sys/time.h>
#include <sys/select.h>

#include "VehicleMessages.h"
#include "VehicleInterface.h"
#include "hri_c_driver/VehicleMessages.h"
#include "hri_c_driver/VehicleInterface.h"

/* File descriptor for VSC Interface */
VscInterfaceType* vscInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include <sys/time.h>
#include <sys/select.h>

#include "VehicleMessages.h"
#include "VehicleInterface.h"
#include "hri_c_driver/VehicleMessages.h"
#include "hri_c_driver/VehicleInterface.h"

/* File descriptor for VSC Interface */
VscInterfaceType* vscInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include <sys/time.h>
#include <sys/select.h>

#include "VehicleMessages.h"
#include "VehicleInterface.h"
#include "hri_c_driver/VehicleMessages.h"
#include "hri_c_driver/VehicleInterface.h"

/* File descriptor for VSC Interface */
VscInterfaceType* vscInterface;
Expand Down
99 changes: 63 additions & 36 deletions hri_safety_sense/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,63 @@
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)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
sensor_msgs
hri_c_driver
hri_safety_sense_srvs
)

###################################
## 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 your 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 sensor_msgs hri_c_driver hri_safety_sense_srvs
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
${catkin_INCLUDE_DIRS}
)

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_executable(safe_remote_control src/main.cpp src/VscProcess.cpp src/JoystickHandler.cpp)

## Specify libraries to link a library or executable target against
target_link_libraries(safe_remote_control
${catkin_LIBRARIES}
)

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executables and/or libraries for installation
install(TARGETS safe_remote_control
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
55 changes: 55 additions & 0 deletions hri_safety_sense/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To compile ROS driver:
```
catkin build hri_safety_sense
```

# To read from joystick, modify permissions to port:
```
sudo chmod 666 <port>
```
where port is for example `/dev/ttyACM1`.

# To run driver:
```
. devel/setup.bash
roscore
roslaunch hri_safety_sense safe_remote_control.launch [serial:=/dev/ttyACM1 frame_id:=/joystick]
```

Optionally pass in serial port and/or joystick frame ID, if different from default values in launch file.

# ROS parameters:

`serial`: Serial port, `/dev/ttyACM0` by default
`serial_speed`: Serial port speed, `115200` by default
`set_priority`: Set priority, `false` by default
`frame_id`: Frame ID, `/srcs` for Safe Remote Control System by default

# ROS topics:

`/safety/emergency_stop`: Boolean indicating whether the emergency stop is pressed
`/joy`: Status of joystick and buttons.

Example joystick message:
```
$ rostopic echo /joy
header:
seq: 892
stamp:
secs: 1574381173
nsecs: 920995966
frame_id: "/joystick"
axes: [-0.21114370226860046, -1.0, 0.0, 0.0, 0.0, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0]
```

`axes` fields are in this order for the 2 joysticks:
Left X, Left Y, Left Z, Right X, Right Y, Right Z
Note that Z axis is on the back of the controller.

`buttons` fields are in this order for the 8 buttons:
Left down, Left right, Left up, Left left, Right down, Right right, Right up, Right left

# Troubleshoot

Joystick goes to sleep automatically after some time. After turning it back on, press button 1 as indicated on the joystick screen to go into remote mode. Then values will show on `/joy` topic.
Loading