param_parser.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef COB_OMNI_DRIVE_CONTROLLER_PARAM_PARSER_H
19 #define COB_OMNI_DRIVE_CONTROLLER_PARAM_PARSER_H
20 
21 #include <urdf/model.h>
22 
25 #include <tf2/LinearMath/Vector3.h>
26 
27 inline bool parseWheelTransform(const std::string& joint_name, const std::string& parent_link_name,
28  tf2::Transform &transform, urdf::Model* model)
29 {
30  urdf::Pose transform_pose;
31  if(model)
32  {
33  urdf::JointConstSharedPtr joint(model->getJoint(joint_name));
34  if (!joint)
35  {
36  ROS_ERROR_STREAM(joint_name
37  << " couldn't be retrieved from model description");
38  return false;
39  }
40 
41  transform_pose.position = joint->parent_to_joint_origin_transform.position;
42  transform_pose.rotation = joint->parent_to_joint_origin_transform.rotation;
43  while(joint->parent_link_name != parent_link_name)
44  {
45  urdf::LinkConstSharedPtr link_parent(model->getLink(joint->parent_link_name));
46  if (!link_parent || !link_parent->parent_joint)
47  {
48  ROS_ERROR_STREAM(joint->parent_link_name
49  << " couldn't be retrieved from model description or his parent joint");
50  return false;
51  }
52  joint = link_parent->parent_joint;
53  transform_pose.position = transform_pose.position + joint->parent_to_joint_origin_transform.position;
54  transform_pose.rotation = transform_pose.rotation * joint->parent_to_joint_origin_transform.rotation;
55  }
56 
57  tf2::Transform rot(tf2::Quaternion(transform_pose.rotation.x,transform_pose.rotation.y,transform_pose.rotation.z,transform_pose.rotation.w),
58  tf2::Vector3(0,0,0));
59 
60  tf2::Transform trans; trans.setIdentity();
61  trans.setOrigin(tf2::Vector3(transform_pose.position.x,transform_pose.position.y,transform_pose.position.z));
62 
63  transform.setIdentity();
64  transform = rot * trans;
65  return true;
66  }
67  else
68  return false;
69 }
70 
71 #endif // COB_OMNI_DRIVE_CONTROLLER_PARAM_PARSER_H
void setIdentity()
bool parseWheelTransform(const std::string &joint_name, const std::string &parent_link_name, tf2::Transform &transform, urdf::Model *model)
Definition: param_parser.h:27
TF2SIMD_FORCE_INLINE void setOrigin(const Vector3 &origin)
#define ROS_ERROR_STREAM(args)


cob_omni_drive_controller
Author(s): Christian Connette, Mathias Lüdtke
autogenerated on Thu Apr 8 2021 02:39:52