37 #include "ompl/control/spaces/RealVectorControlSpace.h"
38 #include "ompl/util/Exception.h"
39 #include <boost/lexical_cast.hpp>
49 for (
unsigned int i = 0 ; i < dim ; ++i)
62 if (bounds.
low.size() != dimension_)
63 throw Exception(
"Bounds do not match dimension of control space: expected dimension " +
64 boost::lexical_cast<std::string>(dimension_) +
" but got dimension " +
65 boost::lexical_cast<std::string>(bounds.
low.size()));
76 memcpy(static_cast<ControlType*>(destination)->values,
77 static_cast<const ControlType*>(source)->values, controlBytes_);
82 const double *s1 =
static_cast<const ControlType*
>(control1)->values;
83 const double *s2 =
static_cast<const ControlType*
>(control2)->values;
84 for (
unsigned int i = 0 ; i < dimension_ ; ++i)
86 double diff = (*s1++) - (*s2++);
87 if (fabs(diff) > std::numeric_limits<double>::epsilon() * 2.0)
101 rcontrol->
values =
new double[dimension_];
108 delete[] rcontrol->
values;
115 for (
unsigned int i = 0 ; i < dimension_ ; ++i)
117 if (bounds_.low[i] <= 0.0 && bounds_.high[i] >= 0.0)
118 rcontrol->
values[i] = 0.0;
120 rcontrol->
values[i] = bounds_.low[i];
126 return index < dimension_ ? static_cast<ControlType*>(control)->values + index : NULL;
131 out <<
"RealVectorControl [";
135 for (
unsigned int i = 0 ; i < dimension_ ; ++i)
137 out << rcontrol->
values[i];
138 if (i + 1 < dimension_)
144 out <<
']' << std::endl;
149 out <<
"Real vector control space '" << getName() <<
"' with bounds: " << std::endl;
151 for (
unsigned int i = 0 ; i < dimension_ ; ++i)
152 out << bounds_.low[i] <<
" ";
155 for (
unsigned int i = 0 ; i < dimension_ ; ++i)
156 out << bounds_.high[i] <<
" ";
162 return controlBytes_;