Skip to content

Commit fa4608d

Browse files
authored
Merge pull request #80 from ROBOTIS-GIT/feature-cmake-fix
Deprecate ament_include_dependency usage in CMakeLists.txt
2 parents 37ba48d + dc3c5f3 commit fa4608d

17 files changed

+395
-410
lines changed

.github/workflows/ros-lint.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# The name of the workflow
2+
name: Lint
3+
4+
# Specifies the events that trigger the workflow
5+
on:
6+
pull_request:
7+
8+
# Defines a set of jobs to be run as part of the workflow
9+
jobs:
10+
ament_lint:
11+
runs-on: ubuntu-latest
12+
container:
13+
image: rostooling/setup-ros-docker:ubuntu-noble-ros-rolling-ros-base-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
linter: [cppcheck, cpplint, uncrustify, flake8, pep257, lint_cmake, xmllint]
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup ROS environment
23+
uses: ros-tooling/setup-ros@v0.7
24+
25+
- name: Run Linter
26+
env:
27+
AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: 1
28+
uses: ros-tooling/action-ros-lint@master
29+
with:
30+
linter: ${{ matrix.linter }}
31+
distribution: rolling
32+
package-name: "*"

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Changelog for package hls_lfcd_lds_driver
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
2.1.1 (2025-05-28)
6+
------------------
7+
* Deprecate ament_include_dependency usage in CMakeLists.txt
8+
* Contributor: Hyungyu Kim
9+
510
2.1.0 (2025-02-25)
611
------------------
712
* ROS 2 Humble Hawksbill supported

CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ include_directories(
3434
${Boost_INCLUDE_DIRS}
3535
)
3636

