-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Closing in on initial cut an an implementation - Will require injection of global swarm state each timestep, which is kind of icky, but the quickest/most computationally efficient way to do it.
- Loading branch information
Showing
51 changed files
with
1,154 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* \file boid_vector.hpp | ||
* | ||
* \copyright 2022 SIFT LLC, All rights reserved. | ||
* | ||
* SPDX-License Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include <vector> | ||
|
||
#include "cosm/apf2D/boid.hpp" | ||
|
||
/******************************************************************************* | ||
* Namespaces/Decls | ||
******************************************************************************/ | ||
namespace cosm::apf2D { | ||
|
||
/******************************************************************************* | ||
* Type Definitions | ||
******************************************************************************/ | ||
using boid_vectorro = std::vector<const boid*>; | ||
|
||
} /* namespace cosm::apf2D */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* \file alignment_force.hpp | ||
* | ||
* \copyright 2018 John Harwell, All rights reserved. | ||
* | ||
* SPDX-License-Identifier: LGPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include <vector> | ||
|
||
#include "cosm/cosm.hpp" | ||
#include "cosm/apf2D/boid.hpp" | ||
#include "cosm/apf2D/flocking/config/alignment_force_config.hpp" | ||
|
||
/******************************************************************************* | ||
* Namespaces/Decls | ||
******************************************************************************/ | ||
namespace cosm::apf2D::flocking { | ||
|
||
/******************************************************************************* | ||
* Class Definitions | ||
******************************************************************************/ | ||
/** | ||
* \class alignment_force | ||
* \ingroup apf2D flocking | ||
* | ||
* \brief A force pulling an agent towards a single other agent, or towards the | ||
* centroid of the positions of a set of agents. | ||
* | ||
* From \cite FLOCK:Bagarti2018-stochfov. | ||
*/ | ||
class alignment_force { | ||
public: | ||
explicit alignment_force(const config::alignment_force_config* config); | ||
|
||
/** | ||
* \brief Calculate the force. | ||
* | ||
* \param agent The current agent. | ||
* | ||
* \param neighbors The velocities of the neighbors of \p agent. | ||
* | ||
* \return The heading correction the agent should take to stay aligned with | ||
* the average position of \p neighbors. | ||
*/ | ||
|
||
rmath::vector2d operator()(const boid& agent, | ||
const std::vector<rmath::vector2d>& others) const; | ||
|
||
private: | ||
/* clang-format off */ | ||
const double mc_max; | ||
/* clang-format on */ | ||
}; | ||
|
||
} /* namespace cosm::apf2D::flocking */ |
37 changes: 37 additions & 0 deletions
37
include/cosm/apf2D/flocking/config/alignment_force_config.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* \file alignment_force_config.hpp | ||
* | ||
* \copyright 2022 SIFT LLC, All rights reserved. | ||
* | ||
* SPDX-License Identifier: LGPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include "rcppsw/config/base_config.hpp" | ||
|
||
/******************************************************************************* | ||
* Namespaces/Decls | ||
******************************************************************************/ | ||
namespace cosm::apf2D::flocking::config { | ||
|
||
/******************************************************************************* | ||
* Structure Definitions | ||
******************************************************************************/ | ||
/** | ||
* \struct alignment_force_config | ||
* \ingroup apf2D flocking config | ||
* | ||
* \brief Configuration for \ref capf2D::flocking::alignment_force. | ||
*/ | ||
struct alignment_force_config : public rconfig::base_config { | ||
/** | ||
* \brief The maximum strength of the force. | ||
*/ | ||
double max{-1}; | ||
}; | ||
|
||
} /* namespace cosm::apf2D::flocking::config */ |
50 changes: 50 additions & 0 deletions
50
include/cosm/apf2D/flocking/config/constant_speed_force_config.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* \file constant_speed_force_config.hpp | ||
* | ||
* \copyright 2022 SIFT LLC, All rights reserved. | ||
* | ||
* SPDX-License Identifier: LGPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include "rcppsw/config/base_config.hpp" | ||
|
||
#include "rcppsw/math/radians.hpp" | ||
#include "rcppsw/spatial/euclidean_dist.hpp" | ||
|
||
/******************************************************************************* | ||
* Namespaces/Decls | ||
******************************************************************************/ | ||
namespace cosm::apf2D::flocking::config { | ||
|
||
/******************************************************************************* | ||
* Structure Definitions | ||
******************************************************************************/ | ||
/** | ||
* \struct constant_speed_force_config | ||
* \ingroup spatial strategy flocking config | ||
* | ||
* \brief Configuration for \ref capf2D::constant_speed_force. | ||
*/ | ||
struct constant_speed_force_config : public rconfig::base_config { | ||
/** | ||
* \brief The maximum strength of the force. | ||
*/ | ||
double max{-1}; | ||
|
||
/** | ||
* \brief The "critical" speed the the swarm is collectively trying to | ||
* maintain. | ||
* | ||
* \f$v_c\f$ in Bagarti2018. | ||
*/ | ||
|
||
double critical_speed{-1}; | ||
}; | ||
|
||
|
||
} /* namespace cosm::apf2D::flocking::config */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* \file flocking_config.hpp | ||
* | ||
* \copyright 2022 SIFT LLC, All rights reserved. | ||
* | ||
* SPDX-License Identifier: LGPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include "cosm/apf2D/flocking/config/alignment_force_config.hpp" | ||
#include "cosm/apf2D/flocking/config/constant_speed_force_config.hpp" | ||
|
||
/******************************************************************************* | ||
* Namespaces/Decls | ||
******************************************************************************/ | ||
namespace cosm::apf2D::flocking::config { | ||
|
||
/******************************************************************************* | ||
* Structure Definitions | ||
******************************************************************************/ | ||
/** | ||
* \struct flocking_config | ||
* \ingroup apf2D flocking config | ||
* | ||
* \brief Configuration force APF forces related to flocking. | ||
*/ | ||
struct flocking_config : public rconfig::base_config { | ||
/* clang-format off */ | ||
alignment_force_config alignment{}; | ||
constant_speed_force_config constant_speed{}; | ||
/* clang-format on */ | ||
}; | ||
|
||
} /* namespace cosm::apf2D::flocking::config */ |
Oops, something went wrong.