Compute Graph Framework SDK Reference  5.8
dwRelativeEgomotionIMUNodeImpl.hpp
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
31#ifndef DW_FRAMEWORK_RELATIVE_EGOMOTION_IMU_IMPL_NODE_HPP_
32#define DW_FRAMEWORK_RELATIVE_EGOMOTION_IMU_IMPL_NODE_HPP_
33
38#include <dw/sensors/imu/IMU.h>
39#include <dw/sensors/canbus/CAN.h>
40#include <dw/egomotion/EgomotionState.h>
41#include <dw/rig/Rig.hpp>
42
43namespace dw
44{
45namespace framework
46{
47
48class dwRelativeEgomotionIMUNodeImpl : public SimpleProcessNodeT<dwRelativeEgomotionIMUNode>, public IAsyncResetable, public IContainsPreShutdownAction
49{
50public:
51 static constexpr char LOG_TAG[] = "dwRelativeEgomotionIMUNode";
52
54 const dwContextHandle_t ctx);
55 dwRelativeEgomotionIMUNodeImpl(const dwContextHandle_t ctx)
56 : m_ctx(ctx){};
57
59
60 dwStatus reset() override;
61
62 dwStatus setAsyncReset() override;
63 dwStatus executeAsyncReset() override;
64 dwStatus preShutdown() override;
65
66 dwStatus setupImpl() override;
67 dwStatus validate() override;
68
69 dwStatus addIMU(ManagedPortInput<dwIMUFrame>& imuFramePort);
72 ManagedPortInput<dwVehicleIONonSafetyState>& vehicleNonSafetyStatePort,
73 ManagedPortInput<dwVehicleIOActuationFeedback>& vehicleActuationFeedbackPort);
76
81
85
86 inline const dwEgomotionParameters& getEgomotionParameters() { return m_egomotionParams; };
87 inline dwEgomotionHandle_t& getEgomotionHandle() { return m_egomotion; };
89
91
92protected:
95
96 void monitorSignals(dwTime_t const currentHostTime, dwTime_t const latestEgomotionTimestamp) const;
97
98 // Vehicle copy
99 dwVehicle m_vehicle{};
100
101 // Time bookkeeping
102 dwTime_t m_lastUpdate{};
103
104 dwEgomotionHandle_t m_egomotion = DW_NULL_HANDLE;
105 const dwContextHandle_t m_ctx = DW_NULL_HANDLE;
106
107 dwEgomotionParameters m_egomotionParams{};
108 void** m_outputHandle{nullptr};
109
110 uint32_t m_imuSensorID = 0U;
111
112 static const dwTime_t INITIALIZATION_TIMEOUT = 5'000'000; // [us]
113 static const dwTime_t MISSING_SIGNAL_TIMEOUT = 50'000; // [us]
114 static const uint64_t MINIMUM_INPUT_COUNT = 100; // [-]
115
116 dwTime_t m_latestVioTimestamp = DW_TIME_INVALID;
117 dwTime_t m_latestIMUTimestamp = DW_TIME_INVALID;
118 dwTime_t m_initTimestamp = DW_TIME_INVALID;
119 mutable bool m_isDrained = false; // marked mutable for usage in logging functions otherwise const
120
121 uint64_t m_vioInputCounter = 0U;
122 uint64_t m_imuInputCounter = 0U;
123
124private:
125 void initializePorts(const dwRelativeEgomotionIMUNodeInitParams& params);
126
127 void monitorVIOTimeOffset(const dwTime_t& currentHostTime) const;
128 void monitorIMUTimeOffset(const dwTime_t& currentHostTime) const;
129 void monitorEgomotionTimeOffset(const dwTime_t& currentHostTime, const dwTime_t& latestEgomotionTimestamp) const;
130
131 dwStatus processAddIMU();
132 dwStatus processAddOdometry();
133 dwStatus processAddVehicleState();
134 dwStatus processUpdateIMUExtrinsics();
135 dwStatus processUpdateWheelRadii();
136 dwStatus processSendState();
137
138 bool m_shutdown = false;
139};
140
141} // namespace framework
142} // namespace dw
143
144#endif // DW_FRAMEWORK_RELATIVE_EGOMOTION_IMU_IMPL_NODE_HPP_
dwStatus addOdometry(ManagedPortInput< dwVehicleIOState > &vehicleStatePort)
dwRelativeEgomotionIMUNodeImpl(const dwRelativeEgomotionIMUNodeInitParams &params, const dwContextHandle_t ctx)
void monitorSignals(dwTime_t const currentHostTime, dwTime_t const latestEgomotionTimestamp) const
dwStatus updateWheelRadii(ManagedPortInput< CalibratedWheelRadii > &wheelRadiiPort)
void sendRoadCast(ManagedPortOutput< dwEgomotionResultPayload > &resultPayloadPort, ManagedPortOutput< dwTransformation3fPayload > &transPayloadPort)
dwStatus sendGyroBias(ManagedPortOutput< CalibratedIMUIntrinsics > &IMUIntrinsicsPort)
dwStatus updateIMUExtrinsics(ManagedPortInput< dwSensorNodeProperties > &imuExtrinsicPort)
dwStatus addIMU(ManagedPortInput< dwIMUFrame > &imuFramePort)
void initializeParams(const dwRelativeEgomotionIMUNodeInitParams &params)
dwStatus sendState(ManagedPortOutput< dwEgomotionStateHandle_t > &egomotionStatePort, ManagedPortOutput< dwEgomotionResultPayload > &resultPayloadPort, ManagedPortOutput< dwTransformation3fPayload > &transPayloadPort)
dwStatus sendState(ManagedPortOutput< dwEgomotionStateHandle_t > &egomotionStatePort, ManagedPortOutput< dwEgomotionResultPayload > &resultPayloadPort, ManagedPortOutput< dwTransformation3fPayload > &transPayloadPort, ManagedPortOutput< CalibratedIMUIntrinsics > &IMUIntrinsicsPort)
dwStatus addVehicleState(ManagedPortInput< dwVehicleIOSafetyState > &vehicleSafetyStatePort, ManagedPortInput< dwVehicleIONonSafetyState > &vehicleNonSafetyStatePort, ManagedPortInput< dwVehicleIOActuationFeedback > &vehicleActuationFeedbackPort)
Definition: Exception.hpp:47