39 #include <kdl/frames.hpp> 40 #include <kdl/chainfksolverpos_recursive.hpp> 41 #include <kdl/chainidsolver_recursive_newton_euler.hpp> 42 #include <kdl/chainiksolvervel_pinv.hpp> 44 #include <sensor_msgs/JointState.h> 71 void js_cb(
const sensor_msgs::JointState::ConstPtr& msg){
72 for(
unsigned int i = 0; i < msg->effort.size(); i++){
84 for (
unsigned int i = 0; i <
mNumJnts; i++) {
94 frc = -1 * (diff) * gr;
98 jnt_wrenches.push_back(wr);
110 ROS_ERROR(
"KDL: inverse dynamics ERROR");
115 for(
unsigned int i = 0; i <
mNumJnts; i++){
119 double spring_offset = (-0.0001215972501*std::pow(
joint_states.position[i], 3)) + (0.0019337012*std::pow(
joint_states.position[i], 2)) + (0.0025029181439*
joint_states.position[i]) + 0.0753200891107 ;
125 if (i == 1 || i == 2)
137 int main(
int argc,
char** argv){
138 ros::init(argc, argv,
"svenzva_dynamics");
139 int mNumJntsRegistered = 6;
140 std::vector<std::string> joint_names_ar;
141 std::string chain_end =
"link_";
148 if (n.
getParam(
"num_motors_present", mNumJntsRegistered))
150 mNumJnts = std::min(mNumJntsRegistered, 6);
158 ROS_INFO(
"SvenzvaDynamics failed to find num joints parameter. Using default.");
161 for(
unsigned int i = 0; i <
mNumJnts+1; i++)
168 std::string full_path = path +
"/robots/svenzva_arm.urdf";
169 ROS_INFO(
"Loading model from %s", full_path.c_str());
173 if (!kdl_parser::treeFromFile(full_path, my_tree)){
174 ROS_ERROR(
"Failed to construct kdl tree");
177 chain_end.append(std::to_string(mNumJnts));
KDL::JntArray jnt_taugc(mNumJnts)
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())
void feel_efforts(ros::Publisher tau_pub)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
KDL::JntArray jnt_qd(mNumJnts)
sensor_msgs::JointState joint_states
KDL::JntArray jnt_qdd(mNumJnts)
int CartToJnt(const JntArray &q, const JntArray &q_dot, const JntArray &q_dotdot, const Wrenches &f_ext, JntArray &torques)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
unsigned int getNrOfJoints() const
KDL_PARSER_PUBLIC bool treeFromFile(const std::string &file, KDL::Tree &tree)
void js_cb(const sensor_msgs::JointState::ConstPtr &msg)
sensor_msgs::JointState model_states
ROSLIB_DECL std::string getPath(const std::string &package_name)
void resize(unsigned int newSize)
std::vector< Wrench > Wrenches
bool getChain(const std::string &chain_root, const std::string &chain_tip, Chain &chain) const
bool getParam(const std::string &key, std::string &s) const
int main(int argc, char **argv)
KDL::ChainIdSolver_RNE * gcSolver
ROSCPP_DECL void spinOnce()
KDL::JntArray jnt_q(mNumJnts)