├── config
├── log
│ └── .gitignore
├── traj
│ ├── Origin.txt
│ ├── Turn.txt
│ ├── MakeCircleTrajectory.py
│ ├── MakeSpiralTrajectory.py
│ ├── MakeHelixTrajectory.py
│ ├── AttitudeTest.txt
│ ├── Square.txt
│ ├── MakeHelixUpDownTrajectory.py
│ ├── MakePeriodicTrajectory.py
│ └── SpiralNoFF.txt
├── X_Scenarios.txt
├── X_TestMavlink.txt
├── Scenarios.txt
├── SimulatedSensors.txt
├── QuadEstimatorEKF.txt
├── 01_Intro.txt
├── X_DebugAttitudeInterp.txt
├── Simulation.txt
├── QuadControlParams.txt
├── 10_MagUpdate.txt
├── 02_AttitudeControl.txt
├── 05_TrajectoryFollow.txt
├── QuadPhysicalParams.txt
├── 03_PositionControl.txt
├── 07_AttitudeEstimation.txt
├── 11_GPSUpdate.txt
├── 08_PredictState.txt
├── 04_Nonidealities.txt
├── 06_SensorNoise.txt
├── X_TestManyQuads.txt
├── X_MonteCarloTest.txt
└── 09_PredictCovariance.txt
├── CODEOWNERS
├── lib
├── Eigen
│ ├── Eigen
│ ├── src
│ │ ├── Core
│ │ │ ├── util
│ │ │ │ ├── NonMPL2.h
│ │ │ │ └── ReenableStupidWarnings.h
│ │ │ ├── functors
│ │ │ │ └── TernaryFunctors.h
│ │ │ ├── DiagonalProduct.h
│ │ │ ├── arch
│ │ │ │ ├── AVX
│ │ │ │ │ └── TypeCasting.h
│ │ │ │ ├── Default
│ │ │ │ │ └── Settings.h
│ │ │ │ ├── SSE
│ │ │ │ │ └── TypeCasting.h
│ │ │ │ ├── CUDA
│ │ │ │ │ └── MathFunctions.h
│ │ │ │ └── NEON
│ │ │ │ │ └── MathFunctions.h
│ │ │ ├── SelfCwiseBinaryOp.h
│ │ │ ├── Swap.h
│ │ │ ├── Assign.h
│ │ │ └── MathFunctionsImpl.h
│ │ ├── misc
│ │ │ ├── lapacke_mangling.h
│ │ │ ├── RealSvd2x2.h
│ │ │ └── Kernel.h
│ │ ├── SparseCore
│ │ │ ├── SparseFuzzy.h
│ │ │ ├── SparseRedux.h
│ │ │ └── MappedSparseMatrix.h
│ │ ├── SparseLU
│ │ │ ├── SparseLU_Utils.h
│ │ │ └── SparseLU_relax_snode.h
│ │ └── StlSupport
│ │ │ └── details.h
│ ├── .hg_archival.txt
│ ├── Dense
│ ├── CMakeLists.txt
│ ├── StdList
│ ├── StdDeque
│ ├── StdVector
│ ├── Householder
│ ├── Sparse
│ ├── Jacobi
│ ├── QtAlignedMalloc
│ ├── MetisSupport
│ ├── PardisoSupport
│ ├── Cholesky
│ ├── SPQRSupport
│ ├── SparseQR
│ ├── QR
│ ├── UmfPackSupport
│ ├── LU
│ ├── SparseCholesky
│ ├── SVD
│ ├── PaStiXSupport
│ ├── SparseLU
│ ├── Eigenvalues
│ ├── CholmodSupport
│ ├── IterativeLinearSolvers
│ ├── Geometry
│ ├── SuperLUSupport
│ ├── SparseCore
│ └── OrderingMethods
├── freeglut
│ ├── Readme.txt
│ ├── bin
│ │ ├── freeglut.dll
│ │ └── x64
│ │ │ └── freeglut.dll
│ ├── lib
│ │ ├── freeglut.lib
│ │ └── x64
│ │ │ └── freeglut.lib
│ ├── include
│ │ └── GL
│ │ │ ├── glut.h
│ │ │ └── freeglut.h
│ └── Copying.txt
├── mavlink
│ ├── mavlink_sha256.h
│ ├── common
│ │ ├── version.h
│ │ └── mavlink.h
│ ├── mavlink_get_info.h
│ └── checksum.h
└── matrix
│ ├── math.hpp
│ ├── filter.hpp
│ ├── helper_functions.hpp
│ ├── integration.hpp
│ ├── Vector2.hpp
│ ├── Scalar.hpp
│ ├── LICENSE
│ ├── Vector.hpp
│ └── Vector3.hpp
├── images
├── mag-drift.png
├── bad-x-sigma.PNG
├── bad-vx-sigma.PNG
├── bad-vx-sigma-low.PNG
├── predict-good-cov.png
├── attitude-screenshot.png
├── mag-good-solution.png
└── predict-slow-drift.png
├── project
├── freeglut.dll
├── Simulator.vcxproj.user
├── FCND-CPPSim.xcodeproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── CPPSim.pro
└── Simulator.sln
├── src
├── Math
│ ├── Constants.h
│ ├── MathUtils.h
│ ├── Random.h
│ ├── LowPassFilter.h
│ ├── Angles.h
│ ├── Random.cpp
│ └── V4D.h
├── BaseQuadEstimator.cpp
├── Drawing
│ ├── BaseAnalyzer.h
│ ├── GraphManager.h
│ ├── GLUTMenu.h
│ ├── ColorUtils.h
│ ├── Graph.h
│ ├── DrawingFuncs.h
│ ├── ColorUtils.cpp
│ ├── AbsThreshold.h
│ └── GLUTMenu.cpp
├── MavlinkNode
│ ├── MavlinkTranslation.h
│ ├── UDPPacket.h
│ ├── MavlinkNode.h
│ ├── MavlinkTranslation.cpp
│ └── MavlinkNode.cpp
├── ControllerFactory.h
├── Simulation
│ ├── Simulator.h
│ ├── rangefinder.h
│ ├── magnetometer.h
│ ├── rangefinder.cpp
│ ├── Simulator.cpp
│ ├── opticalflow.h
│ ├── opticalflow.cpp
│ ├── magnetometer.cpp
│ ├── SimulatedQuadSensor.h
│ ├── SimulatedMag.h
│ └── BaseDynamics.h
├── DataSource.h
├── Utility
│ ├── Timer.cpp
│ ├── Camera.h
│ └── SimpleConfig.h
├── Trajectory.h
├── VehicleDatatypes.h
├── BaseQuadEstimator.h
├── QuadControl.h
├── BaseController.h
├── QuadEstimatorEKF.h
└── BaseController.cpp
├── .gitignore
├── CMakeLists.txt
└── .github
└── workflows
└── manual.yml
/config/log/.gitignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/traj/Origin.txt:
--------------------------------------------------------------------------------
1 | 0,0,0,-1
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @udacity/active-public-content
--------------------------------------------------------------------------------
/lib/Eigen/Eigen:
--------------------------------------------------------------------------------
1 | #include "Dense"
2 | #include "Sparse"
3 |
--------------------------------------------------------------------------------
/images/mag-drift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/mag-drift.png
--------------------------------------------------------------------------------
/project/freeglut.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/project/freeglut.dll
--------------------------------------------------------------------------------
/images/bad-x-sigma.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/bad-x-sigma.PNG
--------------------------------------------------------------------------------
/images/bad-vx-sigma.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/bad-vx-sigma.PNG
--------------------------------------------------------------------------------
/lib/freeglut/Readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/lib/freeglut/Readme.txt
--------------------------------------------------------------------------------
/images/bad-vx-sigma-low.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/bad-vx-sigma-low.PNG
--------------------------------------------------------------------------------
/images/predict-good-cov.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/predict-good-cov.png
--------------------------------------------------------------------------------
/config/X_Scenarios.txt:
--------------------------------------------------------------------------------
1 | X_DebugAttitudeInterp
2 | X_TestMavlink
3 | X_TestManyQuads
4 | X_MonteCarloTest
5 | X_ParamTests
--------------------------------------------------------------------------------
/images/attitude-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/attitude-screenshot.png
--------------------------------------------------------------------------------
/images/mag-good-solution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/mag-good-solution.png
--------------------------------------------------------------------------------
/images/predict-slow-drift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/images/predict-slow-drift.png
--------------------------------------------------------------------------------
/lib/freeglut/bin/freeglut.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/lib/freeglut/bin/freeglut.dll
--------------------------------------------------------------------------------
/lib/freeglut/lib/freeglut.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/lib/freeglut/lib/freeglut.lib
--------------------------------------------------------------------------------
/lib/mavlink/mavlink_sha256.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/lib/mavlink/mavlink_sha256.h
--------------------------------------------------------------------------------
/lib/Eigen/src/Core/util/NonMPL2.h:
--------------------------------------------------------------------------------
1 | #ifdef EIGEN_MPL2_ONLY
2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode
3 | #endif
4 |
--------------------------------------------------------------------------------
/lib/freeglut/bin/x64/freeglut.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/lib/freeglut/bin/x64/freeglut.dll
--------------------------------------------------------------------------------
/lib/freeglut/lib/x64/freeglut.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/udacity/FCND-Estimation-CPP/HEAD/lib/freeglut/lib/x64/freeglut.lib
--------------------------------------------------------------------------------
/config/X_TestMavlink.txt:
--------------------------------------------------------------------------------
1 | # Hover at the initial point using full 3D control
2 |
3 | INCLUDE 5_TrajectoryFollow.txt
4 |
5 | []
6 | Mavlink.Enable=1
--------------------------------------------------------------------------------
/lib/Eigen/.hg_archival.txt:
--------------------------------------------------------------------------------
1 | repo: 8a21fd850624c931e448cbcfb38168cb2717c790
2 | node: 5a0156e40feb7c4136680b493c6e433d91a6f355
3 | branch: 3.3
4 | tag: 3.3.4
5 |
--------------------------------------------------------------------------------
/lib/Eigen/Dense:
--------------------------------------------------------------------------------
1 | #include "Core"
2 | #include "LU"
3 | #include "Cholesky"
4 | #include "QR"
5 | #include "SVD"
6 | #include "Geometry"
7 | #include "Eigenvalues"
8 |
--------------------------------------------------------------------------------
/project/Simulator.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/Math/Constants.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define _USE_MATH_DEFINES
4 | #include
5 |
6 | #ifndef F_PI
7 | #define F_PI ((float)(M_PI))
8 | #endif
9 |
10 | const double CONST_GRAVITY = 9.81; // gravity in [m/s^2]
--------------------------------------------------------------------------------
/project/FCND-CPPSim.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/config/traj/Turn.txt:
--------------------------------------------------------------------------------
1 | # time, x, y, z, vx, vy, vz, yaw
2 | 0.0, 0, 0, -1, 0, 0, 0, 0
3 | 0.5, 0, 0, -1, 0, 0, 0, 1.57
4 | 1.0, 0, 0, -1, 0, 0, 0, 3.14
5 | 1.5, 0, 0, -1, 0, 0, 0, -1.57
6 | 2.0, 0, 0, -1, 0, 0, 0, 0
7 |
--------------------------------------------------------------------------------
/config/Scenarios.txt:
--------------------------------------------------------------------------------
1 | 01_Intro
2 | 02_AttitudeControl
3 | 03_PositionControl
4 | 04_Nonidealities
5 | 05_TrajectoryFollow
6 | 06_SensorNoise
7 | 07_AttitudeEstimation
8 | 08_PredictState
9 | 09_PredictCovariance
10 | 10_MagUpdate
11 | 11_GPSUpdate
--------------------------------------------------------------------------------
/src/BaseQuadEstimator.cpp:
--------------------------------------------------------------------------------
1 | #include "Common.h"
2 | #include "BaseQuadEstimator.h"
3 |
4 | BaseQuadEstimator::BaseQuadEstimator(string config)
5 | {
6 | _config = config;
7 | Init();
8 | }
9 |
10 | BaseQuadEstimator::~BaseQuadEstimator()
11 | {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/Math/MathUtils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef MAX
4 | #define MAX(a,b) (((a)>(b))?(a):(b))
5 | #endif
6 |
7 | #ifndef MIN
8 | #define MIN(a,b) (((a)<(b))?(a):(b))
9 | #endif
10 |
11 | #ifndef CONSTRAIN
12 | #define CONSTRAIN(a,low,high) MAX((low),MIN((a),(high)))
13 | #endif
--------------------------------------------------------------------------------
/src/Drawing/BaseAnalyzer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class BaseAnalyzer
4 | {
5 | public:
6 |
7 | virtual void Reset() {};
8 | virtual void Update(double time, std::vector >& sources) {};
9 | virtual void Draw(float minX, float maxX, float minY, float maxY) {}
10 | };
--------------------------------------------------------------------------------
/src/MavlinkNode/MavlinkTranslation.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | vector MakeMavlinkPacket_LocalPose(float simTime, V3F pos, V3F vel);
4 | vector MakeMavlinkPacket_Heartbeat();
5 | vector MakeMavlinkPacket_Status();
6 | vector MakeMavlinkPacket_Attitude(float simTime, Quaternion attitude, V3F omega);
--------------------------------------------------------------------------------
/src/ControllerFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "QuadControl.h"
4 |
5 | inline ControllerHandle CreateController(string name, string controllerType, string config)
6 | {
7 | ControllerHandle ret;
8 |
9 | if (controllerType == "QuadControl")
10 | {
11 | ret.reset(new QuadControl(name, config));
12 | }
13 |
14 | return ret;
15 | }
--------------------------------------------------------------------------------
/lib/matrix/math.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __PX4_QURT
4 | #include "dspal_math.h"
5 | #endif
6 | #include "Matrix.hpp"
7 | #include "SquareMatrix.hpp"
8 | #include "Vector.hpp"
9 | #include "Vector2.hpp"
10 | #include "Vector3.hpp"
11 | #include "Euler.hpp"
12 | #include "Dcm.hpp"
13 | #include "Scalar.hpp"
14 | #include "Quaternion.hpp"
15 | #include "AxisAngle.hpp"
16 |
--------------------------------------------------------------------------------
/config/SimulatedSensors.txt:
--------------------------------------------------------------------------------
1 | # note that sensors can not be faster than the controller rate (0.002)
2 |
3 | [SimIMU]
4 | AccelStd = .5, .5, 1.5
5 | GyroStd = .5, .5, .5
6 | dt = .002
7 |
8 | [SimBaro]
9 | Std = .1
10 | dt = .01
11 |
12 | [SimMag]
13 | Std = .1
14 | dt = .01
15 |
16 | [SimGPS]
17 | PosStd = .7, .7, 2
18 | #PosRandomWalkStd = .1, .1, .1
19 | VelStd = .1, .1, .3
20 | dt = .1
--------------------------------------------------------------------------------
/src/Simulation/Simulator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | using namespace std;
6 |
7 | class BaseDynamics;
8 |
9 | class Simulator
10 | {
11 | public:
12 | Simulator();
13 |
14 | void Reset();
15 |
16 | void Run(float dt);
17 |
18 | void AddVehicle(shared_ptr vehicle);
19 |
20 | vector > _vehicles;
21 | float _simTime;
22 | };
--------------------------------------------------------------------------------
/src/MavlinkNode/UDPPacket.h:
--------------------------------------------------------------------------------
1 | #ifndef UDP_PACKET_H_FEB_27_2008_SVL5
2 | #define UDP_PACKET_H_FEB_27_2008_SVL5
3 |
4 | #define MAX_UDP_PACKET_SIZE 65467 // UDP protocol max message size
5 |
6 | struct UDPPacket {
7 | unsigned short port;
8 | int source_addr;
9 | int dest_addr;
10 |
11 | unsigned int len;
12 | unsigned char* data;
13 | };
14 |
15 | #endif //UDP_PACKET_H_FEB_27_2008_SVL5
16 |
17 |
--------------------------------------------------------------------------------
/lib/mavlink/common/version.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from common.xml
3 | * @see http://mavlink.org
4 | */
5 | #pragma once
6 |
7 | #ifndef MAVLINK_VERSION_H
8 | #define MAVLINK_VERSION_H
9 |
10 | #define MAVLINK_BUILD_DATE "Mon Feb 19 2018"
11 | #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0"
12 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255
13 |
14 | #endif // MAVLINK_VERSION_H
15 |
--------------------------------------------------------------------------------
/src/DataSource.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | using std::string;
6 | using std::vector;
7 |
8 | class DataSource
9 | {
10 | public:
11 | virtual bool GetData(const string& name, float& ret) const
12 | {
13 | return false;
14 | }
15 |
16 | virtual vector GetFields() const
17 | {
18 | return vector();
19 | }
20 |
21 | virtual void FinalizeDataFrame() {}
22 | };
--------------------------------------------------------------------------------
/src/Simulation/rangefinder.h:
--------------------------------------------------------------------------------
1 | #ifndef RANGEFINDER_H
2 | #define RANGEFINDER_H
3 |
4 | #include "Common.h"
5 | #include "Math/Random.h"
6 | #include "Math/Quaternion.h"
7 | #include "matrix/math.hpp"
8 | #include
9 |
10 | class rangefinder
11 | {
12 | public:
13 | float fd_stddev = 0.0001f;
14 | void range_sensor(V3F position, SLR::Quaternion attitude, float &measurement);
15 | };
16 |
17 | #endif // RANGEFINDER_H
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Simulator specific ignores
2 |
3 | config/LastScenario.txt
4 |
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 |
8 | # Build results
9 | [Dd]ebug/
10 | [Dd]ebugPublic/
11 | [Rr]elease/
12 | [Rr]eleases/
13 | x64/
14 | x86/
15 | bld/
16 | [Bb]in/
17 | [Oo]bj/
18 | [Ll]og/
19 |
20 | # Visual Studio 2015/2017 cache/options directory
21 | .vs/
22 |
23 | # CLion/IntelliJ IDEA
24 | .idea/
25 |
26 | # manual cmake build ignores
27 | build/
28 |
--------------------------------------------------------------------------------
/config/traj/MakeCircleTrajectory.py:
--------------------------------------------------------------------------------
1 | import math;
2 |
3 | def fmt(value):
4 | return "%.3f" % value
5 |
6 | period = 4
7 | radius = 1.5
8 | timestep = 0.02
9 | maxtime = period*1
10 |
11 | with open('CircleNoFF.txt', 'w') as the_file:
12 | t=0;
13 | while t <= maxtime:
14 | x = math.sin(t * 2 * math.pi / period) * radius;
15 | y = math.cos(t * 2 * math.pi / period) * radius;
16 | the_file.write(fmt(t) + "," + fmt(x) + "," + fmt(y) + "," + "-1\n");
17 | t += timestep;
18 |
19 |
--------------------------------------------------------------------------------
/config/traj/MakeSpiralTrajectory.py:
--------------------------------------------------------------------------------
1 | import math;
2 |
3 | def fmt(value):
4 | return "%.3f" % value
5 |
6 | period = 4
7 | radius = 0.5
8 | timestep = 0.05
9 | maxtime = period*1
10 |
11 | with open('SpiralNoFF.txt', 'w') as the_file:
12 | t=0;
13 | while t <= maxtime:
14 | x = math.sin(t * 2 * math.pi / period) * radius;
15 | y = math.cos(t * 2 * math.pi / period) * radius;
16 | the_file.write(fmt(t) + "," + fmt(x) + "," + fmt(y) + "," + "-1\n");
17 | t += timestep;
18 | radius += 0.01
19 |
--------------------------------------------------------------------------------
/config/traj/MakeHelixTrajectory.py:
--------------------------------------------------------------------------------
1 | import math;
2 |
3 | def fmt(value):
4 | return "%.3f" % value
5 |
6 | period = 20
7 | radius = 1.5
8 | timestep = 0.1
9 | maxtime = period*1
10 | z = -1
11 |
12 | with open('HelixNoFF.txt', 'w') as the_file:
13 | t=0;
14 | while t <= maxtime:
15 | x = math.sin(t * 2 * math.pi / period) * radius;
16 | y = math.cos(t * 2 * math.pi / period) * radius;
17 | the_file.write(fmt(t) + "," + fmt(x) + "," + fmt(y) + "," + fmt(z) + "\n");
18 | t += timestep;
19 | z -= 0.01
20 |
--------------------------------------------------------------------------------
/config/QuadEstimatorEKF.txt:
--------------------------------------------------------------------------------
1 | [QuadEstimatorEKF]
2 | InitState = 0, 0, -1, 0, 0, 0, 0
3 | InitStdDevs = .1, .1, .3, .1, .1, .3, .05
4 |
5 | # Process noise model
6 | # note that the process covariance matrix is diag(pow(QStd,2))*dtIMU
7 |
8 | QPosXYStd = .05
9 | QPosZStd = .05
10 | QVelXYStd = .05
11 | QVelZStd = .1
12 | QYawStd = .05
13 |
14 | # GPS measurement std deviations
15 | GPSPosXYStd = 1
16 | GPSPosZStd = 3
17 | GPSVelXYStd = .1
18 | GPSVelZStd = .3
19 |
20 | # Magnetometer
21 | MagYawStd = .1
22 |
23 | dtIMU = 0.002
24 | attitudeTau = 100
25 |
26 |
--------------------------------------------------------------------------------
/src/Simulation/magnetometer.h:
--------------------------------------------------------------------------------
1 | #ifndef MAGNETOMETER_H
2 | #define MAGNETOMETER_H
3 |
4 | #include
5 | #include "Common.h"
6 | #include "Math/Random.h"
7 | #include "Math/Quaternion.h"
8 | #include "matrix/math.hpp"
9 | #include
10 |
11 | class magnetometer
12 | {
13 | public:
14 | V3F mag;
15 | float fx_stddev = 0.0001f;
16 | float fy_stddev = 0.0001f;
17 | float fz_stddev = 0.0001f;
18 | void magnetometer_sensor(float declination, SLR::Quaternion attitude, V3F &mag_measurement);
19 | };
20 |
21 | #endif // MAGNETOMETER_H
22 |
--------------------------------------------------------------------------------
/lib/Eigen/src/misc/lapacke_mangling.h:
--------------------------------------------------------------------------------
1 | #ifndef LAPACK_HEADER_INCLUDED
2 | #define LAPACK_HEADER_INCLUDED
3 |
4 | #ifndef LAPACK_GLOBAL
5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_)
6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER)
8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME
9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE)
10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname
11 | #else
12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
13 | #endif
14 | #endif
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/src/Math/Random.h:
--------------------------------------------------------------------------------
1 | // Random Number Utilities Header, super-lightweight-robotics library
2 | // License: BSD-3-clause
3 |
4 | #pragma once
5 |
6 | // random number routines from Numerical Recipes
7 | double gasdev(int &idum);
8 | double ran1(int &idum);
9 | inline float gasdev_f(int &idum) { return (float)gasdev(idum); }
10 |
11 | inline float ran1_inRange(float min, float max, int& idum)
12 | {
13 | return (float)(ran1(idum)*(max-min)+min);
14 | }
15 |
16 | inline double ran1_inRange(double min, double max, int& idum)
17 | {
18 | return (double)(ran1(idum)*(max-min)+min);
19 | }
--------------------------------------------------------------------------------
/config/traj/AttitudeTest.txt:
--------------------------------------------------------------------------------
1 | # time, x, y, z, vx, vy, vz, yaw
2 | 0.0, 0, 0, -1, 0, 0, 0, 0
3 |
4 | 0.1, 1, 0, -1, 0, 0, 0, 0
5 |
6 | 0.2, 0, 0, -1, 0, 0, 0, 0
7 | 0.9, 0, 0, -1, 0, 0, 0, 0
8 |
9 | 1.0, 0, -1, -1, 0, 0, 0, 0
10 |
11 | 1.1, 0, 0, -1, 0, 0, 0, 0
12 | 1.8, 0, 0, -1, 0, 0, 0, 0
13 |
14 | 1.9, -0.7, -0.7, -1, 0, 0, 0, 0
15 |
16 | 2.0, 0, 0, -1, 0, 0, 0, 0
17 | 2.7, 0, 0, -1, 0, 0, 0, 0
18 |
19 | 3.0, 0, 0, -1, 0, 0, 0, 1.57
20 | 3.2, 0, 0, -1, 0, 0, 0, 3.14
21 | 3.6, 0, 0, -1, 0, 0, 0, -1.57
22 | 3.9, 0, 0, -1, 0, 0, 0, 0
23 |
--------------------------------------------------------------------------------
/src/Simulation/rangefinder.cpp:
--------------------------------------------------------------------------------
1 | #include "rangefinder.h"
2 |
3 | // Assumption: The distance sensor is located at the centre of the crazyflie, implying that the yaw motion does not affect the measurements
4 |
5 | void rangefinder::range_sensor(V3F position, SLR::Quaternion attitude, float &measurement){
6 |
7 | V3D ypr = attitude.ToEulerYPR();
8 | measurement = position.z/(cos(ypr.y)*cos(ypr.z));
9 |
10 | // Now adding the normal noise
11 | std::random_device rd;
12 | std::mt19937 gen(rd());
13 | std::normal_distribution<> fd{0, fd_stddev};
14 |
15 | float fd_sample = fd(gen);
16 |
17 | measurement += fd_sample;
18 | }
19 |
--------------------------------------------------------------------------------
/lib/matrix/filter.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "math.hpp"
4 |
5 | namespace matrix {
6 |
7 | template
8 | int kalman_correct(
9 | const Matrix & P,
10 | const Matrix & C,
11 | const Matrix & R,
12 | const Matrix &r,
13 | Matrix & dx,
14 | Matrix & dP,
15 | Type & beta
16 | )
17 | {
18 | SquareMatrix S_I = SquareMatrix(C*P*C.T() + R).I();
19 | Matrix K = P*C.T()*S_I;
20 | dx = K*r;
21 | beta = Scalar(r.T()*S_I*r);
22 | dP = K*C*P*(-1);
23 | return 0;
24 | }
25 |
26 | } // namespace matrix
27 |
--------------------------------------------------------------------------------
/src/Simulation/Simulator.cpp:
--------------------------------------------------------------------------------
1 | #include "Common.h"
2 | #include "Simulator.h"
3 | #include "Utility/SimpleConfig.h"
4 | #include "Simulation/BaseDynamics.h"
5 | using namespace SLR;
6 |
7 | Simulator::Simulator()
8 | {
9 | Reset();
10 | }
11 |
12 | void Simulator::Reset()
13 | {
14 | ParamsHandle config = SimpleConfig::GetInstance();
15 |
16 | // TODO: parameters
17 |
18 | for (unsigned int i = 0; i < _vehicles.size(); i++)
19 | {
20 | _vehicles[i]->Initialize();
21 | }
22 | }
23 |
24 | void Simulator::Run(float dt)
25 | {
26 | // todo: step in maximally acceptable time steps
27 | }
28 |
29 | void Simulator::AddVehicle(shared_ptr vehicle)
30 | {
31 | _vehicles.push_back(vehicle);
32 | }
33 |
--------------------------------------------------------------------------------
/src/Simulation/opticalflow.h:
--------------------------------------------------------------------------------
1 | #ifndef OPTICALFLOW_H
2 | #define OPTICALFLOW_H
3 |
4 | #include "Common.h"
5 | #include "Math/Random.h"
6 | #include "Math/Quaternion.h"
7 | #include "matrix/math.hpp"
8 | #include
9 |
10 | class opticalflow
11 | {
12 | public:
13 | float omega_factor = 1.25f; // Taken directly from Michael Hamer's code on estimation on crazyflie
14 | float N_pixel = 30.0f;
15 | float aperture = 4.2f * M_PI / 180.f;
16 | float fx_stddev = 0.0001f;
17 | float fy_stddev = 0.0001f;
18 | void opticalflow_sensor(float dt, V3F position, V3F velocity, SLR::Quaternion attitude, V3F omega, float &x_measurement, float &y_measurement);
19 |
20 | };
21 |
22 | #endif // OPTICALFLOW_H
23 |
--------------------------------------------------------------------------------
/lib/Eigen/src/Core/functors/TernaryFunctors.h:
--------------------------------------------------------------------------------
1 | // This file is part of Eigen, a lightweight C++ template library
2 | // for linear algebra.
3 | //
4 | // Copyright (C) 2016 Eugene Brevdo
5 | //
6 | // This Source Code Form is subject to the terms of the Mozilla
7 | // Public License v. 2.0. If a copy of the MPL was not distributed
8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 |
10 | #ifndef EIGEN_TERNARY_FUNCTORS_H
11 | #define EIGEN_TERNARY_FUNCTORS_H
12 |
13 | namespace Eigen {
14 |
15 | namespace internal {
16 |
17 | //---------- associative ternary functors ----------
18 |
19 |
20 |
21 | } // end namespace internal
22 |
23 | } // end namespace Eigen
24 |
25 | #endif // EIGEN_TERNARY_FUNCTORS_H
26 |
--------------------------------------------------------------------------------
/lib/freeglut/include/GL/glut.h:
--------------------------------------------------------------------------------
1 | #ifndef __GLUT_H__
2 | #define __GLUT_H__
3 |
4 | /*
5 | * glut.h
6 | *
7 | * The freeglut library include file
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 |
17 | #include "freeglut_std.h"
18 |
19 | /*** END OF FILE ***/
20 |
21 | #endif /* __GLUT_H__ */
22 |
--------------------------------------------------------------------------------
/lib/mavlink/common/mavlink.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from common.xml
3 | * @see http://mavlink.org
4 | */
5 | #pragma once
6 | #ifndef MAVLINK_H
7 | #define MAVLINK_H
8 |
9 | #define MAVLINK_PRIMARY_XML_IDX 1
10 |
11 | #ifndef MAVLINK_STX
12 | #define MAVLINK_STX 253
13 | #endif
14 |
15 | #ifndef MAVLINK_ENDIAN
16 | #define MAVLINK_ENDIAN MAVLINK_LITTLE_ENDIAN
17 | #endif
18 |
19 | #ifndef MAVLINK_ALIGNED_FIELDS
20 | #define MAVLINK_ALIGNED_FIELDS 1
21 | #endif
22 |
23 | #ifndef MAVLINK_CRC_EXTRA
24 | #define MAVLINK_CRC_EXTRA 1
25 | #endif
26 |
27 | #ifndef MAVLINK_COMMAND_24BIT
28 | #define MAVLINK_COMMAND_24BIT 1
29 | #endif
30 |
31 | #include "version.h"
32 | #include "common.h"
33 |
34 | #endif // MAVLINK_H
35 |
--------------------------------------------------------------------------------
/src/Math/LowPassFilter.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | template
4 | class LowPassFilter
5 | {
6 | public:
7 | LowPassFilter(T_TimeConstant timeConstant=1, T initialVal=1)
8 | {
9 | _timeConstant = timeConstant;
10 | _val = initialVal;
11 | }
12 |
13 | T Read() const
14 | {
15 | return _val;
16 | }
17 |
18 | T Update(T meas, double dt)
19 | {
20 | T_TimeConstant alpha = dt / (_timeConstant + dt);
21 | _val = (T) (_val * (1.0-alpha) + meas*alpha);
22 | return _val;
23 | }
24 |
25 | void Reset(T meas)
26 | {
27 | _val = meas;
28 | }
29 |
30 | void SetTau(T_TimeConstant tau)
31 | {
32 | _timeConstant = tau;
33 | }
34 |
35 | protected:
36 | T _val;
37 | T_TimeConstant _timeConstant;
38 | };
--------------------------------------------------------------------------------
/lib/Eigen/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(RegexUtils)
2 | test_escape_string_as_regex()
3 |
4 | file(GLOB Eigen_directory_files "*")
5 |
6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
7 |
8 | foreach(f ${Eigen_directory_files})
9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src")
10 | list(APPEND Eigen_directory_files_to_install ${f})
11 | endif()
12 | endforeach(f ${Eigen_directory_files})
13 |
14 | install(FILES
15 | ${Eigen_directory_files_to_install}
16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel
17 | )
18 |
19 | install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h")
20 |
--------------------------------------------------------------------------------
/lib/matrix/helper_functions.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "math.hpp"
4 |
5 | // grody hack - this should go once C++11 is supported
6 | // on all platforms.
7 | #if defined (__PX4_NUTTX) || defined (__PX4_QURT)
8 | #include
9 | #else
10 | #include
11 | #endif
12 |
13 | namespace matrix
14 | {
15 |
16 | template
17 | Type wrap_pi(Type x)
18 | {
19 | #if defined (__PX4_NUTTX) || defined (__PX4_QURT)
20 | if (!isfinite(x)) {
21 | #else
22 | if (!std::isfinite(x)) {
23 | #endif
24 | return x;
25 | }
26 |
27 | while (x >= (Type)M_PI) {
28 | x -= (Type)(2.0 * M_PI);
29 |
30 | }
31 |
32 | while (x < (Type)(-M_PI)) {
33 | x += (Type)(2.0 * M_PI);
34 |
35 | }
36 |
37 | return x;
38 | }
39 |
40 |
41 | };
42 |
--------------------------------------------------------------------------------
/config/traj/Square.txt:
--------------------------------------------------------------------------------
1 | # time, x, y, z, vx, vy, vz, yaw
2 | 2.0, 0, 0, -1, 0, 0, 0, 0
3 | 3.0, 3, 0, -1, 0, 0, 0, 0
4 |
5 | 4.0, 3, 0, -1, 0, 0, 0, 1.57
6 | 5.0, 3, 3, -1, 0, 0, 0, 1.57
7 | 6.0, 3, 3, -1, 0, 0, 0, 3.14
8 | 7.0, -3, 3, -1, 0, 0, 0, 3.14
9 | 8.0, -3, 3, -1, 0, 0, 0, -1.57
10 | 9.0, -3, -3, -1, 0, 0, 0, -1.57
11 | 10.0, -3, -3, -1, 0, 0, 0, 0
12 | 11.0, 3, -3, -1, 0, 0, 0, 0
13 | 12.0, 3, -3, -1, 0, 0, 0, 1.57
14 |
15 | 13.0, 3, 3, -1, 0, 0, 0, 1.57
16 | 14.0, 3, 3, -1, 0, 0, 0, 3.14
17 | 15.0, -3, 3, -1, 0, 0, 0, 3.14
18 | 16.0, -3, 3, -1, 0, 0, 0, -1.57
19 | 17.0, -3, -3, -1, 0, 0, 0, -1.57
20 | 18.0, -3, -3, -1, 0, 0, 0, 0
21 | 19.0, 3, -3, -1, 0, 0, 0, 0
22 | 20.0, 3, -3, -1, 0, 0, 0, 1.57
23 |
--------------------------------------------------------------------------------
/lib/freeglut/include/GL/freeglut.h:
--------------------------------------------------------------------------------
1 | #ifndef __FREEGLUT_H__
2 | #define __FREEGLUT_H__
3 |
4 | /*
5 | * freeglut.h
6 | *
7 | * The freeglut library include file
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 |
17 | #include "freeglut_std.h"
18 | #include "freeglut_ext.h"
19 |
20 | /*** END OF FILE ***/
21 |
22 | #endif /* __FREEGLUT_H__ */
23 |
--------------------------------------------------------------------------------
/src/Math/Angles.h:
--------------------------------------------------------------------------------
1 | // Angle utilities, super-lightweight-robotics library
2 | // License: BSD-3-clause
3 |
4 | #pragma once
5 | #include "Constants.h"
6 |
7 | // normalize angle to -pi to pi
8 | inline double AngleNormD(double angle)
9 | {
10 | angle = fmod(angle, (2.0*M_PI));
11 |
12 | if (angle <= -M_PI)
13 | {
14 | angle += (2.0*M_PI);
15 | }
16 | else if (angle > M_PI)
17 | {
18 | angle -= (2.0*M_PI);
19 | }
20 |
21 | return angle;
22 | }
23 |
24 | // normalize angle to -pi to pi
25 | inline float AngleNormF(float angle)
26 | {
27 | angle = fmod(angle, (2.0f*(float)M_PI));
28 |
29 | if (angle <= -(float)M_PI)
30 | {
31 | angle += (2.0f*(float)M_PI);
32 | }
33 | else if (angle > (float)M_PI)
34 | {
35 | angle -= (2.0f*(float)M_PI);
36 | }
37 |
38 | return angle;
39 | }
--------------------------------------------------------------------------------
/project/CPPSim.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | CONFIG += c++11 console
3 | CONFIG -= qt
4 |
5 | TARGET = CPPSim
6 |
7 | INCLUDEPATH += ../src
8 | INCLUDEPATH += ../lib
9 |
10 | SOURCES += ../src/*.cpp
11 | SOURCES += ../src/Drawing/*.cpp
12 | SOURCES += ../src/Math/*.cpp
13 | SOURCES += ../src/Simulation/*.cpp
14 | SOURCES += ../src/Utility/*.cpp
15 | SOURCES += ../src/MavlinkNode/*.cpp
16 |
17 | HEADERS += ../src/*.h
18 | HEADERS += ../src/Drawing/*.h
19 | HEADERS += ../src/Math/*.h
20 | HEADERS += ../src/Simulation/*.h
21 | HEADERS += ../src/Utility/*.h
22 | HEADERS += ../src/MavlinkNode/*.h
23 | HEADERS += ../lib/matrix/*.hpp
24 | HEADERS += ../lib/mavlink/*.h
25 | HEADERS += ../lib/mavlink/common/*.h
26 |
27 | LIBS += -lglut -lGLU -lGL -lpthread
28 |
29 | QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-unused-local-typedefs
30 |
--------------------------------------------------------------------------------
/src/Utility/Timer.cpp:
--------------------------------------------------------------------------------
1 | #include "../Common.h"
2 | #include "Timer.h"
3 | #include
4 |
5 | #ifdef _WIN32
6 | #include
7 | #pragma comment(lib,"winmm.lib")
8 | #endif
9 |
10 | CHighResTimingScope __highResTimingScope;
11 | int64_t __highResCounterFreq=0;
12 |
13 | CHighResTimingScope::CHighResTimingScope(){
14 | #ifdef _WIN32
15 | timeBeginPeriod(1); // inits hi-res sleep
16 | QueryPerformanceFrequency((LARGE_INTEGER*)&__highResCounterFreq);
17 | #else
18 | __highResCounterFreq = 1e6;
19 | #endif
20 | if(__highResCounterFreq==0){
21 | printf("ERROR: no performance counter found\n");
22 | __highResCounterFreq = 1;
23 | }
24 | };
25 |
26 | CHighResTimingScope::~CHighResTimingScope()
27 | {
28 | #ifdef _WIN32
29 | timeEndPeriod(1); // de-inits hi-res sleep
30 | #endif
31 | };
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/lib/Eigen/StdList:
--------------------------------------------------------------------------------
1 | // This file is part of Eigen, a lightweight C++ template library
2 | // for linear algebra.
3 | //
4 | // Copyright (C) 2009 Hauke Heibel
5 | //
6 | // This Source Code Form is subject to the terms of the Mozilla
7 | // Public License v. 2.0. If a copy of the MPL was not distributed
8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 |
10 | #ifndef EIGEN_STDLIST_MODULE_H
11 | #define EIGEN_STDLIST_MODULE_H
12 |
13 | #include "Core"
14 | #include
15 |
16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
17 |
18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...)
19 |
20 | #else
21 |
22 | #include "src/StlSupport/StdList.h"
23 |
24 | #endif
25 |
26 | #endif // EIGEN_STDLIST_MODULE_H
27 |
--------------------------------------------------------------------------------
/config/traj/MakeHelixUpDownTrajectory.py:
--------------------------------------------------------------------------------
1 | import math;
2 |
3 | def fmt(value):
4 | return "%.3f" % value
5 |
6 | period = 40
7 | radius = 1.5
8 | timestep = 0.1
9 | maxtime = period*1
10 | z = -1
11 |
12 | with open('HelixUpDownNoFF.txt', 'w') as the_file:
13 | t=0;
14 | while t <= maxtime/2:
15 | x = math.sin(t * 2 * math.pi / period) * radius;
16 | y = math.cos(t * 2 * math.pi / period) * radius;
17 | the_file.write(fmt(t) + "," + fmt(x) + "," + fmt(y) + "," + fmt(z) + "\n");
18 | t += timestep;
19 | z -= 0.01
20 | while t>maxtime/2 and t <= maxtime:
21 | x = math.sin(t * 2 * math.pi / period) * radius;
22 | y = math.cos(t * 2 * math.pi / period) * radius;
23 | the_file.write(fmt(t) + "," + fmt(x) + "," + fmt(y) + "," + fmt(z) + "\n");
24 | t += timestep;
25 | z += 0.01
26 |
27 |
--------------------------------------------------------------------------------
/config/01_Intro.txt:
--------------------------------------------------------------------------------
1 | # Introduction: open-loop hover
2 |
3 | INCLUDE QuadPhysicalParams.txt
4 |
5 | # simulation setup
6 | Sim.RunMode = Repeat
7 | Sim.EndTime = 1
8 | Sim.Vehicle1 = Quad
9 |
10 | # Controller selection
11 | Quad.ControlType = QuadControl
12 | Quad.ControlConfig = QuadControlParams
13 |
14 | # reference trajectory (just the starting position)
15 | QuadControlParams.Trajectory=0,0,-1
16 |
17 | # initial conditions
18 | Quad.InitialPos=0,0,-1
19 | Quad.InitialVel=0,0,0
20 | Quad.InitialYPR=0,0,0
21 | Quad.InitialOmega=0,0,0
22 |
23 | # graphing commands
24 | Commands.1=AddGraph1.Quad.Pos.Z
25 | Commands.2=AddGraph1.WindowThreshold(Quad.PosFollowErr,.5,.8)
26 |
27 | INCLUDE QuadControlParams.txt
28 | INCLUDE Simulation.txt
29 |
30 | # make sure the controller is off
31 | [QuadControlParams]
32 | kpPosXY = 0
33 | kpPosZ = 0
34 | kpVelXY = 0
35 | kpVelZ = 0
36 | kpBank = 0
37 | kpYaw = 0
38 | kpPQR = 0,0,0
--------------------------------------------------------------------------------
/lib/Eigen/StdDeque:
--------------------------------------------------------------------------------
1 | // This file is part of Eigen, a lightweight C++ template library
2 | // for linear algebra.
3 | //
4 | // Copyright (C) 2009 Gael Guennebaud
5 | // Copyright (C) 2009 Hauke Heibel
6 | //
7 | // This Source Code Form is subject to the terms of the Mozilla
8 | // Public License v. 2.0. If a copy of the MPL was not distributed
9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 |
11 | #ifndef EIGEN_STDDEQUE_MODULE_H
12 | #define EIGEN_STDDEQUE_MODULE_H
13 |
14 | #include "Core"
15 | #include
16 |
17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
18 |
19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...)
20 |
21 | #else
22 |
23 | #include "src/StlSupport/StdDeque.h"
24 |
25 | #endif
26 |
27 | #endif // EIGEN_STDDEQUE_MODULE_H
28 |
--------------------------------------------------------------------------------
/lib/Eigen/StdVector:
--------------------------------------------------------------------------------
1 | // This file is part of Eigen, a lightweight C++ template library
2 | // for linear algebra.
3 | //
4 | // Copyright (C) 2009 Gael Guennebaud
5 | // Copyright (C) 2009 Hauke Heibel
6 | //
7 | // This Source Code Form is subject to the terms of the Mozilla
8 | // Public License v. 2.0. If a copy of the MPL was not distributed
9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 |
11 | #ifndef EIGEN_STDVECTOR_MODULE_H
12 | #define EIGEN_STDVECTOR_MODULE_H
13 |
14 | #include "Core"
15 | #include
16 |
17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
18 |
19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...)
20 |
21 | #else
22 |
23 | #include "src/StlSupport/StdVector.h"
24 |
25 | #endif
26 |
27 | #endif // EIGEN_STDVECTOR_MODULE_H
28 |
--------------------------------------------------------------------------------
/src/Simulation/opticalflow.cpp:
--------------------------------------------------------------------------------
1 | #include "opticalflow.h"
2 |
3 | void opticalflow::opticalflow_sensor(float dt, V3F position, V3F velocity, SLR::Quaternion attitude, V3F omega, float &x_measurement, float &y_measurement){
4 | x_measurement = (dt*N_pixel/aperture) * ((attitude.Rotate_ItoB(velocity).x / attitude.Rotate_ItoB(position).z) + omega_factor * omega.y);
5 | y_measurement = (dt*N_pixel/aperture) * ((attitude.Rotate_ItoB(velocity).y / attitude.Rotate_ItoB(position).z) - omega_factor * omega.x);
6 |
7 | // The signs used for omega above need to be checked again - not sure which frame is used by crazyflie
8 |
9 | std::random_device rd;
10 | std::mt19937 gen(rd());
11 |
12 | std::normal_distribution<> fx{0,fx_stddev};
13 | std::normal_distribution<> fy{0,fy_stddev};
14 |
15 | float fx_sample = fx(gen);
16 | float fy_sample = fy(gen);
17 |
18 | x_measurement += fx_sample;
19 | y_measurement += fy_sample;
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/lib/Eigen/src/Core/util/ReenableStupidWarnings.h:
--------------------------------------------------------------------------------
1 | #ifdef EIGEN_WARNINGS_DISABLED
2 | #undef EIGEN_WARNINGS_DISABLED
3 |
4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
5 | #ifdef _MSC_VER
6 | #pragma warning( pop )
7 | #elif defined __INTEL_COMPILER
8 | #pragma warning pop
9 | #elif defined __clang__
10 | #pragma clang diagnostic pop
11 | #elif defined __GNUC__ && __GNUC__>=6
12 | #pragma GCC diagnostic pop
13 | #endif
14 |
15 | #if defined __NVCC__
16 | // Don't reenable the diagnostic messages, as it turns out these messages need
17 | // to be disabled at the point of the template instantiation (i.e the user code)
18 | // otherwise they'll be triggered by nvcc.
19 | // #pragma diag_default code_is_unreachable
20 | // #pragma diag_default initialization_not_reachable
21 | // #pragma diag_default 2651
22 | // #pragma diag_default 2653
23 | #endif
24 |
25 | #endif
26 |
27 | #endif // EIGEN_WARNINGS_DISABLED
28 |
--------------------------------------------------------------------------------
/src/Drawing/GraphManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Graph.h"
4 | #include