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

Jazzy devel #1

Open
wants to merge 2 commits into
base: kinetic
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
105 changes: 45 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,75 +1,60 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5)
project(pi_sonar)

FIND_LIBRARY(pigpio REQUIRED)
set(CMAKE_CXX_STANDARD 17) # use C++14

## 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
diagnostic_updater
roscpp
sensor_msgs
)

###################################
## catkin specific configuration ##
###################################

catkin_package(
CATKIN_DEPENDS diagnostic_updater roscpp sensor_msgs
)

###########
## Build ##
###########
# Compiler flags for warnings
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(diagnostic_updater REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(
include
pigpio_INCLUDES
${catkin_INCLUDE_DIRS}
)
# Locate pigpio library
find_library(PIGPIO_LIBRARY pigpio PATHS /usr/local/lib)
find_path(PIGPIO_INCLUDE_DIR pigpio.h PATHS /usr/local/include)

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm*)
if (NOT PIGPIO_LIBRARY OR NOT PIGPIO_INCLUDE_DIR)
message(FATAL_ERROR "Could not find pigpio library or headers")
endif()

# Create the executable
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch*")
add_executable(pi_sonar src/pi_sonar.cpp)
target_compile_options(pi_sonar PRIVATE -std=c++11)
target_link_libraries(pi_sonar ${catkin_LIBRARIES}
${roscpp_LIBRARIES} pigpiod_if2 pthread)
target_compile_options(pi_sonar PRIVATE -std=c++17)

# Link libraries
target_link_libraries(pi_sonar
pigpiod_if2
pthread
)

# Install the executable
install(TARGETS pi_sonar
DESTINATION lib/${PROJECT_NAME}
)
endif()

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

if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm*)
install(TARGETS pi_sonar
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
SETUID SETGID
# Install launch files
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)
endif()

## Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
# Link the ROS 2 libraries to the executable using ament_target_dependencies
ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"sensor_msgs"
"diagnostic_updater"
)

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_hercules_sonar_skirt.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
# Install the executable
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
# Package information
ament_package()
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ To build:
cd ~/catkin_ws/src
git clone https://github.com/UbiquityRobotics/pi_sonar.git
cd ..
catkin_make
source devel/setup.bash
colcon build
source install/setup.bash
```

The node needs to access the pigpio daemon, hence the following steps to have it run at startup (if it does not do so already):

```
wget https://raw.githubusercontent.com/joan2937/pigpio/master/util/pigpiod.service
sudo cp pigpiod.service /etc/systemd/system
sudo systemctl enable pigpiod.service
sudo systemctl start pigpiod.service
git clone https://raw.githubusercontent.com/joan2937/pigpio.git
cd pigpio
make
sudo make install

sudo pigpiod
```

To run:

```
roslaunch pi_sonar ubiquity_sonar.launch
ros2 launch pi_sonar ubiquity_sonar.launch.py
```

## For developers only
Expand Down
4 changes: 0 additions & 4 deletions launch/ubiquity_sonar.launch

This file was deleted.

11 changes: 11 additions & 0 deletions launch/ubiquity_sonar.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
Node(
package='pi_sonar',
executable='pi_sonar',
name='pi_sonar',
),
])
3 changes: 2 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<url type="website">http://github.com/UbiquityRobotics/pi_sonar</url>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>diagnostic_updater</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
Expand All @@ -24,5 +24,6 @@
<run_depend>libpigpio</run_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading