21 #include <sensor_msgs/JointState.h> 22 #include <std_msgs/Float64.h> 23 #include <geometry_msgs/Twist.h> 26 #include <kdl/chainfksolvervel_recursive.hpp> 27 #include <kdl/chainjnttojacsolver.hpp> 28 #include <kdl/frames.hpp> 29 #include <kdl/jntarray.hpp> 30 #include <kdl/jntarrayvel.hpp> 32 #include <Eigen/Dense> 52 if (!nh_.
getParam(
"chain_base_link", this->chain_base_link_))
54 ROS_ERROR(
"Failed to get parameter \"chain_base_link\".");
58 if (!nh_.
getParam(
"chain_tip_link", this->chain_tip_link_))
60 ROS_ERROR(
"Failed to get parameter \"chain_tip_link\".");
68 ROS_ERROR(
"Failed to construct kdl tree");
72 my_tree.
getChain(this->chain_base_link_, this->chain_tip_link_, chain_);
75 ROS_ERROR(
"Failed to initialize kinematic chain");
84 manipulability_pub_ = nh_.
advertise<std_msgs::Float64> (
"debug/manipulability", 1);
85 twist_current_pub_ = nh_.
advertise<geometry_msgs::Twist> (
"debug/twist_current", 1);
95 for (
unsigned int i = 0; i < msg->name.size(); i++)
97 q(i) = msg->position[i];
98 q_dot(i) = msg->velocity[i];
104 if (p_fksolver_vel_->
JntToCart(jntArrayVel, FrameVel, -1) >= 0)
106 geometry_msgs::Twist twist_msg;
108 twist_current_pub_.
publish(twist_msg);
114 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> prod = jac.data * jac.data.transpose();
115 double d = prod.determinant();
116 double kappa = std::sqrt(std::abs(d));
117 std_msgs::Float64 manipulability_msg;
118 manipulability_msg.data = kappa;
119 manipulability_pub_.
publish(manipulability_msg);
124 int main(
int argc,
char** argv)
126 ros::init(argc, argv,
"debug_evaluate_jointstates_node");
129 if (dejs.
init() != 0)
131 ROS_ERROR(
"Failed to initialize DebugEvaluateJointStates.");
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
IMETHOD Twist GetTwist() const
ros::Publisher twist_current_pub_
std::string chain_tip_link_
std::string chain_base_link_
ROSCPP_DECL void spin(Spinner &spinner)
KDL::ChainFkSolverVel_recursive * p_fksolver_vel_
void twistKDLToMsg(const KDL::Twist &k, geometry_msgs::Twist &m)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
unsigned int getNrOfJoints() const
bool getChain(const std::string &chain_root, const std::string &chain_tip, Chain &chain) const
virtual int JntToCart(const JntArrayVel &q_in, FrameVel &out, int segmentNr=-1)
KDL_PARSER_PUBLIC bool treeFromParam(const std::string ¶m, KDL::Tree &tree)
ros::Subscriber jointstate_sub_
ros::Publisher manipulability_pub_
bool getParam(const std::string &key, std::string &s) const
void jointstateCallback(const sensor_msgs::JointState::ConstPtr &msg)
virtual int JntToJac(const JntArray &q_in, Jacobian &jac, int seg_nr=-1)
KDL::ChainJntToJacSolver * p_jnt2jac_