From 2aa5cf4bcb23cc892a67e7491c1f492307b9f1d7 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 18 Jan 2011 13:23:14 +0100 Subject: [PATCH] robomon: Whitespace fixes --- src/robomon/RobomonAtlantis.cpp | 144 ++++++++++++++++---------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/src/robomon/RobomonAtlantis.cpp b/src/robomon/RobomonAtlantis.cpp index 49ddb685..246dbaef 100644 --- a/src/robomon/RobomonAtlantis.cpp +++ b/src/robomon/RobomonAtlantis.cpp @@ -80,7 +80,7 @@ RobomonAtlantis::RobomonAtlantis(QWidget *parent) void RobomonAtlantis::createLeftLayout() { leftLayout = new QVBoxLayout(); - + createDebugGroupBox(); debugWindowEnabled = true; createPlaygroundGroupBox(); @@ -91,7 +91,7 @@ void RobomonAtlantis::createLeftLayout() void RobomonAtlantis::createRightLayout() { rightLayout = new QVBoxLayout(); - + createPositionGroupBox(); createMiscGroupBox(); createFSMGroupBox(); @@ -128,7 +128,7 @@ void RobomonAtlantis::createPositionGroupBox() positionGroupBox = new QGroupBox(tr("Position state")); positionGroupBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); QGridLayout *layout = new QGridLayout(); - + actPosX = new QLineEdit(); actPosY = new QLineEdit(); actPosPhi = new QLineEdit(); @@ -136,7 +136,7 @@ void RobomonAtlantis::createPositionGroupBox() estPosX = new QLineEdit(); estPosY = new QLineEdit(); estPosPhi = new QLineEdit(); - + actPosX->setReadOnly(true); actPosY->setReadOnly(true); actPosPhi->setReadOnly(true); @@ -178,10 +178,10 @@ void RobomonAtlantis::createMiscGroupBox() startPlug = new QCheckBox("&Start plug"); layout->addWidget(startPlug); - + colorChoser = new QCheckBox("&Team color"); layout->addWidget(colorChoser); - + miscGroupBox->setLayout(layout); } @@ -323,7 +323,7 @@ void RobomonAtlantis::createRobots() robotRefPos->setZValue(11); trailRefPos = new Trail(QPen(Qt::darkBlue)); trailRefPos->setZValue(11); - + robotEstPosBest = new Robot("Est", QPen(), QBrush(Qt::darkGray)); robotEstPosBest->setZValue(10); trailEstPosBest = new Trail(QPen()); @@ -343,9 +343,9 @@ void RobomonAtlantis::createRobots() playgroundScene->addItem(robotEstPosBest); playgroundScene->addItem(robotEstPosIndepOdo); playgroundScene->addItem(robotEstPosOdo); - + showTrails(false); - + playgroundScene->addItem(trailRefPos); playgroundScene->addItem(trailPosIndepOdo); playgroundScene->addItem(trailOdoPos); @@ -353,7 +353,7 @@ void RobomonAtlantis::createRobots() hokuyoScan = new HokuyoScan(); hokuyoScan->setZValue(10); playgroundScene->addItem(hokuyoScan); - + } /********************************************************************** @@ -362,24 +362,24 @@ void RobomonAtlantis::createRobots() void RobomonAtlantis::createActions() { /* power management */ - connect(voltage33CheckBox, SIGNAL(stateChanged(int)), + connect(voltage33CheckBox, SIGNAL(stateChanged(int)), this, SLOT(setVoltage33(int))); - connect(voltage50CheckBox, SIGNAL(stateChanged(int)), + connect(voltage50CheckBox, SIGNAL(stateChanged(int)), this, SLOT(setVoltage50(int))); - connect(voltage80CheckBox, SIGNAL(stateChanged(int)), + connect(voltage80CheckBox, SIGNAL(stateChanged(int)), this, SLOT(setVoltage80(int))); /* motors */ -// connect(leftMotorSlider, SIGNAL(valueChanged(int)), +// connect(leftMotorSlider, SIGNAL(valueChanged(int)), // this, SLOT(setLeftMotor(int))); -// connect(rightMotorSlider, SIGNAL(valueChanged(int)), +// connect(rightMotorSlider, SIGNAL(valueChanged(int)), // this, SLOT(setRightMotor(int))); -// connect(stopMotorsPushButton, SIGNAL(clicked()), +// connect(stopMotorsPushButton, SIGNAL(clicked()), // this, SLOT(stopMotors())); connect(startPlug, SIGNAL(stateChanged(int)), this, SLOT(sendStart(int))); connect(colorChoser, SIGNAL(stateChanged(int)), this, SLOT(setTeamColor(int))); - + /* obstacle simulation */ simulationEnabled = 0; connect(obstacleSimulationCheckBox, SIGNAL(stateChanged(int)), @@ -388,7 +388,7 @@ void RobomonAtlantis::createActions() this, SLOT(setObstacleSimulation(int))); connect(obstacleSimulationCheckBox, SIGNAL(stateChanged(int)), playgroundScene, SLOT(showObstacle(int))); - connect(playgroundScene, SIGNAL(obstacleChanged(QPointF)), + connect(playgroundScene, SIGNAL(obstacleChanged(QPointF)), this, SLOT(changeObstacle(QPointF))); } @@ -420,32 +420,32 @@ void RobomonAtlantis::setVoltage80(int state) // { // short int leftMotor; // short int rightMotor; - + // if(bothMotorsCheckBox->isChecked()) // rightMotorSlider->setValue(value); // leftMotor = (short int)(MOTOR_LIMIT * (leftMotorSlider->value()/100.0)); // rightMotor = (short int)(MOTOR_LIMIT * (rightMotorSlider->value()/100.0)); - + // orte.motion_speed.left = leftMotor; // orte.motion_speed.right = rightMotor; - + // } // void RobomonAtlantis::setRightMotor(int value) // { // short int leftMotor; // short int rightMotor; - + // if(bothMotorsCheckBox->isChecked()) // leftMotorSlider->setValue(value); // leftMotor = (short int)(MOTOR_LIMIT * (leftMotorSlider->value()/100.0)); // rightMotor = (short int)(MOTOR_LIMIT * (rightMotorSlider->value()/100.0)); - + // orte.motion_speed.left = leftMotor; // orte.motion_speed.right = rightMotor; - + // } // void RobomonAtlantis::stopMotors() @@ -465,7 +465,7 @@ void RobomonAtlantis::showMap(bool show) if (sharedMemoryOpened == false) return; - + if (show) { mapTimer = new QTimer(this); connect(mapTimer, SIGNAL(timeout()), this, SLOT(paintMap())); @@ -485,11 +485,11 @@ void RobomonAtlantis::paintMap() struct map *map = ShmapIsMapInit(); if (!map) return; - + for(int i=0; i < MAP_WIDTH; i++) { for(int j=0; jcells[j][i]; color = lightGray; @@ -520,7 +520,7 @@ void RobomonAtlantis::paintMap() } if (cell->flags & MAP_FLAG_DET_OBST) color = cyan; - + playgroundScene->setMapColor(i, j, color); } } @@ -528,7 +528,7 @@ void RobomonAtlantis::paintMap() void RobomonAtlantis::setSimulation(int state) { - if(state) { + if(state) { robottype_publisher_hokuyo_scan_create(&orte, NULL, this); } else { if (!simulationEnabled) @@ -538,7 +538,7 @@ void RobomonAtlantis::setSimulation(int state) simulationEnabled = state; } -/*! +/*! \fn RobomonAtlantis::setObstacleSimulation(int state) */ void RobomonAtlantis::setObstacleSimulation(int state) @@ -547,12 +547,12 @@ void RobomonAtlantis::setObstacleSimulation(int state) /* TODO Maybe it is possible to attach only once to Shmap */ ShmapInit(0); obstacleSimulationTimer = new QTimer(this); - connect(obstacleSimulationTimer, SIGNAL(timeout()), + connect(obstacleSimulationTimer, SIGNAL(timeout()), this, SLOT(simulateObstaclesHokuyo())); obstacleSimulationTimer->start(100); setMouseTracking(true); } else { - if (obstacleSimulationTimer) + if (obstacleSimulationTimer) delete obstacleSimulationTimer; //double distance = 0.8; } @@ -564,16 +564,16 @@ void RobomonAtlantis::simulateObstaclesHokuyo() double distance, wall_distance; unsigned int i; uint16_t *hokuyo = orte.hokuyo_scan.data; - + for (i=0; isetText(QString("%1(%2)") .arg(DEGREES(orte.est_pos_indep_odo.phi), 0, 'f', 0) .arg(orte.est_pos_indep_odo.phi, 0, 'f', 1)); - robotEstPosIndepOdo->moveRobot(orte.est_pos_indep_odo.x, + robotEstPosIndepOdo->moveRobot(orte.est_pos_indep_odo.x, orte.est_pos_indep_odo.y, orte.est_pos_indep_odo.phi); - trailPosIndepOdo->addPoint(QPointF(orte.est_pos_indep_odo.x, + trailPosIndepOdo->addPoint(QPointF(orte.est_pos_indep_odo.x, orte.est_pos_indep_odo.y)); break; case QEVENT(QEV_ESTIMATED_POSITION_ODO): - robotEstPosOdo->moveRobot(orte.est_pos_odo.x, + robotEstPosOdo->moveRobot(orte.est_pos_odo.x, orte.est_pos_odo.y, orte.est_pos_odo.phi); - trailOdoPos->addPoint(QPointF(orte.est_pos_odo.x, + trailOdoPos->addPoint(QPointF(orte.est_pos_odo.x, orte.est_pos_odo.y)); break; case QEVENT(QEV_ESTIMATED_POSITION_BEST): - robotEstPosBest->moveRobot(orte.est_pos_best.x, + robotEstPosBest->moveRobot(orte.est_pos_best.x, orte.est_pos_best.y, orte.est_pos_best.phi); - trailEstPosBest->addPoint(QPointF(orte.est_pos_best.x, + trailEstPosBest->addPoint(QPointF(orte.est_pos_best.x, orte.est_pos_best.y)); - hokuyoScan->setPosition(orte.est_pos_best.x, + hokuyoScan->setPosition(orte.est_pos_best.x, orte.est_pos_best.y, - orte.est_pos_best.phi); + orte.est_pos_best.phi); break; case QEVENT(QEV_POWER_VOLTAGE): emit powerVoltageReceivedSignal(); @@ -797,27 +797,27 @@ void RobomonAtlantis::createOrte() robottype_publisher_robot_switches_create(&orte, dummy_publisher_callback, &orte); /* subscribers */ - robottype_subscriber_pwr_voltage_create(&orte, + robottype_subscriber_pwr_voltage_create(&orte, receivePowerVoltageCallBack, this); - robottype_subscriber_motion_status_create(&orte, + robottype_subscriber_motion_status_create(&orte, receiveMotionStatusCallBack, this); - robottype_subscriber_ref_pos_create(&orte, + robottype_subscriber_ref_pos_create(&orte, receiveActualPositionCallBack, this); - robottype_subscriber_est_pos_odo_create(&orte, + robottype_subscriber_est_pos_odo_create(&orte, generic_rcv_cb, new OrteCallbackInfo(this, QEV_ESTIMATED_POSITION_ODO)); - robottype_subscriber_est_pos_indep_odo_create(&orte, + robottype_subscriber_est_pos_indep_odo_create(&orte, generic_rcv_cb, new OrteCallbackInfo(this, QEV_ESTIMATED_POSITION_INDEP_ODO)); - robottype_subscriber_est_pos_best_create(&orte, + robottype_subscriber_est_pos_best_create(&orte, generic_rcv_cb, new OrteCallbackInfo(this, QEV_ESTIMATED_POSITION_BEST)); - robottype_subscriber_hokuyo_scan_create(&orte, + robottype_subscriber_hokuyo_scan_create(&orte, generic_rcv_cb, new OrteCallbackInfo(this, QEV_HOKUYO_SCAN)); - robottype_subscriber_vidle_cmd_create(&orte, + robottype_subscriber_vidle_cmd_create(&orte, generic_rcv_cb, new OrteCallbackInfo(this, QEV_VIDLE_CMD)); - robottype_subscriber_fsm_main_create(&orte, + robottype_subscriber_fsm_main_create(&orte, rcv_fsm_main_cb, this); - robottype_subscriber_fsm_motion_create(&orte, + robottype_subscriber_fsm_motion_create(&orte, rcv_fsm_motion_cb, this); - robottype_subscriber_fsm_act_create(&orte, + robottype_subscriber_fsm_act_create(&orte, rcv_fsm_act_cb, this); /* motors */ @@ -835,11 +835,11 @@ void RobomonAtlantis::createOrte() act_init(&orte); /* set actions to do when we receive data from orte */ - connect(this, SIGNAL(motionStatusReceivedSignal()), + connect(this, SIGNAL(motionStatusReceivedSignal()), this, SLOT(motionStatusReceived())); - connect(this, SIGNAL(actualPositionReceivedSignal()), + connect(this, SIGNAL(actualPositionReceivedSignal()), this, SLOT(actualPositionReceived())); - connect(this, SIGNAL(powerVoltageReceivedSignal()), + connect(this, SIGNAL(powerVoltageReceivedSignal()), this, SLOT(powerVoltageReceived())); } @@ -855,7 +855,7 @@ void RobomonAtlantis::actualPositionReceived() actPosPhi->setText(QString("%1(%2)") .arg(DEGREES(orte.ref_pos.phi), 0, 'f', 0) .arg(orte.ref_pos.phi, 0, 'f', 1)); - robotRefPos->moveRobot(orte.ref_pos.x, + robotRefPos->moveRobot(orte.ref_pos.x, orte.ref_pos.y, orte.ref_pos.phi); trailRefPos->addPoint(QPointF(orte.ref_pos.x, orte.ref_pos.y)); } @@ -885,7 +885,7 @@ void RobomonAtlantis::openSharedMemory() return; sharedSegmentSize = sizeof(unsigned int) * MAP_WIDTH * MAP_HEIGHT; - + /* Get segment identificator in a read only mode */ segmentId = shmget(SHM_MAP_KEY, sharedSegmentSize, S_IRUSR); if(segmentId == -1) { @@ -893,10 +893,10 @@ void RobomonAtlantis::openSharedMemory() "Unable to open shared memory segment!"); return; } - + /* Init Shmap */ ShmapInit(0); - + /* Attach the shared memory segment */ //map = (_Map*)shmat (segmentId, (void*) 0, 0); @@ -911,7 +911,7 @@ double RobomonAtlantis::distanceToWallHokuyo(int beamnum) struct map *map = ShmapIsMapInit(); if (!map) return min_distance; - + // Simulate obstacles for(j=0;jflags & MAP_FLAG_SIMULATED_WALL) { // WALL ShmapCell2Point(i, j, &wall.x, &wall.y); - + distance = distanceToObstacleHokuyo(beamnum, wall, MAP_CELL_SIZE_M); if (distance +M_PI) angle -= 2.0*M_PI; @@ -969,7 +969,7 @@ double RobomonAtlantis::distanceToObstacleHokuyo(int beamnum, Point obstacle, do if (angle < M_PI/2.0) { distance = distance/cos(angle); } - if (distance > sensorRange) + if (distance > sensorRange) distance = sensorRange; } else { distance = sensorRange; -- 2.39.2