Skip to content

Commit

Permalink
Added ros1 compatability to ros2 port
Browse files Browse the repository at this point in the history
  • Loading branch information
majohab committed Oct 26, 2023
1 parent dc4088c commit 4cef513
Show file tree
Hide file tree
Showing 34 changed files with 244 additions and 53 deletions.
151 changes: 106 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,111 @@
cmake_minimum_required(VERSION 3.8)
project(gtec_msgs)
if("$ENV{ROS_VERSION}" STREQUAL "2")
cmake_minimum_required(VERSION 3.8)
set(DETECTED_ROS2 TRUE)
else()
cmake_minimum_required(VERSION 2.8.3)
set(DETECTED_ROS1 TRUE)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
add_definitions(-std=c++11)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(geometry_msgs)
find_package(std_msgs)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
"msg/GenericRanging.msg"
"msg/Ranging.msg"
"msg/UWBRanging.msg"
"msg/DWRanging.msg"
"msg/PozyxRanging.msg"
"msg/RangingDiff.msg"
"msg/PozyxRangingWithCir.msg"
"msg/ESP32S2FTMFrame.msg"
"msg/ESP32S2FTMRanging.msg"
"msg/ESP32S2FTMRangingExtra.msg"
"msg/RadarCube.msg"
"msg/RadarRangeAzimuth.msg"
"msg/RadarRangeDoppler.msg"
"msg/RadarFusedPointStamped.msg"
"msg/DoorCounterEvent.msg"
"msg/ZoneOccupancy.msg"
DEPENDENCIES geometry_msgs std_msgs # Add packages that above messages depend on, in this case geometry_msgs for Sphere.msg
)

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()
project(gtec_msgs)

if(DETECTED_ROS1)
## 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
rospy
std_msgs
geometry_msgs
message_generation
)

## Generate messages in the 'msg' folder
add_message_files(
DIRECTORY
msg-ros1
FILES
GenericRanging.msg
Ranging.msg
UWBRanging.msg
DWRanging.msg
PozyxRanging.msg
RangingDiff.msg
PozyxRangingWithCir.msg
ESP32S2FTMFrame.msg
ESP32S2FTMRanging.msg
ESP32S2FTMRangingExtra.msg
RadarCube.msg
RadarRangeAzimuth.msg
RadarRangeDoppler.msg
RadarFusedPointStamped.msg
DoorCounterEvent.msg
ZoneOccupancy.msg
)

## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
)

catkin_package(
)
endif()

