prismatic_joint_model.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
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 /* Author: Ioan Sucan */
36 
38 #include <limits>
39 
40 namespace moveit
41 {
42 namespace core
43 {
44 PrismaticJointModel::PrismaticJointModel(const std::string& name) : JointModel(name), axis_(0.0, 0.0, 0.0)
45 {
46  type_ = PRISMATIC;
47  variable_names_.push_back(name_);
48  variable_bounds_.resize(1);
49  variable_bounds_[0].position_bounded_ = true;
50  variable_bounds_[0].min_position_ = -std::numeric_limits<double>::max();
51  variable_bounds_[0].max_position_ = std::numeric_limits<double>::max();
54 }
55 
57 {
58  return 1;
59 }
60 
61 double PrismaticJointModel::getMaximumExtent(const Bounds& other_bounds) const
62 {
63  return variable_bounds_[0].max_position_ - other_bounds[0].min_position_;
64 }
65 
66 void PrismaticJointModel::getVariableDefaultPositions(double* values, const Bounds& bounds) const
67 {
68  // if zero is a valid value
69  if (bounds[0].min_position_ <= 0.0 && bounds[0].max_position_ >= 0.0)
70  values[0] = 0.0;
71  else
72  values[0] = (bounds[0].min_position_ + bounds[0].max_position_) / 2.0;
73 }
74 
75 bool PrismaticJointModel::satisfiesPositionBounds(const double* values, const Bounds& bounds, double margin) const
76 {
77  if (values[0] < bounds[0].min_position_ - margin || values[0] > bounds[0].max_position_ + margin)
78  return false;
79  return true;
80 }
81 
83  const Bounds& bounds) const
84 {
85  values[0] = rng.uniformReal(bounds[0].min_position_, bounds[0].max_position_);
86 }
87 
89  const Bounds& bounds, const double* near,
90  const double distance) const
91 {
92  values[0] = rng.uniformReal(std::max(bounds[0].min_position_, near[0] - distance),
93  std::min(bounds[0].max_position_, near[0] + distance));
94 }
95 
96 bool PrismaticJointModel::enforcePositionBounds(double* values, const Bounds& bounds) const
97 {
98  if (values[0] < bounds[0].min_position_)
99  {
100  values[0] = bounds[0].min_position_;
101  return true;
102  }
103  else if (values[0] > bounds[0].max_position_)
104  {
105  values[0] = bounds[0].max_position_;
106  return true;
107  }
108  return false;
109 }
110 
111 double PrismaticJointModel::distance(const double* values1, const double* values2) const
112 {
113  return fabs(values1[0] - values2[0]);
114 }
115 
116 void PrismaticJointModel::interpolate(const double* from, const double* to, const double t, double* state) const
117 {
118  state[0] = from[0] + (to[0] - from[0]) * t;
119 }
120 
121 void PrismaticJointModel::computeTransform(const double* joint_values, Eigen::Affine3d& transf) const
122 {
123  double* d = transf.data();
124  d[0] = 1.0;
125  d[1] = 0.0;
126  d[2] = 0.0;
127  d[3] = 0.0;
128 
129  d[4] = 0.0;
130  d[5] = 1.0;
131  d[6] = 0.0;
132  d[7] = 0.0;
133 
134  d[8] = 0.0;
135  d[9] = 0.0;
136  d[10] = 1.0;
137  d[11] = 0.0;
138 
139  d[12] = axis_.x() * joint_values[0];
140  d[13] = axis_.y() * joint_values[0];
141  d[14] = axis_.z() * joint_values[0];
142  d[15] = 1.0;
143 
144  // transf.setIdentity();
145  // transf.translation() = Eigen::Vector3d(axis_ * joint_values[0]);
146 }
147 
148 void PrismaticJointModel::computeVariablePositions(const Eigen::Affine3d& transf, double* joint_values) const
149 {
150  joint_values[0] = transf.translation().dot(axis_);
151 }
152 
153 } // end of namespace core
154 } // end of namespace moveit
d
virtual void interpolate(const double *from, const double *to, const double t, double *state) const
Computes the state that lies at time t in [0, 1] on the segment that connects from state to to state...
virtual void computeVariablePositions(const Eigen::Affine3d &transf, double *joint_values) const
Given the transform generated by joint, compute the corresponding joint values.
std::string name_
Name of the joint.
Definition: joint_model.h:451
Bounds variable_bounds_
The bounds for each variable (low, high) in the same order as variable_names_.
Definition: joint_model.h:463
JointType type_
The type of joint.
Definition: joint_model.h:454
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PrismaticJointModel(const std::string &name)
double getMaximumExtent() const
Definition: joint_model.h:431
Eigen::Vector3d axis_
The axis of the joint.
virtual unsigned int getStateSpaceDimension() const
Get the dimension of the state space that corresponds to this joint.
virtual bool satisfiesPositionBounds(const double *values, const Bounds &other_bounds, double margin) const
Check if the set of position values for the variables of this joint are within bounds, up to some margin.
virtual void getVariableRandomPositionsNearBy(random_numbers::RandomNumberGenerator &rng, double *values, const Bounds &other_bounds, const double *near, const double distance) const
Provide random values for the joint variables (within specified bounds). Enough memory is assumed to ...
double uniformReal(double lower_bound, double upper_bound)
virtual void getVariableRandomPositions(random_numbers::RandomNumberGenerator &rng, double *values, const Bounds &other_bounds) const
Provide random values for the joint variables (within specified bounds). Enough memory is assumed to ...
VariableIndexMap variable_index_map_
Map from variable names to the corresponding index in variable_names_ (indexing makes sense within th...
Definition: joint_model.h:469
A joint from the robot. Models the transform that this joint applies in the kinematic chain...
Definition: joint_model.h:108
virtual bool enforcePositionBounds(double *values, const Bounds &other_bounds) const
Force the specified values to be inside bounds and normalized. Quaternions are normalized, continuous joints are made between -Pi and Pi. Return true if changes were made.
std::vector< std::string > variable_names_
The full names to use for the variables that make up this joint.
Definition: joint_model.h:460
virtual void getVariableDefaultPositions(double *values, const Bounds &other_bounds) const
Provide a default value for the joint given the joint variable bounds. Most joints will use the defau...
virtual void computeTransform(const double *joint_values, Eigen::Affine3d &transf) const
Given the joint values for a joint, compute the corresponding transform.
Main namespace for MoveIt!
std::vector< VariableBounds > Bounds
The datatype for the joint bounds.
Definition: joint_model.h:123
virtual double distance(const double *values1, const double *values2) const
Compute the distance between two joint states of the same model (represented by the variable values) ...


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Sat Apr 21 2018 02:54:51