Skip to content

Commit

Permalink
Merge branch 'ign-math6' into max-min-function
Browse files Browse the repository at this point in the history
  • Loading branch information
chapulina authored Aug 3, 2020
2 parents b260c68 + c43f478 commit 58b69e9
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .github/ci-bionic/after_make.sh → .github/ci/after_make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -x

BUILD_DIR=`pwd`

# Install
make install

Expand All @@ -12,3 +14,5 @@ cd build
cmake ..
make
./graph_example

cd $BUILD_DIR
4 changes: 4 additions & 0 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
libeigen3-dev
libignition-cmake2-dev
ruby-dev
swig
18 changes: 0 additions & 18 deletions .github/workflows/ci-bionic.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Ubuntu CI

on: [push]

jobs:
bionic-ci:
runs-on: ubuntu-latest
name: Ubuntu Bionic CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
id: ci
uses: ignition-tooling/action-ignition-ci@master
with:
codecov-token: ${{ secrets.CODECOV_TOKEN }}
focal-ci:
runs-on: ubuntu-latest
name: Ubuntu Focal CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
id: ci
uses: ignition-tooling/action-ignition-ci@focal
with:
codecov-token: ${{ secrets.CODECOV_TOKEN }}
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ The optional Eigen component of Ignition Math requires:
sudo apt-get install libeigen3-dev
```

The optional Ruby tests of Ignition Math require:

* [Ruby](https://www.ruby-lang.org/). Refer to the [Ruby Documentation](https://www.ruby-lang.org/downloads/) for installation instructions. On Ubuntu systems `apt-get` can be used to install Ubuntu Package `ruby-dev`:

```
sudo apt-get install ruby-dev
```

* [Swig](http://www.swig.org/). Refer to the [Swig Documentation](http://www.swig.org/download.html) for installation instructions. On Ubuntu systems `apt-get` can be used to install Swig:

```
sudo apt-get install swig
```

### Building from source

1. Clone the repository
Expand Down Expand Up @@ -162,6 +176,28 @@ Follow these steps to run tests and static code analysis in your clone of this r
make codecheck
```

## Ruby Tests

### Usage

The C++ classes are available in Ruby code by interface files (`.i`) used by swig to build a C++ extension module.

The interfaces and Ruby test codes are in the `src` folder. To use a C++ class in Ruby you need to:

1. Create an interface file describing the class as in Swig and Ruby reference at [The Ruby-to-C/C++ Mapping](http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn11)

2. Include the interface file in `/src/ing_math.i`

3. Create the Ruby file and import the class as in Swig and Ruby reference at [C++ Classes](http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn18)

### Tests

`make test` already runs all tests, including the ones made in Ruby, but you can run a Ruby test individually using

```
ctest -R Ruby_TEST.rb
```

# Folder Structure

Refer to the following table for information about important directories and files in this repository.
Expand Down
6 changes: 3 additions & 3 deletions include/ignition/math/Filter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace ignition
}

// Documentation Inherited.
public: virtual void Fc(double _fc, double _fs)
public: virtual void Fc(double _fc, double _fs) override
{
b1 = exp(-2.0 * IGN_PI * _fc / _fs);
a0 = 1.0 - b1;
Expand Down Expand Up @@ -168,7 +168,7 @@ namespace ignition
}

// Documentation Inherited.
public: void Fc(double _fc, double _fs)
public: void Fc(double _fc, double _fs) override
{
this->Fc(_fc, _fs, 0.5);
}
Expand All @@ -191,7 +191,7 @@ namespace ignition

/// \brief Set the current filter's output.
/// \param[in] _val New filter's output.
public: virtual void Set(const T &_val)
public: virtual void Set(const T &_val) override
{
this->y0 = this->y1 = this->y2 = this->x1 = this->x2 = _val;
}
Expand Down
1 change: 0 additions & 1 deletion include/ignition/math/MassMatrix3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,6 @@ namespace ignition
+ std::pow(cos(phi11c.Radian()) - cos(phi12c.Radian()), 2);
if (errc < err)
{
err = errc;
phi1 = phi11c.Radian();
signsPhi23.Set(-1, -1);
}
Expand Down
36 changes: 18 additions & 18 deletions include/ignition/math/SignalStats.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ namespace ignition
class IGNITION_MATH_VISIBLE SignalMaximum : public SignalStatistic
{
// Documentation inherited.
public: virtual double Value() const;
public: virtual double Value() const override;

/// \brief Get a short version of the name of this statistical measure.
/// \return "max"
public: virtual std::string ShortName() const;
public: virtual std::string ShortName() const override;

// Documentation inherited.
public: virtual void InsertData(const double _data);
public: virtual void InsertData(const double _data) override;
};
/// \}

Expand All @@ -101,14 +101,14 @@ namespace ignition
class IGNITION_MATH_VISIBLE SignalMean : public SignalStatistic
{
// Documentation inherited.
public: virtual double Value() const;
public: virtual double Value() const override;

/// \brief Get a short version of the name of this statistical measure.
/// \return "mean"
public: virtual std::string ShortName() const;
public: virtual std::string ShortName() const override;

// Documentation inherited.
public: virtual void InsertData(const double _data);
public: virtual void InsertData(const double _data) override;
};
/// \}

Expand All @@ -117,14 +117,14 @@ namespace ignition
class IGNITION_MATH_VISIBLE SignalMinimum : public SignalStatistic
{
// Documentation inherited.
public: virtual double Value() const;
public: virtual double Value() const override;

/// \brief Get a short version of the name of this statistical measure.
/// \return "min"
public: virtual std::string ShortName() const;
public: virtual std::string ShortName() const override;

// Documentation inherited.
public: virtual void InsertData(const double _data);
public: virtual void InsertData(const double _data) override;
};
/// \}

