KDL Tree.NrOfSegments() and SegmentMap.size() disagreement
Submitted by earldarrenj on Wed, 2012-11-28 18:23 |
I've noticed that in the Class Tree that the NrOfSegments() function reports one less segment than is in the SegmentMap segment member variable--presumably the root is not included in the count of segments. The cause is in the constructor (Tree.cpp):
Tree::Tree(const std::string& _root_name) :
nrOfSegments(0), nrOfJoints(0),root_name(_root_name) {
segments.insert(make_pair(root_name, TreeElement::Root(root_name)));
}
Tree::Tree(const Tree& in) {
segments.clear();
nrOfSegments = 0;
nrOfJoints = 0;
root_name = in.root_name;
segments.insert(make_pair(root_name, TreeElement::Root(root_name)));
this->addTree(in, root_name);
}
nrOfSegments is initialized to zero but the root is inserted into segments. Is this intended behaviour? Class Chain seems to count all segments including the root segment, and I found this discrepancy surprising (and a source of a bug in my own program).
KDL Tree.NrOfSegments() and SegmentMap.size() disagreement
On 11/28/2012 07:23 PM, earl, darren j wrote:
> I've noticed that in the Class Tree that the NrOfSegments() function reports one less segment than is in the SegmentMap segment member variable--presumably the root is not included in the count of segments. The cause is in the constructor (Tree.cpp):
>
> Tree::Tree(const std::string& _root_name) :
> nrOfSegments(0), nrOfJoints(0),root_name(_root_name) {
> segments.insert(make_pair(root_name, TreeElement::Root(root_name)));
> }
>
> Tree::Tree(const Tree& in) {
> segments.clear();
> nrOfSegments = 0;
> nrOfJoints = 0;
> root_name = in.root_name;
>
> segments.insert(make_pair(root_name, TreeElement::Root(root_name)));
> this->addTree(in, root_name);
> }
>
>
> nrOfSegments is initialized to zero but the root is inserted into segments. Is this intended behaviour? Class Chain seems to count all segments including the root segment, and I found this discrepancy surprising (and a source of a bug in my own program).
there are indeed some inconsistencies,
we refactored this part of the code that solves this problem
Erwin, is this code available? if yes, where?
nick
KDL Tree.NrOfSegments() and SegmentMap.size() disagreement
Op 28/11/2012 21:47, Dominick Vanthienen schreef:
>
> On 11/28/2012 07:23 PM, earl, darren j wrote:
>> I've noticed that in the Class Tree that the NrOfSegments() function reports one less segment than is in the SegmentMap segment member variable--presumably the root is not included in the count of segments. The cause is in the constructor (Tree.cpp):
>>
>> Tree::Tree(const std::string& _root_name) :
>> nrOfSegments(0), nrOfJoints(0),root_name(_root_name) {
>> segments.insert(make_pair(root_name, TreeElement::Root(root_name)));
>> }
>>
>> Tree::Tree(const Tree& in) {
>> segments.clear();
>> nrOfSegments = 0;
>> nrOfJoints = 0;
>> root_name = in.root_name;
>>
>> segments.insert(make_pair(root_name, TreeElement::Root(root_name)));
>> this->addTree(in, root_name);
>> }
>>
>>
>> nrOfSegments is initialized to zero but the root is inserted into segments. Is this intended behaviour? Class Chain seems to count all segments including the root segment, and I found this discrepancy surprising (and a source of a bug in my own program).
> there are indeed some inconsistencies,
> we refactored this part of the code that solves this problem
> Erwin, is this code available? if yes, where?
ow... This is on our (currently private) branch containing our research
experiments on expression trees.
Nick, you'll find it on the expression tree repository I talked about in
todays meeting (cfr. report of the meeting).
I'm not that familiar with the Tree class, could you transfer this part
to the main branch ? ( the files involving Tree).
> (
>
> nick
>
KDL Tree.NrOfSegments() and SegmentMap.size() disagreement
Seems like a bug; submitted report 1011.