Skip to content

Commit

Permalink
WIP: [core] Add a unidirectional Perlin Ground HeightmapFunction (#799)
Browse files Browse the repository at this point in the history
* [core] Minor improvement periodic Perlin process and periodic stair ground.
* [core] 'PeriodicGaussianProcess' and 'PeriodicFourierProcess' are now differentiable. 
* [core] Fix negative time support for all existing random processes.
* [core] Add N-dimension Perlin processes.
* [core] Add gradient computation for all Perlin processes.
* [core] Make all Perlin processes faster and copy-able.
* [core] Add Perlin ground generators.

---------

Co-authored-by: Alexis Duburcq <alexis.duburcq@gmail.com>
  • Loading branch information
mwulfman and duburcqa authored Jul 13, 2024
1 parent 59383c2 commit 27bbdea
Show file tree
Hide file tree
Showing 13 changed files with 1,088 additions and 476 deletions.
8 changes: 7 additions & 1 deletion core/include/jiminy/core/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ namespace jiminy
using std::logic_error::logic_error::what;
};

// Ground profile functors
template<typename ResultType,
ResultType min_ = std::numeric_limits<ResultType>::min(),
ResultType max_ = std::numeric_limits<ResultType>::max()>
class uniform_random_bit_generator_ref;

// Ground profile functors.
// FIXME: use `std::move_only_function` instead of `std::function` when moving to C++23
using HeightmapFunction = std::function<void(const Eigen::Vector2d & /* xy */,
double & /* height */,
Eigen::Ref<Eigen::Vector3d> /* normal */)>;
Expand Down
3 changes: 2 additions & 1 deletion core/include/jiminy/core/robot/model.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#ifndef JIMINY_MODEL_H
#define JIMINY_MODEL_H

#include <optional>

#include "pinocchio/spatial/fwd.hpp" // `pinocchio::SE3`
#include "pinocchio/multibody/model.hpp" // `pinocchio::Model`
#include "pinocchio/multibody/data.hpp" // `pinocchio::Data`
#include "pinocchio/multibody/geometry.hpp" // `pinocchio::GeometryModel`, `pinocchio::GeometryData`
#include "pinocchio/multibody/frame.hpp" // `pinocchio::FrameType` (C-style enum cannot be forward declared)

#include "jiminy/core/fwd.h"
#include "jiminy/core/utilities/random.h" // `uniform_random_bit_generator_ref`


namespace jiminy
Expand Down
10 changes: 5 additions & 5 deletions core/include/jiminy/core/stepper/lie_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ namespace Eigen

#define StateDerivative_SHARED_ADDON \
template<typename Derived, \
typename = typename std::enable_if_t< \
typename = std::enable_if_t< \
is_base_of_template_v<StateDerivativeBase, \
typename internal::traits<Derived>::ValueType>::value, \
void>> \
Expand Down Expand Up @@ -1268,7 +1268,7 @@ namespace Eigen
template< \
typename Derived, \
typename OtherDerived, \
typename = typename std::enable_if_t< \
typename = std::enable_if_t< \
is_base_of_template_v<StateDerivativeBase, \
typename internal::traits<Derived>::ValueType>::value && \
is_base_of_template_v<StateBase, \
Expand All @@ -1290,7 +1290,7 @@ namespace Eigen
} \
\
template<typename Derived, \
typename = typename std::enable_if_t< \
typename = std::enable_if_t< \
is_base_of_template_v<StateDerivativeBase, \
typename internal::traits<Derived>::ValueType>::value, \
void>> \
Expand All @@ -1301,7 +1301,7 @@ namespace Eigen
} \
\
template<typename Derived, \
typename = typename std::enable_if_t< \
typename = std::enable_if_t< \
is_base_of_template_v<StateDerivativeBase, \
typename internal::traits<Derived>::ValueType>::value, \
void>> \
Expand All @@ -1320,7 +1320,7 @@ namespace Eigen
template< \
typename Derived, \
typename OtherDerived, \
typename = typename std::enable_if_t< \
typename = std::enable_if_t< \
is_base_of_template_v<StateBase, \
typename internal::traits<Derived>::ValueType>::value && \
is_base_of_template_v<StateDerivativeBase, \
Expand Down
17 changes: 16 additions & 1 deletion core/include/jiminy/core/utilities/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,23 @@ namespace jiminy
/// \param[in] stepHeight Heigh of the steps.
/// \param[in] stepNumber Number of steps in the ascending or descending direction.
/// \param[in] orientation Orientation of the staircases in the XY plane.
HeightmapFunction JIMINY_DLLAPI stairs(
HeightmapFunction JIMINY_DLLAPI periodicStairs(
double stepWidth, double stepHeight, uint32_t stepNumber, double orientation);

HeightmapFunction JIMINY_DLLAPI unidirectionalRandomPerlinGround(
double wavelength, std::size_t numOctaves, double orientation, uint32_t seed);

HeightmapFunction JIMINY_DLLAPI unidirectionalPeriodicPerlinGround(double wavelength,
double period,
std::size_t numOctaves,
double orientation,
uint32_t seed);

HeightmapFunction JIMINY_DLLAPI randomPerlinGround(
double wavelength, std::size_t numOctaves, uint32_t seed);

HeightmapFunction JIMINY_DLLAPI periodicPerlinGround(
double wavelength, double period, std::size_t numOctaves, uint32_t seed);
}

#endif // JIMINY_GEOMETRY_H
Loading

0 comments on commit 27bbdea

Please sign in to comment.