File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,13 @@ void ForagingTwoSpotsLoopFunction::PostStep() {
101
101
UInt32 unId;
102
102
for (CSpace::TMapPerType::iterator it = tEpuckMap.begin (); it != tEpuckMap.end (); ++it) {
103
103
CEPuckEntity* pcEpuck = any_cast<CEPuckEntity*>(it->second );
104
- unId = atoi (pcEpuck->GetId ().substr (5 , 2 ).c_str ());
104
+ // unId = atoi(pcEpuck->GetId().substr(5, 2).c_str());
105
+ // expects the id to be in the following form: epuck_{unId}_{robotId}
106
+ std::string robot_id = pcEpuck->GetId ();
107
+ UInt8 first_underscore = robot_id.find (" _" );
108
+ UInt8 second_underscore = robot_id.find (" _" , first_underscore+1 );
109
+ robot_id = robot_id.substr (first_underscore, second_underscore-first_underscore);
110
+ unId = atoi (robot_id.c_str ());
105
111
cEpuckPosition.Set (pcEpuck->GetEmbodiedEntity ().GetOriginAnchor ().Position .GetX (),
106
112
pcEpuck->GetEmbodiedEntity ().GetOriginAnchor ().Position .GetY ());
107
113
@@ -114,9 +120,9 @@ void ForagingTwoSpotsLoopFunction::PostStep() {
114
120
} else if (cEpuckPosition.GetY () <= m_fNestLimit) {
115
121
m_fObjectiveFunction = m_fObjectiveFunction + m_punFoodData[unId];
116
122
m_punFoodData[unId] = 0 ;
123
+ // LOG << "Obj " << m_fObjectiveFunction << std::endl;
117
124
}
118
125
}
119
- // LOG << "Obj " << m_fObjectiveFunction << std::endl;
120
126
}
121
127
122
128
/* ***************************************/
You can’t perform that action at this time.
0 commit comments