-
Notifications
You must be signed in to change notification settings - Fork 23
Add DENM TS access functions #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b58253e
5ac6375
4e9fa46
be2d5e4
37c18d6
7b38130
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| ============================================================================= | ||
| MIT License | ||
|
|
||
| Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
| ============================================================================= | ||
| */ | ||
|
|
||
| /** | ||
| * @file denm_ts_access.hpp | ||
| * @brief Main DENM TS access header to include in ROS 2 projects | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| // Messages | ||
| #include <etsi_its_denm_ts_msgs/msg/denm.hpp> | ||
| #include <geometry_msgs/msg/point_stamped.hpp> | ||
|
|
||
| namespace etsi_its_denm_ts_msgs { | ||
| using namespace msg; | ||
| namespace gm = geometry_msgs::msg; | ||
| } | ||
|
|
||
| // Implementation | ||
| #include <etsi_its_msgs_utils/impl/denm/denm_ts_access.h> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| ============================================================================= | ||
| MIT License | ||
|
|
||
| Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
| ============================================================================= | ||
| */ | ||
|
|
||
| /** | ||
| * @file impl/cdd/cdd_v2-2-1_getters.h | ||
| * @brief Getter functions for the ETSI ITS Common Data Dictionary (CDD) v2.2.1 | ||
| */ | ||
|
|
||
| #ifndef ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_GETTERS_H | ||
| #define ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_GETTERS_H | ||
| #include <GeographicLib/UTMUPS.hpp> | ||
|
|
||
| #include <etsi_its_msgs_utils/impl/cdd/cdd_getters_common.h> | ||
|
|
||
| /** | ||
| * @brief Get the WGS Heading value | ||
| * | ||
| * 0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West | ||
| * | ||
| * @param heading to get the WGS Heading value from | ||
| * @return WGS Heading value in degree as decimal number | ||
| */ | ||
| template <typename Wgs84Angle> | ||
| inline double getWGSHeadingCDD(const Wgs84Angle& heading) { return ((double)heading.value.value) * 1e-1; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific reason for this |
||
|
|
||
| /** | ||
| * @brief Get the WGS Heading confidence | ||
| * | ||
| * 0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West | ||
| * | ||
| * @param heading to get the WGS Heading standard deviation from | ||
| * @return WGS Heading standard deviation in degree as decimal number | ||
| */ | ||
|
|
||
| template <typename Wgs84Angle> | ||
| inline double getWGSHeadingConfidenceCDD(const Wgs84Angle& heading) { return ((double)heading.confidence.value) * 1e-1 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: |
||
|
|
||
| #endif // ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_GETTERS_H | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| ============================================================================= | ||
| MIT License | ||
|
|
||
| Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
| ============================================================================= | ||
| */ | ||
|
|
||
| /** | ||
| * @file impl/cdd/cdd_v2-2-1_setters.h | ||
| * @brief Setter functions for the ETSI ITS Common Data Dictionary (CDD) v2.2.1 | ||
| */ | ||
|
|
||
| #ifndef ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_SETTERS_H | ||
| #define ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_SETTERS_H | ||
|
|
||
| #include <etsi_its_msgs_utils/impl/cdd/cdd_setters_common.h> | ||
| #include <etsi_its_msgs_utils/impl/checks.h> | ||
| #include <GeographicLib/UTMUPS.hpp> | ||
| #include <cstring> | ||
|
|
||
| /** | ||
| * @brief Set the Its Pdu Header object | ||
| * | ||
| * @param header ItsPduHeader to be set | ||
| * @param message_id ID of the message | ||
| * @param station_id | ||
| * @param protocol_version | ||
| */ | ||
| inline void setItsPduHeader(ItsPduHeader& header, const uint8_t message_id, const uint32_t station_id, | ||
| const uint8_t protocol_version = 0) { | ||
| setStationId(header.station_id, station_id); | ||
| throwIfOutOfRange(message_id, MessageId::MIN, MessageId::MAX, "MessageID"); | ||
| header.message_id.value = message_id; | ||
| throwIfOutOfRange(protocol_version, OrdinalNumber1B::MIN, OrdinalNumber1B::MAX, "ProtocolVersion"); | ||
| header.protocol_version.value = protocol_version; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set the Wgs84AngleValue object | ||
| * | ||
| * 0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West | ||
| * | ||
| * @param heading object to set | ||
| * @param value Heading value in degree as decimal number | ||
| */ | ||
| template <typename Wgs84AngleValue> | ||
| inline void setWGSHeadingValue(Wgs84AngleValue& heading, const double value) { | ||
| int64_t deg = (int64_t)std::round(value * 1e1); | ||
| throwIfOutOfRange(deg, Wgs84AngleValue::MIN, Wgs84AngleValue::MAX, "Wgs84AngleValue"); | ||
| heading.value = deg; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set the Wgs84AngleConfidence object | ||
| * | ||
| * @param confidence object to set | ||
| * @param value standard deviation of heading in degree as decimal number | ||
| */ | ||
| template<typename Wgs84AngleConfidence> | ||
| inline void setWGSHeadingConfidence(Wgs84AngleConfidence& confidence, const double value) { | ||
| auto heading_conf = std::round(value * 1e1 * etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR); | ||
| if (heading_conf < Wgs84AngleConfidence::MIN && heading_conf > 0.0){ | ||
| heading_conf = Wgs84AngleConfidence::MIN; | ||
| } else if (heading_conf >= Wgs84AngleConfidence::OUT_OF_RANGE || heading_conf <= 0.0) { | ||
| heading_conf = Wgs84AngleConfidence::UNAVAILABLE; | ||
| } | ||
| confidence.value = static_cast<decltype(confidence.value)>(heading_conf); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set the Wgs84Angle object | ||
| * | ||
| * 0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West | ||
| * Wgs84AngleConfidence is set to UNAVAILABLE | ||
| * | ||
| * @param heading object to set | ||
| * @param value Heading value in degree as decimal number | ||
| * @param confidence standard deviation of heading in degree as decimal number (default: infinity, mapping to Wgs84AngleConfidence::UNAVAILABLE) | ||
| */ | ||
| template <typename Wgs84Angle, typename Wgs84AngleConfidence = decltype(Wgs84Angle::confidence)> | ||
| void setWGSHeadingCDD(Wgs84Angle& heading, const double value, double confidence = std::numeric_limits<double>::infinity()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: |
||
| setWGSHeadingConfidence(heading.confidence, confidence); | ||
| setWGSHeadingValue(heading.value, value); | ||
| } | ||
|
|
||
| #endif // ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_SETTERS_H | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason for this
CDDpostfix in the function-name? I think we're not having these for the ohter setter/getter functions?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
CDDpostfix is already used for low-level CDD functions (e.g. getHeadingCDD(), setHeadingCDD(), getYawRateCDD() in cdd_*_common.h). The message-level access functions stay without postfix. getWGSHeadingCDD() follows the same pattern.