Expand All @@ -134,14 +134,14 @@ namespace ignition
class IGNITION_MATH_VISIBLE SignalRootMeanSquare : public SignalStatistic
{
// Documentation inherited.
public: virtual double Value() const;
public: virtual double Value() const override;

/// \brief Get a short version of the name of this statistical measure.
/// \return "rms"
public: virtual std::string ShortName() const;
public: virtual std::string ShortName() const override;

// Documentation inherited.
public: virtual void InsertData(const double _data);
public: virtual void InsertData(const double _data) override;
};
/// \}

Expand All @@ -153,14 +153,14 @@ namespace ignition
class IGNITION_MATH_VISIBLE SignalMaxAbsoluteValue : public SignalStatistic
{
// Documentation inherited.
public: virtual double Value() const;
public: virtual double Value() const override;

/// \brief Get a short version of the name of this statistical measure.
/// \return "maxAbs"
public: virtual std::string ShortName() const;
public: virtual std::string ShortName() const override;

// Documentation inherited.
public: virtual void InsertData(const double _data);
public: virtual void InsertData(const double _data) override;
};
/// \}

Expand All @@ -170,14 +170,14 @@ namespace ignition
class IGNITION_MATH_VISIBLE SignalVariance : public SignalStatistic
{
// Documentation inherited.
public: virtual double Value() const;
public: virtual double Value() const override;

/// \brief Get a short version of the name of this statistical measure.
/// \return "var"
public: virtual std::string ShortName() const;
public: virtual std::string ShortName() const override;

// Documentation inherited.
public: virtual void InsertData(const double _data);
public: virtual void InsertData(const double _data) override;
};
/// \}

Expand Down
14 changes: 7 additions & 7 deletions src/Frustum_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ TEST(FrustumTest, PyramidYAxis)
// Field of view
Angle(IGN_DTOR(45)),
// Aspect ratio
320.0/320.0,
1.0,
// Pose
Pose3d(0, 0, 0, 0, 0, IGN_PI*0.5));

Expand Down Expand Up @@ -223,7 +223,7 @@ TEST(FrustumTest, PyramidZAxis)
// Field of view
Angle(IGN_DTOR(45)),
// Aspect ratio
320.0/320.0,
1.0,
// Pose
Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0));

Expand Down Expand Up @@ -254,7 +254,7 @@ TEST(FrustumTest, NearFar)
// Field of view
Angle(IGN_DTOR(45)),
// Aspect ratio
320.0/320.0,
1.0,
// Pose
Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0));

Expand All @@ -279,7 +279,7 @@ TEST(FrustumTest, FOV)
// Field of view
Angle(IGN_DTOR(45)),
// Aspect ratio
320.0/320.0,
1.0,
// Pose
Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0));

Expand All @@ -301,11 +301,11 @@ TEST(FrustumTest, AspectRatio)
// Field of view
Angle(IGN_DTOR(45)),
// Aspect ratio
320.0/320.0,
1.0,
// Pose
Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0));

EXPECT_DOUBLE_EQ(frustum.AspectRatio(), 320.0/320.0);
EXPECT_DOUBLE_EQ(frustum.AspectRatio(), 1);

frustum.SetAspectRatio(1.3434);

Expand All @@ -323,7 +323,7 @@ TEST(FrustumTest, Pose)
// Field of view
Angle(IGN_DTOR(45)),
// Aspect ratio
320.0/320.0,
1.0,
// Pose
Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0));

Expand Down
4 changes: 2 additions & 2 deletions src/Helpers_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ TEST(HelpersTest, FixNaN)
{
EXPECT_DOUBLE_EQ(math::fixnan(1.0 / 0.0), 0.0);
EXPECT_DOUBLE_EQ(math::fixnan(-1.0 / 0.0), 0.0);
EXPECT_DOUBLE_EQ(math::fixnan(0.0 / 0.0), 0.0);
EXPECT_DOUBLE_EQ(math::fixnan(1.0 / 0.0), 0.0);

EXPECT_DOUBLE_EQ(math::fixnan(42.0), 42.0);
EXPECT_DOUBLE_EQ(math::fixnan(-42.0), -42.0);

EXPECT_FLOAT_EQ(math::fixnan(1.0f / 0.0f), 0.0f);
EXPECT_FLOAT_EQ(math::fixnan(-1.0f / 0.0f), 0.0f);
EXPECT_FLOAT_EQ(math::fixnan(0.0f / 0.0f), 0.0f);
EXPECT_FLOAT_EQ(math::fixnan(1.0f / 0.0f), 0.0f);

EXPECT_FLOAT_EQ(math::fixnan(42.0f), 42.0f);
EXPECT_FLOAT_EQ(math::fixnan(-42.0f), -42.0f);
Expand Down
1 change: 0 additions & 1 deletion src/RotationSpline_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ TEST(RotationSplineTest, RecalcTangents)
EXPECT_EQ(s.Interpolate(0, 0.5),
math::Quaterniond(0.987225, 0.077057, 0.11624, 0.077057));

math::Quaterniond q = s.Interpolate(1, 0.5);
EXPECT_EQ(s.Interpolate(1, 0.5),
math::Quaterniond(0.987225, 0.077057, 0.11624, 0.077057));
}

0 comments on commit 58b69e9

Please sign in to comment.