37-
add_executable(hlds_laser_publisher src/hlds_laser_publisher.cpp)
38-
target_link_libraries(hlds_laser_publisher ${Boost_LIBRARIES})
39-
ament_target_dependencies(hlds_laser_publisher
40-
rclcpp
41-
std_msgs
42-
sensor_msgs
37+
add_executable(hlds_laser_publisher src/hlds_laser_publisher.cpp)
38+
target_link_libraries(hlds_laser_publisher
39+
${Boost_LIBRARIES}
40+
${sensor_msgs_TARGETS}
41+
${std_msgs_TARGETS}
42+
rclcpp::rclcpp
4343
)
4444

45+
4546
################################################################################
4647
# Install
4748
################################################################################
@@ -57,8 +58,10 @@ install(
5758
################################################################################
5859
# Macro for ament package
5960
################################################################################
60-
ament_export_dependencies(rclcpp)
61-
ament_export_dependencies(std_msgs)
62-
ament_export_dependencies(sensor_msgs)
61+
ament_export_dependencies(
62+
rclcpp
63+
std_msgs
64+
sensor_msgs
65+
)
6366
ament_export_include_directories(include)
6467
ament_package()

LICENSE

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
BSD 3-Clause License
2-
3-
Copyright (c) 2016, Hitachi-LG Data Storage
4-
Copyright (c) 2017, ROBOTIS
5-
All rights reserved.
6-
71
Redistribution and use in source and binary forms, with or without
82
modification, are permitted provided that the following conditions are met:
93

10-
* Redistributions of source code must retain the above copyright notice, this
11-
list of conditions and the following disclaimer.
4+
* Redistributions of source code must retain the above copyright
5+
notice, this list of conditions and the following disclaimer.
126

13-
* Redistributions in binary form must reproduce the above copyright notice,
14-
this list of conditions and the following disclaimer in the documentation
15-
and/or other materials provided with the distribution.
7+
* Redistributions in binary form must reproduce the above copyright
8+
notice, this list of conditions and the following disclaimer in the
9+
documentation and/or other materials provided with the distribution.
1610

17-
* Neither the name of the copyright holder nor the names of its
18-
contributors may be used to endorse or promote products derived from
19-
this software without specific prior written permission.
11+
* Neither the name of the copyright holder nor the names of its
12+
contributors may be used to endorse or promote products derived from
13+
this software without specific prior written permission.
2014

2115
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2216
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
POSSIBILITY OF SUCH DAMAGE.

applications/lds_driver/lds_driver.cpp

Lines changed: 67 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1-
/*******************************************************************************
2-
* Copyright (c) 2016, Hitachi-LG Data Storage
3-
* Copyright (c) 2017, ROBOTIS
4-
* All rights reserved.
5-
*
6-
* Redistribution and use in source and binary forms, with or without
7-
* modification, are permitted provided that the following conditions are met:
8-
*
9-
* * Redistributions of source code must retain the above copyright notice, this
10-
* list of conditions and the following disclaimer.
11-
*
12-
* * Redistributions in binary form must reproduce the above copyright notice,
13-
* this list of conditions and the following disclaimer in the documentation
14-
* and/or other materials provided with the distribution.
15-
*
16-
* * Neither the name of the copyright holder nor the names of its
17-
* contributors may be used to endorse or promote products derived from
18-
* this software without specific prior written permission.
19-
*
20-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30-
*******************************************************************************/
31-
32-
/* Authors: SP Kong, JH Yang, Pyo */
33-
/* maintainer: Pyo */
34-
35-
#include "lds_driver.h"
1+
// Copyright (c) 2016, Hitachi-LG Data Storage
2+
// Copyright (c) 2017, ROBOTIS
3+
//
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file or at
6+
// https://developers.google.com/open-source/licenses/bsd
7+
//
8+
// Redistribution and use in source and binary forms, with or without
9+
// modification, are permitted provided that the following conditions are met:
10+
//
11+
// * Redistributions of source code must retain the above copyright
12+
// notice, this list of conditions and the following disclaimer.
13+
//
14+
// * Redistributions in binary form must reproduce the above copyright
15+
// notice, this list of conditions and the following disclaimer in the
16+
// documentation and/or other materials provided with the distribution.
17+
//
18+
// * Neither the name of the {copyright_holder} nor the names of its
19+
// contributors may be used to endorse or promote products derived from
20+
// this software without specific prior written permission.
21+
//
22+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
// POSSIBILITY OF SUCH DAMAGE.
33+
34+
/* Authors: SP Kong, JH Yang, Pyo */
35+
/* maintainer: Pyo */
36+
37+
#include "../applications/lds_driver/lds_driver.hpp"
3638

3739
namespace lds
3840
{
39-
LFCDLaser::LFCDLaser(const std::string& port, uint32_t baud_rate, boost::asio::io_service& io)
40-
: port_(port), baud_rate_(baud_rate), shutting_down_(false), serial_(io, port_)
41+
LFCDLaser::LFCDLaser(const std::string & port, uint32_t baud_rate, boost::asio::io_service & io)
42+
: port_(port), baud_rate_(baud_rate), shutting_down_(false), serial_(io, port_)
4143
{
4244
serial_.set_option(boost::asio::serial_port_base::baud_rate(baud_rate_));
4345

@@ -58,31 +60,25 @@ void LFCDLaser::poll()
5860
boost::array<uint8_t, 2520> raw_bytes;
5961
uint8_t good_sets = 0;
6062
uint32_t motor_speed = 0;
61-
rpms=0;
63+
rpms = 0;
6264
int index;
6365

64-
while (!shutting_down_ && !got_scan)
65-
{
66+
while (!shutting_down_ && !got_scan) {
6667
// Wait until first data sync of frame: 0xFA, 0xA0
67-
boost::asio::read(serial_, boost::asio::buffer(&raw_bytes[start_count],1));
68+
boost::asio::read(serial_, boost::asio::buffer(&raw_bytes[start_count], 1));
6869

69-
if(start_count == 0)
70-
{
71-
if(raw_bytes[start_count] == 0xFA)
72-
{
70+
if (start_count == 0) {
71+
if (raw_bytes[start_count] == 0xFA) {
7372
start_count = 1;
7473
}
75-
}
76-
else if(start_count == 1)
77-
{
78-
if(raw_bytes[start_count] == 0xA0)
79-
{
74+
} else if (start_count == 1) {
75+
if (raw_bytes[start_count] == 0xA0) {
8076
start_count = 0;
8177

8278
// Now that entire start sequence has been found, read in the rest of the message
8379
got_scan = true;
8480

85-
boost::asio::read(serial_,boost::asio::buffer(&raw_bytes[2], 2518));
81+
boost::asio::read(serial_, boost::asio::buffer(&raw_bytes[2], 2518));
8682

8783
// scan->angle_min = 0.0;
8884
// scan->angle_max = 2.0*M_PI;
@@ -92,51 +88,48 @@ void LFCDLaser::poll()
9288
// scan->ranges.resize(360);
9389
// scan->intensities.resize(360);
9490

95-
//read data in sets of 6
96-
for(uint16_t i = 0; i < raw_bytes.size(); i=i+42)
97-
{
98-
if(raw_bytes[i] == 0xFA && raw_bytes[i+1] == (0xA0 + i / 42)) //&& CRC check
99-
{
91+
// read data in sets of 6
92+
93+
for (uint16_t i = 0; i < raw_bytes.size(); i = i + 42) {
94+
if (raw_bytes[i] == 0xFA && raw_bytes[i + 1] == (0xA0 + i / 42)) {
10095
good_sets++;
101-
motor_speed += (raw_bytes[i+3] << 8) + raw_bytes[i+2]; //accumulate count for avg. time increment
102-
rpms=(raw_bytes[i+3]<<8|raw_bytes[i+2])/10;
96+
motor_speed += (raw_bytes[i + 3] << 8) + raw_bytes[i + 2];
97+
rpms = (raw_bytes[i + 3] << 8 | raw_bytes[i + 2]) / 10;
10398

104-
for(uint16_t j = i+4; j < i+40; j=j+6)
105-
{
106-
index = 6*(i/42) + (j-4-i)/6;
99+
for (uint16_t j = i + 4; j < i + 40; j = j + 6) {
100+
index = 6 * (i / 42) + (j - 4 - i) / 6;
107101

108102
// Four bytes per reading
109103
uint8_t byte0 = raw_bytes[j];
110-
uint8_t byte1 = raw_bytes[j+1];
111-
uint8_t byte2 = raw_bytes[j+2];
112-
uint8_t byte3 = raw_bytes[j+3];
104+
uint8_t byte1 = raw_bytes[j + 1];
105+
uint8_t byte2 = raw_bytes[j + 2];
106+
uint8_t byte3 = raw_bytes[j + 3];
113107

114108
// Remaining bits are the range in mm
115109
uint16_t intensity = (byte1 << 8) + byte0;
116110

117-
// Last two bytes represent the uncertanty or intensity, might also be pixel area of target...
111+
// Last two bytes represent the uncertanty or intensity,
112+
// might also be pixel area of target...
118113
// uint16_t intensity = (byte3 << 8) + byte2;
119114
uint16_t range = (byte3 << 8) + byte2;
120115

121116
// scan->ranges[359-index] = range / 1000.0;
122117
// scan->intensities[359-index] = intensity;
123-
printf ("r[%d]=%f,",359-index, range / 1000.0);
118+
printf("r[%d]=%f,", 359 - index, range / 1000.0);
124119
}
125120
}
126121
}
127122

128123
// scan->time_increment = motor_speed/good_sets/1e8;
129-
}
130-
else
131-
{
124+
} else {
132125
start_count = 0;
133126
}
134127
}
135128
}
136129
}
137-
}
130+
} // namespace lds
138131

139-
int main(int argc, char **argv)
132+
int main(int argc, char ** argv)
140133
{
141134
std::string port;
142135
int baud_rate;
@@ -145,20 +138,16 @@ int main(int argc, char **argv)
145138
baud_rate = 230400;
146139
boost::asio::io_service io;
147140

148-
try
149-
{
141+
try {
150142
lds::LFCDLaser laser(port, baud_rate, io);
151143

152-
while (1)
153-
{
144+
while (1) {
154145
laser.poll();
155146
}
156147
laser.close();
157148

158149
return 0;
159-
}
160-
catch (boost::system::system_error ex)
161-
{
150+
} catch (boost::system::system_error ex) {
162151
printf("An exception was thrown: %s", ex.what());
163152
return -1;
164153
}

0 commit comments

Comments
 (0)