52 PositionVelocity(Vector3d::Zero(), Vector3d::Zero());
54 PositionVelocity(Vector3d::Zero(), Vector3d::Zero());
59 :
State(), position_(Vector3d(x, y, z)), velocity_(Vector3d(vx, vy, vz)) {}
61 const Vector3d &velocity)
78 ROS_ERROR_THROTTLE(1.0,
79 "PositionVelocity: msg dimension is incorrect: %zu.",
98 throw std::runtime_error(
"PositionVelocity: incorrect input dimension.");
105 throw std::runtime_error(
106 "PositionVelocity: invalid configuration_dot dim.");
117 const size_t kConfigurationSpaceDimension = 3;
120 std::uniform_real_distribution<double> unif(0.0, 1.0);
127 VectorXd sample(kConfigurationSpaceDimension);
128 for (
size_t ii = 0; ii < kConfigurationSpaceDimension; ii++)
130 lower_config(ii) + (upper_config(ii) - lower_config(ii)) * unif(
rng_);
138 std::uniform_real_distribution<double> unif(0.0, 1.0);
161 std::uniform_real_distribution<double> x_dist(
164 std::uniform_real_distribution<double> y_dist(
167 std::uniform_real_distribution<double> z_dist(
181 return std::vector<Vector3d>({
position_});
194 const std::vector<double> &upper) {
196 if (lower.size() != 6 || upper.size() != 6)
197 throw std::runtime_error(
"PositionVelocity: bad bound dimension.");
226 ROS_ERROR(
"PositionVelocity: vector is of the wrong size.");
245 if (msg.x.size() == 6) {
253 }
else if (msg.x.size() == 3) {
259 ROS_ERROR(
"PositionVelocity: msg is neither state nor configuration.");
264 fastrack_msgs::State msg;
VectorXd ToVector() const
static void SetBounds(const PositionVelocity &lower, const PositionVelocity &upper)
static PositionVelocity Sample()
void SetConfigurationDot(const VectorXd &configuration_dot)
PositionVelocity & operator+=(const PositionVelocity &rhs)
void FromVector(const VectorXd &x)
friend PositionVelocity operator/(PositionVelocity lhs, double s)
static const PositionVelocity & GetUpper()
PositionVelocity & operator-=(const PositionVelocity &rhs)
friend PositionVelocity operator+(PositionVelocity lhs, const PositionVelocity &rhs)
static VectorXd GetConfigurationLower()
static const PositionVelocity & GetLower()
PositionVelocity & operator*=(double s)
static PositionVelocity lower_
std::vector< Vector3d > OccupiedPositions() const
static VectorXd GetConfigurationUpper()
void FromRos(const fastrack_msgs::State &msg)
fastrack_msgs::State ToRos() const
static constexpr size_t StateDimension()
static std::default_random_engine rng_
PositionVelocity & operator/=(double s)
friend PositionVelocity operator*(PositionVelocity lhs, double s)
static VectorXd SampleConfiguration()
static PositionVelocity upper_
static constexpr size_t ConfigurationDimension()
VectorXd Configuration() const
static PositionVelocity SampleCloseTo(const Vector3d &pos, double d)
friend PositionVelocity operator-(PositionVelocity lhs, const PositionVelocity &rhs)