Skip to content

Commit 5d653e8

Browse files
authored
Revive planSnap() not to break downstream (#414)
1 parent 15adfa6 commit 5d653e8

File tree

5 files changed

+134
-1
lines changed

5 files changed

+134
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
* Added parabolic timing for linear spline [#302](https://github.com/personalrobotics/aikido/pull/302), [#324](https://github.com/personalrobotics/aikido/pull/324)
3535
* Fixed step sequence iteration in VPF: [#303](https://github.com/personalrobotics/aikido/pull/303)
36-
* Refactored planning API: [#314](https://github.com/personalrobotics/aikido/pull/314)
36+
* Refactored planning API: [#314](https://github.com/personalrobotics/aikido/pull/314), [#414](https://github.com/personalrobotics/aikido/pull/414)
3737
* Added flags to WorldStateSaver to specify what to save: [#339](https://github.com/personalrobotics/aikido/pull/339)
3838
* Changed interface for TrajectoryPostProcessor: [#341](https://github.com/personalrobotics/aikido/pull/341)
3939
* Planning calls with InverseKinematicsSampleable constraints explicitly set MetaSkeleton to solve IK with: [#379](https://github.com/personalrobotics/aikido/pull/379)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef AIKIDO_COMMON_DEPRECATED_HPP_
2+
#define AIKIDO_COMMON_DEPRECATED_HPP_
3+
4+
#include <dart/config.hpp>
5+
6+
// NOTE: Deprecated macros are used for backward compatibility between different
7+
// minor versions of AIKIDO. Deprecated API can be removed in every major
8+
// version up.
9+
10+
#if defined(__GNUC__) || defined(__clang__)
11+
#define AIKIDO_DEPRECATED(version) __attribute__((deprecated))
12+
#elif defined(_MSC_VER)
13+
#define AIKIDO_DEPRECATED(version) __declspec(deprecated)
14+
#else
15+
#define AIKIDO_DEPRECATED(version) ()
16+
#endif
17+
18+
// We define two convenient macros that can be used to suppress
19+
// deprecated-warnings for a specific code block rather than a whole project.
20+
// This macros would be useful when you need to call deprecated function for
21+
// some reasons (e.g., for backward compatibility) but don't want warnings.
22+
//
23+
// Example code:
24+
//
25+
// deprecated_function() // warning
26+
//
27+
// AIKIDO_SUPPRESS_DEPRECATED_BEGIN
28+
// deprecated_function() // okay, no warning
29+
// AIKIDO_SUPPRESS_DEPRECATED_END
30+
//
31+
#if defined(__GNUC__) || defined(__GNUG__)
32+
33+
#define AIKIDO_SUPPRESS_DEPRECATED_BEGIN \
34+
_Pragma("GCC diagnostic push") \
35+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
36+
37+
#define AIKIDO_SUPPRESS_DEPRECATED_END _Pragma("GCC diagnostic pop")
38+
39+
#elif defined(__clang__)
40+
41+
#define AIKIDO_SUPPRESS_DEPRECATED_BEGIN \
42+
_Pragma("clang diagnostic push") \
43+
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
44+
45+
#define AIKIDO_SUPPRESS_DEPRECATED_END _Pragma("clang diagnostic pop")
46+
47+
#else
48+
49+
#warning "AIKIDO is being built by unsupported compiler."
50+
51+
#define AIKIDO_SUPPRESS_DEPRECATED_BEGIN
52+
#define AIKIDO_SUPPRESS_DEPRECATED_END
53+
54+
#endif
55+
56+
#endif // AIKIDO_COMMON_DEPRECATED_HPP_
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef AIKIDO_PLANNER_SNAPPLANNER_HPP_
2+
#define AIKIDO_PLANNER_SNAPPLANNER_HPP_
3+
4+
#include <memory>
5+
#include "aikido/common/deprecated.hpp"
6+
#include "aikido/constraint/Testable.hpp"
7+
#include "aikido/planner/PlanningResult.hpp"
8+
#include "aikido/statespace/Interpolator.hpp"
9+
#include "aikido/statespace/StateSpace.hpp"
10+
#include "aikido/trajectory/Interpolated.hpp"
11+
12+
namespace aikido {
13+
namespace planner {
14+
15+
/// Plan a trajectory from \c startState to \c goalState by using
16+
/// \c interpolator to interpolate between them. The planner returns success if
17+
/// the resulting trajectory satisfies \c constraint at some resolution and
18+
/// failure (returning \c nullptr) otherwise. The reason for the failure is
19+
/// stored in the \c planningResult output parameter.
20+
///
21+
/// \param stateSpace state space
22+
/// \param startState start state
23+
/// \param goalState goal state
24+
/// \param interpolator interpolator used to produce the output trajectory
25+
/// \param constraint trajectory-wide constraint that must be satisfied
26+
/// \param[out] planningResult information about success or failure
27+
/// \return trajectory or \c nullptr if planning failed
28+
///
29+
/// \deprecated Deprecated in 0.3. Please use
30+
/// SnapConfigurationToConfigurationPlanner instead.
31+
AIKIDO_DEPRECATED(0.3)
32+
trajectory::InterpolatedPtr planSnap(
33+
const statespace::ConstStateSpacePtr& stateSpace,
34+
const statespace::StateSpace::State* startState,
35+
const statespace::StateSpace::State* goalState,
36+
const std::shared_ptr<statespace::Interpolator>& interpolator,
37+
const std::shared_ptr<constraint::Testable>& constraint,
38+
planner::PlanningResult& planningResult);
39+
40+
} // namespace planner
41+
} // namespace aikido
42+
43+
#endif // AIKIDO_PLANNER_SNAPPLANNER_HPP_

src/planner/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(sources
1212
Problem.cpp
1313
RankedMetaPlanner.cpp
1414
SnapConfigurationToConfigurationPlanner.cpp
15+
SnapPlanner.cpp
1516
SequenceMetaPlanner.cpp
1617
World.cpp
1718
WorldStateSaver.cpp

src/planner/SnapPlanner.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "aikido/planner/SnapPlanner.hpp"
2+
3+
#include "aikido/planner/ConfigurationToConfiguration.hpp"
4+
#include "aikido/planner/PlanningResult.hpp"
5+
#include "aikido/planner/SnapConfigurationToConfigurationPlanner.hpp"
6+
7+
namespace aikido {
8+
namespace planner {
9+
10+
trajectory::InterpolatedPtr planSnap(
11+
const statespace::ConstStateSpacePtr& stateSpace,
12+
const aikido::statespace::StateSpace::State* startState,
13+
const aikido::statespace::StateSpace::State* goalState,
14+
const std::shared_ptr<aikido::statespace::Interpolator>& interpolator,
15+
const std::shared_ptr<aikido::constraint::Testable>& constraint,
16+
aikido::planner::PlanningResult& planningResult)
17+
{
18+
auto problem = ConfigurationToConfiguration(
19+
stateSpace, startState, goalState, constraint);
20+
21+
auto planner = std::make_shared<SnapConfigurationToConfigurationPlanner>(
22+
stateSpace, interpolator);
23+
24+
SnapConfigurationToConfigurationPlanner::Result result;
25+
auto trj = planner->plan(problem, &result);
26+
planningResult.setMessage(result.getMessage());
27+
28+
assert(std::dynamic_pointer_cast<trajectory::Interpolated>(trj));
29+
return std::static_pointer_cast<trajectory::Interpolated>(trj);
30+
}
31+
32+
} // namespace planner
33+
} // namespace aikido

0 commit comments

Comments
 (0)