10
10
#include " sco/modeling_utils.hpp"
11
11
#include " utils/stl_to_string.hpp"
12
12
#include " utils/logging.hpp"
13
+ #include < boost/functional/hash.hpp>
13
14
using namespace OpenRAVE ;
14
15
using namespace sco ;
15
16
using namespace util ;
@@ -68,7 +69,6 @@ void CollisionsToDistanceExpressions(const vector<Collision>& collisions, Config
68
69
CollisionsToDistanceExpressions (collisions, rad, link2ind, vars1, vals1, exprs1,true );
69
70
70
71
exprs.resize (exprs0.size ());
71
-
72
72
for (int i=0 ; i < exprs0.size (); ++i) {
73
73
exprScale (exprs0[i], (1 -collisions[i].time ));
74
74
exprScale (exprs1[i], collisions[i].time );
@@ -79,8 +79,12 @@ void CollisionsToDistanceExpressions(const vector<Collision>& collisions, Config
79
79
}
80
80
}
81
81
82
+ inline size_t hash (const DblVec& x) {
83
+ return boost::hash_range (x.begin (), x.end ());
84
+ }
85
+
82
86
void CollisionEvaluator::GetCollisionsCached (const DblVec& x, vector<Collision>& collisions) {
83
- double key = getVec ( x, GetVars ()). sum ( );
87
+ double key = hash ( getDblVec ( x, GetVars ()));
84
88
vector<Collision>* it = m_cache.get (key);
85
89
if (it != NULL ) {
86
90
LOG_DEBUG (" using cached collision check\n " );
@@ -181,7 +185,11 @@ void PlotCollisions(const std::vector<Collision>& collisions, OR::EnvironmentBas
181
185
if (col.distance < 0 ) color = RaveVectorf (1 ,0 ,0 ,1 );
182
186
else if (col.distance < safe_dist) color = RaveVectorf (1 ,1 ,0 ,1 );
183
187
else color = RaveVectorf (0 ,1 ,0 ,1 );
184
- handles.push_back (env.drawarrow (col.ptA , col.ptB , .0025 , color));
188
+ if (col.cctype == CCType_Between) {
189
+ handles.push_back (env.drawarrow (col.ptB , col.ptB1 , .002 , RaveVectorf (0 ,0 ,0 ,1 )));
190
+ }
191
+ OR::Vector ptB = (col.cctype == CCType_Between) ? ((1 -col.time )* col.ptB +col.time *col.ptB1 ) : col.ptB ;
192
+ handles.push_back (env.drawarrow (col.ptA , ptB, .0025 , color));
185
193
}
186
194
}
187
195
0 commit comments