VFMechanicalWorkOptimizationObjective.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2015, Caleb Voss and Wilson Beebe
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Authors: Caleb Voss, Wilson Beebe */
36 
37 #ifndef OMPL_BASE_OBJECTIVES_VF_MECHANICAL_WORK_OPTIMIZATION_OBJECTIVE_
38 #define OMPL_BASE_OBJECTIVES_VF_MECHANICAL_WORK_OPTIMIZATION_OBJECTIVE_
39 
40 #include "ompl/base/objectives/MechanicalWorkOptimizationObjective.h"
41 #include "ompl/geometric/planners/rrt/VFRRT.h"
42 
43 namespace ompl
44 {
45  namespace base
46  {
47 
52  {
53 
54  public:
55 
58  const geometric::VFRRT::VectorField& vf)
60  {
61  }
62 
65  {
66  return false;
67  }
68 
71  {
72  const base::StateSpacePtr &space = si_->getStateSpace();
73  // Per equation 7 in the paper
74  Eigen::VectorXd f = vf_(s2);
75  unsigned int vfdim = f.size();
76  Eigen::VectorXd qprime(vfdim);
77 
78  for (unsigned int i = 0; i < vfdim; i++)
79  qprime[i] = *space->getValueAddressAtIndex(s2, i)
80  - *space->getValueAddressAtIndex(s1, i);
81 
82  // Don't included negative work
83  double positiveCostAccrued = std::max(-(f.dot(qprime)), 0.);
84  return ompl::base::Cost(positiveCostAccrued + pathLengthWeight_ * si_->distance(s1, s2));
85  }
86 
87  bool isSymmetric(void) const
88  {
89  return false;
90  }
91 
92  protected:
94  geometric::VFRRT::VectorField vf_;
95  };
96  }
97 }
98 
99 #endif
ompl::base::Cost motionCost(const ompl::base::State *s1, const ompl::base::State *s2) const
A shared pointer wrapper for ompl::base::StateSpace.
An optimization objective which defines path cost using the idea of mechanical work. To be used in conjunction with TRRT.
VFMechanicalWorkOptimizationObjective(const ompl::base::SpaceInformationPtr &si, const geometric::VFRRT::VectorField &vf)
Main namespace. Contains everything in this library.
Definition: Cost.h:42
A shared pointer wrapper for ompl::base::SpaceInformation.
bool isSymmetric(void) const
Check if this objective has a symmetric cost metric, i.e. motionCost(s1, s2) = motionCost(s2, s1). Default implementation returns whether the underlying state space has symmetric interpolation.
Definition of an abstract state.
Definition: State.h:50
double pathLengthWeight_
The weighing factor for the path length in the mechanical work objective formulation.
SpaceInformationPtr si_
The space information for this objective.
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition: Cost.h:47