AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
Engine.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
9having been advised so by Algoryx Simulation AB for a time limited evaluation,
10or having purchased a valid 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
17#pragma once
18
19#include <agxDriveTrain/Shaft.h>
22
23namespace agxDriveTrain
24{
26
31 {
32 public:
39
43 virtual agx::Real getCurrentPowerTimeIntegral() const override;
44
48 void setMinTorque(agx::Real minTorque);
49
51
55 virtual agx::Real variableLookupFunction( ) const override;
56
60 virtual agx::Real resultScalerFunction() const override;
61
65 virtual bool store(agxStream::StorageStream& str) const override;
66
70 virtual bool restore(agxStream::StorageStream& str) override;
71
73
74 protected:
78 };
79
80
81
83
88 {
89 public:
94
99
104
109
114 void setThrottle(agx::Real throttle);
115
119 virtual agx::Real getThrottle() const;
120
124 void setIdleRPM(agx::Real idleRPM);
125
130
131 public:
135 virtual bool preUpdate(agx::Real timeStep) override;
136
140 virtual bool store(agxStream::StorageStream& str) const override;
141
145 virtual bool restore(agxStream::StorageStream& str) override;
146
148
149 protected:
150 virtual ~Engine();
151
152 protected:
156 };
157
158
159
161
170 {
171 public:
176
182
187
193
197 virtual bool store( agxStream::StorageStream& str ) const;
198
202 virtual bool restore( agxStream::StorageStream& str );
203
204 void store( agxStream::OutputArchive& out ) const override;
205
206 void restore( agxStream::InputArchive& in ) override;
207
209
211
212 protected:
215 };
216
218
219
220
245 {
246 public:
259 PidControlledEngine* engine, agx::Real targetRpm,
260 agx::Real pGain, agx::Real dGain, agx::Real iGain,
261 agx::Real iRange);
262
264 void setTargetRpm(agx::Real targetRpm);
265
267
268
269 // Methods called other classes in the DriveTrain framework.
270 public:
271 virtual agx::Real calculateThrottle() override;
272
276 virtual bool store(agxStream::StorageStream& str) const override;
277
281 virtual bool restore(agxStream::StorageStream& str) override;
282
284
285 protected:
287 virtual ~RpmController();
288
289 private:
290 agx::Real m_targetRpm;
291
292 agx::Real m_pGain;
293 agx::Real m_dGain;
294 agx::Real m_iGain;
295 agx::Real m_iRange;
296
297 agx::Real m_iState;
298 agx::Real m_lastRpmDiff;
299 agx::Real m_lastThrottle; // \todo Should this be in ThrottleCalculator? If so, how should it be updated?
300 };
301
302
304
305
306
321 {
322 public:
327
331 void ignition( bool ignition );
332
336 void shutdown( bool shutdown );
337
341 bool isRunning( ) const;
342
347
352
356 void setRPMTorqueTable( const agx::RealPairVector& rpm_torques );
357
361 void setRPMPowerTable( const agx::RealPairVector& rpm_power );
362
367
372 void setExtraLoad( agx::Real torque );
373
375
381
387
392
393 public:
397 virtual bool preUpdate( agx::Real timeStamp ) override;
398
402 virtual bool store( agxStream::StorageStream& str ) const override;
403
407 virtual bool restore( agxStream::StorageStream& str ) override;
408
410
411 protected:
413 bool m_isOn;
416 };
417
419
420
425 {
426 public:
431
441
446
451
458
464
474
479
484
488 virtual bool addNotification(agxSDK::Simulation* simulation) override;
489
492 virtual bool removeNotification(agxUtil::ConstraintHolder* constraintHolder, agxSDK::Simulation* simulation) override;
493
497 virtual bool store(agxStream::StorageStream& str) const override;
498
502 virtual bool postStore(agxStream::StorageStream& str) const override;
503
507 virtual bool restore(agxStream::StorageStream& str) override;
508
512 virtual bool postRestore(agxStream::StorageStream& str) override;
513
516
517 protected:
519
521 };
522
524}
#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 AGXMODEL_EXPORT
Power generator that adds torque to the engine according to a lookup table.
Definition: Engine.h:31
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
EnginePowerGenerator(agxPowerLine::RotationalDimension *dimension, agx::Real minTorque)
Create an engine power generator.
void setMinTorque(agx::Real minTorque)
The min torque is the torque an engine produces at idle.
virtual agx::Real resultScalerFunction() const override
Scales the resulting torque with the throttle input to the engine.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
virtual agx::Real variableLookupFunction() const override
Finds the current RPM (and not angular velocity)
virtual agx::Real getCurrentPowerTimeIntegral() const override
Return the current torque to add (time integral of power)
An engine that is driven by an EnginePowerGenerator.
Definition: Engine.h:88
virtual bool preUpdate(agx::Real timeStep) override
Function called by static functions.
agx::Real m_throttle
Definition: Engine.h:154
void setIdleRPM(agx::Real idleRPM)
Set the wanted RPM when there is no throttle.
Engine()
Create an engine with an EnginePowerGenerator.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
agx::Real getRPM() const
Get revolutions per minute.
void setThrottle(agx::Real throttle)
Set the throttle input.
agxPowerLine::PowerGenerator * getPowerGenerator() const
virtual agx::Real getThrottle() const
agx::Real m_idleRPM
Definition: Engine.h:155
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
agx::Real getIdleRPM() const
void setPowerGenerator(agxPowerLine::PowerGenerator *generator)
Set the power generator to use for this engine.
agxPowerLine::PowerGeneratorRef m_generator
Definition: Engine.h:153
An engine that tries to hold a fixed velocity.
Definition: Engine.h:425
agxDriveTrain::VelocityConstraint * getConstraint()
void setTargetVelocity(agx::Real velocity)
Set the target velocity of the engine.
void setTorqueRange(agx::RangeReal range)
Set the torque range to limit the available torque of the engine.
const agxDriveTrain::VelocityConstraint * getConstraint() const
FixedVelocityEngine()
Create an engine with target velocity set to zero.
agx::Real getCurrentTorque()
Get the torque applied on the engine during the last time step.
void setTargetRpm(agx::Real rpm)
Set the RPM that the engine should try to hold.
Implementation of a combustion engine.
Definition: Engine.h:321
ThrottleCalculatorRef m_pidController
Definition: Engine.h:415
void setExtraLoad(agx::Real torque)
Use the extra load to be able to set an extra torque loss to simulate friction, electrical systems lo...
agx::Real getTorqueAtRPM(agx::Real rpm) const
PidControlledEngine()
Create an engine with an empty torque table and no ThrottleCalculator.
void setRPMTorqueTable(const agx::RealPairVector &rpm_torques)
Give the engine output torque at different engine RPMs.
void setThrottleCalculator(ThrottleCalculator *controller)
Set a throttle controller that will be asked for a throttle every time step while the engine is turne...
virtual bool preUpdate(agx::Real timeStamp) override
Function that has to be public since it is called by static functions.
const ThrottleCalculator * getThrottleCalculator() const
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
void setRPMPowerTable(const agx::RealPairVector &rpm_power)
Give the engine output power at different engine RPMs.
ThrottleCalculator * getThrottleCalculator()
void shutdown(bool shutdown)
Turn off the ignition key.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
void ignition(bool ignition)
If ignition is true - start the engine.
ThrottleCalculator that strives to keep the engine at some given RPM.
Definition: Engine.h:245
RpmController(PidControlledEngine *engine, agx::Real targetRpm, agx::Real pGain, agx::Real dGain, agx::Real iGain, agx::Real iRange)
Create a RpmController that operates on the given engine.
agx::Real getLastThrottle() const
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
virtual agx::Real calculateThrottle() override
Classes inheriting from ThrottleCalculator has to implement the calculateThrottle function.
agx::Real getTargetRpm() const
void setTargetRpm(agx::Real targetRpm)
A Shaft is the most basic PowerLine Unit.
Definition: Shaft.h:35
Inherit from the ThrottleCalculator and implement the calculateThrottle() function to control the tor...
Definition: Engine.h:170
void store(agxStream::OutputArchive &out) const override
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxDriveTrain::ThrottleCalculator)
virtual bool store(agxStream::StorageStream &str) const
Stores internal data into stream.
virtual agx::Real calculateThrottle()=0
Classes inheriting from ThrottleCalculator has to implement the calculateThrottle function.
virtual bool restore(agxStream::StorageStream &str)
Restores internal data from stream.
PidControlledEngine * m_engine
Definition: Engine.h:214
void setEngine(PidControlledEngine *engine)
Set an engine to the controller.
void restore(agxStream::InputArchive &in) override
const PidControlledEngine * getEngine() const
PidControlledEngine * getEngine()
ThrottleCalculator(PidControlledEngine *engine)
Create a ThrottleCalculator given a PidControlledEngine.
A constraint holding a single VelocityConstraintImplementation.
Will generate power by adding a load to a physical dimension.
The rotational has one rotational degree of freedom.
A torque generator adds torque to the body of a rotational dimension.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
Base class providing referencing counted objects.
Definition: Referenced.h:120
Templated vector class.
Definition: agx/Vector.h:53
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
A library of agxPowerLine components designed to model the various parts of a vehicle drive train.
agx::ref_ptr< RpmController > RpmControllerRef
Definition: Engine.h:303
agx::ref_ptr< PidControlledEngine > PidControlledEngineRef
Definition: Engine.h:418
agx::ref_ptr< ThrottleCalculator > ThrottleCalculatorRef
Definition: Engine.h:217
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agxUtil namespace contain classes and methods for utility functionality.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:41