Skip to content

Commit a8ee797

Browse files
authored
Merge pull request #509 from SteveMacenski/dashing-devel
Dashing cleanup
2 parents 9314379 + 475e8c9 commit a8ee797

File tree

56 files changed

+1309
-1878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1309
-1878
lines changed

CMakeLists.txt

Lines changed: 84 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ rosidl_target_interfaces(${library_name}
5757
${PROJECT_NAME} "rosidl_typesupport_cpp")
5858

5959
add_executable(
60-
se_node
61-
src/se_node.cpp
60+
ekf_node
61+
src/ekf_node.cpp
62+
)
63+
64+
add_executable(
65+
ukf_node
66+
src/ukf_node.cpp
6267
)
6368

6469
add_executable(
@@ -86,31 +91,33 @@ ament_target_dependencies(
8691
)
8792

8893
target_link_libraries(
89-
se_node
94+
ekf_node
9095
${library_name}
9196
)
9297

9398
ament_target_dependencies(
94-
se_node
99+
ekf_node
95100
rclcpp
96101
)
97102

98103
target_link_libraries(
99-
navsat_transform_node
104+
ukf_node
100105
${library_name}
101106
)
102107

103108
ament_target_dependencies(
104-
navsat_transform_node
109+
ukf_node
105110
rclcpp
106111
)
107112

108-
install(
109-
TARGETS
113+
target_link_libraries(
110114
navsat_transform_node
111-
se_node
112115
${library_name}
113-
DESTINATION lib/${PROJECT_NAME}
116+
)
117+
118+
ament_target_dependencies(
119+
navsat_transform_node
120+
rclcpp
114121
)
115122

116123
if(BUILD_TESTING)
@@ -125,48 +132,68 @@ if(BUILD_TESTING)
125132
ament_add_gtest(filter_base-test test/test_filter_base.cpp)
126133
target_link_libraries(filter_base-test ${library_name})
127134

128-
# This test uses se_node node for convenience.
129-
ament_add_gtest(test_filter_base_diagnostics_timestamps
135+
#### DIAGNOSTICS TESTS ####
136+
ament_add_gtest_executable(test_filter_base_diagnostics_timestamps
130137
test/test_filter_base_diagnostics_timestamps.cpp)
131138
target_link_libraries(test_filter_base_diagnostics_timestamps ${library_name})
132-
add_dependencies(test_filter_base_diagnostics_timestamps se_node)
139+
add_dependencies(test_filter_base_diagnostics_timestamps ekf_node)
140+
ament_add_test(test_filter_base_diagnostics_timestamps
141+
GENERATE_RESULT_FOR_RETURN_CODE_ZERO
142+
TIMEOUT 300
143+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test/test_filter_base_diagnostics_timestamps.launch.py"
144+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
145+
)
133146

134147
#### EKF TESTS ######
135148
ament_add_gtest(test_ekf test/test_ekf.cpp)
136149
target_link_libraries(test_ekf ${library_name})
137150

138-
ament_add_gtest(test_ekf_localization_node_interfaces
139-
test/test_ekf_localization_node_interfaces.cpp)
151+
ament_add_gtest_executable(test_ekf_localization_node_interfaces
152+
test/test_ekf_localization_node_interfaces.cpp)
140153
target_link_libraries(test_ekf_localization_node_interfaces ${library_name})
141-
142-
ament_add_gtest(test_ekf_localization_node_bag1 test/test_localization_node_bag_pose_tester.cpp)
143-
target_link_libraries(test_ekf_localization_node_bag1 ${library_name})
144-
145-
ament_add_gtest(test_ekf_localization_node_bag2 test/test_localization_node_bag_pose_tester.cpp)
146-
target_link_libraries(test_ekf_localization_node_bag2 ${library_name})
147-
148-
ament_add_gtest(test_ekf_localization_node_bag3 test/test_localization_node_bag_pose_tester.cpp)
149-
target_link_libraries(test_ekf_localization_node_bag3 ${library_name})
154+
add_dependencies(test_ekf_localization_node_interfaces ekf_node)
155+
ament_add_test(test_ekf_localization_node_interfaces
156+
GENERATE_RESULT_FOR_RETURN_CODE_ZERO
157+
TIMEOUT 300
158+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test/test_ekf_localization_node_interfaces.launch.py"
159+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
160+
)
150161

151162
#### UKF TESTS #####
152163
ament_add_gtest(test_ukf test/test_ukf.cpp)
153164
target_link_libraries(test_ukf ${library_name})
154165

155-
ament_add_gtest(test_ukf_localization_node_interfaces test/test_ukf_localization_node_interfaces.cpp)
166+
167+
ament_add_gtest_executable(test_ukf_localization_node_interfaces
168+
test/test_ukf_localization_node_interfaces.cpp)
156169
target_link_libraries(test_ukf_localization_node_interfaces ${library_name})
170+
add_dependencies(test_ukf_localization_node_interfaces ekf_node)
171+
ament_add_test(test_ukf_localization_node_interfaces
172+
GENERATE_RESULT_FOR_RETURN_CODE_ZERO
173+
TIMEOUT 300
174+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test/test_ukf_localization_node_interfaces.launch.py"
175+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
176+
)
157177

158-
ament_add_gtest(test_ukf_localization_node_bag1 test/test_localization_node_bag_pose_tester.cpp)
159-
target_link_libraries(test_ukf_localization_node_bag1 ${library_name})
178+
#### DATA TESTS #####
179+
# ament_add_gtest(test_ekf_localization_node_bag1 test/test_localization_node_bag_pose_tester.cpp)
180+
# target_link_libraries(test_ekf_localization_node_bag1 ${library_name})
160181

161-
ament_add_gtest(test_ukf_localization_node_bag2 test/test_localization_node_bag_pose_tester.cpp)
162-
target_link_libraries(test_ukf_localization_node_bag2 ${library_name})
182+
# ament_add_gtest(test_ekf_localization_node_bag2 test/test_localization_node_bag_pose_tester.cpp)
183+
# target_link_libraries(test_ekf_localization_node_bag2 ${library_name})
163184

164-
ament_add_gtest(test_ukf_localization_node_bag3 test/test_localization_node_bag_pose_tester.cpp)
165-
target_link_libraries(test_ukf_localization_node_bag3 ${library_name})
185+
# ament_add_gtest(test_ekf_localization_node_bag3 test/test_localization_node_bag_pose_tester.cpp)
186+
# target_link_libraries(test_ekf_localization_node_bag3 ${library_name})
187+
188+
# ament_add_gtest(test_ukf_localization_node_bag1 test/test_localization_node_bag_pose_tester.cpp)
189+
# target_link_libraries(test_ukf_localization_node_bag1 ${library_name})
190+
191+
# ament_add_gtest(test_ukf_localization_node_bag2 test/test_localization_node_bag_pose_tester.cpp)
192+
# target_link_libraries(test_ukf_localization_node_bag2 ${library_name})
193+
194+
# ament_add_gtest(test_ukf_localization_node_bag3 test/test_localization_node_bag_pose_tester.cpp)
195+
# target_link_libraries(test_ukf_localization_node_bag3 ${library_name})
166196

167-
# This forces cppcheck to consider all files in this project to be C++,
168-
# including the headers which end with .h, which cppcheck would normally
169-
# consider to be C instead.
170197
ament_cppcheck(LANGUAGE "c++")
171198
ament_cpplint()
172199
ament_lint_cmake()
@@ -178,23 +205,40 @@ if(BUILD_TESTING)
178205
test_filter_base_diagnostics_timestamps
179206
test_ekf
180207
test_ekf_localization_node_interfaces
181-
test_ekf_localization_node_bag1
182-
test_ekf_localization_node_bag2
183-
test_ekf_localization_node_bag3
184208
test_ukf
185209
test_ukf_localization_node_interfaces
186-
test_ukf_localization_node_bag1
187-
test_ukf_localization_node_bag2
188-
test_ukf_localization_node_bag3
210+
#test_ekf_localization_node_bag1
211+
#test_ekf_localization_node_bag2
212+
#test_ekf_localization_node_bag3
213+
#test_ukf_localization_node_bag1
214+
#test_ukf_localization_node_bag2
215+
#test_ukf_localization_node_bag3
189216
DESTINATION lib/${PROJECT_NAME}
190217
)
218+
219+
# Install test launch config files.
220+
install(DIRECTORY
221+
test
222+
DESTINATION share/${PROJECT_NAME}
223+
USE_SOURCE_PERMISSIONS
224+
)
191225
endif()
192226

227+
install(
228+
TARGETS
229+
navsat_transform_node
230+
ekf_node
231+
ukf_node
232+
${library_name}
233+
DESTINATION lib/${PROJECT_NAME}
234+
)
235+
193236
# Install params config files.
194237
install(DIRECTORY
195238
params
196239
launch
197240
DESTINATION share/${PROJECT_NAME}
241+
USE_SOURCE_PERMISSIONS
198242
)
199243

200244
ament_export_include_directories(include)

include/robot_localization/filter_base.hpp

Lines changed: 4 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@
3636

3737
#include <robot_localization/filter_common.hpp>
3838
#include <robot_localization/filter_utilities.hpp>
39-
40-
#include <Eigen/Dense>
41-
#include <rclcpp/duration.hpp>
42-
#include <rclcpp/macros.hpp>
43-
#include <rclcpp/time.hpp>
39+
#include <robot_localization/measurement.hpp>
40+
#include <robot_localization/filter_state.hpp>
4441

4542
#include <algorithm>
4643
#include <memory>
@@ -52,96 +49,6 @@
5249
namespace robot_localization
5350
{
5451

55-
/**
56-
* @brief Structure used for storing and comparing measurements
57-
* (for priority queues)
58-
*
59-
* Measurement units are assumed to be in meters and radians. Times are
60-
* real-valued and measured in seconds.
61-
*/
62-
struct Measurement
63-
{
64-
// The real-valued time, in seconds, since some epoch (presumably the start of
65-
// execution, but any will do)
66-
rclcpp::Time time_;
67-
68-
// The Mahalanobis distance threshold in number of sigmas
69-
double mahalanobis_thresh_;
70-
71-
// The time stamp of the most recent control term (needed for lagged data)
72-
rclcpp::Time latest_control_time_;
73-
74-
// The topic name for this measurement. Needed for capturing previous state
75-
// values for new measurements.
76-
std::string topic_name_;
77-
78-
// This defines which variables within this measurement actually get passed
79-
// into the filter. std::vector<bool> is generally frowned upon, so we use
80-
// ints.
81-
std::vector<bool> update_vector_;
82-
83-
// The most recent control vector (needed for lagged data)
84-
Eigen::VectorXd latest_control_;
85-
86-
// The measurement and its associated covariance
87-
Eigen::VectorXd measurement_;
88-
Eigen::MatrixXd covariance_;
89-
90-
// We want earlier times to have greater priority
91-
bool operator()(
92-
const std::shared_ptr<Measurement> & a,
93-
const std::shared_ptr<Measurement> & b)
94-
{
95-
return (*this)(*(a.get()), *(b.get()));
96-
}
97-
98-
bool operator()(const Measurement & a, const Measurement & b)
99-
{
100-
return a.time_ > b.time_;
101-
}
102-
103-
Measurement()
104-
: time_(0), mahalanobis_thresh_(std::numeric_limits<double>::max()),
105-
latest_control_time_(0), topic_name_(""), latest_control_() {}
106-
};
107-
using MeasurementPtr = std::shared_ptr<Measurement>;
108-
109-
/**
110-
* @brief Structure used for storing and comparing filter states
111-
*
112-
* This structure is useful when higher-level classes need to remember filter
113-
* history. Measurement units are assumed to be in meters and radians. Times are
114-
* real-valued and measured in seconds.
115-
*/
116-
struct FilterState
117-
{
118-
// The filter state vector
119-
Eigen::VectorXd state_;
120-
121-
// The filter error covariance matrix
122-
Eigen::MatrixXd estimate_error_covariance_;
123-
124-
// The most recent control vector
125-
Eigen::VectorXd latest_control_;
126-
127-
// The time stamp of the most recent measurement for the filter
128-
rclcpp::Time last_measurement_time_;
129-
130-
// The time stamp of the most recent control term
131-
rclcpp::Time latest_control_time_;
132-
133-
// We want the queue to be sorted from latest to earliest timestamps.
134-
bool operator()(const FilterState & a, const FilterState & b)
135-
{
136-
return a.last_measurement_time_ < b.last_measurement_time_;
137-
}
138-
139-
FilterState()
140-
: state_(), estimate_error_covariance_(), latest_control_(),
141-
last_measurement_time_(0.0), latest_control_time_(0) {}
142-
};
143-
using FilterStatePtr = std::shared_ptr<FilterState>;
144-
14552
class FilterBase
14653
{
14754
public:
@@ -384,43 +291,13 @@ class FilterBase
384291
* @param[in] deceleration_gain - Gain applied to deceleration control error
385292
* @return a usable acceleration estimate for the control vector
386293
*/
387-
inline double computeControlAcceleration(
294+
double computeControlAcceleration(
388295
const double state,
389296
const double control,
390297
const double acceleration_limit,
391298
const double acceleration_gain,
392299
const double deceleration_limit,
393-
const double deceleration_gain)
394-
{
395-
FB_DEBUG("---------- FilterBase::computeControlAcceleration ----------\n");
396-
397-
const double error = control - state;
398-
const bool same_sign = (::fabs(error) <= ::fabs(control) + 0.01);
399-
const double set_point = (same_sign ? control : 0.0);
400-
const bool decelerating = ::fabs(set_point) < ::fabs(state);
401-
double limit = acceleration_limit;
402-
double gain = acceleration_gain;
403-
404-
if (decelerating) {
405-
limit = deceleration_limit;
406-
gain = deceleration_gain;
407-
}
408-
409-
const double final_accel = std::min(std::max(gain * error, -limit), limit);
410-
411-
FB_DEBUG("Control value: " <<
412-
control << "\n" <<
413-
"State value: " << state << "\n" <<
414-
"Error: " << error << "\n" <<
415-
"Same sign: " << (same_sign ? "true" : "false") << "\n" <<
416-
"Set point: " << set_point << "\n" <<
417-
"Decelerating: " << (decelerating ? "true" : "false") << "\n" <<
418-
"Limit: " << limit << "\n" <<
419-
"Gain: " << gain << "\n" <<
420-
"Final is " << final_accel << "\n");
421-
422-
return final_accel;
423-
}
300+
const double deceleration_gain);
424301

425302
/**
426303
* @brief Keeps the state Euler angles in the range [-pi, pi]

0 commit comments

Comments
 (0)