AGXDynamics  2.35.0.3
Engine.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxDriveTrain/Shaft.h>
22 
23 namespace agxDriveTrain
24 {
26 
31  {
32  public:
39 
43  virtual agx::Real getCurrentPowerTimeIntegral() const override;
44 
48  void setMinTorque(agx::Real minTorque);
49 
50  agx::Real getMinTorque() const;
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:
76  virtual ~EnginePowerGenerator();
78  };
79 
80 
81 
83 
88  {
89  public:
93  Engine();
94 
98  agxPowerLine::PowerGenerator* getPowerGenerator() const;
99 
103  void setPowerGenerator(agxPowerLine::PowerGenerator* generator);
104 
108  agx::Real getRPM() const;
109 
114  void setThrottle(agx::Real throttle);
115 
119  virtual agx::Real getThrottle() const;
120 
124  void setIdleRPM(agx::Real idleRPM);
125 
129  agx::Real getIdleRPM() const;
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 
160  class PidControlledEngine;
161 
170  {
171  public:
175  explicit ThrottleCalculator( PidControlledEngine* engine );
176 
181  virtual agx::Real calculateThrottle() = 0;
182 
186  void setEngine( PidControlledEngine* engine );
187 
191  PidControlledEngine* getEngine();
192  const PidControlledEngine* getEngine() const;
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:
213  virtual ~ThrottleCalculator( );
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 
263  agx::Real getTargetRpm() const;
264  void setTargetRpm(agx::Real targetRpm);
265 
266  agx::Real getLastThrottle() const;
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:
286  RpmController();
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 
346  agx::Real getRPM( ) const;
347 
351  agx::Real getLoadTorque( ) const;
352 
356  void setRPMTorqueTable( const agx::RealPairVector& rpm_torques );
357 
361  void setRPMPowerTable( const agx::RealPairVector& rpm_power );
362 
366  agx::Real getTorqueAtRPM( agx::Real rpm ) const;
367 
372  void setExtraLoad( agx::Real torque );
373 
374  agx::Real getExtraLoad( ) const;
375 
380  void setThrottleCalculator( ThrottleCalculator* controller );
381 
385  const ThrottleCalculator* getThrottleCalculator() const;
386  ThrottleCalculator* getThrottleCalculator();
387 
391  agx::Real getTorque( ) const;
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:
412  virtual ~PidControlledEngine( );
413  bool m_isOn;
416  };
417 
419 
420 
425  {
426  public:
431 
440  agx::Real getCurrentTorque();
441 
445  agx::Real getTargetVelocity();
446 
450  agx::RangeReal getTorqueRange();
451 
457  void setTargetVelocity(agx::Real velocity);
458 
463  void setTargetRpm(agx::Real rpm);
464 
473  void setTorqueRange(agx::RangeReal range);
474 
478  const agxDriveTrain::VelocityConstraint* getConstraint() const;
479 
483  virtual bool addNotification(agxSDK::Simulation* simulation) override;
484 
487  virtual bool removeNotification(agxUtil::ConstraintHolder* constraintHolder, agxSDK::Simulation* simulation) override;
488 
492  virtual bool store(agxStream::StorageStream& str) const override;
493 
497  virtual bool postStore(agxStream::StorageStream& str) const override;
498 
502  virtual bool restore(agxStream::StorageStream& str) override;
503 
507  virtual bool postRestore(agxStream::StorageStream& str) override;
508 
511 
512  protected:
513  virtual ~FixedVelocityEngine();
514 
516  };
517 
519 }
agxDriveTrain::FixedVelocityEngine
An engine that tries to hold a fixed velocity.
Definition: Engine.h:424
agxDriveTrain::EnginePowerGenerator
Power generator that adds torque to the engine according to a lookup table.
Definition: Engine.h:30
agx::Real
double Real
Definition: Real.h:42
agxDriveTrain::ThrottleCalculatorRef
agx::ref_ptr< ThrottleCalculator > ThrottleCalculatorRef
Definition: Engine.h:217
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition: OutputArchive.h:412
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agxDriveTrain::Engine::m_generator
agxPowerLine::PowerGeneratorRef m_generator
Definition: Engine.h:153
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agxDriveTrain
A library of agxPowerLine components designed to model the various parts of a vehicle drive train.
agxUtil::ConstraintHolder
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:463
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxDriveTrain::Engine::m_throttle
agx::Real m_throttle
Definition: Engine.h:154
agxDriveTrain::PidControlledEngine::m_pidController
ThrottleCalculatorRef m_pidController
Definition: Engine.h:415
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
agxDriveTrain::FixedVelocityEngineRef
agx::ref_ptr< FixedVelocityEngine > FixedVelocityEngineRef
Definition: Engine.h:518
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agxDriveTrain::Shaft
A Shaft is the most basic PowerLine Unit.
Definition: Shaft.h:34
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
PowerLineConstraints.h
agxDriveTrain::RpmControllerRef
agx::ref_ptr< RpmController > RpmControllerRef
Definition: Engine.h:303
agxDriveTrain::PidControlledEngineRef
agx::ref_ptr< PidControlledEngine > PidControlledEngineRef
Definition: Engine.h:418
agx::ref_ptr< PowerGenerator >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agx::shutdown
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.
agxDriveTrain::ThrottleCalculator::m_engine
PidControlledEngine * m_engine
Definition: Engine.h:214
agxDriveTrain::Engine::m_idleRPM
agx::Real m_idleRPM
Definition: Engine.h:155
agxDriveTrain::Engine
An engine that is driven by an EnginePowerGenerator.
Definition: Engine.h:87
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agxPowerLine::RotationalDimension
The rotational has one rotational degree of freedom.
Definition: RotationalDimension.h:45
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agxDriveTrain::EnginePowerGenerator::m_minTorque
agx::Real m_minTorque
Definition: Engine.h:77
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxDriveTrain::PidControlledEngine::m_extraLoad
agx::Real m_extraLoad
Definition: Engine.h:414
Shaft.h
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agx::Range< Real >
VelocityConstraint.h
agxDriveTrain::PidControlledEngine
Implementation of a combustion engine.
Definition: Engine.h:320
agxDriveTrain::RpmController
ThrottleCalculator that strives to keep the engine at some given RPM.
Definition: Engine.h:244
agxDriveTrain::PidControlledEngine::m_isOn
bool m_isOn
Definition: Engine.h:413
agxPowerLine::PowerGenerator
Will generate power by adding a load to a physical dimension.
Definition: PowerLineUtils.h:187
agxDriveTrain::ThrottleCalculator
Inherit from the ThrottleCalculator and implement the calculateThrottle() function to control the tor...
Definition: Engine.h:169
agxPowerLine::TorqueGenerator
A torque generator adds torque to the body of a rotational dimension.
Definition: RotationalDimension.h:195
agxDriveTrain::FixedVelocityEngine::m_velocityConstraint
agxDriveTrain::VelocityConstraintRef m_velocityConstraint
Definition: Engine.h:515