コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: jcarn/robocup-software
void MainWindow::on_actionStopRobots_triggered() {
    SimCommand cmd;
    // TODO: check that this handles threads properly
    for (OurRobot* robot : state()->self) {
        if (robot->visible) {
            SimCommand::Robot* r = cmd.add_robots();
            r->set_shell(robot->shell());
            r->set_blue_team(processor()->blueTeam());
            Geometry2d::Point newPos =
                _ui.fieldView->getTeamToWorld() * robot->pos;
            r->mutable_pos()->set_x(newPos.x);
            r->mutable_pos()->set_y(newPos.y);
            r->mutable_vel()->set_x(0);
            r->mutable_vel()->set_y(0);
            r->set_w(0);
        }
    }
    for (OpponentRobot* robot : state()->opp) {
        if (robot->visible) {
            SimCommand::Robot* r = cmd.add_robots();
            r->set_shell(robot->shell());
            r->set_blue_team(!processor()->blueTeam());
            Geometry2d::Point newPos =
                _ui.fieldView->getTeamToWorld() * robot->pos;
            r->mutable_pos()->set_x(newPos.x);
            r->mutable_pos()->set_y(newPos.y);
            r->mutable_vel()->set_x(0);
            r->mutable_vel()->set_y(0);
            r->set_w(0);
        }
    }
    _ui.fieldView->sendSimCommand(cmd);
}
コード例 #2
0
ファイル: MainWindow.cpp プロジェクト: jcarn/robocup-software
void MainWindow::on_actionQuicksaveRobotLocations_triggered() {
    _ui.actionQuickloadRobotLocations->setEnabled(true);
    _quickLoadCmd.reset();
    for (OurRobot* robot : state()->self) {
        if (robot->visible) {
            SimCommand::Robot* r = _quickLoadCmd.add_robots();
            r->set_shell(robot->shell());
            r->set_blue_team(processor()->blueTeam());
            Geometry2d::Point newPos =
                _ui.fieldView->getTeamToWorld() * robot->pos;
            r->mutable_pos()->set_x(newPos.x);
            r->mutable_pos()->set_y(newPos.y);
            r->mutable_vel()->set_x(0);
            r->mutable_vel()->set_y(0);
            r->set_w(0);
        }
    }
    for (OpponentRobot* robot : state()->opp) {
        if (robot->visible) {
            SimCommand::Robot* r = _quickLoadCmd.add_robots();
            r->set_shell(robot->shell());
            r->set_blue_team(!processor()->blueTeam());
            Geometry2d::Point newPos =
                _ui.fieldView->getTeamToWorld() * robot->pos;
            r->mutable_pos()->set_x(newPos.x);
            r->mutable_pos()->set_y(newPos.y);
            r->mutable_vel()->set_x(0);
            r->mutable_vel()->set_y(0);
            r->set_w(0);
        }
    }

    Geometry2d::Point ballPos =
        _ui.fieldView->getTeamToWorld() * state()->ball.pos;
    _quickLoadCmd.mutable_ball_pos()->set_x(ballPos.x);
    _quickLoadCmd.mutable_ball_pos()->set_y(ballPos.y);
    _quickLoadCmd.mutable_ball_vel()->set_x(0);
    _quickLoadCmd.mutable_ball_vel()->set_y(0);
}