-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A few changes to CMake, motor_node.cc and motor_hardware.h
- Loading branch information
1 parent
f938f99
commit a4448c3
Showing
12 changed files
with
785 additions
and
1,755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,85 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
cmake_minimum_required(VERSION 3.5) | ||
project(ubiquity_motor_ros2) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
# Find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
#find_package(message_generation REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(rclpy REQUIRED) | ||
find_package(geometry_msgs REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(nav_msgs REQUIRED) | ||
find_package(sensor_msgs REQUIRED) | ||
find_package(hardware_interface REQUIRED) | ||
find_package(controller_manager REQUIRED) | ||
find_package(ros2_control REQUIRED) | ||
find_package(diagnostic_updater REQUIRED) | ||
#find_package(dynamic_reconfigure REQUIRED) - does not exist in ROS2 | ||
|
||
#find_package(Boost REQUIRED) | ||
#find_package(thread REQUIRED) | ||
#find_package(atomic REQUIRED) | ||
|
||
add_library(ubiquity_motor | ||
src/motor_message.cc src/motor_serial.cc src/motor_hardware.cc | ||
|
||
# ROS 2 message generation | ||
rosidl_generate_interfaces(${PROJECT_NAME} | ||
"msg/MotorState.msg" | ||
DEPENDENCIES std_msgs | ||
) | ||
|
||
install(PROGRAMS | ||
scripts/upgrade_firmware.py | ||
scripts/test_motor_board.py | ||
scripts/test_pi_gpio.py | ||
DESTINATION lib/${PROJECT_NAME} | ||
# Include directories | ||
include_directories( | ||
include | ||
) | ||
|
||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
# the following line skips the linter which checks for copyrights | ||
# comment the line when a copyright and license is added to all source files | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
# the following line skips cpplint (only works in a git repo) | ||
# comment the line when this package is in a git repo and when | ||
# a copyright and license is added to all source files | ||
set(ament_cmake_cpplint_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package() | ||
# Build the library containing reusable code | ||
# add_library(ubiquity_motor | ||
# src/motor_message.cc | ||
# src/motor_serial.cc | ||
# src/motor_hardware.cc | ||
# ) | ||
|
||
# Link the generated messages to the library | ||
# ament_target_dependencies(ubiquity_motor | ||
# "rclcpp" | ||
# "std_msgs" | ||
# "sensor_msgs" | ||
# "hardware_interface" | ||
# "ros2_control" | ||
# "diagnostic_updater" | ||
# ) | ||
|
||
# Add executable | ||
add_executable(motor_node src/motor_node.cc) | ||
|
||
# add_dependencies(motor_node ${PROJECT_NAME}_interfaces) | ||
|
||
# Link the generated messages and the library to the executable | ||
# target_link_libraries(motor_node ubiquity_motor) | ||
|
||
ament_target_dependencies(motor_node | ||
"rclcpp" | ||
"std_msgs" | ||
"sensor_msgs" | ||
"hardware_interface" | ||
"ros2_control" | ||
"diagnostic_updater" | ||
) | ||
|
||
ament_export_dependencies(rosidl_default_runtime) | ||
|
||
# # Install the library and executable | ||
install(TARGETS | ||
motor_node | ||
#ubiquity_motor | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
|
||
# # Install any Python scripts (if any) | ||
# install(PROGRAMS | ||
# scripts/upgrade_firmware.py | ||
# scripts/test_motor_board.py | ||
# scripts/test_pi_gpio.py | ||
# DESTINATION lib/${PROJECT_NAME} | ||
# ) | ||
|
||
# Finish up the package | ||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(ubiquity_motor_ros2) | ||
|
||
set(CMAKE_CXX_STANDARD 14) # use C++14 | ||
|
||
# Compiler flags for warnings | ||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# Find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(sensor_msgs REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(hardware_interface REQUIRED) | ||
find_package(ros2_control REQUIRED) | ||
find_package(diagnostic_updater REQUIRED) | ||
|
||
# ROS 2 message generation | ||
rosidl_generate_interfaces(${PROJECT_NAME} | ||
"msg/MotorState.msg" | ||
) | ||
|
||
# Add library | ||
add_library(ubiquity_motor | ||
#src/motor_message.cc src/motor_serial.cc src/motor_hardware.cc | ||
src/motor_node.cc | ||
) | ||
|
||
# Include directories for library | ||
target_include_directories(ubiquity_motor | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
ament_target_dependencies(ubiquity_motor | ||
"rclcpp" | ||
"std_msgs" | ||
"sensor_msgs" | ||
"hardware_interface" | ||
"ros2_control" | ||
"diagnostic_updater" | ||
) | ||
|
||
# Add executable | ||
add_executable(motor_node src/motor_node.cc) | ||
|
||
# Include directories for executable | ||
target_include_directories(motor_node | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
ament_target_dependencies(motor_node | ||
"rclcpp" | ||
"std_msgs" | ||
"sensor_msgs" | ||
"hardware_interface" | ||
"ros2_control" | ||
"diagnostic_updater" | ||
) | ||
|
||
# Install targets | ||
install(TARGETS | ||
motor_node | ||
ubiquity_motor | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
|
||
# Install scripts | ||
install(PROGRAMS | ||
scripts/upgrade_firmware.py | ||
scripts/test_motor_board.py | ||
scripts/test_pi_gpio.py | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
|
||
# Test dependencies | ||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
set(ament_cmake_cpplint_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bool led1 | ||
bool led2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
std_msgs/Header header | ||
float64 left_position | ||
float64 right_position | ||
float64 left_rotate_rate | ||
float64 right_rotate_rate | ||
float32 left_current | ||
float32 right_current | ||
int32 left_pwm_drive | ||
int32 right_pwm_drive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.