63 double maxSensorRangeLandmarks = 2.5 * stepLen;
65 int landMarksPerSquareMeter = 1;
66 double observationProb = 0.8;
68 int landmarksRange = 2;
70 Vector2d transNoise(0.05, 0.01);
72 Vector2d landmarkNoise(0.05, 0.05);
74 Vector2d bound(boundArea, boundArea);
77 probLimits.resize(MO_NUM_ELEMS);
78 for (
int i = 0; i < probLimits.size(); ++i)
79 probLimits[i] = (i + 1) / (double)MO_NUM_ELEMS;
83 covariance(0, 0) = transNoise[0] * transNoise[0];
84 covariance(1, 1) = transNoise[1] * transNoise[1];
85 covariance(2, 2) = rotNoise * rotNoise;
86 Matrix3d information = covariance.inverse();
88 SE2 maxStepTransf(stepLen * steps, 0, 0);
97 poses.push_back(firstPose);
98 cerr <<
"Simulator: sampling nodes ...";
99 while ((
int)
poses.size() < numNodes) {
101 for (
int i = 1; i < steps && (int)
poses.size() < numNodes; ++i) {
103 poses.back(),
SE2(stepLen, 0, 0), transNoise, rotNoise);
104 poses.push_back(nextGridPose);
106 if ((
int)
poses.size() == numNodes)
break;
110 int motionDirection = 0;
111 while (probLimits[motionDirection] < sampleMove &&
112 motionDirection + 1 < MO_NUM_ELEMS) {
116 SE2 nextMotionStep =
getMotion(motionDirection, stepLen);
121 SE2 nextStepFinalPose = nextGridPose.
truePose * maxStepTransf;
122 if (fabs(nextStepFinalPose.
translation().x()) >= bound[0] ||
123 fabs(nextStepFinalPose.
translation().y()) >= bound[1]) {
126 for (
int i = 0; i < MO_NUM_ELEMS; ++i) {
130 nextStepFinalPose = nextGridPose.
truePose * maxStepTransf;
131 if (fabs(nextStepFinalPose.
translation().x()) < bound[0] &&
132 fabs(nextStepFinalPose.
translation().y()) < bound[1])
137 poses.push_back(nextGridPose);
139 cerr <<
"done." << endl;
142 cerr <<
"Simulator: Creating landmarks ... ";
144 for (PosesVector::const_iterator it =
poses.begin(); it !=
poses.end();
146 int ccx = (int)round(it->truePose.translation().x());
147 int ccy = (int)round(it->truePose.translation().y());
148 for (
int a = -landmarksRange; a <= landmarksRange; a++)
149 for (
int b = -landmarksRange; b <= landmarksRange; b++) {
153 if (landmarksForCell.size() == 0) {
154 for (
int i = 0; i < landMarksPerSquareMeter; ++i) {
160 }
while (
hypot_sqr(offx, offy) < 0.25 * 0.25);
163 landmarksForCell.push_back(l);
168 cerr <<
"done." << endl;
170 cerr <<
"Simulator: Simulating landmark observations for the poses ... ";
171 double maxSensorSqr = maxSensorRangeLandmarks * maxSensorRangeLandmarks;
173 for (PosesVector::iterator it =
poses.begin(); it !=
poses.end(); ++it) {
175 int cx = (int)round(it->truePose.translation().x());
176 int cy = (int)round(it->truePose.translation().y());
177 int numGridCells = (int)(maxSensorRangeLandmarks) + 1;
182 for (
int xx = cx - numGridCells; xx <= cx + numGridCells; ++xx)
183 for (
int yy = cy - numGridCells; yy <= cy + numGridCells; ++yy) {
185 if (landmarksForCell.size() == 0)
continue;
186 for (
size_t i = 0; i < landmarksForCell.size(); ++i) {
191 if (dSqr > maxSensorSqr)
continue;
193 if (obs > observationProb)
195 if (l->
id < 0) l->
id = globalId++;
196 if (l->
seenBy.size() == 0) {
197 Vector2d trueObservation = trueInv * l->
truePose;
198 Vector2d observation = trueObservation;
208 cerr <<
"done." << endl;
212 cerr <<
"Simulator: Adding odometry measurements ... ";
213 for (
size_t i = 1; i <
poses.size(); ++i) {
226 cerr <<
"done." << endl;
232 cerr <<
"Simulator: add landmark observations ... ";
235 covariance(0, 0) = landmarkNoise[0] * landmarkNoise[0];
236 covariance(1, 1) = landmarkNoise[1] * landmarkNoise[1];
237 Matrix2d information = covariance.inverse();
239 for (
size_t i = 0; i <
poses.size(); ++i) {
241 for (
size_t j = 0; j < p.
landmarks.size(); ++j) {
249 for (
size_t i = 0; i <
poses.size(); ++i) {
251 SE2 trueInv = (p.
truePose * sensorOffset).inverse();
252 for (
size_t j = 0; j < p.
landmarks.size(); ++j) {
254 Vector2d observation;
255 Vector2d trueObservation = trueInv * l->
truePose;
256 observation = trueObservation;
257 if (l->
seenBy.size() > 0 &&
278 cerr <<
"done." << endl;
282 for (LandmarkGrid::iterator it = grid.begin(); it != grid.end(); ++it) {
283 for (std::map<int, Simulator::LandmarkPtrVector>::iterator itt =
285 itt != it->second.end(); ++itt) {