colorChoser = new QCheckBox("&Team color");
layout->addWidget(colorChoser);
+
+ strategyButton= new QPushButton(tr("Strategy"));
+ layout->addWidget(strategyButton);
miscGroupBox->setLayout(layout);
}
connect(startPlug, SIGNAL(stateChanged(int)), this, SLOT(sendStart(int)));
connect(colorChoser, SIGNAL(stateChanged(int)), this, SLOT(setTeamColor(int)));
+ connect(strategyButton, SIGNAL(pressed()), this, SLOT(changeStrategy_1()));
+ connect(strategyButton, SIGNAL(released()), this, SLOT(changeStrategy_0()));
/* obstacle simulation */
simulationEnabled = 0;
this, SLOT(changeObstacle(QPointF)));
}
+void RobomonAtlantis::changeStrategy_1()
+{
+ orte.robot_switches.strategy = true;
+ ORTEPublicationSend(orte.publication_robot_switches);
+}
+
+void RobomonAtlantis::changeStrategy_0()
+{
+ orte.robot_switches.strategy = false;
+ ORTEPublicationSend(orte.publication_robot_switches);
+}
+
void RobomonAtlantis::setVoltage33(int state)
{
if (state)
for (i=0; i<HOKUYO_ARRAY_SIZE; i++) {
wall_distance = distanceToWallHokuyo(i);
- distance = distanceToObstacleHokuyo(i, simulatedObstacle, SIM_OBST_SIZE_M/*meters*/);
+
+ distance = distanceToCircularObstacleHokuyo(i, simulatedObstacle, SIM_OBST_SIZE_M);
if (wall_distance < distance)
distance = wall_distance;
hokuyo[i] = distance*1000;
case QEVENT(QEV_HOKUYO_SCAN):
hokuyoScan->newScan(&orte.hokuyo_scan);
break;
- case QEVENT(QEV_VIDLE_CMD):
- robotEstPosBest->setVidle(orte.vidle_cmd.req_pos);
+ case QEVENT(QEV_JAWS_CMD):
+ robotEstPosBest->setJaws(orte.jaws_cmd.req_pos.left);
+ robotRefPos->setJaws(orte.jaws_cmd.req_pos.left);
+ robotEstPosIndepOdo->setJaws(orte.jaws_cmd.req_pos.left);
+ robotEstPosOdo->setJaws(orte.jaws_cmd.req_pos.left);
break;
case QEVENT(QEV_REFERENCE_POSITION):
emit actualPositionReceivedSignal();
{
int rv;
- orte.strength = 11;
-
memset(&orte, 0, sizeof(orte));
rv = robottype_roboorte_init(&orte);
if (rv) {
generic_rcv_cb, new OrteCallbackInfo(this, QEV_ESTIMATED_POSITION_BEST));
robottype_subscriber_hokuyo_scan_create(&orte,
generic_rcv_cb, new OrteCallbackInfo(this, QEV_HOKUYO_SCAN));
- robottype_subscriber_vidle_cmd_create(&orte,
- generic_rcv_cb, new OrteCallbackInfo(this, QEV_VIDLE_CMD));
+ robottype_subscriber_jaws_cmd_create(&orte,
+ generic_rcv_cb, new OrteCallbackInfo(this, QEV_JAWS_CMD));
robottype_subscriber_fsm_main_create(&orte,
rcv_fsm_main_cb, this);
robottype_subscriber_fsm_motion_create(&orte,
return min_distance;
}
+double RobomonAtlantis::distanceToCircularObstacleHokuyo(int beamnum, Point center, double diameter)
+{
+ struct robot_pos_type e = orte.est_pos_best;
+ double sensor_a;
+ struct sharp_pos s;
+
+ s.x = HOKUYO_CENTER_OFFSET_M;
+ s.y = 0.0;
+ s.ang = HOKUYO_INDEX_TO_RAD(beamnum);
+
+ Point sensor(e.x + s.x*cos(e.phi) - s.y*sin(e.phi),
+ e.y + s.x*sin(e.phi) + s.y*cos(e.phi));
+ sensor_a = e.phi + s.ang;
+
+ const double sensorRange = 4.0; /*[meters]*/
+
+ double distance = sensorRange;
+ double angle;
+
+ angle = sensor.angleTo(center) - sensor_a;
+ angle = fmod(angle, 2.0*M_PI);
+ if (angle > +M_PI) angle -= 2.0*M_PI;
+ if (angle < -M_PI) angle += 2.0*M_PI;
+ angle = fabs(angle);
+
+ double k = tan(sensor_a);
+ double r = diameter / 2.0;
+
+ double A = 1 + k*k;
+ double B = 2 * (sensor.y*k - center.x - k*k*sensor.x - center.y*k);
+ double C = center.x*center.x + center.y*center.y +
+ k*k*sensor.x*sensor.x - 2*sensor.y*k*sensor.x +
+ sensor.y*sensor.y + 2*k*sensor.x*center.y -
+ 2*sensor.y*center.y - r*r;
+
+ double D = B*B - 4*A*C;
+
+ if (D > 0) {
+ Point ob1, ob2;
+
+ ob1.x = (-B + sqrt(D)) / (2*A);
+ ob2.x = (-B - sqrt(D)) / (2*A);
+ ob1.y = k * (ob1.x - sensor.x) + sensor.y;
+ ob2.y = k * (ob2.x - sensor.x) + sensor.y;
+
+ double distance1 = sensor.distanceTo(ob1);
+ double distance2 = sensor.distanceTo(ob2);
+ distance = (distance1 < distance2) ? distance1 : distance2;
+ } else if (D == 0) {
+ Point ob;
+ ob.x = -B / (2*A);
+ ob.y = k * (ob.x - sensor.x) + sensor.y;
+ distance = sensor.distanceTo(ob);
+ }
+ distance = distance + (drand48()-0.5)*3.0e-2;
+ if (D < 0 || angle > atan(r / distance))
+ distance = sensorRange;
+ if (distance > sensorRange)
+ distance = sensorRange;
+
+ return distance;
+}
+
/**
* Calculation for Hokuyo simulation. Calculates distance that would
* be returned by Hokuyo sensors, if there is only one obstacle (as