Go to the documentation of this file.00001
00060 template<typename NODE>
00061 void Path<NODE>::startFrame(const double time_in_sec)
00062 {
00063 act_ctxt_.clear();
00064
00065 local_.link_.setTime(time_in_sec);
00066 last_time_ = time_in_sec;
00067 }
00068
00069 template<typename NODE>
00070 void Path<NODE>::operator+=(typename OBJECT::Ptr obj)
00071 {
00072 act_ctxt_ += obj;
00073
00074
00075
00076 }
00077
00078 template<typename NODE>
00079 void Path<NODE>::finishFrame()
00080 {
00081
00082
00083
00084
00085 {
00086 std::map<typename OBJECT::Ptr,bool> used;
00087 std::map<const NODE*,bool> visited_list;
00088 std::cout<<"LINK BEF123\n"<<local_.link_;
00089 local_.node_->compute(act_ctxt_, local_.link_, used, visited_list);
00090 std::cout<<"LINK AFT123\n"<<local_.link_;
00091 }
00092
00093 if(needNewNode()) {
00094 const SWAY<NODE> * add = NULL;
00095 DOF6 l;
00096
00097 for(size_t i=0; i<local_.node_->getConnections().size(); i++)
00098 {
00099
00100
00101
00102 if(!getTF(l, &local_.node_->getConnections()[i], &local_))
00103 continue;
00104
00105 std::cout<<"CHECKING LINK\n"<<l<<"\n";
00106
00107 l = l+local_.link_;
00108
00109 std::cout<<"CHECKING LINK\n"<<l<<"\n";
00110
00111 if(
00112
00113 l.getTranslation().norm() + l.getTranslationVariance() < translation_res_
00114 &&
00115
00116 l.getRotation().norm() + l.getRotationVariance() < rotation_res_
00117 )
00118 {
00119 add = &local_.node_->getConnections()[i];
00120 break;
00121 }
00122 }
00123
00124 if(add)
00125 {
00126
00127 ROS_INFO("reuse node");
00128
00129
00130 path_.push_back(local_);
00131
00132 std::cout<<"REUSED LINK\n"<<l<<"\n";
00133
00134 local_ = *add;
00135 local_.link_.deepCopy(l);
00136
00137
00138
00139
00140
00141
00142
00143 local_.node_->addLink(path_.back());
00144 }
00145 else
00146 {
00147
00148
00149
00150 path_.push_back(local_);
00151
00152
00153 newNode();
00154 local_.link_.setTime(last_time_);
00155
00156
00157 local_.node_->addLink(path_.back());
00158
00159
00160
00161
00162 ROS_INFO("new node %d", local_.id_);
00163 }
00164 }
00165 else
00166 {
00167 ROS_INFO("no new node");
00168
00169
00170 }
00171
00172 }
00173
00174 template<typename NODE>
00175 bool Path<NODE>::getTF(DOF6 &tf, const SWAY<NODE> *start, const SWAY<NODE> *end)
00176 {
00177 if(start->id_<end->id_)
00178 {
00179 bool r = getTF(tf,end,start);
00180 tf.transpose();
00181 return r;
00182 }
00183
00184 ROS_INFO("IDSSSS %d %d", start->id_, end->id_);
00185
00186 if(start->id_!=end->id_)
00187 {
00188 for(size_t i=0; i<start->node_->getConnections().size(); i++)
00189 {
00190 if(start->node_->getConnections()[i].id_==end->id_)
00191 {
00192 tf.deepCopy(start->node_->getConnections()[i].link_);
00193 std::cout<<"SET LINK\n"<<tf<<"\n";
00194 return true;
00195 }
00196 else if(getTF(tf, &start->node_->getConnections()[i], end)) {
00197 tf = tf + start->node_->getConnections()[i].link_;
00198 std::cout<<"ADD LINK\n"<<start->node_->getConnections()[i].link_<<"\n";
00199 std::cout<<"NEW LINK\n"<<tf<<"\n";
00200 return true;
00201 }
00202 }
00203 }
00204
00205 return false;
00206 }
00207
00208
00209 template<typename NODE>
00210 void Path<NODE>::test() {
00211 Eigen::Matrix4f M = Eigen::Matrix4f::Identity();
00212 Eigen::AngleAxisf aa(1,Eigen::Vector3f::Identity());
00213
00214 M.topLeftCorner(3,3) = aa.toRotationMatrix();
00215 M.col(3).head<3>() = Eigen::Vector3f::Identity();
00216
00217 local_.link_.setVariance(
00218 0,
00219 M.col(3).head<3>(),
00220 0,
00221 (typename DOF6::TROTATION)(M.topLeftCorner(3,3)));
00222
00223
00224 path_.push_back(local_);
00225
00226
00227 newNode();
00228 local_.link_.setTime(last_time_);
00229
00230
00231 local_.node_->addLink(path_.back());
00232
00233
00234 M = M.inverse().eval();
00235 local_.link_.setVariance(
00236 0,
00237 M.col(3).head<3>(),
00238 0,
00239 (typename DOF6::TROTATION)(M.topLeftCorner(3,3)));
00240
00241
00242 const SWAY<NODE> * add = NULL;
00243 DOF6 l;
00244
00245 for(size_t i=0; i<local_.node_->getConnections().size(); i++)
00246 {
00247
00248
00249
00250 if(!getTF(l, &local_.node_->getConnections()[i], &local_))
00251 continue;
00252
00253 std::cout<<"CHECKING LINK\n"<<l<<"\n";
00254
00255 l = l+local_.link_;
00256
00257 std::cout<<"CHECKING LINK\n"<<l<<"\n";
00258
00259 if(
00260
00261 l.getTranslation().norm() + l.getTranslationVariance() < translation_res_
00262 &&
00263
00264 l.getRotation().norm() + l.getRotationVariance() < rotation_res_
00265 )
00266 {
00267 add = &local_.node_->getConnections()[i];
00268 break;
00269 }
00270 }
00271
00272 if(add)
00273 {
00274
00275 ROS_INFO("reuse node");
00276
00277
00278 path_.push_back(local_);
00279
00280 std::cout<<"REUSED LINK\n"<<l<<"\n";
00281
00282 local_ = *add;
00283 local_.link_.deepCopy(l);
00284
00285
00286
00287
00288
00289
00290
00291 local_.node_->addLink(path_.back());
00292 }
00293 else
00294 {
00295
00296
00297
00298 path_.push_back(local_);
00299
00300
00301 newNode();
00302 local_.link_.setTime(last_time_);
00303
00304
00305 local_.node_->addLink(path_.back());
00306
00307
00308
00309
00310 ROS_INFO("new node %d", local_.id_);
00311 }
00312 }