Loading...
Searching...
No Matches
Utils.h
1#pragma once
2
3#include <ompl/base/State.h>
4#include <ompl/base/spaces/RealVectorStateSpace.h>
5
6namespace ompl::vamp
7{
8 namespace ob = ompl::base;
9
10 //==========================================================================
11 // OMPL Conversion Utilities
12 //==========================================================================
13
15 template <typename Robot>
16 inline auto ompl_to_vamp(const ob::State *state) -> typename Robot::Configuration
17 {
18 using Configuration = typename Robot::Configuration;
19
20 alignas(Configuration::S::Alignment) std::array<typename Configuration::S::ScalarT, Configuration::num_scalars>
21 aligned_buffer{};
22
23 const auto *as = state->as<ob::RealVectorStateSpace::StateType>();
24 for (std::size_t i = 0; i < Robot::dimension; ++i)
25 {
26 aligned_buffer[i] = static_cast<float>(as->values[i]);
27 }
28
29 return Configuration(aligned_buffer.data());
30 }
31
33 template <typename Robot>
34 inline void vamp_to_ompl(const typename Robot::Configuration &config, ob::State *state)
35 {
36 auto *as = state->as<ob::RealVectorStateSpace::StateType>();
37 for (std::size_t i = 0; i < Robot::dimension; ++i)
38 {
39 as->values[i] = static_cast<double>(config[{i, 0}]);
40 }
41 }
42
43} // namespace ompl::vamp
Definition of an abstract state.
Definition State.h:50
const T * as() const
Cast this instance to a desired type.
Definition State.h:66
This namespace contains sampling based planning routines shared by both planning under geometric cons...