Skip to content

Commit

Permalink
Added cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesar Munoz committed Sep 28, 2023
1 parent 8ac9274 commit efbaed5
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 32 deletions.
5 changes: 4 additions & 1 deletion C++/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple Makefile to build DAIDALUS library and example applications
NAME=DAIDALUS
MAJOR=2
MINOR=.0.3
MINOR=.0.4
VERSION=$(NAME)$(MAJOR)
RELEASE=$(NAME)v$(MAJOR)$(MINOR)

Expand Down Expand Up @@ -51,6 +51,9 @@ configs: examples
clean:
rm -f DaidalusExample DaidalusAlerting DaidalusBatch src/*.o examples/*.o lib/*.a

check:
cppcheck --enable=all $(INCLUDEFLAGS) -q $(SRC)

mold: examples
./DaidalusExample --config no_sum --verbose > ../Regression/C++/DaidalusExample-no_sum.out
./DaidalusExample --config nom_a --verbose > ../Regression/C++/DaidalusExample-nom_a.out
Expand Down
2 changes: 1 addition & 1 deletion C++/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DAIDALUS: Detect and Avoid Alerting Logic for Unmanned Systems
---------------------------------------------------------

Release: v2.0.3a (C++), September-8-2023
Release: v2.0.4 (C++), October-31-2023

Copyright: Copyright (c) 2021 United States Government as represented by
the National Aeronautics and Space Administration. No copyright
Expand Down
11 changes: 5 additions & 6 deletions C++/include/ProjectedKinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ProjectedKinematics {
* @param R
* @return the turn angle
*/
static double turnAngle(Position s1, Position s2, double R);
static double turnAngle(const Position& s1, const Position& s2, double R);

/**
* Horizontal distance covered in a turn
Expand All @@ -44,7 +44,7 @@ class ProjectedKinematics {
* @param R
* @return the turn distance
*/
static double turnDistance(Position s1, Position s2, double R);
static double turnDistance(const Position& s1, const Position& s2, double R);

/**
* Given two points on a turn and the velocity (direction) at the first point, determine the direction for the shortest turn going through the second point,
Expand All @@ -55,7 +55,7 @@ class ProjectedKinematics {
* @param s2
* @return true if clockwise turn
*/
static bool clockwise(Position s1, Velocity v1, Position s2);
static bool clockwise(const Position& s1, const Velocity& v1, const Position& s2);

//static double closestTimeOnTurn(const Position& turnstart, const Velocity& v1, double omega, const Position& x, double endTime);

