41 const double rot_tolerance,
const std::vector<double>& speed_scale,
45 for (
int i = 0; i < speed_scale.size(); i++)
47 if (0. > speed_scale[i] || 1. < speed_scale[i])
49 ROS_ERROR_STREAM(
"[jog_api::jacobianMove] Velocity scaling parameter should be between 0 and 1.");
54 geometry_msgs::PoseStamped current_pose;
96 for (
int i = 0; i < speed_scale.size(); i++)
98 if (0. > speed_scale[i] || 1. < speed_scale[i])
100 ROS_ERROR_STREAM(
"[jog_api::maintainPose] Velocity scaling parameter should be between 0 and 1.");
106 geometry_msgs::PoseStamped initial_pose;
114 geometry_msgs::PoseStamped current_pose;
126 if ( ! (std::isnan(currentDistanceAndTwist.
twist.twist.linear.x) || std::isnan(currentDistanceAndTwist.
twist.twist.linear.y) || std::isnan(currentDistanceAndTwist.
twist.twist.linear.z) ||
127 std::isnan(currentDistanceAndTwist.
twist.twist.angular.x) || std::isnan(currentDistanceAndTwist.
twist.twist.angular.y) || std::isnan(currentDistanceAndTwist.
twist.twist.angular.z)))
132 previousGoodDistanceAndTwist = currentDistanceAndTwist;
136 ROS_WARN_STREAM(
"[jog_api] nan in incoming command. Skipping this datapoint.");
144 currentDistanceAndTwist.
twist.twist.linear.x = 0;
145 currentDistanceAndTwist.
twist.twist.linear.y = 0;
146 currentDistanceAndTwist.
twist.twist.linear.z = 0;
147 currentDistanceAndTwist.
twist.twist.angular.x = 0;
148 currentDistanceAndTwist.
twist.twist.angular.y = 0;
149 currentDistanceAndTwist.
twist.twist.angular.z = 0;
161 if (pose.header.frame_id.at(0) ==
'/')
162 pose.header.frame_id.erase(0, 1);
163 if (desired_frame.at(0) ==
'/')
164 desired_frame.erase(0, 1);
168 geometry_msgs::TransformStamped current_frame_to_target =
171 pose.header.frame_id = desired_frame;
191 const geometry_msgs::PoseStamped& target_pose,
192 const std::vector<double>& speed_scale)
197 if (current_pose.header.frame_id != target_pose.header.frame_id)
199 ROS_ERROR_STREAM(
"[JogAPI::distanceAndTwist] Incoming PoseStamped tf frames do not match.");
202 result.
twist.header.frame_id = current_pose.header.frame_id;
206 tf::Quaternion q(current_pose.pose.orientation.x, current_pose.pose.orientation.y, current_pose.pose.orientation.z,
207 current_pose.pose.orientation.w);
209 double curr_r, curr_p, curr_y;
210 m.
getRPY(curr_r, curr_p, curr_y);
213 q =
tf::Quaternion(target_pose.pose.orientation.x, target_pose.pose.orientation.y, target_pose.pose.orientation.z,
214 target_pose.pose.orientation.w);
216 double targ_r, targ_p, targ_y;
217 m.
getRPY(targ_r, targ_p, targ_y);
223 result.
twist.twist.linear.x = target_pose.pose.position.x - current_pose.pose.position.x;
224 result.
twist.twist.linear.y = target_pose.pose.position.y - current_pose.pose.position.y;
225 result.
twist.twist.linear.z = target_pose.pose.position.z - current_pose.pose.position.z;
228 result.
twist.twist.angular.x = targ_r - curr_r;
229 result.
twist.twist.angular.y = targ_p - curr_p;
230 result.
twist.twist.angular.z = targ_y - curr_y;
237 double sos = pow(result.
twist.twist.linear.x, 2.);
238 sos += pow(result.
twist.twist.linear.y, 2.);
239 sos += pow(result.
twist.twist.linear.z, 2.);
247 sos = pow(result.
twist.twist.angular.x, 2.);
248 sos += pow(result.
twist.twist.angular.y, 2.);
249 sos += pow(result.
twist.twist.angular.z, 2.);
ros::Publisher jog_vel_pub_
bool jacobianMove(geometry_msgs::PoseStamped &target_pose, const double trans_tolerance, const double rot_tolerance, const std::vector< double > &speed_scale, const ros::Duration &timeout)
void publish(const boost::shared_ptr< M > &message) const
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout) const
bool transformPose(geometry_msgs::PoseStamped &pose, std::string &desired_frame)
distanceAndTwist calculateDistanceAndTwist(const geometry_msgs::PoseStamped ¤t_pose, const geometry_msgs::PoseStamped &target_pose, const std::vector< double > &speed_scale)
void doTransform(const T &data_in, T &data_out, const geometry_msgs::TransformStamped &transform)
bool maintainPose(std::string frame, const ros::Duration duration, const std::vector< double > &speed_scale)
moveit::planning_interface::MoveGroupInterface move_group_
void getRPY(tfScalar &roll, tfScalar &pitch, tfScalar &yaw, unsigned int solution_number=1) const
tf2_ros::Buffer tf_buffer_
geometry_msgs::PoseStamped getCurrentPose(const std::string &end_effector_link="")
double rotational_distance
#define ROS_WARN_STREAM(args)
geometry_msgs::TwistStamped twist
#define ROS_ERROR_STREAM(args)
double translational_distance