ament_package()
if(DETECTED_ROS2)
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(geometry_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(geometry_msgs)
find_package(std_msgs)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
"msg-ros2/GenericRanging.msg"
"msg-ros2/Ranging.msg"
"msg-ros2/UWBRanging.msg"
"msg-ros2/DWRanging.msg"
"msg-ros2/PozyxRanging.msg"
"msg-ros2/RangingDiff.msg"
"msg-ros2/PozyxRangingWithCir.msg"
"msg-ros2/ESP32S2FTMFrame.msg"
"msg-ros2/ESP32S2FTMRanging.msg"
"msg-ros2/ESP32S2FTMRangingExtra.msg"
"msg-ros2/RadarCube.msg"
"msg-ros2/RadarRangeAzimuth.msg"
"msg-ros2/RadarRangeDoppler.msg"
"msg-ros2/RadarFusedPointStamped.msg"
"msg-ros2/DoorCounterEvent.msg"
"msg-ros2/ZoneOccupancy.msg"
DEPENDENCIES geometry_msgs std_msgs # Add packages that above messages depend on, in this case geometry_msgs for Sphere.msg
)

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()
endif()
18 changes: 18 additions & 0 deletions msg-ros1/DWRanging.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
int16 anchorId
int16 tagId
int32 range
int32 rawrange
int32 seq
int32 maxNoise
int32 stdNoise
int32 firstPathAmp1
int32 firstPathAmp2
int32 firstPathAmp3
int32 maxGrowthCIR
int32 rxPreamCount
int32 firstPath
float64 channel
int32 prf
float64 datarate
int32 preambleLength
int32 pacSize
3 changes: 3 additions & 0 deletions msg-ros1/DoorCounterEvent.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Header header
int16 lth
int16 htl
File renamed without changes.
6 changes: 6 additions & 0 deletions msg-ros1/ESP32S2FTMRanging.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
string anchorId
int32 rtt_est
int32 rtt_raw
float32 dist_est
int32 num_frames
gtec_msgs/ESP32S2FTMFrame[] frames
7 changes: 7 additions & 0 deletions msg-ros1/ESP32S2FTMRangingExtra.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
string anchorId
int32 rtt_est
int32 rtt_raw
float32 dist_est
float32 own_est
int32 num_frames
gtec_msgs/ESP32S2FTMFrame[] frames
5 changes: 5 additions & 0 deletions msg-ros1/GenericRanging.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int16 anchorId
int16 tagId
int32 range
int32 seq
float64 rxPower
14 changes: 14 additions & 0 deletions msg-ros1/PozyxRanging.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
int32 originId
int16 originType
int32 destinationId
int16 destinationType
int32 range
int32 ts
int32 seq
float64 rxPower
float64 channel
float64 datarate
int32 prf
int32 preambleLength
float64 txGain
float64 angle
15 changes: 15 additions & 0 deletions msg-ros1/PozyxRangingWithCir.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
int32 originId
int16 originType
int32 destinationId
int16 destinationType
int32 range
int32 ts
int32 seq
float64 rxPower
float64 channel
float64 datarate
int32 prf
int32 preambleLength
float64 txGain
float64 angle
int16[] cir
4 changes: 4 additions & 0 deletions msg-ros1/RadarCube.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Header header
int16 fftSize
int16 angleBins
float64[] data
3 changes: 3 additions & 0 deletions msg-ros1/RadarFusedPointStamped.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Header header
geometry_msgs/Point point
int16 targetId
4 changes: 4 additions & 0 deletions msg-ros1/RadarRangeAzimuth.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Header header
int16 numRangeBins
int16 numVirtualAntennas
float64[] data
4 changes: 4 additions & 0 deletions msg-ros1/RadarRangeDoppler.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Header header
int16 numRangeBins
int16 numDopplerBins
float64[] data
6 changes: 6 additions & 0 deletions msg-ros1/Ranging.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int16 anchorId
int16 tagId
int32 range
int32 seq
float64 rss
float64 errorEstimation
5 changes: 5 additions & 0 deletions msg-ros1/RangingDiff.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int16 anchorId
int16 tagId
float32 range
float32 distance
float32 diff
20 changes: 20 additions & 0 deletions msg-ros1/UWBRanging.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
int16 anchorId
int16 tagId
int32 range
int32 rawrange
int32 biasCorrection
int32 seq
int32 maxNoise
int32 stdNoise
int32 firstPathAmp1
int32 firstPathAmp2
int32 firstPathAmp3
int32 maxGrowthCIR
int32 rxPreamCount
int32 firstPath
float64 channel
int32 prf
float64 datarate
int32 preambleLength
int32 pacSize
float64 errorEstimation
4 changes: 4 additions & 0 deletions msg-ros1/ZoneOccupancy.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Header header
string zoneId
int16[] targetIds
int16 count
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions msg-ros2/ESP32S2FTMFrame.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int32 rssi
int32 rtt
int64 t1
int64 t2
int64 t3
int64 t4
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 14 additions & 8 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@
<name>gtec_msgs</name>
<version>1.0.0</version>
<description>The GTEC MSGS package</description>
<maintainer email="[email protected]">todo</maintainer>
<maintainer email="[email protected]">Valentin Barral</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 2">rosidl_default_generators</buildtool_depend>

<build_depend condition="$ROS_VERSION == 1">message_generation</build_depend>
<exec_depend condition="$ROS_VERSION == 1">message_runtime</exec_depend>

<depend>geometry_msgs</depend>
<depend>std_msgs</depend>

<exec_depend>rosidl_default_runtime</exec_depend>
<build_depend condition="$ROS_VERSION == 2">rosidl_default_generators</build_depend>
<exec_depend condition="$ROS_VERSION == 2">rosidl_default_runtime</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend condition="$ROS_VERSION == 2">ament_lint_auto</test_depend>
<test_depend condition="$ROS_VERSION == 2">ament_lint_common</test_depend>

<member_of_group>rosidl_interface_packages</member_of_group>
<member_of_group condition="$ROS_VERSION == 2">rosidl_interface_packages</member_of_group>

<export>
<build_type>ament_cmake</build_type>
<build_type condition="$ROS_VERSION == 1">catkin</build_type>
<build_type condition="$ROS_VERSION == 2">ament_cmake</build_type>
</export>
</package>

0 comments on commit 4cef513

Please sign in to comment.