void ControlReplannerJulian::compute(void)
{
	if(leftObstacle && !rightObstacle)	//turn right
		newPoint=getRightPoint();
	else if (rightObstacle && !leftObstacle)	//turn left
		newPoint=getLeftPoint();
	else if	(!rightObstacle && !leftObstacle)//choose the best option left/right
	{
		if(minLeftRange<minRightRange)//turn right
			newPoint=getRightPoint();
		else
			newPoint=getLeftPoint();
	}
	else
		LOG_ERROR("ERROR: Robot stucked! ");
}
Пример #2
0
void GLWidget::mousePressEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton ) {
        QPointF clickedPoint = transformPosition(event->pos());

        if (getFirstPoint) {
            getFirstPoint = false;
            lastPoint = clickedPoint;
        } else {
            getFirstPoint = true;

            std::shared_ptr<IsoSegment> isoSeg;

            if (isHorizontalSegment(lastPoint, clickedPoint)) {
                // Horizontal: Gleiche Y-Position an
                clickedPoint.ry() = lastPoint.ry();

                QPointF leftPoint = getLeftPoint(clickedPoint, lastPoint);
                QPointF rightPoint = getRightPoint(clickedPoint, lastPoint);

                // ISO-Segment auf dem Heap-Speicher erstellen
                isoSeg = std::make_shared<IsoSegment>(leftPoint, rightPoint);

                // Start- und End-Event in Vector einfügen
                events.push_back(Event(leftPoint.rx (), START_EVENT, isoSeg));
                events.push_back(Event(rightPoint.rx(), END_EVENT  , isoSeg));
            } else {
                // Vertikal: Gleiche X-Position an
                clickedPoint.rx() = lastPoint.rx();

                // ISO-Segment auf dem Heap-Speicher erstellen
                isoSeg = std::make_shared<IsoSegment>(lastPoint, clickedPoint);
                events.push_back(Event(clickedPoint.rx(), VERTICAL, isoSeg));
            }

            segments.push_back(isoSeg);
        }
        points.push_back(clickedPoint);
    }

    update();
}