moveit2
The MoveIt Motion Planning Framework for ROS 2.
utilities.h
Go to the documentation of this file.
1 // Copyright 2022 PickNik Inc.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 //
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 //
13 // * Neither the name of the PickNik Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 
29 /* Author : Andy Zelenak
30  Desc : Free functions. We keep them in a separate translation unit to reduce .o filesize
31  Title : utilities.h
32  Project : moveit_servo
33 */
34 
35 #pragma once
36 
37 #include <control_msgs/msg/joint_jog.hpp>
38 #include <geometry_msgs/msg/twist_stamped.hpp>
41 #include <rclcpp/rclcpp.hpp>
42 #include <tf2_eigen/tf2_eigen.hpp>
43 
45 
46 namespace moveit_servo
47 {
48 // Helper function for detecting zeroed message
49 bool isNonZero(const geometry_msgs::msg::TwistStamped& msg);
50 
51 // Helper function for detecting zeroed message
52 bool isNonZero(const control_msgs::msg::JointJog& msg);
53 
54 // Helper function for converting Eigen::Isometry3d to geometry_msgs/TransformStamped
55 geometry_msgs::msg::TransformStamped convertIsometryToTransform(const Eigen::Isometry3d& eigen_tf,
56  const std::string& parent_frame,
57  const std::string& child_frame);
58 
73  const Eigen::VectorXd& commanded_twist,
74  const Eigen::JacobiSVD<Eigen::MatrixXd>& svd,
75  const Eigen::MatrixXd& pseudo_inverse,
76  const double hard_stop_singularity_threshold,
77  const double lower_singularity_threshold,
78  const double leaving_singularity_threshold_multiplier, rclcpp::Clock& clock,
79  moveit::core::RobotStatePtr& current_state, StatusCode& status);
80 
81 } // namespace moveit_servo
double velocityScalingFactorForSingularity(const moveit::core::JointModelGroup *joint_model_group, const Eigen::VectorXd &commanded_twist, const Eigen::JacobiSVD< Eigen::MatrixXd > &svd, const Eigen::MatrixXd &pseudo_inverse, const double hard_stop_singularity_threshold, const double lower_singularity_threshold, const double leaving_singularity_threshold_multiplier, rclcpp::Clock &clock, moveit::core::RobotStatePtr &current_state, StatusCode &status)
Possibly calculate a velocity scaling factor, due to proximity of singularity and direction of motion...
Definition: utilities.cpp:88
geometry_msgs::msg::TransformStamped convertIsometryToTransform(const Eigen::Isometry3d &eigen_tf, const std::string &parent_frame, const std::string &child_frame)
Helper function for converting Eigen::Isometry3d to geometry_msgs/TransformStamped.
Definition: utilities.cpp:64
bool isNonZero(const geometry_msgs::msg::TwistStamped &msg)
Helper function for detecting zeroed message.
Definition: utilities.cpp:46