Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
149 changed files
with
27,529 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
**Edit a file, create a new file, and clone from Bitbucket in under 2 minutes** | ||
|
||
When you're done, you can delete the content in this README and update the file with details for others getting started with your repository. | ||
|
||
*We recommend that you open this README in another tab as you perform the tasks below. You can [watch our video](https://youtu.be/0ocf7u76WSo) for a full demo of all the steps in this tutorial. Open the video in a new tab to avoid leaving Bitbucket.* | ||
|
||
--- | ||
|
||
## Edit a file | ||
|
||
You’ll start by editing this README file to learn how to edit a file in Bitbucket. | ||
|
||
1. Click **Source** on the left side. | ||
2. Click the README.md link from the list of files. | ||
3. Click the **Edit** button. | ||
4. Delete the following text: *Delete this line to make a change to the README from Bitbucket.* | ||
5. After making your change, click **Commit** and then **Commit** again in the dialog. The commit page will open and you’ll see the change you just made. | ||
6. Go back to the **Source** page. | ||
|
||
--- | ||
|
||
## Create a file | ||
|
||
Next, you’ll add a new file to this repository. | ||
|
||
1. Click the **New file** button at the top of the **Source** page. | ||
2. Give the file a filename of **contributors.txt**. | ||
3. Enter your name in the empty file space. | ||
4. Click **Commit** and then **Commit** again in the dialog. | ||
5. Go back to the **Source** page. | ||
|
||
Before you move on, go ahead and explore the repository. You've already seen the **Source** page, but check out the **Commits**, **Branches**, and **Settings** pages. | ||
|
||
--- | ||
|
||
## Clone a repository | ||
|
||
Use these steps to clone from SourceTree, our client for using the repository command-line free. Cloning allows you to work on your files locally. If you don't yet have SourceTree, [download and install first](https://www.sourcetreeapp.com/). If you prefer to clone from the command line, see [Clone a repository](https://confluence.atlassian.com/x/4whODQ). | ||
|
||
1. You’ll see the clone button under the **Source** heading. Click that button. | ||
2. Now click **Check out in SourceTree**. You may need to create a SourceTree account or log in. | ||
3. When you see the **Clone New** dialog in SourceTree, update the destination path and name if you’d like to and then click **Clone**. | ||
4. Open the directory you just created to see your repository’s files. | ||
|
||
Now that you're more familiar with your Bitbucket repository, go ahead and add a new file locally. You can [push your change back to Bitbucket with SourceTree](https://confluence.atlassian.com/x/iqyBMg), or you can [add, commit,](https://confluence.atlassian.com/x/8QhODQ) and [push from the command line](https://confluence.atlassian.com/x/NQ0zDQ). |
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,74 @@ | ||
# All variables and this file are optional, if they are not present the PG and the | ||
# makefiles will try to parse the correct values from the file system. | ||
# | ||
# Variables that specify exclusions can use % as a wildcard to specify that anything in | ||
# that position will match. A partial path can also be specified to, for example, exclude | ||
# a whole folder from the parsed paths from the file system | ||
# | ||
# Variables can be specified using = or += | ||
# = will clear the contents of that variable both specified from the file or the ones parsed | ||
# from the file system | ||
# += will add the values to the previous ones in the file or the ones parsed from the file | ||
# system | ||
# | ||
# The PG can be used to detect errors in this file, just create a new project with this addon | ||
# and the PG will write to the console the kind of error and in which line it is | ||
|
||
meta: | ||
ADDON_NAME = ofxDabFlock | ||
ADDON_DESCRIPTION = Flocking Simulation | ||
ADDON_AUTHOR = Daniel Bisig / ICST | ||
ADDON_TAGS = "flocking" "simulation" | ||
|
||
common: | ||
# dependencies with other addons, a list of them separated by spaces | ||
# or use += in several lines | ||
# ADDON_DEPENDENCIES = | ||
|
||
# include search paths, this will be usually parsed from the file system | ||
# but if the addon or addon libraries need special search paths they can be | ||
# specified here separated by spaces or one per line using += | ||
# ADDON_INCLUDES = | ||
|
||
# any special flag that should be passed to the compiler when using this | ||
# addon | ||
# ADDON_CFLAGS = | ||
|
||
# any special flag that should be passed to the linker when using this | ||
# addon, also used for system libraries with -lname | ||
# ADDON_LDFLAGS = | ||
|
||
# linux only, any library that should be included in the project using | ||
# pkg-config | ||
# ADDON_PKG_CONFIG_LIBRARIES = | ||
|
||
# osx/iOS only, any framework that should be included in the project | ||
# ADDON_FRAMEWORKS = | ||
|
||
# source files, these will be usually parsed from the file system looking | ||
# in the src folders in libs and the root of the addon. if your addon needs | ||
# to include files in different places or a different set of files per platform | ||
# they can be specified here | ||
# ADDON_SOURCES = | ||
|
||
# some addons need resources to be copied to the bin/data folder of the project | ||
# specify here any files that need to be copied, you can use wildcards like * and ? | ||
# ADDON_DATA = | ||
|
||
# when parsing the file system looking for libraries exclude this for all or | ||
# a specific platform | ||
# ADDON_LIBS_EXCLUDE = | ||
|
||
ADDON_DEPENDENCIES = | ||
ADDON_DEPENDENCIES += "ofxDabBase" | ||
ADDON_DEPENDENCIES += "ofxDabEvent" | ||
ADDON_DEPENDENCIES += "ofxDabMath" | ||
ADDON_DEPENDENCIES += "ofxDabGeom" | ||
ADDON_DEPENDENCIES += "ofxDabOsc" | ||
ADDON_DEPENDENCIES += "ofxDabSpace" | ||
ADDON_DEPENDENCIES += "ofxAssimpModelLoader" | ||
ADDON_DEPENDENCIES += "ofxJSON" | ||
|
||
|
||
ADDON_INCLUDES = | ||
ADDON_INCLUDES += ../../libs/eigen3/include/ |
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,110 @@ | ||
/** \file dab_flock_acceleration_behavior.cpp | ||
*/ | ||
|
||
#include "dab_flock_acceleration_behavior.h" | ||
#include "dab_flock_parameter.h" | ||
#include "dab_flock_agent.h" | ||
|
||
using namespace dab; | ||
using namespace dab::flock; | ||
|
||
AccelerationBehavior::AccelerationBehavior(const std::string& pInputParameterString, const std::string& pOutputParameterString) | ||
: Behavior(pInputParameterString, pOutputParameterString) | ||
{ | ||
mClassName = "AccelerationBehavior"; | ||
} | ||
|
||
AccelerationBehavior::AccelerationBehavior(Agent* pAgent, const std::string& pBehaviorName, const std::string& pInputParameterString, const std::string& pOutputParameterString) throw (Exception) | ||
: Behavior(pAgent, pBehaviorName, pInputParameterString, pOutputParameterString) | ||
{ | ||
mClassName = "AccelerationBehavior"; | ||
|
||
if( mInputParameters.size() < 3 ) throw Exception( "FLOCK ERROR: " + std::to_string(mInputParameters.size() ) + " input parameters supplied, " + std::to_string(3) + " needed", __FILE__, __FUNCTION__, __LINE__ ); | ||
if( mOutputParameters.size() < 1 ) throw Exception( "FLOCK ERROR: " + std::to_string(mOutputParameters.size()) + " output parameters supplied, " + std::to_string(1) + " needed", __FILE__, __FUNCTION__, __LINE__); | ||
if( mInputParameters[1]->dim() != mOutputParameters[0]->dim() ) throw Exception( "FLOCK ERROR: input parameter " + mInputParameters[1]->name() + " dim " + std::to_string(mInputParameters[1]->dim()) + " must match output parameter " + mOutputParameters[1]->name() + " dim " + std::to_string(mOutputParameters[1]->dim()), __FILE__, __FUNCTION__, __LINE__ ); | ||
if( mInputParameters[2]->dim() != mOutputParameters[0]->dim() ) throw Exception( "FLOCK ERROR: input parameter " + mInputParameters[2]->name() + " dim " + std::to_string(mInputParameters[2]->dim()) + " must match output parameter " + mOutputParameters[1]->name() + " dim " + std::to_string(mOutputParameters[1]->dim()), __FILE__, __FUNCTION__, __LINE__ ); | ||
|
||
// input parameters | ||
mMassPar = mInputParameters[0]; | ||
mVelocityPar = mInputParameters[1]; | ||
mForcePar = mInputParameters[2]; | ||
|
||
// output parameters | ||
mAcceleration = mOutputParameters[0]; | ||
|
||
// create internal parameters | ||
mMaxLinearAccelerationPar = createInternalParameter("maxLinearAcceleration", mOutputParameters[0]->dim(), 0.5); | ||
mMaxAngularAccelerationPar = createInternalParameter("maxAngularAcceleration", mOutputParameters[0]->dim(), 0.5); | ||
|
||
// remaining stuff | ||
unsigned int dim = mForcePar->dim(); | ||
mPrefAccel.resize(dim, 1); | ||
mLinearAccel.resize(dim, 1); | ||
mAngularAccel.resize(dim, 1); | ||
} | ||
|
||
AccelerationBehavior::~AccelerationBehavior() | ||
{} | ||
|
||
Behavior* | ||
AccelerationBehavior::create(const std::string& pBehaviorName, Agent* pAgent) const throw (Exception) | ||
{ | ||
try | ||
{ | ||
if(pAgent != NULL) return new AccelerationBehavior(pAgent, pBehaviorName, mInputParameterString, mOutputParameterString); | ||
else return new AccelerationBehavior(mInputParameterString, mOutputParameterString); | ||
} | ||
catch(Exception& e) | ||
{ | ||
throw; | ||
} | ||
} | ||
|
||
Behavior* | ||
AccelerationBehavior::create(const std::string& pInputParameterString, const std::string& pOutputParameterString) const | ||
{ | ||
try | ||
{ | ||
return new AccelerationBehavior(pInputParameterString, pOutputParameterString); | ||
} | ||
catch(Exception& e) | ||
{ | ||
throw; | ||
} | ||
} | ||
|
||
void | ||
AccelerationBehavior::act() | ||
{ | ||
//std::cout << "AccelerationBehavior begin: out values" << mOutputParameters[0]->values() << " bValues " << mOutputParameters[0]->backupValues() << "\n"; | ||
|
||
if(mActivePar->value() <= 0.0) return; | ||
|
||
float& mass = mMassPar->value(); | ||
Eigen::VectorXf& velocity = mVelocityPar->values(); | ||
Eigen::VectorXf& force = mForcePar->values(); | ||
float& maxLinearAcceleration = mMaxLinearAccelerationPar->value(); | ||
float& maxAngularAcceleration = mMaxAngularAccelerationPar->value(); | ||
Eigen::VectorXf& acceleration = mAcceleration->backupValues(); | ||
|
||
Eigen::VectorXf& prefAccel = mPrefAccel; | ||
Eigen::VectorXf& linearAccel = mLinearAccel; | ||
Eigen::VectorXf& angularAccel = mAngularAccel; | ||
|
||
prefAccel = force / mass; | ||
linearAccel = velocity; | ||
linearAccel.normalize(); | ||
|
||
float dotProd = prefAccel.dot(linearAccel); | ||
linearAccel *= dotProd; | ||
angularAccel = prefAccel - linearAccel; | ||
|
||
linearAccel.cwiseMax(maxLinearAcceleration); | ||
angularAccel.cwiseMax(maxAngularAcceleration); | ||
|
||
acceleration = (linearAccel + angularAccel); | ||
|
||
//std::cout << "AccelerationBehavior end: out values" << mOutputParameters[0]->values() << " bValues " << mOutputParameters[0]->backupValues() << "\n"; | ||
|
||
//assert(std::isnan(acceleration[0]) == false && "isNan"); | ||
} |
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,101 @@ | ||
/** \file dab_flock_acceleration_behavior.h | ||
* \class dab::flock::AccelerationBehavior acceleration behavior | ||
* \brief acceleration behavior | ||
* | ||
* Behavior for calculating an Agent 's acceleration from a force acting on it.\n | ||
* can limit the resulting acceleration by clamping its linear and angular components.\n | ||
* \n | ||
* Input Parameter:\n | ||
* type: mass dim: 1D neighbors: ignore\n | ||
* type: velocity dim: nD neighbors: ignore\n | ||
* type: force dim: nD neighbors: ignore\n | ||
* \n | ||
* Output Parameter:\n | ||
* type: acceleration dim: nD write: replace\n | ||
* \n | ||
* Internal Parameter:\n | ||
* name: xxx_maxLinearAcceleration dim: 1D defaultValue: 0.5\n | ||
* name: xxx_maxAngularAcceleration dim: 1D defaultValue: 0.5\n | ||
* name: xxx_active dim: 1D defaultValue: 1.0\n | ||
* \n | ||
* Created by Daniel Bisig on 4/17/07. | ||
* Ported to OpenFrameworks by Daniel Bisig on 01/10/2017 | ||
*/ | ||
|
||
#ifndef _dab_flock_acceleration_behavior_h_ | ||
#define _dab_flock_acceleration_behavior_h_ | ||
|
||
#include "dab_flock_behavior.h" | ||
#include <Eigen/Dense> | ||
|
||
namespace dab | ||
{ | ||
|
||
namespace flock | ||
{ | ||
|
||
class AccelerationBehavior : public Behavior | ||
{ | ||
public: | ||
/** | ||
\brief create behavior | ||
\param pInputParameterString input parameter string (parameters are space separated) | ||
\param pOutputParameterString output paramaters are space separated) | ||
*/ | ||
AccelerationBehavior(const std::string& pInputParameterString, const std::string& pOutputParameterString); | ||
|
||
/** | ||
\brief create behavior | ||
\param pAgent agent this behavior belongs to | ||
\param pBehaviorName name of behavior | ||
\param pInputParameterString input parameter string (parameters are space separated) | ||
\param pOutputParameterString output paramaters are space separated) | ||
\exception Exception wrong number of type of parameters | ||
*/ | ||
AccelerationBehavior(Agent* pAgent, const std::string& pBehaviorName, const std::string& pInputParameterString, const std::string& pOutputParameterString) throw (Exception); | ||
|
||
/** | ||
\brief destructor | ||
*/ | ||
~AccelerationBehavior(); | ||
|
||
/** | ||
\brief create copy of behavior | ||
\param pAgent agent this behavior belongs to | ||
\param pBehaviorName name of behavior | ||
\return new behavior | ||
\exception Exception wrong number of type of parameters | ||
*/ | ||
virtual Behavior* create(const std::string& pBehaviorName, Agent* pAgent) const throw (Exception); | ||
|
||
/** | ||
\brief create copy of behavior | ||
\param pInputParameterString input parameter string | ||
\param pOutputParameterString output parameter string | ||
\return new behavior | ||
*/ | ||
virtual Behavior* create(const std::string& pInputParameterString, const std::string& pOutputParameterString) const; | ||
|
||
/** | ||
\brief perform behavior action | ||
*/ | ||
virtual void act(); | ||
|
||
protected: | ||
Parameter* mMassPar; /// \brief mass parameter (input) | ||
Parameter* mVelocityPar; /// \brief velocity parameter (input) | ||
Parameter* mForcePar; /// \brief force parameter (input) | ||
Parameter* mAcceleration; /// \brief acceleration parameter (output) | ||
Parameter* mMaxLinearAccelerationPar; /// \brief maximum linear acceleration parameter (internal) | ||
Parameter* mMaxAngularAccelerationPar; /// \brief maximum angular acceleration parameter (internal) | ||
|
||
Eigen::VectorXf mPrefAccel; /// \brief preferred acceleration | ||
Eigen::VectorXf mLinearAccel; /// \brief linear acceleration | ||
Eigen::VectorXf mAngularAccel; /// \brief angular acceleration | ||
}; | ||
|
||
}; | ||
|
||
}; | ||
|
||
#endif |
Oops, something went wrong.