Expand Down Expand Up @@ -109,10 +109,9 @@ class ProjectedKinematics {
*/
static std::pair<Position,Velocity> turnUntil(const Position& so, const Velocity& vo, double t, double goalTrack, double bankAngle);

static std::pair<Position,Velocity> turnUntil(std::pair<Position,Velocity> sv, double t, double goalTrack, double bankAngle);
static std::pair<Position,Velocity> turnUntil(const std::pair<Position,Velocity>& sv, double t, double goalTrack, double bankAngle);


static std::pair<Position,Velocity> linear(std::pair<Position,Velocity> p, double t);
static std::pair<Position,Velocity> linear(const std::pair<Position,Velocity>& p, double t);

static std::pair<Position,Velocity> linear(const Position& so, const Velocity& p, double t);

Expand Down
2 changes: 1 addition & 1 deletion C++/include/TrafficState.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TrafficState {
* @param eprj Euclidean projection
*/
TrafficState(const std::string& id, const Position& pos, const Velocity& vel,
EuclideanProjection eprj,int alerter);
const EuclideanProjection& eprj,int alerter);

/**
* Apply Euclidean projection. Requires aircraft's position in lat/lon
Expand Down
24 changes: 5 additions & 19 deletions C++/src/ProjectedKinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace larcfm {

std::pair<Position,Velocity> ProjectedKinematics::linear(std::pair<Position,Velocity> p, double t) {
std::pair<Position,Velocity> ProjectedKinematics::linear(const std::pair<Position,Velocity>& p, double t) {
return linear(p.first, p.second, t);
}

Expand All @@ -49,15 +49,15 @@ std::pair<Position,Velocity> ProjectedKinematics::linear(const Position& so, con
/**
* Calculate the angle of a constant-radius turn from two points and the radius
*/
double ProjectedKinematics::turnAngle(Position s1, Position s2, double R) {
double ProjectedKinematics::turnAngle(const Position& s1, const Position& s2, double R) {
double distAB = s1.distanceH(s2);
return 2*(Util::asin_safe(distAB/(2*R)));
}

/**
* Horizontal distance covered in a turn
*/
double ProjectedKinematics::turnDistance(Position s1, Position s2, double R) {
double ProjectedKinematics::turnDistance(const Position& s1, const Position& s2, double R) {
return turnAngle(s1,s2,R)*R;
}

Expand All @@ -66,7 +66,7 @@ double ProjectedKinematics::turnDistance(Position s1, Position s2, double R) {
* Given two points on a turn and the velocity (direction) at the first point, determine the direction for the shortest turn going through the second point,
* returning true if that relative direction is to the right
*/
bool ProjectedKinematics::clockwise(Position s1, Velocity v1, Position s2) {
bool ProjectedKinematics::clockwise(const Position& s1, const Velocity& v1, const Position& s2) {
double trk1 = v1.trk();
double trk2;
if (s1.isLatLon()) {
Expand Down Expand Up @@ -187,12 +187,10 @@ std::pair<Position,Velocity> ProjectedKinematics::turnUntil(const Position& so,
}
}

std::pair<Position,Velocity> ProjectedKinematics::turnUntil(std::pair<Position,Velocity> sv, double t, double goalTrack, double bankAngle) {
std::pair<Position,Velocity> ProjectedKinematics::turnUntil(const std::pair<Position,Velocity>& sv, double t, double goalTrack, double bankAngle) {
return turnUntil(sv.first, sv.second,t, goalTrack, bankAngle);
}



std::pair<Position,Velocity> ProjectedKinematics::gsAccel(const Position& so, const Velocity& vo, double t, double a) {
if (so.isLatLon()) {
EuclideanProjection proj = Projection::createProjection(so.lla().zeroAlt());
Expand Down Expand Up @@ -257,8 +255,6 @@ std::pair<Position,Velocity> ProjectedKinematics::vsAccelUntil(const Position& s
}
}



// if this fails, it returns a NaN time
std::pair<Position,double> ProjectedKinematics::intersection(const Position& so, const Velocity& vo, const Position& si, const Velocity& vi) {
Vect3 so3 = so.vect3();
Expand All @@ -276,7 +272,6 @@ std::pair<Position,double> ProjectedKinematics::intersection(const Position& so,
}
}


double ProjectedKinematics::timeOfintersection(const Position& so, const Velocity& vo, const Position& si, const Velocity& vi) {
Vect3 so3 = so.vect3();
Vect3 si3 = si.vect3();
Expand All @@ -289,15 +284,6 @@ double ProjectedKinematics::timeOfintersection(const Position& so, const Velocit
return intersectTime;
}










/** Wrapper around Kinematic.turnTimeDirecTo()
* Returns a triple: end of turn point, velocity at that point, time at that point
*/
Expand Down
2 changes: 1 addition & 1 deletion C++/src/TrafficState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TrafficState::TrafficState(const std::string& id, const Position& pos, const Vel
sxyz_(pos.vect3()),
velxyz_(airvel) {}

TrafficState::TrafficState(const std::string& id, const Position& pos, const Velocity& vel, EuclideanProjection eprj, int alerter) :
TrafficState::TrafficState(const std::string& id, const Position& pos, const Velocity& vel, const EuclideanProjection& eprj, int alerter) :
id_(id),
pos_(pos),
gvel_(vel),
Expand Down
2 changes: 1 addition & 1 deletion Java/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple Makefile to build DAIDALUS library and example applications
NAME=DAIDALUS
MAJOR=2
MINOR=.0.3
MINOR=.0.4
VERSION=$(NAME)$(MAJOR)
RELEASE=$(NAME)v$(MAJOR)$(MINOR)

Expand Down
2 changes: 1 addition & 1 deletion Java/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DAIDALUS: Detect and Avoid Alerting Logic for Unmanned Systems
---------------------------------------------------------

Release: v2.0.3a (Java), September-8-2023
Release: v2.0.4 (Java), October-31-2023

Copyright: Copyright (c) 2021 United States Government as represented by
the National Aeronautics and Space Administration. No copyright
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ repository, visit https://shemesh.larc.nasa.gov/fm/DAIDALUS.

### Current Release

v2.0.3a, September-8-2023
v2.0.4, October-31-2023

### License

Expand Down

0 comments on commit efbaed5

Please sign in to comment.