Skip to content

Commit

Permalink
migrate ros2 devel (#50)
Browse files Browse the repository at this point in the history
* Initial port to ros 2.

Separated messages into separate package (urg_node_msgs). Ported code to support ros 2. Created initial example launch file with ros 2 python format.  Updated to use time to header stamp functions.  Updated to cmake 3.5.  Fixing many mistakes to allow driver to function.  Removed creation of private node handle which is not allowed in ROS 2.  Removed use of SyncParameterClient until all ROS 2 nodes are launched with a parameter server.  Replace boost:: with std:: wherever possible.

Signed-off-by: Karsten Knese <[email protected]>

Co-authored-by: Brett <[email protected]>
Co-authored-by: Gu, Chao Jie <[email protected]>
Co-authored-by: Aarush Gupta <[email protected]>
Co-authored-by: aswinthomas <[email protected]>
Co-authored-by: Marc-Antoine Testier <[email protected]>
Co-authored-by: Zoe <[email protected]>
Co-authored-by: Chris Lalancette <[email protected]>
  • Loading branch information
8 people committed Jan 22, 2020
1 parent d2722c6 commit e33674b
Show file tree
Hide file tree
Showing 18 changed files with 1,451 additions and 1,318 deletions.
43 changes: 10 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
# This config file for Travis CI utilizes ros-industrial/industrial_ci package.
# For more info for the package, see https://github.com/ros-industrial/industrial_ci/blob/master/README.rst
sudo: required
dist: trusty
services:
- docker
language: generic
compiler:
- gcc
notifications:
email:
on_success: always
on_failure: always
recipients:
- [email protected]
env:
matrix:
- ROS_DISTRO="indigo" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu
- ROS_DISTRO="indigo" ROS_REPOSITORY_PATH=http://packages.ros.org/ros-shadow-fixed/ubuntu
- ROS_DISTRO="indigo" PRERELEASE=true
- ROS_DISTRO="kinetic" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu
- ROS_DISTRO="kinetic" ROS_REPOSITORY_PATH=http://packages.ros.org/ros-shadow-fixed/ubuntu
- ROS_DISTRO="kinetic" PRERELEASE=true
- ROS_DISTRO="lunar" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu
- ROS_DISTRO="lunar" ROS_REPOSITORY_PATH=http://packages.ros.org/ros-shadow-fixed/ubuntu
- ROS_DISTRO="lunar" PRERELEASE=true
matrix:
allow_failures:
- env: ROS_DISTRO="indigo" PRERELEASE=true # Run docker-based ROS prerelease test http://wiki.ros.org/bloom/Tutorials/PrereleaseTest Because we might not want to run prerelease test for all PRs, it's omitted from pass-fail criteria.
- env: ROS_DISTRO="kinetic" PRERELEASE=true
- env: ROS_DISTRO="lunar" PRERELEASE=true

install:
- git clone https://github.com/ros-industrial/industrial_ci.git .ci_config
script:
- source .ci_config/travis.sh
# - source ./travis.sh # Enable this when you have a package-local script
- git clone --quiet --depth 1 https://github.com/mikaelarguedas/ros2ci.git .ros2ci
- cp additional_repos.repos .ros2ci/

matrix:
include:
- env: JOB_TYPE=dashing
script: .ros2ci/travis.bash $JOB_TYPE
- env: JOB_TYPE=eloquent
script: .ros2ci/travis.bash $JOB_TYPE
144 changes: 78 additions & 66 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,84 +1,96 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)
project(urg_node)

find_package(catkin REQUIRED COMPONENTS
diagnostic_updater dynamic_reconfigure laser_proc message_generation
nodelet rosconsole roscpp sensor_msgs std_msgs std_srvs tf urg_c
)
set_directory_properties(PROPERTIES COMPILE_OPTIONS "-std=c++11")
find_package(ament_cmake REQUIRED)

# Dynamic reconfigure support
generate_dynamic_reconfigure_options(cfg/URG.cfg)
if(WIN32)
message(WARNING "${PROJECT_NAME} is currently not supported on Windows")
ament_package()
return()
endif()

add_message_files(FILES
Status.msg
)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

