<commit_before>/*
 * Laser.cpp
 *
 *  Created on: May 27, 2014
 *      Author: user
 */

#include "Laser.h"

double Laser::convertIndexToDegree(int index) const
{
	return (index * LASER_RESOLUTION) - LASER_MESURING_AREA;
}

int Laser::convertDegreeToIndex(double degree) const
{
	return (degree + LASER_MESURING_AREA) / LASER_RESOLUTION;
}

void Laser::getObstacles(double x, double y, double yaw, vector<Point>& obstacles) const
{
	// Clear the data structure
	obstacles.clear();

	for (unsigned int index = 0; index < _laserProxy.GetCount(); index++)
	{
		double distance = _laserProxy[index];

		// If the laser cannot seet an obstacle
		if (distance >= LASER_MAXIMUM_RANGE)
		{
			// let's move to the next sample
			continue;
		}

		double indexDegree = convertIndexToDegree(index);
		double indexRadian = MathHelper::ConvertDegreeToRadian(indexDegree);

		double obstacleRadian = indexRadian + yaw;

		double obstacleX = distance * cos(obstacleRadian) + x;
		double obstacleY = distance * sin(obstacleRadian) + y;

		Point point(obstacleX, obstacleY);

		obstacles.push_back(point);
	}
}

void Laser::getObstacles(vector<Point>& obstacles) const
{
	getObstacles(_robot.getX(), _robot.getY(), _robot.getYaw(), obstacles);
}

bool Laser::canRotate() const
{

	double minRotationDistance = LASER_MIN_ROTATION_DISTANCE;

	bool canRotate = true;

	for (unsigned int index = 0; index < _laserProxy.GetCount(); index++)
	{
		double distance = _laserProxy[index];

		if (distance < minRotationDistance)
		{
			canRotate = false;
			break;
		}
	}

	return canRotate;
}

bool Laser::canMoveForward() const
{
	double minForwardDistance = LASER_MIN_FORWARD_DISTANCE;

	bool canMoveForward = true;
	for (unsigned int index = LASER_MIN_FORWARD_START_INDEX; index < LASER_MIN_FORWARD_END_INDEX; index++)
	{
		double distance = _laserProxy[index];

		if (distance < minForwardDistance)
		{
			canMoveForward = false;
			break;
		}
	}

	return canMoveForward;
}

void Laser::updateMap(Map& map) const
{

}
<commit_msg>add funcion to calc rank for each side<commit_after>/*
 * Laser.cpp
 *
 *  Created on: May 27, 2014
 *      Author: user
 */

#include "Laser.h"

double Laser::convertIndexToDegree(int index) const
{
	return (index * LASER_RESOLUTION) - LASER_MESURING_AREA;
}

int Laser::convertDegreeToIndex(double degree) const
{
	return (degree + LASER_MESURING_AREA) / LASER_RESOLUTION;
}

void Laser::getObstacles(double x, double y, double yaw, vector<Point>& obstacles) const
{
	// Clear the data structure
	obstacles.clear();

	for (unsigned int index = 0; index < _laserProxy.GetCount(); index++)
	{
		double distance = _laserProxy[index];

		// If the laser cannot seet an obstacle
		if (distance >= LASER_MAXIMUM_RANGE)
		{
			// let's move to the next sample
			continue;
		}

		double indexDegree = convertIndexToDegree(index);
		double indexRadian = MathHelper::ConvertDegreeToRadian(indexDegree);

		double obstacleRadian = indexRadian + yaw;

		double obstacleX = distance * cos(obstacleRadian) + x;
		double obstacleY = distance * sin(obstacleRadian) + y;

		Point point(obstacleX, obstacleY);

		obstacles.push_back(point);
	}
}

void Laser::getObstacles(vector<Point>& obstacles) const
{
	getObstacles(_robot.getX(), _robot.getY(), _robot.getYaw(), obstacles);
}

bool Laser::canRotate() const
{

	double minRotationDistance = LASER_MIN_ROTATION_DISTANCE;

	bool canRotate = true;

	for (unsigned int index = 0; index < _laserProxy.GetCount(); index++)
	{
		double distance = _laserProxy[index];

		if (distance < minRotationDistance)
		{
			canRotate = false;
			break;
		}
	}

	return canRotate;
}

bool Laser::canMoveForward() const
{
	double minForwardDistance = LASER_MIN_FORWARD_DISTANCE;

	bool canMoveForward = true;
	for (unsigned int index = LASER_MIN_FORWARD_START_INDEX; index < LASER_MIN_FORWARD_END_INDEX; index++)
	{
		double distance = _laserProxy[index];

		if (distance < minForwardDistance)
		{
			canMoveForward = false;
			break;
		}
	}

	return canMoveForward;
}

double Laser::GetRightRank() const
{
	double ret = 0;

	for (unsigned int index = LASER_MIN_FORWARD_END_INDEX; index < LASER_ARRAY_SIZE; index += 10)
	{
		ret += _laserProxy[index];
	}

	return ret;
}

double Laser::GetLeftRank() const
{
	double ret = 0;

	for (unsigned int index = 0; index < LASER_MIN_FORWARD_START_INDEX; index += 10)
	{
		ret += _laserProxy[index];
	}

	return ret;

}


{'fraction_non_alphanumeric': 0.11009801686801915, 'fraction_numerical': 0.005242762708000912, 'mean_word_length': 4.498746867167919, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2414775', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1548, 'n_words': 367}