Skip to content

Commit b52f004

Browse files
committed
Release 3.0.0 sick_lidar_localization phase III: ROS services SIM Konfiguration
Release 3.0.0 sick_lidar_localization phase III: ROS services SIM Konfiguration
1 parent ad044d1 commit b52f004

37 files changed

+2084
-69
lines changed

CMakeLists.txt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ add_service_files(
7474
FILES
7575
SickLocColaTelegramSrv.srv
7676
SickLocRequestTimestampSrv.srv
77+
SickLocSetResultModeSrv.srv
78+
SickLocSetResultPoseIntervalSrv.srv
79+
SickLocStopAndSaveSrv.srv
80+
SickLocIsSystemReadySrv.srv
81+
SickLocSetPoseSrv.srv
82+
SickLocSetResultPortSrv.srv
83+
SickLocStartLocalizingSrv.srv
84+
SickLocStopSrv.srv
85+
SickLocRequestResultDataSrv.srv
86+
SickLocSetResultEndiannessSrv.srv
87+
SickLocSetResultPoseEnabledSrv.srv
88+
SickLocStateSrv.srv
7789
SickLocTimeSyncSrv.srv
7890
)
7991

@@ -145,8 +157,10 @@ include_directories(
145157
## Declare a C++ library
146158
add_library(sick_localization_lib
147159
src/client_socket.cpp
160+
src/cola_configuration.cpp
148161
src/cola_converter.cpp
149162
src/cola_parser.cpp
163+
src/cola_services.cpp
150164
src/cola_transmitter.cpp
151165
src/driver_check_thread.cpp
152166
src/driver_monitor.cpp
@@ -175,6 +189,7 @@ add_executable(sim_loc_driver src/driver.cpp)
175189
add_executable(sim_loc_driver_check src/driver_check.cpp)
176190
add_executable(sim_loc_time_sync src/time_sync.cpp)
177191
add_executable(pointcloud_converter src/pointcloud_converter.cpp)
192+
add_executable(cola_service_node src/cola_service_node.cpp)
178193

179194
## Executables for test purposes
180195
add_executable(sim_loc_test_server test/src/test_server.cpp test/src/test_server_thread.cpp)
@@ -218,6 +233,11 @@ add_dependencies(pointcloud_converter
218233
${${PROJECT_NAME}_EXPORTED_TARGETS}
219234
${catkin_EXPORTED_TARGETS}
220235
)
236+
add_dependencies(cola_service_node
237+
sick_localization_lib
238+
${${PROJECT_NAME}_EXPORTED_TARGETS}
239+
${catkin_EXPORTED_TARGETS}
240+
)
221241
add_dependencies(unittest_sim_loc_parser
222242
sick_localization_lib
223243
${${PROJECT_NAME}_EXPORTED_TARGETS}
@@ -259,6 +279,11 @@ target_link_libraries(pointcloud_converter
259279
${Boost_LIBRARIES}
260280
${catkin_LIBRARIES}
261281
)
282+
target_link_libraries(cola_service_node
283+
sick_localization_lib
284+
${Boost_LIBRARIES}
285+
${catkin_LIBRARIES}
286+
)
262287
target_link_libraries(unittest_sim_loc_parser
263288
sick_localization_lib
264289
${Boost_LIBRARIES}
@@ -285,7 +310,7 @@ target_link_libraries(verify_sim_loc_driver
285310
# )
286311

287312
## Mark executables and/or libraries for installation
288-
install(TARGETS sick_localization_lib sim_loc_driver sim_loc_driver_check sim_loc_test_server sim_loc_time_sync pointcloud_converter unittest_sim_loc_parser verify_sim_loc_driver
313+
install(TARGETS sick_localization_lib sim_loc_driver sim_loc_driver_check sim_loc_test_server sim_loc_time_sync pointcloud_converter cola_service_node unittest_sim_loc_parser verify_sim_loc_driver
289314
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
290315
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
291316
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}

README.md

Lines changed: 148 additions & 10 deletions
Large diffs are not rendered by default.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/*
2+
* @brief cola_configuration sets the initial SIM result output configuration
3+
* using ros cola services.
4+
* Configures the following result output settings from launch file:
5+
* LocSetResultPort, LocSetResultMode, LocSetResultPoseEnabled, LocSetResultEndianness, LocSetResultPoseInterval,
6+
* LocRequestResultData
7+
*
8+
* Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
9+
* Copyright (C) 2019 SICK AG, Waldkirch
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*
23+
* All rights reserved.
24+
*
25+
* Redistribution and use in source and binary forms, with or without
26+
* modification, are permitted provided that the following conditions are met:
27+
*
28+
* * Redistributions of source code must retain the above copyright
29+
* notice, this list of conditions and the following disclaimer.
30+
* * Redistributions in binary form must reproduce the above copyright
31+
* notice, this list of conditions and the following disclaimer in the
32+
* documentation and/or other materials provided with the distribution.
33+
* * Neither the name of SICK AG nor the names of its
34+
* contributors may be used to endorse or promote products derived from
35+
* this software without specific prior written permission
36+
* * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
37+
* contributors may be used to endorse or promote products derived from
38+
* this software without specific prior written permission
39+
*
40+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
44+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
46+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
47+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50+
* POSSIBILITY OF SUCH DAMAGE.
51+
*
52+
* Authors:
53+
* Michael Lehning <michael.lehning@lehning.de>
54+
*
55+
* Copyright 2019 SICK AG
56+
* Copyright 2019 Ing.-Buero Dr. Michael Lehning
57+
*
58+
*/
59+
#ifndef __SIM_LOC_COLA_CONFIGURATION_H_INCLUDED
60+
#define __SIM_LOC_COLA_CONFIGURATION_H_INCLUDED
61+
62+
#include "sick_lidar_localization/cola_services.h"
63+
64+
namespace sick_lidar_localization
65+
{
66+
/*!
67+
* Class sick_lidar_localization::ColaConfiguration sets the initial SIM result output configuration
68+
* using ros cola services.
69+
* Configures the following result output settings from launch file:
70+
* LocSetResultPort, LocSetResultMode, LocSetResultPoseEnabled, LocSetResultEndianness, LocSetResultPoseInterval,
71+
* LocRequestResultData
72+
*/
73+
class ColaConfiguration
74+
{
75+
public:
76+
77+
/*!
78+
* Constructor
79+
*/
80+
ColaConfiguration(ros::NodeHandle* nh = 0);
81+
82+
/*!
83+
* Destructor
84+
*/
85+
virtual ~ColaConfiguration();
86+
87+
/*!
88+
* Starts transmitting the initial result output configuration to the localization controller.
89+
* Configures the following result output settings from launch file:
90+
* LocSetResultPort, LocSetResultMode, LocSetResultPoseEnabled, LocSetResultEndianness, LocSetResultPoseInterval,
91+
* LocRequestResultData
92+
* @return true on success, false in case of errors.
93+
*/
94+
virtual bool start(void);
95+
96+
/*!
97+
* Stops transmitting the initial result output configuration to the localization controller.
98+
*/
99+
virtual void stop(void);
100+
101+
protected:
102+
103+
/*!
104+
* Thread callback, transmits the initial SIM result output configuration using ros cola services.
105+
* Configures the following result output settings from launch file:
106+
* LocSetResultPort, LocSetResultMode, LocSetResultPoseEnabled, LocSetResultEndianness, LocSetResultPoseInterval,
107+
* LocRequestResultData
108+
*/
109+
virtual void runConfigurationThreadCb(void);
110+
111+
/*!
112+
* Calls a ros service until successfully executed or configuration thread cancelled.
113+
* @param[in/out] service_telegram service request and response
114+
* @param[in] service_client ros service client
115+
* @param[in] retry_delay delay before next retry in case of errors
116+
* @return true on success or false on failure
117+
*/
118+
template<typename T> bool callService(T & service_telegram, ros::ServiceClient & service_client, double retry_delay)
119+
{
120+
service_telegram.response.success = false;
121+
while(ros::ok() && m_nh && m_configuration_thread_running && (!service_client.call(service_telegram) || !service_telegram.response.success))
122+
{
123+
ROS_WARN_STREAM("## ERROR ColaConfiguration: service call(" << sick_lidar_localization::Utils::flattenToString(service_telegram.request) << ") failed, response: " << sick_lidar_localization::Utils::flattenToString(service_telegram.response) << ", retrying");
124+
ros::Duration(retry_delay).sleep();
125+
}
126+
ROS_INFO_STREAM("ColaConfiguration " << typeid(T).name() << " " << (service_telegram.response.success ? "successfull" : "failed"));
127+
return service_telegram.response.success;
128+
}
129+
130+
/*
131+
* member variables
132+
*/
133+
134+
ros::NodeHandle* m_nh; ///< ros node handle
135+
boost::thread* m_configuration_thread; ///< thread to transmit configuration
136+
bool m_configuration_thread_running; ///< true: m_configuration_thread is running, otherwise false
137+
138+
}; // class ColaServices
139+
140+
} // namespace sick_lidar_localization
141+
#endif // __SIM_LOC_COLA_CONFIGURATION_H_INCLUDED

0 commit comments

Comments
 (0)