@@ -86,22 +86,30 @@ void ArmControlBase::toTcpPose(const Eigen::Isometry3d& pose, TcpPose& tcp_pose)
86
86
tcp_pose.gamma = euler_angles[2 ];
87
87
}
88
88
89
- Eigen::Vector3d ArmControlBase::getUnitApproachVector (const double & alpha, const double & beta, const double & gamma)
89
+ std::vector< Eigen::Vector3d> ArmControlBase::getUnitApproachVectors (const double & alpha, const double & beta, const double & gamma)
90
90
{
91
91
tf2::Quaternion q;
92
92
q.setRPY (alpha, beta, gamma);
93
93
tf2::Matrix3x3 r (q);
94
94
95
- tf2::Vector3 approach_vector = r * tf2::Vector3 (0 , 0 , 1 );
96
- approach_vector = approach_vector.normalize ();
97
- return Eigen::Vector3d (approach_vector[0 ], approach_vector[1 ], approach_vector[2 ]);
95
+ // get approach_vectors along x, y, z axes
96
+ std::vector<Eigen::Vector3d> approach_vectors;
97
+ for (size_t i = 0 ; i < 3 ; i++)
98
+ {
99
+ tf2::Vector3 pre_rotation_vector (0 , 0 , 0 );
100
+ pre_rotation_vector[i] = 1 ;
101
+ tf2::Vector3 post_rotation_vector = r * pre_rotation_vector;
102
+ post_rotation_vector = post_rotation_vector.normalize ();
103
+ approach_vectors.push_back (Eigen::Vector3d (post_rotation_vector[0 ], post_rotation_vector[1 ], post_rotation_vector[2 ]));
104
+ }
105
+ return approach_vectors;
98
106
}
99
107
100
108
bool ArmControlBase::pick (double x, double y, double z,
101
109
double alpha, double beta, double gamma,
102
110
double vel, double acc, double vel_scale, double approach)
103
111
{
104
- Eigen::Vector3d pre_grasp_origin = Eigen::Vector3d (x, y, z) - getUnitApproachVector (alpha, beta, gamma) * approach;
112
+ Eigen::Vector3d pre_grasp_origin = Eigen::Vector3d (x, y, z) - getUnitApproachVectors (alpha, beta, gamma)[ 2 ] * approach;
105
113
106
114
Eigen::Isometry3d grasp, orientation, pre_grasp;
107
115
orientation = Eigen::AngleAxisd (alpha, Eigen::Vector3d::UnitX ())
@@ -146,7 +154,7 @@ bool ArmControlBase::place(double x, double y, double z,
146
154
double alpha, double beta, double gamma,
147
155
double vel, double acc, double vel_scale, double retract)
148
156
{
149
- Eigen::Vector3d pre_place_origin = Eigen::Vector3d (x, y, z) - getUnitApproachVector (alpha, beta, gamma) * retract;
157
+ Eigen::Vector3d pre_place_origin = Eigen::Vector3d (x, y, z) - getUnitApproachVectors (alpha, beta, gamma)[ 2 ] * retract;
150
158
151
159
Eigen::Isometry3d place, orientation, pre_place;
152
160
orientation = Eigen::AngleAxisd (alpha, Eigen::Vector3d::UnitX ())
0 commit comments