Class ParallelVehicles#

Inheritance Relationships#

Base Type#

Class Documentation#

class ParallelVehicles : public Karana::Models::KModel<ParallelVehicles>#

Run vehicles associated with the provided StatePropagators in parallel.

This KModel runs vehicles in parallel. Each vehicle should be associated with one of the provided StatePropagators. For clarity, these StatePropagators will be referred to as vehicle StatePropagators. This KModel should be registered on a different ModelManager/StatePropagator, which will be referred to as the global StatePropagators. To use this KModel, do the following:

  1. Ensure the Karana::KCore::ThreadPool has a size of at least the number of vehicles + 1. The get/setThreadPoolSize methods can be used to do this.

  2. This model should be registered with the global StatePropagator before any other KModel that has a postHop. This ensures that the dynamics of the vehicles run after any KModel preHopss on the global StatePropagator, and before all other KModel postHops.

This model should not be used in the following scenarios:

  • Spice frames are present. This will data race issues when the separate vehicles each try to update the ephemeris time.

  • Collision/contact. If two vehicles may collide, then they cannot be run in parallel, as their dynamics are coupled.

Public Functions

ParallelVehicles(std::string_view name, const kc::ks_ptr<kd::ModelManager> &mm)#

ParallelVehicles constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.

Parameters:
  • name – The name of the model.

  • mm – The ModelManager to register this model with.

~ParallelVehicles()#

Destructor for ParallelVehicles.

void postHop(const km::Ktime &t, const km::Vec &x)#

Temporarily release the GIL so other threads can do work.

Parameters:
  • t – Current time.

  • x – Current state. Not used.

const std::vector<kc::ks_ptr<kd::StatePropagator>> &getVehicleStatePropagators() const#

Get the StatePropagators for the vehicles.

Returns:

The vehicle StatePropagators.

void setVehicleStatePropagators(const std::vector<kc::ks_ptr<kd::StatePropagator>> &sps)#

Set the StatePropagators for the vehicles.

Parameters:

sps – The StatePropagators to use for the vehicles.

bool getRunInSerial() const#

Get whether this model will run the vehicles in serial or not.

Returns:

True if running in serial, false otherwise.

void setRunInSerial(bool run_in_serial)#

Set whether this model will run the vehicles in serial or not.

Serial mode can be used for debugging, but should remain false (the default) when running production code.

Parameters:

run_in_serial – True to run in serial, false to run in parallel.

Public Static Functions

static kc::ks_ptr<ParallelVehicles> create(std::string_view name, const kc::ks_ptr<kd::ModelManager> &mm, const std::vector<kc::ks_ptr<kd::StatePropagator>> &sps)#

Constructor.

Parameters:
  • name – The name of the model.

  • mm – The ModelManager to register this model with.

  • sps – The StatePropagators associated with the vehicles that should be run in parallel.

Returns:

A ks_ptr to the newly created instance of the ParallelVehicles model.

Protected Functions

virtual void _registerModel() override#

Register the model.

virtual void _unregisterModel() override#

Unregister the model.