kinfam_io.cpp
Go to the documentation of this file.
1 // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
2 
3 // Version: 1.0
4 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
5 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
6 // URL: http://www.orocos.org/kdl
7 
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #include "kinfam_io.hpp"
23 #include "frames_io.hpp"
24 #include <sstream>
25 
26 namespace KDL {
27 std::ostream& operator <<(std::ostream& os, const Joint& joint) {
28  return os << joint.getName()<<":["<<joint.getTypeName()
29  <<", axis: "<<joint.JointAxis() << ", origin"<<joint.JointOrigin()<<"]";
30 }
31 
32 std::istream& operator >>(std::istream& is, Joint& joint) {
33  return is;
34 }
35 
36 std::ostream& operator <<(std::ostream& os, const Segment& segment) {
37  os << segment.getName()<<":[" << segment.getJoint() << ",\n tip: \n" << segment.getFrameToTip() << "]";
38  return os;
39 }
40 
41 std::istream& operator >>(std::istream& is, Segment& segment) {
42  return is;
43 }
44 
45 std::ostream& operator <<(std::ostream& os, const Chain& chain) {
46  os << "[";
47  for (unsigned int i = 0; i < chain.getNrOfSegments(); i++)
48  os << chain.getSegment(i) << "\n";
49  os << "]";
50  return os;
51 }
52 
53 std::istream& operator >>(std::istream& is, Chain& chain) {
54  return is;
55 }
56 
57 std::ostream& operator <<(std::ostream& os, const Tree& tree) {
58  SegmentMap::const_iterator root = tree.getRootSegment();
59  return os << root;
60 }
61 
62 std::ostream& operator <<(std::ostream& os, SegmentMap::const_iterator root) {
63  //os<<root->first<<": "<<root->second.segment<<"\n";
64  os << root->first<<"(q_nr: "<< GetTreeElementQNr(root->second) << ")" << "\n \t";
65  for (unsigned int i = 0; i < GetTreeElementChildren(root->second).size(); i++) {
66  os << ( GetTreeElementChildren(root->second)[i] ) << "\t";
67  }
68  return os << "\n";
69 }
70 
71 std::istream& operator >>(std::istream& is, Tree& tree) {
72  return is;
73 }
74 
75 std::ostream& operator <<(std::ostream& os, const JntArray& array) {
76  os << "[";
77  for (unsigned int i = 0; i < array.rows(); i++)
78  os << std::setw(KDL_FRAME_WIDTH) << array(i);
79  os << "]";
80  return os;
81 }
82 
83 std::istream& operator >>(std::istream& is, JntArray& array) {
84  return is;
85 }
86 
87 std::ostream& operator <<(std::ostream& os, const Jacobian& jac) {
88  os << "[";
89  for (unsigned int i = 0; i < jac.rows(); i++) {
90  for (unsigned int j = 0; j < jac.columns(); j++)
91  os << std::setw(KDL_FRAME_WIDTH) << jac(i, j);
92  os << std::endl;
93  }
94  os << "]";
95  return os;
96 }
97 
98 std::istream& operator >>(std::istream& is, Jacobian& jac) {
99  return is;
100 }
101 std::ostream& operator <<(std::ostream& os, const JntSpaceInertiaMatrix& jntspaceinertiamatrix) {
102  os << "[";
103  for (unsigned int i = 0; i < jntspaceinertiamatrix.rows(); i++) {
104  for (unsigned int j = 0; j < jntspaceinertiamatrix.columns(); j++)
105  os << std::setw(KDL_FRAME_WIDTH) << jntspaceinertiamatrix(i, j);
106  os << std::endl;
107  }
108  os << "]";
109  return os;
110 }
111 
112 std::istream& operator >>(std::istream& is, JntSpaceInertiaMatrix& jntspaceinertiamatrix) {
113  return is;
114 }
115 
116 
117 std::string tree2str(const SegmentMap::const_iterator it, const std::string& separator, const std::string& preamble, unsigned int level) {
118  std::stringstream out;
119  out << preamble;
120  for(unsigned int i=0; i<level; i++)
121  out << separator;
122  out << it->first << "(q_nr: " << GetTreeElementQNr(it->second) << ")\n";
123  for (unsigned int i = 0; i < GetTreeElementChildren(it->second).size(); i++)
124  out << tree2str(GetTreeElementChildren(it->second)[i], separator, preamble, level+1);
125  return out.str();
126 }
127 
128 std::string tree2str(const Tree& tree, const std::string& separator, const std::string& preamble) {
129  return tree2str(tree.getRootSegment(), separator, preamble, 0);
130 }
131 
132 }
const Segment & getSegment(unsigned int nr) const
Definition: chain.cpp:68
This class encapsulates a simple segment, that is a "rigid body" (i.e., a frame and a rigid body...
Definition: segment.hpp:46
unsigned int rows() const
Definition: jntarray.cpp:72
#define GetTreeElementQNr(tree_element)
Definition: tree.hpp:61
This class encapsulates a serial kinematic interconnection structure. It is built out of segments...
Definition: chain.hpp:35
std::istream & operator>>(std::istream &is, Vector &v)
Definition: frames_io.cpp:129
unsigned int getNrOfSegments() const
Definition: chain.hpp:76
This class represents an fixed size array containing joint values of a KDL::Chain.
Definition: jntarray.hpp:69
Frame getFrameToTip() const
Definition: segment.hpp:149
#define KDL_FRAME_WIDTH
Definition: kdl-config.h:27
std::string tree2str(const SegmentMap::const_iterator it, const std::string &separator, const std::string &preamble, unsigned int level)
Definition: kinfam_io.cpp:117
std::ostream & operator<<(std::ostream &os, const VectorAcc &r)
Definition: frameacc_io.hpp:32
#define GetTreeElementChildren(tree_element)
Definition: tree.hpp:59
unsigned int columns() const
Definition: jacobian.cpp:76
Vector JointOrigin() const
Definition: joint.cpp:157
const std::string & getName() const
Definition: joint.hpp:150
const std::string & getName() const
Definition: segment.hpp:108
const Joint & getJoint() const
Definition: segment.hpp:118
SegmentMap::const_iterator getRootSegment() const
Definition: tree.hpp:186
This class encapsulates a simple joint, that is with one parameterized degree of freedom and with sca...
Definition: joint.hpp:45
const std::string getTypeName() const
Definition: joint.hpp:169
Vector JointAxis() const
Definition: joint.cpp:131
This class encapsulates a tree kinematic interconnection structure. It is built out of segments...
Definition: tree.hpp:99
unsigned int rows() const
Definition: jacobian.cpp:71


orocos_kdl
Author(s):
autogenerated on Fri Mar 12 2021 03:05:43