AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
EncoderOutputHandler.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16#pragma once
22
23#include <optional>
24#include <utility>
25
26namespace agxSensor
27{
28 using OptionalUniqueId = std::optional<size_t>;
29 using OptionalEncoderOutputMapping = std::optional<std::pair<size_t, EncoderOutput*>>;
30
32
37 {
38 public:
43
50 bool add( size_t uniqueId, EncoderOutput* output );
51
59
66 template<typename T, EncoderOutput::Field... field>
67 bool add( size_t uniqueId );
68
75 template<typename T, EncoderOutput::Field... field>
77
83 EncoderOutput* get( size_t uniqueId );
84
90 ISensorOutput* getBase( size_t uniqueId ) override;
91
98
107
112 bool contains( const MonoaxialGaussianNoise* noise ) const;
113
119 bool add( MonoaxialSignalResolution* resolution );
120
128
133 bool contains( const MonoaxialSignalResolution* resolution ) const;
134
140 bool add( MonoaxialSignalScaling* scaling );
141
150
155 bool contains( const MonoaxialSignalScaling* scaling ) const;
156
161
163
164 public:
165 virtual void synchronize( const CallbackData& data ) override;
166 virtual void cleanup() override;
167
169
170 protected:
171 using OutputTable = agx::HashTable<size_t, EncoderOutputRef>;
172
173 protected:
174 bool addModifierInternal( IMonoaxialSignalSystemNode* node );
175 bool removeModifierInternal( IMonoaxialSignalSystemNode* node );
176 bool containsModifierInternal( const IMonoaxialSignalSystemNode* node ) const;
177
179
180 protected:
181 OutputTable m_outputs;
183 SystemNodeRef m_signalAssembler;
184 SystemNodeRef m_tailNode;
185 };
186
187 template<typename T, EncoderOutput::Field... field>
188 bool EncoderOutputHandler::add( size_t uniqueId )
189 {
190 EncoderOutputRef output = new EncoderOutput();
191 output->build<field...>();
192 return add( uniqueId, output );
193 }
194
195 template<typename T, EncoderOutput::Field... field>
196 OptionalEncoderOutputMapping EncoderOutputHandler::add()
197 {
198 EncoderOutputRef output = new EncoderOutput();
199 output->build<field...>();
200
201 auto uniqueId = add( output );
202 if ( uniqueId )
203 return std::make_pair( *uniqueId, output );
204 else
205 return std::nullopt;
206 }
207}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXSENSOR_EXPORT
Handler responsible for how the encoder readings are assembled and provided to the user.
IMonoaxialSignalSystemNodeRefVector getOutputModifiers() const
bool remove(MonoaxialSignalResolution *resolution)
Remove the resolution binning instance from the system tree.
bool add(MonoaxialGaussianNoise *noise)
Add a Gaussian noise instance to the system tree.
bool add(MonoaxialSignalScaling *scaling)
Add a signal scaling instance to the system tree.
bool contains(const MonoaxialGaussianNoise *noise) const
bool remove(MonoaxialSignalScaling *scaling)
Remove the signal scaling instance from the system tree.
ISensorOutput * getBase(size_t uniqueId) override
Access encoder output instance given the unique id from when it was added.
bool add(MonoaxialSignalResolution *resolution)
Add a resolution binning instance to the system tree.
bool add(size_t uniqueId, EncoderOutput *output)
Add the given encoder output to the output handler mapped to the given unique id.
EncoderOutputHandler()
Default constructor.
EncoderOutput * get(size_t uniqueId)
Access encoder output instance given the unique id from when it was added.
bool remove(MonoaxialGaussianNoise *noise)
Remove the Gaussian noise instance from the system tree.
OptionalUniqueId add(EncoderOutput *output)
Add the given encoder output to the output handler.
bool contains(const MonoaxialSignalScaling *scaling) const
bool contains(const MonoaxialSignalResolution *resolution) const
Encoder sensor output data where EncoderOutput::Field is used to define the data available.
Definition: EncoderOutput.h:48
Interface for implementation details for system nodes carrying a monoaxial signal.
Common interface for sensor output handlers.
Common interface for sensor output data.
Definition: SensorOutput.h:27
Applies a total Gaussian noise to the monoaxial signal based on a specified noise RMS.
Applies resolution binning to a monoaxial signal.
Applies a constant scaling to the monoaxial signal.
System node is a separate step/operation in an execution tree representing a sensor (or such) in a se...
Definition: SystemNode.h:44
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
std::optional< size_t > OptionalUniqueId
std::optional< std::pair< size_t, EncoderOutput * > > OptionalEncoderOutputMapping
The agx namespace contains the dynamics/math part of the AGX Dynamics API.