generate_messages(
DEPENDENCIES std_msgs
# we currently still rely on boost for its `crc` component
# unfortunately, I haven't found a way to incorporate only crc
# as a single components, hence including `thread` here.
find_package(Boost COMPONENTS thread REQUIRED)
find_package(diagnostic_updater REQUIRED)
find_package(laser_proc REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(urg_c REQUIRED)
find_package(urg_node_msgs REQUIRED)

add_library(urg_node SHARED
src/urg_c_wrapper.cpp
src/urg_node.cpp
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES urg_c_wrapper urg_node_driver
CATKIN_DEPENDS dynamic_reconfigure laser_proc message_runtime nodelet rosconsole
roscpp sensor_msgs std_msgs std_srvs urg_c
DEPENDS
target_include_directories(urg_node
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${Boost_INCLUDE_DIR}
)
target_link_libraries(urg_node ${Boost_LIBRARIES})
ament_target_dependencies(urg_node
diagnostic_updater
laser_proc
rclcpp
rclcpp_components
sensor_msgs
std_srvs
urg_c
urg_node_msgs
)
rclcpp_components_register_node(urg_node
PLUGIN "urg_node::UrgNode"
EXECUTABLE urg_node_driver)

add_executable(getID src/get_id.cpp)
target_link_libraries(getID urg_node)

include_directories(include ${catkin_INCLUDE_DIRS})

## Declare a cpp library
add_library(urg_c_wrapper src/urg_c_wrapper.cpp)
target_link_libraries(urg_c_wrapper ${catkin_LIBRARIES})

# Declare the cpp as a lib also
add_library(urg_node_driver src/urg_node_driver.cpp)
add_dependencies(urg_node_driver ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_gencpp)
target_link_libraries(urg_node_driver urg_c_wrapper ${catkin_LIBRARIES})

## Declare a cpp executable
add_executable(urg_node src/urg_node.cpp)
target_link_libraries(urg_node urg_node_driver ${catkin_LIBRARIES})

## Declare getID tool
add_executable(getID src/getID.cpp)
target_link_libraries(getID urg_c_wrapper ${catkin_LIBRARIES})

## Mark executables and/or libraries for installation
install(TARGETS urg_c_wrapper urg_node urg_node_driver getID
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
install(TARGETS urg_node getID
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/
DESTINATION include
)

## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
install(PROGRAMS scripts/set_urg_ip.py
DESTINATION lib/${PROJECT_NAME}
)

## Install script to set IP addresses
install(PROGRAMS
scripts/set_urg_ip.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)

if(CATKIN_ENABLE_TESTING)
find_package(roslint)
# Ignore long -> int32_t warning, urg_c driver uses
# long, etc. Wrapper must also use these
set(ROSLINT_CPP_OPTS "--filter=-runtime/references,-runtime/int")
roslint_cpp()
roslint_add_test()

find_package(roslaunch REQUIRED)
roslaunch_add_file_check(launch/urg_lidar.launch)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_export_dependencies(urg_node_msgs)
ament_export_dependencies(
diagnostic_updater
laser_proc
rclcpp
sensor_msgs
std_srvs
urg_c
)
ament_export_include_directories(include)
ament_export_libraries(urg_node)
ament_package()
128 changes: 127 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,130 @@
urg_node
===================

ROS wrapper for the Hokuyo urg_c library.
#### LaserScan Visualization

Until the launch API is sorted out, there are two ways to view the laserscan in RViz:

1) use the static_transform_publisher tool from tf2_ros to publish a static transform for a fixed frame simultaneously with rviz and urg_node.

```
ros2 run tf2_ros static_transform_publisher 0 0 0 0 0 0 "world" "laser"
```

where "laser" is the frame id, which you can set in your urg_node yaml file

2) Run the robot_state_publisher along with a urdf file so that a fixed frame can be loaded in rviz

```
ros2 run robot_state_publisher robot_state_publisher <path to urdf file>
```

A urdf file is already included and if you have succesfully ran an `colcon build`, the path to urdf file will be:

```
<path to ros2_ws>/install/share/urg_node/launch/hokuyo_laser.urdf
```


#### Parameters

A YAML file example is included in the launch folder, all the available parameters are listed in it.
For example (note that the serial_port is commented because you can't set a param with an empty string):

```
urg_node:
ros__parameters:
ip_address: "192.168.0.10"
ip_port: 10940
#serial_port: ""
serial_baud: 115200
laser_frame_id: laser
angle_max: 3.14
angle_min: -3.14
publish_intensity: false
publish_multiecho: false
calibrate_time: false
default_user_latency: 0
diagnostics_tolerance: 0.05
diagnostics_window_time: 5.0
error_limit: 4
get_detailed_status: false
cluster: 0
skip: 1
```

To give parameters to urg_node :

```
ros2 run urg_node urg_node __params:=path/to/my/file.yaml
```

You can reconfigure parameters while the node is launched.
For now, you can only reconfigure the following parameters:

```
laser_frame_id
error_limit
default_user_latency
angle_max
angle_min
cluster
skip
```

For example to reconfigure the cluster parameter using command line :
```
ros2 param set /urg_node cluster 1
```

#### How to use the ust-20lx (and other ethernet based laser)

To use ust-20lx, you need to be on the same subnet as the laser.
The ust-20lx default ip is 192.168.0.10, so you might need to change your ip, for something on the same subnet.

On Ubuntu :
- go to the network settings
- settings of the wired connection
- under IPv4, change the IPv4 method from automatic to Manual and under Addresses, set the values:

```
Address : 192.168.0.15
Netmask : 255.255.255.0
Gateway : 192.168.0.1
```

- Turn off and on the connection or wait a bit for the change to apply
- To check if it worked, open a terminal and type

```
ifconfig
```

- Under eth0 (or maybe something like enpxxxxx), your IP should be 192.168.0.15.
You should now be able to ping the ust-20lx at its address (by default 192.168.0.10)

```
ping 192.168.0.10
```

If you don't receive any answer, you might have a connection problem or the IP of your laser might have been change, either find it and go on the same subnet or reset it.

- Once you can ping the laser, you can launch the urg_node:

```
ros2 run urg_node urg_node __params:=path/to/my/file.yaml
```

then the static publisher:

```
ros2 run tf2_ros static_transform_publisher 0 0 0 0 0 0 "world" "laser"
```

and rviz:

```
ros2 run rviz2 rviz2
```

Add the laserScan topic, change the frame on rviz from map to world and you should be able to see the laser.
13 changes: 13 additions & 0 deletions additional_repos.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repositories:
urg_node_msgs:
type: git
url: https://github.com/ros-drivers/urg_node_msgs.git
version: master
urg_c:
type: git
url: https://github.com/ros-drivers/urg_c.git
version: ros2-devel
laser_proc:
type: git
url: https://github.com/ros-perception/laser_proc.git
version: ros2-devel
19 changes: 0 additions & 19 deletions cfg/URG.cfg

This file was deleted.

Loading

0 comments on commit e33674b

Please sign in to comment.