Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to light sensor: wrong id bug. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace argos {

static CRange<Real> SENSOR_RANGE(0.0f, 1.0f);
static CRadians SENSOR_SPACING = CRadians(ARGOS_PI / 12.0f);
static CRadians SENSOR_HALF_SPACING = SENSOR_SPACING * 0.5;

/****************************************/
/****************************************/
Expand Down Expand Up @@ -157,16 +158,17 @@ namespace argos {
* Division says how many sensor spacings there are between first sensor and point at which ray hits kheperaiv body
* Increase magnitude of result of division to ensure correct rounding
*/
Real fIdx = cAngleLightWrtRobot / SENSOR_SPACING;
Real fIdx = (cAngleLightWrtRobot) / SENSOR_SPACING;
SInt32 nReadingIdx = (fIdx > 0) ? fIdx + 0.5f : fIdx - 0.5f;

/* Set the actual readings */
Real fReading = cRobotToLight.Length();
/*
* Take 2 readings before closest sensor and 2 readings after - thus we
* Take 6 readings before closest sensor and 6 readings after - thus we
* process sensors that are with 180 degrees of intersection of light
* ray with robot body
*/
for(SInt32 nIndexOffset = -2; nIndexOffset < 3; ++nIndexOffset) {
for(SInt32 nIndexOffset = -4; nIndexOffset < 5; ++nIndexOffset) {
UInt32 unIdx = Modulo(nReadingIdx + nIndexOffset, 8);
CRadians cAngularDistanceFromOptimalLightReceptionPoint = Abs((cAngleLightWrtRobot - m_tReadings[unIdx].Angle).SignedNormalize());
/*
Expand All @@ -175,7 +177,8 @@ namespace argos {
* 0) to 0 (dist PI/2)
*/
m_tReadings[unIdx].Value += ComputeReading(fReading) * ScaleReading(cAngularDistanceFromOptimalLightReceptionPoint);
}
}

}
else {
/* The ray is occluded */
Expand Down