├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE │ ├── bug_fix.md │ ├── documentation.md │ ├── feature_change.md │ └── performance_improvement.md ├── renovate.json └── workflows │ └── build.yaml ├── .gitignore ├── AUTHORS.md ├── CHANGELOG.md ├── CMakeLists.txt ├── CMakePresets.json ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── INSTALL.md ├── LICENSE.md ├── Makefile ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── clients ├── java │ ├── .gitignore │ ├── README.md │ ├── build.xml │ ├── lib │ │ └── protobuf-java-2.4.1.jar │ ├── manifest.mf │ ├── nbproject │ │ ├── build-impl.xml │ │ ├── genfiles.properties │ │ ├── private │ │ │ ├── private.properties │ │ │ └── private.xml │ │ ├── project.properties │ │ └── project.xml │ └── src │ │ ├── Client │ │ ├── Conection.java │ │ ├── Interface.form │ │ └── Interface.java │ │ └── Protobuf │ │ ├── GrSimCommands.java │ │ ├── GrSimPacket.java │ │ ├── GrSimReplacement.java │ │ ├── MessagesRobocupSslDetection.java │ │ ├── MessagesRobocupSslGeometry.java │ │ ├── MessagesRobocupSslRefboxLog.java │ │ ├── MessagesRobocupSslWrapper.java │ │ └── protobuf-java-2.4.1.jar └── qt │ ├── .gitignore │ ├── CMakeLists.txt │ ├── main.cpp │ ├── mainwindow.cpp │ └── mainwindow.h ├── cmake ├── Utils.cmake └── modules │ ├── BuildODE.cmake │ ├── BuildProtobuf.cmake │ ├── EnvHelper.cmake │ ├── FindODE.cmake │ ├── FindOrBuildProtobuf.cmake │ └── FindVarTypes.cmake ├── config ├── Parsian.ini ├── ParsianNew.ini └── RoboIME2012.ini ├── docker-entry.sh ├── docs └── img │ └── screenshot01.jpg ├── include ├── common.h ├── config.h ├── configwidget.h ├── getpositionwidget.h ├── glwidget.h ├── graphics.h ├── logger.h ├── mainwindow.h ├── net │ ├── robocup_ssl_client.h │ └── robocup_ssl_server.h ├── physics │ ├── pball.h │ ├── pbox.h │ ├── pcylinder.h │ ├── pfixedbox.h │ ├── pground.h │ ├── pobject.h │ ├── pray.h │ └── pworld.h ├── robot.h ├── robotwidget.h ├── sslworld.h ├── statuswidget.h └── winmain.h ├── resources ├── grsim.desktop ├── grsim.rc ├── icons │ ├── grsim.icns │ ├── grsim.ico │ └── grsim.svg ├── textures.qrc └── textures │ ├── b0.png │ ├── b1.png │ ├── b10.png │ ├── b11.png │ ├── b12.png │ ├── b13.png │ ├── b14.png │ ├── b15.png │ ├── b2.png │ ├── b3.png │ ├── b4.png │ ├── b5.png │ ├── b6.png │ ├── b7.png │ ├── b8.png │ ├── b9.png │ ├── grass.png │ ├── qt.png │ ├── sky │ ├── arabian_nights_bk.png │ ├── arabian_nights_dn.png │ ├── arabian_nights_ft.png │ ├── arabian_nights_lf.png │ ├── arabian_nights_rt.png │ └── arabian_nights_up.png │ ├── wheel.png │ ├── y0.png │ ├── y1.png │ ├── y10.png │ ├── y11.png │ ├── y12.png │ ├── y13.png │ ├── y14.png │ ├── y15.png │ ├── y2.png │ ├── y3.png │ ├── y4.png │ ├── y5.png │ ├── y6.png │ ├── y7.png │ ├── y8.png │ └── y9.png ├── src ├── configwidget.cpp ├── getpositionwidget.cpp ├── glwidget.cpp ├── graphics.cpp ├── logger.cpp ├── main.cpp ├── mainwindow.cpp ├── net │ ├── robocup_ssl_client.cpp │ └── robocup_ssl_server.cpp ├── physics │ ├── pball.cpp │ ├── pbox.cpp │ ├── pcylinder.cpp │ ├── pfixedbox.cpp │ ├── pground.cpp │ ├── pobject.cpp │ ├── pray.cpp │ └── pworld.cpp ├── proto │ ├── grSim_Commands.proto │ ├── grSim_Packet.proto │ ├── grSim_Replacement.proto │ ├── grSim_Robotstatus.proto │ ├── ssl_gc_common.proto │ ├── ssl_simulation_config.proto │ ├── ssl_simulation_control.proto │ ├── ssl_simulation_error.proto │ ├── ssl_simulation_robot_control.proto │ ├── ssl_simulation_robot_feedback.proto │ ├── ssl_simulation_synchronous.proto │ ├── ssl_vision_detection.proto │ ├── ssl_vision_geometry.proto │ └── ssl_vision_wrapper.proto ├── robot.cpp ├── robotwidget.cpp ├── sslworld.cpp └── statuswidget.cpp └── vcpkg.json /.dockerignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /cmake-build-debug 3 | /cmake-build-release 4 | /build 5 | /.git 6 | /.idea 7 | /Dockerfile 8 | /.dockerignore -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Version [e.g. 22] 29 | 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: feature request 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/bug_fix.md: -------------------------------------------------------------------------------- 1 | ### Identify the Bug 2 | 3 | 11 | 12 | ### Description of the Change 13 | 14 | 19 | 20 | ### Alternate Designs 21 | 22 | 23 | 24 | ### Possible Drawbacks 25 | 26 | 27 | 28 | ### Verification Process 29 | 30 | 35 | 36 | ### Release Notes 37 | 38 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | ### Description of the Change 2 | 3 | 8 | 9 | ### Release Notes 10 | 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/feature_change.md: -------------------------------------------------------------------------------- 1 | ### Issue or RFC Endorsed by GrSim's Maintainers 2 | 3 | 14 | 15 | ### Description of the Change 16 | 17 | 22 | 23 | ### Alternate Designs 24 | 25 | 26 | 27 | ### Possible Drawbacks 28 | 29 | 30 | 31 | ### Verification Process 32 | 33 | 44 | 45 | ### Release Notes 46 | 47 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/performance_improvement.md: -------------------------------------------------------------------------------- 1 | ### Description of the Change 2 | 3 | 8 | 9 | ### Quantitative Performance Benefits 10 | 11 | 16 | 17 | ### Possible Drawbacks 18 | 19 | 20 | 21 | ### Verification Process 22 | 23 | 28 | 29 | ### Applicable Issues 30 | 31 | 32 | 33 | ### Release Notes 34 | 35 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "schedule:yearly" 5 | ], 6 | "labels": [ 7 | "dependencies" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | build-linux: 9 | runs-on: ${{ matrix.os }} 10 | continue-on-error: true 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04 ] 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: "Update dependencies" 18 | run: sudo apt-get update 19 | - name: "Install dependencies" 20 | run: sudo apt-get install -y build-essential cmake pkg-config qtbase5-dev libqt5opengl5-dev libgl1-mesa-dev libglu1-mesa-dev libprotobuf-dev protobuf-compiler libode-dev libboost-dev 21 | - name: "Build" 22 | run: make 23 | 24 | build-macos: 25 | runs-on: ${{ matrix.os }} 26 | continue-on-error: true 27 | strategy: 28 | fail-fast: false 29 | matrix: 30 | os: [ macos-13, macos-14 ] 31 | steps: 32 | - uses: actions/checkout@v4 33 | - name: "Install dependencies" 34 | run: brew tap robotology/formulae && brew install cmake pkg-config qt@5 35 | - name: "Build" 36 | run: | 37 | # For macOS 13 38 | export PATH="/usr/local/opt/qt@5/bin:$PATH" 39 | export LDFLAGS="-L/usr/local/opt/qt@5/lib" 40 | export CPPFLAGS="-I/usr/local/opt/qt@5/include" 41 | export PKG_CONFIG_PATH="/usr/local/opt/qt@5/lib/pkgconfig" 42 | 43 | # For macOS 14 44 | export PATH="/opt/homebrew/opt/qt@5/bin:$PATH" 45 | export LDFLAGS="-L/opt/homebrew/opt/qt@5/lib" 46 | export CPPFLAGS="-I/opt/homebrew/opt/qt@5/include" 47 | export PKG_CONFIG_PATH="/opt/homebrew/opt/qt@5/lib/pkgconfig" 48 | 49 | make 50 | 51 | # Windows build does not work currently, see https://github.com/RoboCup-SSL/grSim/issues/183 52 | # build-windows: 53 | # runs-on: windows-latest 54 | # steps: 55 | # - uses: actions/checkout@v4 56 | # 57 | # - name: Install dependencies # saves / restores cache to avoid rebuilding dependencies 58 | # uses: lukka/run-vcpkg@v11 59 | # with: 60 | # vcpkgGitCommitId: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50 61 | # vcpkgDirectory: c:/vcpkg # folder must reside in c:\ otherwise qt wont install due to long path errors 62 | # 63 | # - name: Run CMake and run vcpkg to build packages 64 | # uses: lukka/run-cmake@v10 65 | # with: 66 | # # this preset is needed to actually install the vcpkg dependencies 67 | # configurePreset: "ninja-multi-vcpkg" 68 | # configPresetAdditionalArgs: "[-DVCPKG_TARGET_TRIPLET=x64-windows]" 69 | # buildPreset: "ninja-multi-vcpkg" 70 | # buildPresetAdditionalArgs: "['--config Release']" 71 | # env: 72 | # # [OPTIONAL] Define the vcpkg's triplet you want to enforce, otherwise the default one 73 | # # for the hosting system will be automatically choosen (x64 is the default on all 74 | # # platforms, e.g. `x64-osx`). 75 | # VCPKG_DEFAULT_TRIPLET: "x64-windows" 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | build*/* 3 | dist/* 4 | bin*/* 5 | *.user 6 | *.swp 7 | Thumbs.db 8 | .idea/* 9 | *.iml 10 | cmake-build-debug 11 | cmake-build-release 12 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | ## Authors 2 | 3 | grSim was originally developed by [Ali Koochakzadeh](https://github.com/ali-k) and [Mani Monajjemi](https://mani.im) from [Parsian](https://github.com/ParsianRoboticLab), the RoboCup Small Size Team of [Amirkabir University of Technology](http://www.aut.ac.ir/aut/). Since 2011, it has received numerous contributions from the RoboCup SSL community as well as Parsian team members (listed below). grSim is Currently maintained by [Mohammad Mahdi Rahimi](https://github.com/Mahi97). 4 | 5 | ### Contributers 6 | 7 | - [Christopher Head](https://github.com/Hawk777) - Thunderbots (University of British Coloumbia) 8 | - [Jonathan Fraser](https://github.com/Binaryblade) - Thunderbots (University of British Coloumbia) 9 | - [Verónica Raspeño](vero.uc3m@gmail.com) - University Carlos III of Madrid 10 | - [Alejandro Caparrós](alexcap.uc3m@gmail.com) - University Carlos III of Madrid 11 | - [Jan Segre](jan@segre.in) - RoboIME 12 | - [Henrique Bonini de Britto Menezes](henrique.menezes@usp.br) - Universidade de São Paulo 13 | 14 | ### Contributers from Parsian SSL 15 | 16 | - [Sepehr Mohaimanianpour](http://sepehr.im) 17 | - [Arash Behmand](https://github.com/arashbehmand) 18 | - [Mohammad Mahdi Rahimi](https://github.com/Mahi97) 19 | - [Ehsan Omidi](#) 20 | - [Atousa Ahsani](http://github.com/aahsani) 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | grSim is a software from developers for developers, mainly 2 | in RoboCup Small Size League domain. Commit logs can be 3 | accessed [here](https://github.com/RoboCup-SSL/grSim/commits/master) 4 | 5 | 2017-01-09 6 | ---------- 7 | 8 | Mohammad Mahdi Rahimi 9 | 10 | - Milestone 2.0 11 | - Update documentation files 12 | - Updates from Parsian 13 | - Set explicitly the C++ standard to use : c++03 14 | - Enable multi-target build on TravisCI 15 | - Use pkg-config for ODE and protobuf 16 | 17 | 2016-11-05 18 | ---------- 19 | 20 | Mohammad Mahdi Rahimi 21 | 22 | - Fix png texture chunks 23 | - Send data in 4 camera packet. 24 | - Make it full compatible with both Linux and Mac-osx 25 | - Add Commands for more control on the ball and robots. 26 | 27 | 2013-03-28 28 | ---------- 29 | 30 | Jan Segre 31 | 32 | - Using standard pattern textures. 33 | - Improved grass texture. 34 | - Send geometry packets once in X frames. 35 | - Standard field layout compliant. 36 | - Field lines have thickness. 37 | - Ported to CMake. 38 | - Refactored folder structure. 39 | - Formatted READMEs with markdown. 40 | - Tested on MacOSX 64-bit Lion. 41 | - Fixing port reusing issue. (Mac only?) 42 | 43 | 44 | 2011-09-03 45 | ---------- 46 | 47 | Ali Koochakzadeh 48 | 49 | - Added Java client to the project. 50 | - Created the changelog file. 51 | - Solved 64-bit library problems. 52 | 53 | 54 | 2011-07-27 55 | ---------- 56 | 57 | Verónica Raspeño 58 | 59 | - Developed a client under java environment for grSim. 60 | 61 | 62 | 2011-07-02 63 | ---------- 64 | 65 | Christopher Head 66 | 67 | - Created 2 patches for library compatibility problems. 68 | 69 | 70 | Pre-github migration Changelog 71 | ============================== 72 | 73 | 74 | 2011-07-02 75 | ---------- 76 | 77 | - Initial Public Release. (r1354) 78 | 79 | 80 | 2011-06-20 81 | ---------- 82 | 83 | - Initial Release. (r1240) 84 | 85 | -------------------------------------------------------------------------------- /CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 6, 3 | "configurePresets": [ 4 | { 5 | "name": "windows-default", 6 | "displayName": "Windows x64 Release", 7 | "generator": "Ninja", 8 | "binaryDir": "${sourceDir}/out/build/${presetName}", 9 | "architecture": { 10 | "value": "x64", 11 | "strategy": "external" 12 | }, 13 | "cacheVariables": { 14 | "CMAKE_BUILD_TYPE": "Release", 15 | "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" 16 | } 17 | }, 18 | { 19 | "name": "ninja-multi-vcpkg", 20 | "displayName": "Windows x64 Release vcpkg", 21 | "generator": "Ninja Multi-Config", 22 | "binaryDir": "${sourceDir}/out/build/${presetName}", 23 | "architecture": { 24 | "value": "x64", 25 | "strategy": "external" 26 | }, 27 | "cacheVariables": { 28 | "CMAKE_TOOLCHAIN_FILE": { 29 | "type": "FILEPATH", 30 | "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" 31 | }, 32 | "CMAKE_BUILD_TYPE": "Release", 33 | "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" 34 | } 35 | } 36 | ], 37 | "buildPresets": [ 38 | { 39 | "name": "ninja-multi-vcpkg", 40 | "configurePreset": "ninja-multi-vcpkg", 41 | "displayName": "Build ninja-multi-vcpkg", 42 | "description": "Build ninja-multi-vcpkg Configurations" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mohammadmahdi76@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 AS build 2 | ENV DEBIAN_FRONTEND=noninteractive 3 | 4 | RUN apt-get update && apt-get install -y \ 5 | git \ 6 | build-essential \ 7 | cmake \ 8 | pkg-config \ 9 | qt5-default \ 10 | libqt5opengl5-dev \ 11 | libgl1-mesa-dev \ 12 | libglu1-mesa-dev \ 13 | libprotobuf-dev \ 14 | protobuf-compiler \ 15 | libode-dev \ 16 | libboost-dev 17 | 18 | WORKDIR /vartypes 19 | RUN git clone https://github.com/jpfeltracco/vartypes.git . && \ 20 | git checkout 2d16e81b7995f25c5ba5e4bc31bf9a514ee4bc42 && \ 21 | mkdir build && \ 22 | cd build && \ 23 | cmake .. && \ 24 | make && \ 25 | make install 26 | 27 | WORKDIR /grsim 28 | COPY clients /grsim/clients 29 | COPY cmake /grsim/cmake 30 | COPY config /grsim/config 31 | COPY include /grsim/include 32 | COPY resources /grsim/resources 33 | COPY src /grsim/src 34 | COPY CMakeLists.txt README.md LICENSE.md /grsim/ 35 | RUN mkdir build && \ 36 | cd build && \ 37 | cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ 38 | make && \ 39 | make install 40 | 41 | 42 | FROM ubuntu:20.04 43 | ENV DEBIAN_FRONTEND=noninteractive \ 44 | LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib 45 | 46 | RUN apt-get update && apt-get install -y \ 47 | tini \ 48 | qt5-default \ 49 | libqt5opengl5 \ 50 | libode8 \ 51 | libprotobuf17 \ 52 | # virtual display and VNC server 53 | x11vnc xvfb && \ 54 | apt-get clean -y 55 | COPY --from=build /usr/local /usr/local 56 | 57 | RUN useradd -ms /bin/bash default 58 | COPY /docker-entry.sh . 59 | RUN chmod 775 /docker-entry.sh 60 | 61 | EXPOSE 20011 30011 30012 10300 10301 10302 5900 62 | USER default 63 | WORKDIR /home/default 64 | ENTRYPOINT ["tini", "--", "/docker-entry.sh"] 65 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | # GrSim - INSTALL 2 | 3 | ## Overview 4 | 5 | We developed grSim on Ubuntu OS. (Ubuntu 14.04+ tested and is recommended). It is important that the graphics card driver is installed properly (the official Ubuntu packages for nVidia and AMD(ATI) graphics cards are available). grSim will compile and run in both 32 and 64 bits Linux and Mac OS, and in 64 bit Windows. 6 | 7 | GrSim is written in C++, in order to compile it, you will need a working toolchain and a c++ compiler. 8 | 9 | ## Dependencies 10 | 11 | GrSim depends on: 12 | 13 | - [CMake](https://cmake.org/) version 3.5+ 14 | - [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) 15 | - [OpenGL](https://www.opengl.org) 16 | - [Qt5 Development Libraries](https://www.qt.io) 17 | - [Open Dynamics Engine (ODE)](http://www.ode.org) 18 | - [VarTypes Library](https://github.com/jpfeltracco/vartypes) forked from [Szi's Vartypes](https://github.com/szi/vartypes) 19 | - [Google Protobuf](https://github.com/google/protobuf) 20 | - [Boost development libraries](http://www.boost.org/) (needed by VarTypes) 21 | 22 | **Note:** It's necessary to compile ODE in double precision. This is default when installing the ODE binaries in Ubuntu. However, if you are compiling ODE from source (e.g on Mac OS), please make sure to enable the double precision during the configuration step: `./configure --enable-double-precision`. 23 | 24 | 25 | 26 | ## Run from pre-build packages 27 | ### Installing from Arch Linux package manager 28 | 29 | A package of grSim is avaliable on the [Arch User Repository](https://aur.archlinux.org/packages/grsim-git/), you can install it with your preferred AUR manager. Using `yay` it can be done with: 30 | ```bash 31 | yay -S grsim-git 32 | ``` 33 | 34 | ### Using docker image 35 | You can get latest grSim from [Docker Hub](https://hub.docker.com/r/robocupssl/grsim) with: 36 | ```shell 37 | docker pull robocupssl/grsim:latest 38 | ``` 39 | 40 | The container can be run in two flavors: 41 | 1. Headless: `docker run robocupssl/grsim` 42 | 1. With VNC: `docker run --net=host -eVNC_PASSWORD=vnc -eVNC_GEOMETRY=1920x1080 robocupssl/grsim vnc` 43 | 1. Then launch your VNC client app (e.g. [Remmina](https://remmina.org/)). 44 | 1. Connect to `localhot:5900`. 45 | 1. Enter a password (default:`vnc`) to login. 46 | 47 | ## Building and installing from the source code 48 | 49 | ### Installing Dependencies 50 | 51 | #### Arch Linux 52 | 53 | If you are running Arch Linux or an Arch Linux based distribution, install the dependencies with: 54 | ``` 55 | $ sudo pacman -S base-devel boost hicolor-icon-theme \ 56 | mesa ode protobuf qt5-base cmake git 57 | ``` 58 | 59 | #### Ubuntu / Debian 60 | 61 | For Debian, or derivative 62 | ``` 63 | sudo apt install git build-essential cmake pkg-config qtbase5-dev \ 64 | libqt5opengl5-dev libgl1-mesa-dev libglu1-mesa-dev \ 65 | libprotobuf-dev protobuf-compiler libode-dev libboost-dev 66 | ``` 67 | 68 | #### Mac OS X 69 | 70 | For Mac OS X, you will need to have installed: 71 | 72 | - [Xcode](https://developer.apple.com/xcode/) or Xcode Command Line Tools 8.0 or newer; 73 | - [Homebrew](http://brew.sh/) package manager. 74 | 75 | Than install the dependencies needed: 76 | 77 | ```bash 78 | brew install cmake 79 | brew install pkg-config 80 | brew tap robotology/formulae 81 | brew install robotology/formulae/ode 82 | brew install qt@5 83 | brew install protobuf@21 84 | ``` 85 | 86 | If you run into build issues, you may need to run this first: 87 | 88 | ```bash 89 | brew update 90 | brew doctor 91 | ``` 92 | 93 | #### Windows (64 bits) 94 | 95 | For Windows, you will need to have installed: 96 | 97 | - [CMake](https://cmake.org/) (tested with version 3.17.2 ). Download and install cmake for windows. 98 | - [Visual Studio](https://visualstudio.microsoft.com/) (tested with version 16.7.0). During installation make sure to include workload `Desktop development with C++` and `C++ MFC for latest v142 build tools (x86 x64)` 99 | - [vcpkg](https://github.com/microsoft/vcpkg) package manager. Follow installation instructions on their github website. 100 | 101 | To install the dependencies, open a terminal in vcpkg installation folder and run the following command (it will take very long to run): 102 | 103 | ```bash 104 | $ ./vcpkg install qt5:x64-windows ode:x64-windows protobuf:x64-windows 105 | ``` 106 | 107 | ### Building 108 | 109 | First clone grSim into your preferred location. 110 | 111 | ```bash 112 | $ cd /path/to/grsim_ws 113 | $ git clone https://github.com/RoboCup-SSL/grSim.git 114 | $ cd grSim 115 | ``` 116 | 117 | Create a build directory within the project (this is ignored by .gitignore): 118 | 119 | ```bash 120 | $ mkdir build 121 | $ cd build 122 | ``` 123 | 124 | #### Linux and Mac OS X 125 | 126 | Run CMake to generate the makefile (note: if you proceed with the installation, grSim will be installed into directory chosen, by default `/usr/local`): 127 | 128 | ```bash 129 | $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. 130 | ``` 131 | 132 | Then compile the program: 133 | 134 | ```bash 135 | $ make 136 | ``` 137 | 138 | The executable will be located on the `bin` directory. 139 | 140 | #### Windows 141 | 142 | Run CMake to generate a solution in visual studio and the build the solution (note: modify the command below to reflect your vcpkg installation folder). 143 | 144 | ```bash 145 | $ cmake -DCMAKE_TOOLCHAIN_FILE=${PATH_TO_VCPKG}\\scripts\\buildsystems\\vcpkg.cmake .. 146 | $ cmake --build . --config Release 147 | ``` 148 | 149 | The executable will be located on the `bin` directory. 150 | 151 | ### Installing (Linux and Mac OS X) 152 | 153 | At least, if you want to install grSim on your system, run the follow: 154 | 155 | ```bash 156 | $ sudo make install 157 | ``` 158 | 159 | grSim will be — by default — installed on the `/usr/local` directory. 160 | 161 | 162 | ## Troubleshooting 163 | 164 | If you face any problem regarding of updating the grsim version, you can try removing the `grsim.xml`. 165 | If grSim crashes almost instantly with some ODE error the issue might by your ODE version. 166 | Try adding -DBUILD_ODE=TRUE to build ODE from source instead of using the system dependency. 167 | 168 | ## Notes on the performance 169 | 170 | When running grSim, check the FPS in the status bar. If it is running at **60 FPS** or higher, everything is ok. Otherwise check the graphics card's driver installation and OpenGL settings. 171 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | grSim - RoboCup Small Size League Simulator 2 | Copyright (c) 2011 Parsian SSL Team (Amirkabir University of Technology) 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BUILDDIR=build 2 | 3 | #change to Debug for debug mode 4 | BUILDTYPE=Release 5 | #BUILDTYPE=Debug 6 | 7 | BUILD_ODE=OFF 8 | 9 | .PHONY: all build mkbuilddir cmake dist package deb install clean clean-all 10 | 11 | all: build 12 | 13 | deploy: dist upload 14 | 15 | # requires pygithub3: 16 | # pip install pygithub3 17 | upload: 18 | ./upload.py --all 19 | 20 | build: mkbuilddir cmake 21 | $(MAKE) -C $(BUILDDIR) 22 | 23 | mkbuilddir: 24 | [ -d $(BUILDDIR) ] || mkdir $(BUILDDIR) 25 | 26 | cmake: CMakeLists.txt 27 | cd $(BUILDDIR) && cmake -DCMAKE_BUILD_TYPE=$(BUILDTYPE) -DBUILD_ODE=$(BUILD_ODE) .. 28 | 29 | dist: package 30 | 31 | package: all 32 | $(MAKE) -C $(BUILDDIR) package 33 | 34 | deb: all 35 | cd $(BUILDDIR) && cpack -G DEB 36 | 37 | install: all 38 | $(MAKE) -C $(BUILDDIR) install 39 | 40 | clean: mkkbuilddir cmake 41 | $(MAKE) -C $(BUILDDIR) clean 42 | 43 | clean-all: mkbuilddir 44 | cd $(BUILDDIR) && rm -rf * 45 | 46 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 1. Copy the correct template for your contribution 3 | - 🐛 Are you fixing a bug? Copy the template from http://bit.ly/grsim-bugfix 4 | - 📈 Are you improving the performance? Copy the template from http://bit.ly/grsim-perf 5 | - 📝 Are you updating the documentation? Copy the template from http://bit.ly/grsim-doc 6 | - 💻 Are you changing a functionality? Copy the template from http://bit.ly/grsim-feature 7 | 2. Replace this text with the contents of the template 8 | 3. Fill in all sections of the template 9 | 4. Click "Create pull request" 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://github.com/RoboCup-SSL/grSim/workflows/Build/badge.svg)](https://github.com/RoboCup-SSL/grSim/actions?query=workflow%3ABuild+branch%3Amaster) [![CodeFactor](https://www.codefactor.io/repository/github/robocup-ssl/grsim/badge/master)](https://www.codefactor.io/repository/github/robocup-ssl/grsim/overview/master) 2 | 3 | grSim 4 | ======================= 5 | 6 | [RoboCup Small Size League](https://ssl.robocup.org/) Simulator. 7 | 8 | ![grSim on Ubuntu](docs/img/screenshot01.jpg?raw=true "grSim on Ubuntu") 9 | 10 | - [Install instructions](INSTALL.md) 11 | - [Authors](AUTHORS.md) 12 | - [Changelog](CHANGELOG.md) 13 | - License: [GNU General Public License (GPLv3)](LICENSE.md) 14 | 15 | System Requirements 16 | ----------------------- 17 | 18 | grSim will likely run on a modern dual-core PC with a decent graphics card. A typical configuration is: 19 | 20 | - Dual Core CPU (2.0 Ghz+) 21 | - 1GB of RAM 22 | - 256MB nVidia or ATI graphics card 23 | 24 | Note that it may run on lower-end equipment though good performance is not guaranteed. 25 | 26 | 27 | Software Requirements 28 | --------------------- 29 | 30 | grSim compiles on Linux (tested on Ubuntu and Arch Linux variants only) and Mac OS. It depends on the following libraries: 31 | 32 | - [CMake](https://cmake.org/) version 3.5+ 33 | - [pkg-config](https://freedesktop.org/wiki/Software/pkg-config/) 34 | - [OpenGL](https://www.opengl.org) 35 | - [Qt5 Development Libraries](https://www.qt.io) 36 | - [Open Dynamics Engine (ODE)](http://www.ode.org) 37 | - [VarTypes Library](https://github.com/jpfeltracco/vartypes) forked from [Szi's Vartypes](https://github.com/szi/vartypes) 38 | - [Google Protobuf](https://github.com/google/protobuf) 39 | - [Boost development libraries](http://www.boost.org/) (needed by VarTypes) 40 | 41 | Please consult the [install instructions](INSTALL.md) for more details. 42 | 43 | Usage 44 | ----- 45 | 46 | Receiving data from the grSim is similar to receiving data from the [SSL-Vision](https://github.com/RoboCup-SSL/ssl-vision) using [Google Protobuf](https://github.com/google/protobuf) library. 47 | Sending data to the simulator is also possible using Google Protobuf. Sample clients are included in [clients](./clients) folder. There are two clients available, *qt-based* and *Java-based*. The native client is compiled during the grSim compilation. To compile the Java client, please consult the corresponding `README` file. 48 | 49 | Qt [example project](https://github.com/robocin/ssl-client) to receive and send data to the simulator. 50 | 51 | Star History 52 | ------ 53 | [![Star History Chart](https://api.star-history.com/svg?repos=robocup-ssl/grsim&type=Date)](https://star-history.com/#robocup-ssl/grsim&Date) 54 | 55 | Citing 56 | ------ 57 | 58 | If you use this in your research, please cite the original paper: 59 | ``` 60 | @inproceedings{Monajjemi2011grSimR, 61 | title={grSim - RoboCup Small Size Robot Soccer Simulator}, 62 | author={Valiallah Monajjemi and A. Koochakzadeh and S. S. Ghidary}, 63 | booktitle={RoboCup}, 64 | year={2011} 65 | } 66 | ``` 67 | 68 | If you wish to cite this repo with it's modifications specifically, please cite: 69 | 70 | ``` 71 | @misc{grsim2021, 72 | author = {Mohammad Mahdi Rahimi and Jan Segre and Valiallah Monajjemi and A. Koochakzadeh and Sepehr MohaimenianPour and Nicolai Ommer and Avatar 73 | Kazunori Kimura and Jeremy Feltracco and Kenta Sato and Atousa Ahsani}, 74 | title = {GRSIM}, 75 | year = {2021}, 76 | publisher = {GitHub}, 77 | note = {GitHub repository}, 78 | howpublished = {\url{https://github.com/RoboCup-SSL/grSim/}} 79 | } 80 | ``` 81 | -------------------------------------------------------------------------------- /clients/java/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | build 3 | -------------------------------------------------------------------------------- /clients/java/README.md: -------------------------------------------------------------------------------- 1 | This is the documentation for Java’s client. 2 | 3 | ### Compile 4 | To execute compilation, you can use ant to compile `build.xml`. 5 | 6 | ### Execute 7 | Executable file (.jar) is in `/Java_Client/dist` directory. 8 | 9 | ```java -jar Java_Client.jar``` 10 | -------------------------------------------------------------------------------- /clients/java/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project Java Client. 12 | 13 | 74 | 75 | -------------------------------------------------------------------------------- /clients/java/lib/protobuf-java-2.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/clients/java/lib/protobuf-java-2.4.1.jar -------------------------------------------------------------------------------- /clients/java/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /clients/java/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=56ecc063 2 | build.xml.script.CRC32=8276ed54 3 | build.xml.stylesheet.CRC32=28e38971@1.38.1.45 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=56ecc063 7 | nbproject/build-impl.xml.script.CRC32=cd906182 8 | nbproject/build-impl.xml.stylesheet.CRC32=78c6a6ee@1.38.1.45 9 | -------------------------------------------------------------------------------- /clients/java/nbproject/private/private.properties: -------------------------------------------------------------------------------- 1 | compile.on.save=true 2 | user.properties.file=/home/alex/.netbeans/6.9/build.properties 3 | -------------------------------------------------------------------------------- /clients/java/nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /clients/java/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processor.options= 4 | annotation.processing.processors.list= 5 | annotation.processing.run.all.processors=true 6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 7 | build.classes.dir=${build.dir}/classes 8 | build.classes.excludes=**/*.java,**/*.form 9 | # This directory is removed when the project is cleaned: 10 | build.dir=build 11 | build.generated.dir=${build.dir}/generated 12 | build.generated.sources.dir=${build.dir}/generated-sources 13 | # Only compile against the classpath explicitly listed here: 14 | build.sysclasspath=ignore 15 | build.test.classes.dir=${build.dir}/test/classes 16 | build.test.results.dir=${build.dir}/test/results 17 | # Uncomment to specify the preferred debugger connection transport: 18 | #debug.transport=dt_socket 19 | debug.classpath=\ 20 | ${run.classpath} 21 | debug.test.classpath=\ 22 | ${run.test.classpath} 23 | # This directory is removed when the project is cleaned: 24 | dist.dir=dist 25 | dist.jar=${dist.dir}/Java_Client.jar 26 | dist.javadoc.dir=${dist.dir}/javadoc 27 | excludes= 28 | file.reference.protobuf-java-2.4.1.jar=src/protobuf-java-2.4.1.jar 29 | file.reference.protobuf-java-2.4.1.jar-1=src/Protobuf/protobuf-java-2.4.1.jar 30 | includes=** 31 | jar.compress=false 32 | javac.classpath=\ 33 | ${file.reference.protobuf-java-2.4.1.jar}:\ 34 | ${file.reference.protobuf-java-2.4.1.jar-1} 35 | # Space-separated list of extra javac options 36 | javac.compilerargs= 37 | javac.deprecation=false 38 | javac.processorpath=\ 39 | ${javac.classpath} 40 | javac.source=1.5 41 | javac.target=1.5 42 | javac.test.classpath=\ 43 | ${javac.classpath}:\ 44 | ${build.classes.dir}:\ 45 | ${libs.junit.classpath}:\ 46 | ${libs.junit_4.classpath} 47 | javac.test.processorpath=\ 48 | ${javac.test.classpath} 49 | javadoc.additionalparam= 50 | javadoc.author=false 51 | javadoc.encoding=${source.encoding} 52 | javadoc.noindex=false 53 | javadoc.nonavbar=false 54 | javadoc.notree=false 55 | javadoc.private=false 56 | javadoc.splitindex=true 57 | javadoc.use=true 58 | javadoc.version=false 59 | javadoc.windowtitle= 60 | main.class=Client.Interface 61 | manifest.file=manifest.mf 62 | meta.inf.dir=${src.dir}/META-INF 63 | platform.active=default_platform 64 | run.classpath=\ 65 | ${javac.classpath}:\ 66 | ${build.classes.dir} 67 | # Space-separated list of JVM arguments used when running the project 68 | # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value 69 | # or test-sys-prop.name=value to set system properties for unit tests): 70 | run.jvmargs= 71 | run.test.classpath=\ 72 | ${javac.test.classpath}:\ 73 | ${build.test.classes.dir} 74 | source.encoding=UTF-8 75 | src.dir=src 76 | test.src.dir=test 77 | -------------------------------------------------------------------------------- /clients/java/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | Java Client 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /clients/java/src/Client/Conection.java: -------------------------------------------------------------------------------- 1 | package Client; 2 | 3 | import java.net.DatagramSocket; 4 | import java.net.DatagramPacket; 5 | import java.net.InetAddress; 6 | import Protobuf.*; 7 | 8 | 9 | public class Conection { 10 | 11 | DatagramSocket ds; 12 | String ip; 13 | int port, id; 14 | byte [] buffer2; 15 | int envio = 1; 16 | float timeStamp, wheel1, wheel2, wheel3, wheel4, kickspeedx, kickspeedz, velx, vely, velz; 17 | boolean spinner, wheelSpeed, teamYellow; 18 | 19 | Conection () { 20 | 21 | ip="127.0.0.1"; 22 | port=20011; 23 | timeStamp=0; 24 | wheel1=0; 25 | wheel2=0; 26 | wheel3=0; 27 | wheel4=0; 28 | kickspeedx=0; 29 | kickspeedz=0; 30 | velx=0; 31 | vely=0; 32 | velz=0; 33 | id=0; 34 | spinner=false; 35 | wheelSpeed=false; 36 | teamYellow=false; 37 | } 38 | 39 | public void setTime(float timeStamp){ 40 | this.timeStamp=timeStamp; 41 | } 42 | 43 | public void setWheel1(float wheel1){ 44 | this.wheel1=wheel1; 45 | } 46 | 47 | public void setWheel2(float wheel2){ 48 | this.wheel2=wheel2; 49 | } 50 | 51 | public void setWheel3(float wheel3){ 52 | this.wheel3=wheel3; 53 | } 54 | 55 | public void setWheel4(float wheel4){ 56 | this.wheel4=wheel4; 57 | } 58 | 59 | public void setKickspeedX(float kickspeedx){ 60 | this.kickspeedx=kickspeedx; 61 | } 62 | 63 | public void setKickspeedZ(float kickspeedz){ 64 | this.kickspeedz=kickspeedz; 65 | } 66 | 67 | public void setVelX(float velx){ 68 | this.velx=velx; 69 | } 70 | 71 | public void setVelY(float vely){ 72 | this.vely=vely; 73 | } 74 | 75 | public void setVelZ(float velz){ 76 | this.velz=velz; 77 | } 78 | 79 | public void setId(int id){ 80 | this.id=id; 81 | } 82 | 83 | public void setSpinner(boolean spinner){ 84 | this.spinner=spinner; 85 | } 86 | 87 | public void setWheelSpeed(boolean wheelSpeed){ 88 | this.wheelSpeed=wheelSpeed; 89 | } 90 | 91 | public void setTeamYellow(boolean teamYellow){ 92 | this.teamYellow=teamYellow; 93 | } 94 | 95 | public void setIp(String ip){ 96 | this.ip=ip; 97 | } 98 | 99 | public void setPort(int port){ 100 | this.port=port; 101 | } 102 | 103 | public void send(){ 104 | GrSimCommands.grSim_Robot_Command command = GrSimCommands.grSim_Robot_Command.newBuilder().setId(this.id).setWheel2(this.wheel2).setWheel1(this.wheel1).setWheel3(this.wheel3).setWheel4(this.wheel4).setKickspeedx(this.kickspeedx).setKickspeedz(this.kickspeedz).setVeltangent(this.velx).setVelnormal(this.vely).setVelangular(this.velz).setSpinner(this.spinner).setWheelsspeed(this.wheelSpeed).build(); 105 | GrSimCommands.grSim_Commands command2 = GrSimCommands.grSim_Commands.newBuilder().setTimestamp(this.timeStamp).setIsteamyellow(this.teamYellow).addRobotCommands(command).build(); 106 | GrSimPacket.grSim_Packet packet = GrSimPacket.grSim_Packet.newBuilder().setCommands(command2).build(); 107 | String buffer = packet.toString(); 108 | buffer2=packet.toByteArray(); 109 | try{ 110 | ds = new DatagramSocket(); 111 | DatagramPacket dp = new DatagramPacket(buffer2, buffer2.length, InetAddress.getByName("127.0.0.1"),20011); 112 | ds.send(dp); 113 | 114 | System.out.println(buffer); 115 | }catch(Exception e){ 116 | System.out.println(e); 117 | } 118 | 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /clients/java/src/Protobuf/protobuf-java-2.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/clients/java/src/Protobuf/protobuf-java-2.4.1.jar -------------------------------------------------------------------------------- /clients/qt/.gitignore: -------------------------------------------------------------------------------- 1 | build*/* 2 | -------------------------------------------------------------------------------- /clients/qt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(CMAKE_AUTOMOC ON) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | # policy regarding how to handle generated stuff, OLD behavior would ignore generated files 8 | # (which includes the generated protobuf cpp files) 9 | if (POLICY CMP0071) 10 | cmake_policy(SET CMP0071 NEW) 11 | endif() 12 | 13 | # policy regarding when to rebuild stuff when external projects downloaded with URL changes 14 | if (POLICY CMP0135) 15 | cmake_policy(SET CMP0135 NEW) 16 | endif() 17 | 18 | set(libs) 19 | 20 | find_package(Qt5 COMPONENTS Core Widgets Network REQUIRED) 21 | list(APPEND libs Qt5::Core Qt5::Widgets Qt5::Network) 22 | 23 | # if find_package was already executed and we already included BuildProtobuf find_package fails, 24 | # so we only want to do execute find_package if protobuf was not found yet 25 | if(NOT Protobuf_FOUND) 26 | include(FindOrBuildProtobuf) 27 | endif() 28 | 29 | include_directories(${Protobuf_INCLUDE_DIRS}) 30 | list(APPEND libs ${Protobuf_LIBRARIES}) 31 | 32 | protobuf_generate_cpp(PROTO_CPP PROTO_H 33 | ../../src/proto/grSim_Replacement.proto 34 | ../../src/proto/grSim_Commands.proto 35 | ../../src/proto/grSim_Packet.proto 36 | ) 37 | 38 | set(app client) 39 | 40 | add_executable(${app} MACOSX_BUNDLE 41 | ${PROTO_CPP} 42 | ${PROTO_H} 43 | main.cpp 44 | mainwindow.cpp 45 | mainwindow.h 46 | ) 47 | 48 | if(TARGET protobuf_external) 49 | add_dependencies(${app} protobuf_external) 50 | endif() 51 | 52 | target_link_libraries(${app} ${libs}) 53 | 54 | -------------------------------------------------------------------------------- /clients/qt/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /clients/qt/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | #include 4 | #include 5 | 6 | MainWindow::MainWindow(QWidget *parent) 7 | : QDialog(parent), 8 | udpsocket(this) 9 | { 10 | QGridLayout* layout = new QGridLayout(this); 11 | edtIp = new QLineEdit("127.0.0.1", this); 12 | edtPort = new QLineEdit("20011", this); 13 | edtId = new QLineEdit("0", this); 14 | edtVx = new QLineEdit("0", this); 15 | edtVy = new QLineEdit("0", this); 16 | edtW = new QLineEdit("0", this); 17 | edtV1 = new QLineEdit("0", this); 18 | edtV2 = new QLineEdit("0", this); 19 | edtV3 = new QLineEdit("0", this); 20 | edtV4 = new QLineEdit("0", this); 21 | edtChip = new QLineEdit("0", this); 22 | edtKick = new QLineEdit("0", this); 23 | 24 | this->setWindowTitle(QString("grSim Sample Client - v 2.0")); 25 | 26 | lblIp = new QLabel("Simulator Address", this); 27 | lblPort = new QLabel("Simulator Port", this); 28 | lblId = new QLabel("Id", this); 29 | lblVx = new QLabel("Velocity X (m/s)", this); 30 | lblVy = new QLabel("Velocity Y (m/s)", this); 31 | lblW = new QLabel("Velocity W (rad/s)", this); 32 | lblV1 = new QLabel("Wheel1 (rad/s)", this); 33 | lblV2 = new QLabel("Wheel2 (rad/s)", this); 34 | lblV3 = new QLabel("Wheel3 (rad/s)", this); 35 | lblV4 = new QLabel("Wheel4 (rad/s)", this); 36 | cmbTeam = new QComboBox(this); 37 | cmbTeam->addItem("Yellow"); 38 | cmbTeam->addItem("Blue"); 39 | lblChip = new QLabel("Chip (m/s)", this); 40 | lblKick = new QLabel("Kick (m/s)", this); 41 | txtInfo = new QTextEdit(this); 42 | chkVel = new QCheckBox("Send Velocity? (or wheels)", this); 43 | chkSpin = new QCheckBox("Spin", this); 44 | btnSend = new QPushButton("Send", this); 45 | btnReset = new QPushButton("Reset", this); 46 | btnConnect = new QPushButton("Connect", this); 47 | txtInfo->setReadOnly(true); 48 | txtInfo->setHtml("This program is part of grSim RoboCup SSL Simulator package.
For more information please refer to http://eew.aut.ac.ir/~parsian/grsim
This program is free software under the terms of GNU General Public License Version 3."); 49 | txtInfo->setFixedHeight(70); 50 | layout->addWidget(lblIp, 1, 1, 1, 1);layout->addWidget(edtIp, 1, 2, 1, 1); 51 | layout->addWidget(lblPort, 1, 3, 1, 1);layout->addWidget(edtPort, 1, 4, 1, 1); 52 | layout->addWidget(lblId, 2, 1, 1, 1);layout->addWidget(edtId, 2, 2, 1, 1);layout->addWidget(cmbTeam, 2, 3, 1, 2); 53 | layout->addWidget(lblVx, 3, 1, 1, 1);layout->addWidget(edtVx, 3, 2, 1, 1); 54 | layout->addWidget(lblVy, 4, 1, 1, 1);layout->addWidget(edtVy, 4, 2, 1, 1); 55 | layout->addWidget(lblW, 5, 1, 1, 1);layout->addWidget(edtW, 5, 2, 1, 1); 56 | layout->addWidget(chkVel, 6, 1, 1, 1);layout->addWidget(edtKick, 6, 2, 1, 1); 57 | layout->addWidget(lblV1, 3, 3, 1, 1);layout->addWidget(edtV1, 3, 4, 1, 1); 58 | layout->addWidget(lblV2, 4, 3, 1, 1);layout->addWidget(edtV2, 4, 4, 1, 1); 59 | layout->addWidget(lblV3, 5, 3, 1, 1);layout->addWidget(edtV3, 5, 4, 1, 1); 60 | layout->addWidget(lblV4, 6, 3, 1, 1);layout->addWidget(edtV4, 6, 4, 1, 1); 61 | layout->addWidget(lblChip, 7, 1, 1, 1);layout->addWidget(edtChip, 7, 2, 1, 1); 62 | layout->addWidget(lblKick, 7, 3, 1, 1);layout->addWidget(edtKick, 7, 4, 1, 1); 63 | layout->addWidget(chkSpin, 8, 1, 1, 4); 64 | layout->addWidget(btnConnect, 9, 1, 1, 2);layout->addWidget(btnSend, 9, 3, 1, 1);layout->addWidget(btnReset, 9, 4, 1, 1); 65 | layout->addWidget(txtInfo, 10, 1, 1, 4); 66 | timer = new QTimer (this); 67 | timer->setInterval(20); 68 | connect(edtIp, SIGNAL(textChanged(QString)), this, SLOT(disconnectUdp())); 69 | connect(edtPort, SIGNAL(textChanged(QString)), this, SLOT(disconnectUdp())); 70 | connect(timer, SIGNAL(timeout()), this, SLOT(sendPacket())); 71 | connect(btnConnect, SIGNAL(clicked()), this, SLOT(reconnectUdp())); 72 | connect(btnSend, SIGNAL(clicked()), this, SLOT(sendBtnClicked())); 73 | connect(btnReset, SIGNAL(clicked()), this, SLOT(resetBtnClicked())); 74 | btnSend->setDisabled(true); 75 | chkVel->setChecked(true); 76 | sending = false; 77 | reseting = false; 78 | } 79 | 80 | MainWindow::~MainWindow() 81 | { 82 | 83 | } 84 | 85 | void MainWindow::disconnectUdp() 86 | { 87 | udpsocket.close(); 88 | sending = false; 89 | btnSend->setText("Send"); 90 | btnSend->setDisabled(true); 91 | } 92 | 93 | void MainWindow::sendBtnClicked() 94 | { 95 | sending = !sending; 96 | if (!sending) 97 | { 98 | timer->stop(); 99 | btnSend->setText("Send"); 100 | } 101 | else { 102 | timer->start(); 103 | btnSend->setText("Pause"); 104 | } 105 | } 106 | 107 | void MainWindow::resetBtnClicked() 108 | { 109 | reseting = true; 110 | edtVx->setText("0"); 111 | edtVy->setText("0"); 112 | edtW->setText("0"); 113 | edtV1->setText("0"); 114 | edtV2->setText("0"); 115 | edtV3->setText("0"); 116 | edtV4->setText("0"); 117 | edtChip->setText("0"); 118 | edtKick->setText("0"); 119 | chkVel->setChecked(true); 120 | chkSpin->setChecked(false); 121 | } 122 | 123 | 124 | void MainWindow::reconnectUdp() 125 | { 126 | _addr = QHostAddress(edtIp->text()); 127 | _port = edtPort->text().toUShort(); 128 | btnSend->setDisabled(false); 129 | } 130 | 131 | void MainWindow::sendPacket() 132 | { 133 | if (reseting) 134 | { 135 | sendBtnClicked(); 136 | reseting = false; 137 | } 138 | grSim_Packet packet; 139 | bool yellow = false; 140 | if (cmbTeam->currentText()=="Yellow") yellow = true; 141 | packet.mutable_commands()->set_isteamyellow(yellow); 142 | packet.mutable_commands()->set_timestamp(0.0); 143 | grSim_Robot_Command* command = packet.mutable_commands()->add_robot_commands(); 144 | command->set_id(edtId->text().toInt()); 145 | 146 | command->set_wheelsspeed(!chkVel->isChecked()); 147 | command->set_wheel1(edtV1->text().toDouble()); 148 | command->set_wheel2(edtV2->text().toDouble()); 149 | command->set_wheel3(edtV3->text().toDouble()); 150 | command->set_wheel4(edtV4->text().toDouble()); 151 | command->set_veltangent(edtVx->text().toDouble()); 152 | command->set_velnormal(edtVy->text().toDouble()); 153 | command->set_velangular(edtW->text().toDouble()); 154 | 155 | command->set_kickspeedx(edtKick->text().toDouble()); 156 | command->set_kickspeedz(edtChip->text().toDouble()); 157 | command->set_spinner(chkSpin->isChecked()); 158 | 159 | QByteArray dgram; 160 | dgram.resize(packet.ByteSize()); 161 | packet.SerializeToArray(dgram.data(), dgram.size()); 162 | udpsocket.writeDatagram(dgram, _addr, _port); 163 | } 164 | -------------------------------------------------------------------------------- /clients/qt/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "grSim_Packet.pb.h" 15 | #include "grSim_Commands.pb.h" 16 | #include "grSim_Replacement.pb.h" 17 | 18 | 19 | class MainWindow : public QDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | MainWindow(QWidget *parent = 0); 25 | ~MainWindow(); 26 | public slots: 27 | void reconnectUdp(); 28 | void sendPacket(); 29 | void sendBtnClicked(); 30 | void resetBtnClicked(); 31 | void disconnectUdp(); 32 | private: 33 | bool sending, reseting; 34 | QUdpSocket udpsocket; 35 | QHostAddress _addr; 36 | quint16 _port; 37 | QLineEdit* edtIp; 38 | QLineEdit* edtPort; 39 | QLineEdit* edtId; 40 | QLineEdit* edtVx, *edtVy, *edtW; 41 | QLineEdit* edtV1, *edtV2, *edtV3, *edtV4; 42 | QLineEdit* edtKick, *edtChip; 43 | QLabel* lblIp; 44 | QLabel* lblPort; 45 | QLabel* lblId; 46 | QComboBox* cmbTeam; 47 | QLabel* lblVx, *lblVy, *lblW; 48 | QLabel* lblV1, *lblV2, *lblV3, *lblV4; 49 | QLabel* lblKick, *lblChip; 50 | QTextEdit* txtInfo; 51 | QCheckBox* chkVel, *chkSpin; 52 | QPushButton* btnSend; 53 | QPushButton* btnReset; 54 | QPushButton* btnConnect; 55 | QTimer* timer; 56 | }; 57 | 58 | #endif // MAINWINDOW_H 59 | -------------------------------------------------------------------------------- /cmake/Utils.cmake: -------------------------------------------------------------------------------- 1 | # Some utilities 2 | #TODO: comment/document 3 | 4 | macro(standard_paths ARG0 ARG1 ARG2) 5 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ARG0}/${ARG1}) 6 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ARG0}/${ARG2}) 7 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ARG0}/${ARG2}) 8 | foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) 9 | string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) 10 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 11 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 12 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) 13 | endforeach() 14 | set(CMAKE_DEBUG_POSTFIX d) 15 | set(CMAKE_MINSIZEREL_POSTFIX min) 16 | endmacro() 17 | 18 | macro(standard_config) 19 | set(CMAKE_AUTOMOC YES) 20 | set(CMAKE_INCLUDE_CURRENT_DIR YES) 21 | endmacro() 22 | 23 | -------------------------------------------------------------------------------- /cmake/modules/BuildODE.cmake: -------------------------------------------------------------------------------- 1 | # build ODE, because some versions of it cause grSim to segfault somewhere 2 | # could be because in some packages the double precision is turned off 3 | include(ExternalProject) 4 | 5 | ExternalProject_Add(ode_external 6 | GIT_REPOSITORY https://bitbucket.org/odedevs/ode.git 7 | GIT_TAG 0.16.4 8 | CMAKE_ARGS 9 | -DCMAKE_INSTALL_PREFIX:PATH= 10 | -DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE} 11 | -DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER} 12 | -DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER} 13 | -DCMAKE_MAKE_PROGRAM:PATH=${CMAKE_MAKE_PROGRAM} 14 | # necessary, because it does not build the static libs if this is ON 15 | -DBUILD_SHARED_LIBS=OFF 16 | # if this is OFF grSim just dies instantly and INSTALL.md says it should be ON 17 | -DODE_DOUBLE_PRECISION=ON 18 | -DCMAKE_INSTALL_PREFIX= 19 | STEP_TARGETS install 20 | ) 21 | 22 | set(ODE_LIB_SUBPATH "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ode${CMAKE_STATIC_LIBRARY_SUFFIX}") 23 | 24 | # the byproducts are available after the install step 25 | ExternalProject_Add_Step(ode_external out 26 | DEPENDEES install 27 | BYPRODUCTS 28 | "/${ODE_LIB_SUBPATH}" 29 | ) 30 | 31 | ExternalProject_Get_Property(ode_external install_dir) 32 | set(ODE_LIBRARY "${install_dir}/${ODE_LIB_SUBPATH}") 33 | list(APPEND libs ${ODE_LIBRARY}) 34 | target_include_directories(${app} PRIVATE "${install_dir}/include") 35 | -------------------------------------------------------------------------------- /cmake/modules/BuildProtobuf.cmake: -------------------------------------------------------------------------------- 1 | # *************************************************************************** 2 | # * Copyright 2017 Michael Eischer * 3 | # * Robotics Erlangen e.V. * 4 | # * http://www.robotics-erlangen.de/ * 5 | # * info@robotics-erlangen.de * 6 | # * * 7 | # * This program is free software: you can redistribute it and/or modify * 8 | # * it under the terms of the GNU General Public License as published by * 9 | # * the Free Software Foundation, either version 3 of the License, or * 10 | # * any later version. * 11 | # * * 12 | # * This program is distributed in the hope that it will be useful, * 13 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | # * GNU General Public License for more details. * 16 | # * * 17 | # * You should have received a copy of the GNU General Public License * 18 | # * along with this program. If not, see . * 19 | # *************************************************************************** 20 | 21 | include(ExternalProject) 22 | 23 | set(PROTOBUF_CMAKE_ARGS ) 24 | 25 | ExternalProject_Add(protobuf_external 26 | # URL is the same as in the ER-Force framework, 27 | # because ER-Force needs it and has an incentive to keep the link stable 28 | URL http://www.robotics-erlangen.de/downloads/libraries/protobuf-cpp-3.6.1.tar.gz 29 | URL_HASH SHA256=b3732e471a9bb7950f090fd0457ebd2536a9ba0891b7f3785919c654fe2a2529 30 | SOURCE_SUBDIR cmake 31 | CMAKE_ARGS 32 | -DCMAKE_INSTALL_PREFIX:PATH= 33 | -DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE} 34 | -DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER} 35 | -DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER} 36 | -DCMAKE_MAKE_PROGRAM:PATH=${CMAKE_MAKE_PROGRAM} 37 | # the tests fail to build :-( 38 | -Dprotobuf_BUILD_TESTS:BOOL=OFF 39 | STEP_TARGETS install 40 | ) 41 | 42 | set(PROTOBUF_SUBPATH "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}") 43 | set(LIBPROTOC_SUBPATH "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}") 44 | set(PROTOC_SUBPATH "bin/protoc${CMAKE_EXECUTABLE_SUFFIX}") 45 | 46 | # the byproducts are available after the install step 47 | ExternalProject_Add_Step(protobuf_external out 48 | DEPENDEES install 49 | BYPRODUCTS 50 | "/${PROTOBUF_SUBPATH}" 51 | "/${LIBPROTOC_SUBPATH}" 52 | "/${PROTOC_SUBPATH}" 53 | ) 54 | 55 | ExternalProject_Get_Property(protobuf_external install_dir) 56 | set_target_properties(protobuf_external PROPERTIES EXCLUDE_FROM_ALL true) 57 | 58 | # override all necessary variables originally set by find_package 59 | # if FORCE is not set cmake does not allow us to override the variables, for some unknown reason 60 | set(Protobuf_FOUND true CACHE BOOL "" FORCE) 61 | set(Protobuf_VERSION "3.6.1" CACHE STRING "" FORCE) 62 | set(Protobuf_INCLUDE_DIR "${install_dir}/include" CACHE PATH "" FORCE) 63 | set(Protobuf_INCLUDE_DIRS "${Protobuf_INCLUDE_DIR}" CACHE PATH "" FORCE) 64 | set(Protobuf_LIBRARY "${install_dir}/${PROTOBUF_SUBPATH}" CACHE PATH "" FORCE) 65 | set(Protobuf_LIBRARIES "${Protobuf_LIBRARY}" CACHE PATH "" FORCE) 66 | set(Protobuf_LIBRARY_DEBUG "${install_dir}/${PROTOBUF_SUBPATH}" CACHE PATH "" FORCE) 67 | set(Protobuf_LIBRARY_RELEASE "${install_dir}/${PROTOBUF_SUBPATH}" CACHE PATH "" FORCE) 68 | set(Protobuf_LITE_LIBRARY_DEBUG "${install_dir}/${PROTOBUF_SUBPATH}" CACHE PATH "" FORCE) 69 | set(Protobuf_LITE_LIBRARY_RELEASE "${install_dir}/${PROTOBUF_SUBPATH}" CACHE PATH "" FORCE) 70 | set(Protobuf_PROTOC_EXECUTABLE "${install_dir}/${PROTOC_SUBPATH}" CACHE PATH "" FORCE) 71 | set(Protobuf_PROTOC_LIBRARY_DEBUG "${install_dir}/${LIBPROTOC_SUBPATH}" CACHE PATH "" FORCE) 72 | set(Protobuf_PROTOC_LIBRARY_RELEASE "${install_dir}/${LIBPROTOC_SUBPATH}" CACHE PATH "" FORCE) 73 | # this is a dependency for the protobuf_generate_cpp custom command 74 | # if this is not set the generate command sometimes get executed before protoc is compiled 75 | set(protobuf_generate_DEPENDENCIES protobuf_external CACHE STRING "" FORCE) 76 | 77 | # compatibility with cmake 3.10 78 | if(NOT TARGET protobuf::protoc) 79 | # avoid error if target was already created for an older version 80 | add_executable(protobuf::protoc IMPORTED) 81 | endif() 82 | # override the protobuf::protoc path used by the protobuf_generate_cpp macro 83 | set_target_properties(protobuf::protoc PROPERTIES 84 | IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}" 85 | ) 86 | 87 | message(STATUS "Building protobuf ${Protobuf_VERSION}") 88 | -------------------------------------------------------------------------------- /cmake/modules/EnvHelper.cmake: -------------------------------------------------------------------------------- 1 | # *************************************************************************** 2 | # * Copyright 2017 Michael Eischer * 3 | # * Robotics Erlangen e.V. * 4 | # * http://www.robotics-erlangen.de/ * 5 | # * info@robotics-erlangen.de * 6 | # * * 7 | # * This program is free software: you can redistribute it and/or modify * 8 | # * it under the terms of the GNU General Public License as published by * 9 | # * the Free Software Foundation, either version 3 of the License, or * 10 | # * any later version. * 11 | # * * 12 | # * This program is distributed in the hope that it will be useful, * 13 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | # * GNU General Public License for more details. * 16 | # * * 17 | # * You should have received a copy of the GNU General Public License * 18 | # * along with this program. If not, see . * 19 | # *************************************************************************** 20 | 21 | macro(sanitize_env) 22 | # remove "." from path to avoid searching the build_dir/bin folder 23 | set(ORIG_PATH $ENV{PATH}) 24 | set(MOD_PATH $ENV{PATH}) 25 | list(REMOVE_ITEM MOD_PATH .) 26 | set(ENV{PATH} ${MOD_PATH}) 27 | endmacro() 28 | 29 | macro(restore_env) 30 | set(ENV{PATH} ${ORIG_PATH}) 31 | endmacro() 32 | -------------------------------------------------------------------------------- /cmake/modules/FindODE.cmake: -------------------------------------------------------------------------------- 1 | find_package(PkgConfig QUIET) 2 | 3 | foreach(pc_lib ode-double ode) 4 | pkg_check_modules(pc_ode QUIET "${pc_lib}") 5 | if(pc_ode_FOUND) 6 | if(pc_ode_VERSION VERSION_LESS "0.13") 7 | if (pc_ode_CFLAGS MATCHES "-D(dSINGLE|dDOUBLE)") 8 | set(pc_ode_precision "${CMAKE_MATCH_1}") 9 | endif() 10 | else() 11 | pkg_get_variable(pc_ode_precision "${pc_lib}" precision) 12 | endif() 13 | 14 | break() 15 | endif() 16 | endforeach() 17 | 18 | find_library(ODE_LIBRARIES 19 | NAMES "${pc_ode_LIBRARIES}" 20 | HINTS "${pc_ode_LIBRARY_DIRS}" 21 | ) 22 | 23 | find_path(ODE_INCLUDE_DIR 24 | NAMES ode/ode.h 25 | HINTS "${pc_ode_INCLUDEDIR}" 26 | ) 27 | 28 | set(ODE_VERSION "${pc_ode_VERSION}") 29 | set(ODE_PRECISION "${pc_ode_precision}") 30 | 31 | include(FindPackageHandleStandardArgs) 32 | find_package_handle_standard_args(ODE 33 | REQUIRED_VARS ODE_LIBRARIES ODE_INCLUDE_DIR ODE_PRECISION 34 | VERSION_VAR ODE_VERSION 35 | ) 36 | 37 | mark_as_advanced(ODE_LIBRARIES ODE_INCLUDE_DIR ODE_PRECISION) 38 | 39 | if(ODE_LIBRARIES AND NOT TARGET ode::ode) 40 | add_library(ode::ode UNKNOWN IMPORTED) 41 | set_target_properties(ode::ode PROPERTIES 42 | IMPORTED_LOCATION "${ODE_LIBRARIES}" 43 | INTERFACE_INCLUDE_DIRECTORIES "${ODE_INCLUDE_DIR}") 44 | 45 | if(ODE_VERSION VERSION_LESS "0.13") 46 | if(ODE_PRECISION STREQUAL "dSINGLE") 47 | set_target_properties(ode::ode PROPERTIES 48 | INTERFACE_COMPILE_DEFINITIONS "dSINGLE") 49 | elseif(ODE_PRECISION STREQUAL "dDOUBLE") 50 | set_target_properties(ode::ode PROPERTIES 51 | INTERFACE_COMPILE_DEFINITIONS "dDOUBLE") 52 | endif() 53 | else() 54 | if(ODE_PRECISION STREQUAL "dSINGLE") 55 | set_target_properties(ode::ode PROPERTIES 56 | INTERFACE_COMPILE_DEFINITIONS "dIDESINGLE") 57 | elseif(ODE_PRECISION STREQUAL "dDOUBLE") 58 | set_target_properties(ode::ode PROPERTIES 59 | INTERFACE_COMPILE_DEFINITIONS "dIDEDOUBLE") 60 | endif() 61 | endif() 62 | endif() 63 | -------------------------------------------------------------------------------- /cmake/modules/FindOrBuildProtobuf.cmake: -------------------------------------------------------------------------------- 1 | # sanitize environment before find_package, because otherwise it also looks in the directory created for the ExternalProject 2 | include(EnvHelper) 3 | sanitize_env() 4 | find_package(Protobuf 3.3.0) 5 | restore_env() 6 | 7 | # protobuf versions >= 3.21 are incompatible with how the project is setup and cause weird errors 8 | # so we build protobuf ourselves 9 | if(NOT Protobuf_FOUND OR Protobuf_VERSION VERSION_GREATER_EQUAL 3.21) 10 | include(BuildProtobuf) 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/modules/FindVarTypes.cmake: -------------------------------------------------------------------------------- 1 | find_path( 2 | VARTYPES_INCLUDE_DIRS 3 | NAMES 4 | vartypes/VarTypes.h 5 | HINTS 6 | $ENV{HOME}/include 7 | /usr/local/include 8 | /usr/include 9 | $ENV{ProgramFiles}/vartypes/include 10 | ) 11 | 12 | find_library( 13 | VARTYPES_LIBRARY 14 | NAMES 15 | vartypes 16 | HINTS 17 | $ENV{HOME}/lib 18 | /usr/local/lib 19 | /usr/lib 20 | $ENV{ProgramFiles}/vartypes/lib 21 | ) 22 | 23 | set(VARTYPES_LIBRARIES ${VARTYPES_LIBRARY}) 24 | 25 | find_package_handle_standard_args( 26 | VARTYPES 27 | DEFAULT_MSG 28 | VARTYPES_INCLUDE_DIRS 29 | VARTYPES_LIBRARIES 30 | ) 31 | 32 | mark_as_advanced( 33 | VARTYPES_INCLUDE_DIRS 34 | VARTYPES_LIBRARIES 35 | VARTYPES_LIBRARY 36 | ) 37 | 38 | -------------------------------------------------------------------------------- /config/Parsian.ini: -------------------------------------------------------------------------------- 1 | [Geometery] 2 | CenterFromKicker= 0.073 3 | Radius = 0.09 4 | Height = 0.147 5 | RobotBottomZValue = 0.02 6 | KickerZValue = 0.005 7 | KickerThickness = 0.005 8 | KickerWidth = 0.08 9 | KickerHeight = 0.04 10 | WheelRadius = 0.027 11 | WheelThickness = 0.005 12 | Wheel1Angle = 60 13 | Wheel2Angle = 135 14 | Wheel3Angle = 225 15 | Wheel4Angle = 300 16 | [Physics] 17 | Bodymass = 2 18 | Wheelmass = 0.2 19 | Kickermass =0.02 20 | KickerDampFactor = 0.2 21 | RollerTorqueFactor = 0.06 22 | RollerPerpendicularTorqueFactor = 0.005 23 | KickerFriction = 0.8 24 | WheelTangentFriction = 0.8 25 | WheelPerpendicularFriction = 0.05 26 | WheelMotorMaximumApplyingTorque= 0.2 27 | 28 | MaxLinearKickSpeed=10 29 | MaxChipKickSpeed=10 30 | AccSpeedupAbsoluteMax=4 31 | AccSpeedupAngularMax=50 32 | AccBrakeAbsoluteMax=4 33 | AccBrakeAngularMax=50 34 | VelAbsoluteMax=5 35 | VelAngularMax=20 36 | -------------------------------------------------------------------------------- /config/ParsianNew.ini: -------------------------------------------------------------------------------- 1 | [Geometery] 2 | CenterFromKicker= 0.068 3 | Radius = 0.0793 4 | Height = 0.138 5 | RobotBottomZValue = 0.02 6 | KickerZValue = 0.005 7 | KickerThickness = 0.005 8 | KickerWidth = 0.08 9 | KickerHeight = 0.04 10 | WheelRadius = 0.027 11 | WheelThickness = 0.005 12 | Wheel1Angle = 60 13 | Wheel2Angle = 135 14 | Wheel3Angle = 225 15 | Wheel4Angle = 300 16 | [Physics] 17 | Bodymass = 2 18 | Wheelmass = 0.2 19 | Kickermass =0.02 20 | KickerDampFactor = 0.2 21 | RollerTorqueFactor = 0.06 22 | RollerPerpendicularTorqueFactor = 0.005 23 | KickerFriction = 0.8 24 | WheelTangentFriction = 0.8 25 | WheelPerpendicularFriction = 0.05 26 | WheelMotorMaximumApplyingTorque= 0.2 27 | 28 | MaxLinearKickSpeed=10 29 | MaxChipKickSpeed=10 30 | AccSpeedupAbsoluteMax=4 31 | AccSpeedupAngularMax=50 32 | AccBrakeAbsoluteMax=4 33 | AccBrakeAngularMax=50 34 | VelAbsoluteMax=5 35 | VelAngularMax=20 36 | 37 | -------------------------------------------------------------------------------- /config/RoboIME2012.ini: -------------------------------------------------------------------------------- 1 | [Geometery] 2 | CenterFromKicker = 0.073 3 | Radius = 0.0875 4 | Height = 0.141 5 | RobotBottomZValue = 0.005 6 | KickerZValue = 0.005 7 | KickerThickness = 0.005 8 | KickerWidth = 0.08 9 | KickerHeight = 0.04 10 | WheelRadius = 0.0289 11 | WheelThickness = 0.005 12 | Wheel1Angle = 57 13 | Wheel2Angle = 135 14 | Wheel3Angle = 225 15 | Wheel4Angle = 303 16 | 17 | [Physics] 18 | Bodymass = 2 19 | Wheelmass = 0.2 20 | Kickermass = 0.02 21 | KickerDampFactor = 0.2 22 | RollerTorqueFactor = 0.06 23 | RollerPerpendicularTorqueFactor = 0.005 24 | KickerFriction = 0.8 25 | WheelTangentFriction = 0.8 26 | WheelPerpendicularFriction = 0.05 27 | WheelMotorMaximumApplyingTorque = 0.2 28 | 29 | MaxLinearKickSpeed=10 30 | MaxChipKickSpeed=10 31 | AccSpeedupAbsoluteMax=4 32 | AccSpeedupAngularMax=50 33 | AccBrakeAbsoluteMax=4 34 | AccBrakeAngularMax=50 35 | VelAbsoluteMax=5 36 | VelAngularMax=20 37 | 38 | -------------------------------------------------------------------------------- /docker-entry.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | grSimArgs="$@" 4 | 5 | if [[ "$1" == "vnc" ]]; then 6 | echo "Launch in VNC mode" 7 | grSimArgs="${@:1}" 8 | if [[ -z "${VNC_PASSWORD}" ]]; then 9 | VNC_PASSWORD=vncpassword 10 | fi 11 | if [[ -z "${VNC_GEOMETRY}" ]]; then 12 | VNC_GEOMETRY=1280x1024 13 | fi 14 | 15 | mkdir ~/.vnc 16 | x11vnc -storepasswd "${VNC_PASSWORD}" ~/.vnc/passwd 17 | 18 | cat <>~/.xinitrc 19 | #!/bin/sh 20 | exec /usr/local/bin/grSim --qwindowgeometry ${VNC_GEOMETRY} $grSimArgs 21 | EOF 22 | chmod 700 ~/.xinitrc 23 | 24 | export X11VNC_CREATE_GEOM="${VNC_GEOMETRY}" 25 | exec x11vnc -forever -usepw -display WAIT:cmd=FINDCREATEDISPLAY-Xvfb 26 | else 27 | echo "Launch in headless mode" 28 | exec /usr/local/bin/grSim --headless -platform offscreen $grSimArgs 29 | fi 30 | -------------------------------------------------------------------------------- /docs/img/screenshot01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/docs/img/screenshot01.jpg -------------------------------------------------------------------------------- /include/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef COMMON_H 20 | #define COMMON_H 21 | 22 | #ifdef dDOUBLE 23 | #define GLreal GLdouble 24 | #else 25 | #define GLreal GLfloat 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTANTS_H 2 | #define CONSTANTS_H 3 | 4 | #define MAX_ROBOT_COUNT 16 //don't change 5 | #define TEAM_COUNT 2 6 | 7 | #endif //CONSTANTS_H 8 | 9 | -------------------------------------------------------------------------------- /include/configwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef CONFIGWIDGET_H 20 | #define CONFIGWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | using namespace VarTypes; 47 | 48 | 49 | #ifdef HAVE_MACOSX 50 | 51 | #define DEF_VALUE(type,Type,name) \ 52 | std::shared_ptr v_##name; \ 53 | inline type name() {return v_##name->get##Type();} 54 | 55 | #define DEF_FIELD_VALUE(type,Type,name) \ 56 | std::shared_ptr v_DivA_##name; \ 57 | std::shared_ptr v_DivB_##name; \ 58 | inline type name() {return (Division() == "Division A" ? v_DivA_##name: v_DivB_##name)->get##Type(); } 59 | 60 | 61 | #define DEF_ENUM(type,name) \ 62 | std::shared_ptr v_##name; \ 63 | type name() {if(v_##name!=nullptr) return v_##name->getString();return * (new type);} 64 | 65 | #define DEF_TREE(name) \ 66 | std::shared_ptr name; 67 | #define DEF_PTREE(parents, name) \ 68 | std::shared_ptr parents##_##name; 69 | 70 | #else 71 | 72 | #define DEF_VALUE(type,Type,name) \ 73 | std::shared_ptr v_##name; \ 74 | inline type name() {return v_##name->get##Type();} 75 | 76 | #define DEF_FIELD_VALUE(type,Type,name) \ 77 | std::shared_ptr v_DivA_##name; \ 78 | std::shared_ptr v_DivB_##name; \ 79 | inline type name() {return (Division() == "Division A" ? v_DivA_##name: v_DivB_##name)->get##Type(); } 80 | 81 | #define DEF_ENUM(type,name) \ 82 | std::shared_ptr v_##name; \ 83 | type name() {if(v_##name!=NULL) return v_##name->getString();return * (new type);} 84 | 85 | #define DEF_TREE(name) \ 86 | std::shared_ptr name; 87 | #define DEF_PTREE(parents, name) \ 88 | std::shared_ptr parents##_##name; 89 | 90 | #endif 91 | 92 | 93 | class RobotSettings { 94 | public: 95 | //geometeric settings 96 | double RobotCenterFromKicker; 97 | double RobotRadius; 98 | double RobotHeight; 99 | double BottomHeight; 100 | double KickerZ; 101 | double KickerThickness; 102 | double KickerWidth; 103 | double KickerHeight; 104 | double WheelRadius; 105 | double WheelThickness; 106 | double Wheel1Angle; 107 | double Wheel2Angle; 108 | double Wheel3Angle; 109 | double Wheel4Angle; 110 | //physical settings 111 | double BodyMass; 112 | double WheelMass; 113 | double KickerMass; 114 | double KickerDampFactor; 115 | double RollerTorqueFactor; 116 | double RollerPerpendicularTorqueFactor; 117 | double Kicker_Friction; 118 | double WheelTangentFriction; 119 | double WheelPerpendicularFriction; 120 | double Wheel_Motor_FMax; 121 | double MaxLinearKickSpeed; 122 | double MaxChipKickSpeed; 123 | double AccSpeedupAbsoluteMax; 124 | double AccSpeedupAngularMax; 125 | double AccBrakeAbsoluteMax; 126 | double AccBrakeAngularMax; 127 | double VelAbsoluteMax; 128 | double VelAngularMax; 129 | }; 130 | 131 | 132 | class ConfigWidget : public VarTreeView 133 | { 134 | Q_OBJECT 135 | 136 | protected: 137 | vector world; 138 | VarTreeModel * tmodel; 139 | public: 140 | VarListPtr geo_vars; 141 | ConfigWidget(); 142 | ~ConfigWidget() override; 143 | 144 | QSettings* robot_settings; 145 | RobotSettings robotSettings{}; 146 | RobotSettings blueSettings{}; 147 | RobotSettings yellowSettings{}; 148 | 149 | /* Geometry/Game Vartypes */ 150 | DEF_ENUM(std::string, Division) 151 | DEF_VALUE(int, Int, Robots_Count) 152 | DEF_FIELD_VALUE(double,Double,Field_Line_Width) 153 | DEF_FIELD_VALUE(double,Double,Field_Length) 154 | DEF_FIELD_VALUE(double,Double,Field_Width) 155 | DEF_FIELD_VALUE(double,Double,Field_Rad) 156 | DEF_FIELD_VALUE(double,Double,Field_Free_Kick) 157 | DEF_FIELD_VALUE(double,Double,Field_Penalty_Width) 158 | DEF_FIELD_VALUE(double,Double,Field_Penalty_Depth) 159 | DEF_FIELD_VALUE(double,Double,Field_Penalty_Point) 160 | DEF_FIELD_VALUE(double,Double,Field_Margin) 161 | DEF_FIELD_VALUE(double,Double,Field_Referee_Margin) 162 | DEF_FIELD_VALUE(double,Double,Wall_Thickness) 163 | DEF_FIELD_VALUE(double,Double,Goal_Thickness) 164 | DEF_FIELD_VALUE(double,Double,Goal_Depth) 165 | DEF_FIELD_VALUE(double,Double,Goal_Width) 166 | DEF_FIELD_VALUE(double,Double,Goal_Height) 167 | DEF_VALUE(double,Double,Camera_Height) 168 | DEF_VALUE(double,Double,Camera_Focal_Length) 169 | DEF_VALUE(double,Double,Camera_Scaling_Limit) 170 | 171 | DEF_ENUM(std::string,YellowTeam) 172 | DEF_ENUM(std::string,BlueTeam) 173 | DEF_VALUE(double,Double,BallRadius) 174 | DEF_VALUE(double,Double,BallMass) 175 | DEF_VALUE(double,Double,BallFriction) 176 | DEF_VALUE(double,Double,BallSlip) 177 | DEF_VALUE(double,Double,BallBounce) 178 | DEF_VALUE(double,Double,BallBounceVel) 179 | DEF_VALUE(double,Double,BallLinearDamp) 180 | DEF_VALUE(double,Double,BallAngularDamp) 181 | DEF_VALUE(bool,Bool,BallProjectAirborne) 182 | DEF_VALUE(double,Double,BallModelTwoPhaseAccSlide) 183 | DEF_VALUE(double,Double,BallModelTwoPhaseAccRoll) 184 | DEF_VALUE(double,Double,BallModelTwoPhaseKSwitch) 185 | DEF_VALUE(double,Double,BallModelChipFixedLossDampingXyFirstHop) 186 | DEF_VALUE(double,Double,BallModelChipFixedLossDampingXyOtherHops) 187 | DEF_VALUE(double,Double,BallModelChipFixedLossDampingZ) 188 | 189 | DEF_VALUE(bool,Bool,SyncWithGL) 190 | DEF_VALUE(double,Double,DesiredFPS) 191 | DEF_VALUE(double,Double,DeltaTime) 192 | DEF_VALUE(int,Int,sendGeometryEvery) 193 | DEF_VALUE(double,Double,Gravity) 194 | DEF_VALUE(bool,Bool,ResetTurnOver) 195 | DEF_VALUE(std::string,String,VisionMulticastAddr) 196 | DEF_VALUE(int,Int,VisionMulticastPort) 197 | DEF_VALUE(int,Int,CommandListenPort) 198 | DEF_VALUE(int,Int,BlueStatusSendPort) 199 | DEF_VALUE(int,Int,YellowStatusSendPort) 200 | DEF_VALUE(int,Int,SimControlListenPort) 201 | DEF_VALUE(int,Int,BlueControlListenPort) 202 | DEF_VALUE(int,Int,YellowControlListenPort) 203 | DEF_VALUE(int,Int,sendDelay) 204 | DEF_VALUE(bool,Bool,noise) 205 | DEF_VALUE(double,Double,noiseDeviation_x) 206 | DEF_VALUE(double,Double,noiseDeviation_y) 207 | DEF_VALUE(double,Double,noiseDeviation_angle) 208 | DEF_VALUE(bool,Bool,vanishing) 209 | DEF_VALUE(double,Double,ball_vanishing) 210 | DEF_VALUE(double,Double,blue_team_vanishing) 211 | DEF_VALUE(double,Double,yellow_team_vanishing) 212 | DEF_VALUE(std::string, String, plotter_addr) 213 | DEF_VALUE(int, Int, plotter_port) 214 | DEF_VALUE(bool, Bool, plotter) 215 | 216 | DEF_VALUE(std::string, String, ColorRobotBlue) 217 | DEF_VALUE(std::string, String, ColorRobotYellow) 218 | 219 | void loadRobotSettings(QString team); 220 | public slots: 221 | void loadRobotsSettings(); 222 | }; 223 | 224 | class ConfigDockWidget : public QDockWidget 225 | { 226 | Q_OBJECT 227 | public: 228 | QWidget* parent; 229 | ConfigWidget* conf; 230 | ConfigDockWidget(QWidget* _parent,ConfigWidget* _conf); 231 | protected: 232 | void closeEvent(QCloseEvent* event); 233 | signals: 234 | void closeSignal(bool); 235 | }; 236 | 237 | #endif // CONFIGWIDGET_H 238 | -------------------------------------------------------------------------------- /include/getpositionwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef GETPOSITIONWIDGET_H 20 | #define GETPOSITIONWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class GetPositionWidget : public QWidget 27 | { 28 | Q_OBJECT 29 | public: 30 | GetPositionWidget(); 31 | QLineEdit *x,*y,*a; 32 | QPushButton *okBtn,*cancelBtn; 33 | public slots: 34 | void cancelBtnClicked(); 35 | }; 36 | 37 | #endif // GETPOSITIONWIDGET_H 38 | -------------------------------------------------------------------------------- /include/glwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef GLWIDGET_H 20 | #define GLWIDGET_H 21 | 22 | #define GL_SILENCE_DEPRECATION 23 | #include 24 | #include 25 | #include 26 | 27 | #include "sslworld.h" 28 | #include "configwidget.h" 29 | 30 | 31 | class GLWidget : public QGLWidget { 32 | 33 | Q_OBJECT 34 | public: 35 | enum class CursorMode { 36 | STEADY = 0, 37 | PLACE_ROBOT = 1, 38 | PLACE_BALL = 2, 39 | }; 40 | enum class CameraMode { 41 | BIRDS_EYE_FROM_TOUCH_LINE = 0, 42 | CURRENT_ROBOT_VIEW = 1, 43 | TOP_VIEW = 2, 44 | BIRDS_EYE_FROM_OPPOSITE_TOUCH_LINE = 3, 45 | BIRDS_EYE_FROM_BLUE = 4, 46 | BIRDS_EYE_FROM_YELLOW = 5, 47 | MAX_ACTIVE_MODE_FOR_CHANGEMODE=BIRDS_EYE_FROM_YELLOW, 48 | // non-avaliable modes when "toggle camera mode" called 49 | LOCK_TO_ROBOT = -1, 50 | LOCK_TO_BALL = -2, 51 | }; 52 | GLWidget(QWidget *parent,ConfigWidget* _cfg); 53 | ~GLWidget(); 54 | dReal getFPS(); 55 | ConfigWidget* cfg; 56 | SSLWorld* ssl; 57 | RobotsFormation* forms[4]; 58 | QMenu* robpopup,*ballpopup,*mainpopup; 59 | QMenu *blueRobotsMenu,*yellowRobotsMenu,*allRobotsMenu; 60 | QAction* moveRobotAct; 61 | QAction* selectRobotAct; 62 | QAction* resetRobotAct; 63 | QAction* moveBallAct; 64 | QAction* lockToBallAct; 65 | QAction* onOffRobotAct; 66 | QAction* lockToRobotAct; 67 | QAction* moveBallHereAct; 68 | QAction* moveRobotHereAct; 69 | QAction* changeCamModeAct; 70 | QMenu *cameraMenu; 71 | int Current_robot,Current_team; 72 | int lockedIndex; 73 | bool ctrl,alt,kickingball,altTrigger; 74 | bool chiping; 75 | double kickpower, chipAngle; 76 | void update3DCursor(int mouse_x,int mouse_y); 77 | void putBall(dReal x,dReal y); 78 | void reform(int team,const QString& act); 79 | void step(); 80 | public slots: 81 | void moveRobot(); 82 | void selectRobot(); 83 | void unselectRobot(); 84 | void moveCurrentRobot(); 85 | void resetCurrentRobot(); 86 | void moveBall(); 87 | void changeCameraMode(); 88 | void yellowRobotsMenuTriggered(QAction* act); 89 | void blueRobotsMenuTriggered(QAction* act); 90 | void switchRobotOnOff(); 91 | void moveRobotHere(); 92 | void moveBallHere(); 93 | void lockCameraToRobot(); 94 | void lockCameraToBall(); 95 | signals: 96 | void clicked(); 97 | void selectedRobot(); 98 | void closeSignal(bool); 99 | void robotTurnedOnOff(int,bool); 100 | protected: 101 | void paintGL (); 102 | void initializeGL (); 103 | 104 | void mousePressEvent(QMouseEvent *event); 105 | void mouseMoveEvent(QMouseEvent *event); 106 | void mouseReleaseEvent(QMouseEvent *event); 107 | void wheelEvent(QWheelEvent *event); 108 | void keyPressEvent(QKeyEvent *event); 109 | void keyReleaseEvent(QKeyEvent* event); 110 | void closeEvent(QCloseEvent *event); 111 | private: 112 | CursorMode state; 113 | CameraMode cammode; 114 | int moving_robot_id,clicked_robot; 115 | int frames; 116 | bool first_time; 117 | QTime time,rendertimer; 118 | dReal m_fps; 119 | QPoint lastPos; 120 | }; 121 | 122 | #endif // WIDGET_H 123 | -------------------------------------------------------------------------------- /include/graphics.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef GRAPHICS_H 20 | #define GRAPHICS_H 21 | 22 | #define GL_SILENCE_DEPRECATION 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | enum CameraMotionMode { 30 | ROTATE_VIEW_POINT = 1, 31 | MOVE_POSITION_FREELY = 2, 32 | MOVE_POSITION_LR = 4, 33 | }; 34 | 35 | class CGraphics 36 | { 37 | private: 38 | dReal view_xyz[3],view_hpr[3]; 39 | QVector tex_ids; 40 | dReal frustum_right,frustum_bottom,frustum_vnear,m_renderDepth; 41 | int _width,_height; 42 | QGLWidget* owner; 43 | int sphere_quality; 44 | void _drawBox (const dReal sides[3]); 45 | void _drawPatch (dReal p1[3], dReal p2[3], dReal p3[3], int level); 46 | void _drawSphere(); 47 | void _drawCapsule (dReal l, dReal r); 48 | void _drawCylinder (dReal l, dReal r, dReal zoffset); 49 | void _drawCylinder_TopTextured (dReal l, dReal r, dReal zoffset,int tex_id,bool robot=false); 50 | void wrapCameraAngles(); 51 | void setCamera (dReal x, dReal y, dReal z, dReal h, dReal p, dReal r); 52 | bool graphicDisabled; 53 | public: 54 | CGraphics(QGLWidget* _owner); 55 | ~CGraphics(); 56 | void disableGraphics(); 57 | void enableGraphics(); 58 | bool isGraphicsEnabled(); 59 | int loadTexture(QImage* img); 60 | int loadTextureSkyBox(QImage* img); 61 | void setViewpoint (dReal xyz[3], dReal hpr[3]); 62 | void getViewpoint (dReal* xyz, dReal* hpr); 63 | void getFrustum(dReal& right,dReal& bottom,dReal& vnear); 64 | int getWidth(); 65 | int getHeight(); 66 | dReal renderDepth(); 67 | void setRenderDepth(dReal depth); 68 | void setViewpoint (dReal x,dReal y,dReal z,dReal h,dReal p,dReal r); 69 | void cameraMotion (CameraMotionMode mode, int deltax, int deltay); 70 | void lookAt(dReal x,dReal y,dReal z); 71 | void getCameraForward(dReal& x,dReal& y,dReal& z); 72 | void getCameraRight(dReal& x,dReal& y,dReal& z); 73 | void zoomCamera(dReal dz); 74 | void setColor (dReal r, dReal g, dReal b, dReal alpha); 75 | void setSphereQuality(int q); 76 | void setShadow(bool state); 77 | void useTexture(int tex_id); 78 | void noTexture(); 79 | void setTransform (const dReal pos[3], const dReal R[12]); 80 | void setTransformD (const double pos[3], const double R[12]); 81 | 82 | void initScene(int width,int height,dReal rc,dReal gc,dReal bc,bool fog=false,dReal fogr=0.6,dReal fogg=0.6,dReal fogb=0.6,dReal fogdensity=0.6); 83 | void finalizeScene(); 84 | void resetState(); 85 | void drawSkybox(int t1,int t2,int t3,int t4,int t5,int t6); 86 | void drawSky (); 87 | void drawGround(); 88 | void drawSSLGround(dReal SSL_FIELD_RAD,dReal SSL_FIELD_LENGTH,dReal SSL_FIELD_WIDTH,dReal SSL_FIELD_PENALTY_DEPTH,dReal SSL_FIELD_PENALTY_WIDTH,dReal SSL_FIELD_PENALTY_POINT, dReal SSL_FIELD_LINE_WIDTH, dReal epsilon); 89 | 90 | void drawBox (const dReal pos[3], const dReal R[12],const dReal sides[3]); 91 | void drawSphere (const dReal pos[3], const dReal R[12],dReal radius); 92 | void drawCylinder (const dReal pos[3], const dReal R[12],dReal length, dReal radius); 93 | void drawCylinder_TopTextured (const dReal pos[3], const dReal R[12],dReal length, dReal radius,int tex_id,bool robot=false); 94 | void drawCapsule (const dReal pos[3], const dReal R[12],dReal length, dReal radius); 95 | void drawLine (const dReal pos1[3], const dReal pos2[3]); 96 | void drawCircle(dReal x0,dReal y0,dReal z0,dReal r); 97 | 98 | }; 99 | 100 | #endif // GRAPHICS_H 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /include/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef LOGGER_H 20 | #define LOGGER_H 21 | 22 | #include 23 | #include 24 | 25 | void initLogger(void*); //MUST BE INITED FROM MAINWINDOW.CPP 26 | void logStatus(QString s,QColor c); 27 | 28 | #endif // LOGGER_H 29 | -------------------------------------------------------------------------------- /include/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef MAINWINDOW_H 20 | #define MAINWINDOW_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include "glwidget.h" 27 | #include "configwidget.h" 28 | #include "statuswidget.h" 29 | #include "robotwidget.h" 30 | 31 | class MainWindow : public QMainWindow 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | MainWindow(QWidget *parent = 0); 37 | ~MainWindow() override; 38 | public slots: 39 | void update(); 40 | void updateRobotLabel(); 41 | void showHideSimulator(bool v); 42 | void changeCurrentRobot(); 43 | void changeCurrentTeam(); 44 | 45 | void changeRobotCount(); 46 | 47 | void changeBallMass(); 48 | void changeBallGroundSurface(); 49 | void changeBallDamping(); 50 | void changeGravity(); 51 | void changeTimer(); 52 | 53 | void restartSimulator(); 54 | void ballMenuTriggered(QAction* act); 55 | void toggleFullScreen(bool); 56 | void setCurrentRobotPosition(); 57 | void takeSnapshot(); 58 | void takeSnapshotToClipboard(); 59 | 60 | void customFPS(int fps); 61 | void showAbout(); 62 | void reconnectCommandSocket(); 63 | void reconnectYellowStatusSocket(); 64 | void reconnectBlueStatusSocket(); 65 | void reconnectVisionSocket(); 66 | void reconnectSimControlSocket(); 67 | void reconnectBlueControlSocket(); 68 | void reconnectYellowControlSocket(); 69 | void recvActions(); 70 | void simControlSocketReady(); 71 | void blueControlSocketReady(); 72 | void yellowControlSocketReady(); 73 | void setIsGlEnabled(bool value); 74 | 75 | int robotIndex(int robot,int team); 76 | private: 77 | int getInterval(); 78 | QTimer *timer; 79 | GLWidget *glwidget; 80 | ConfigWidget *configwidget; 81 | ConfigDockWidget *dockconfig; 82 | RobotWidget *robotwidget; 83 | QByteArray prevState; 84 | 85 | CStatusPrinter *printer; 86 | CStatusWidget *statusWidget; 87 | 88 | QAction *showsimulator, *showconfig, *showrobot; 89 | QAction* fullScreenAct; 90 | QLabel *fpslabel,*cursorlabel,*selectinglabel,*vanishlabel,*noiselabel; 91 | QString current_dir; 92 | 93 | RoboCupSSLServer *visionServer; 94 | QUdpSocket *commandSocket; 95 | QUdpSocket *blueStatusSocket,*yellowStatusSocket; 96 | QUdpSocket *simControlSocket; 97 | QUdpSocket *blueControlSocket; 98 | QUdpSocket *yellowControlSocket; 99 | }; 100 | 101 | #endif // MAINWINDOW_H 102 | -------------------------------------------------------------------------------- /include/net/robocup_ssl_client.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This software is free: you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License Version 3, 4 | // as published by the Free Software Foundation. 5 | // 6 | // This software is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // Version 3 in the file COPYING that came with this distribution. 13 | // If not, see . 14 | //======================================================================== 15 | /*! 16 | \file robocup_ssl_client.h 17 | \brief C++ Interface: robocup_ssl_client 18 | \author Stefan Zickler, 2009 19 | \author Jan Segre, 2012 20 | */ 21 | //======================================================================== 22 | #ifndef ROBOCUP_SSL_CLIENT_H 23 | #define ROBOCUP_SSL_CLIENT_H 24 | #include 25 | #include 26 | #include "ssl_vision_detection.pb.h" 27 | #include "ssl_vision_geometry.pb.h" 28 | #include "ssl_vision_wrapper.pb.h" 29 | using namespace std; 30 | 31 | class QUdpSocket; 32 | class QHostAddress; 33 | class QNetworkInterface; 34 | 35 | class RoboCupSSLClient 36 | { 37 | public: 38 | RoboCupSSLClient(const quint16 & port=10002, 39 | const string & net_address="224.5.23.2", 40 | const string & net_interface=""); 41 | 42 | RoboCupSSLClient(const quint16 & port, 43 | const QHostAddress &, 44 | const QNetworkInterface &); 45 | 46 | ~RoboCupSSLClient(); 47 | 48 | bool open(); 49 | void close(); 50 | bool receive(SSL_WrapperPacket & packet); 51 | inline void changePort(quint16 port) {_port = port;} 52 | 53 | protected: 54 | QUdpSocket * _socket; 55 | QMutex mutex; 56 | quint16 _port; 57 | QHostAddress * _net_address; 58 | QNetworkInterface * _net_interface; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/net/robocup_ssl_server.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This software is free: you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License Version 3, 4 | // as published by the Free Software Foundation. 5 | // 6 | // This software is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // Version 3 in the file COPYING that came with this distribution. 13 | // If not, see . 14 | //======================================================================== 15 | /*! 16 | \file robocup_ssl_server.h 17 | \brief C++ Interface: robocup_ssl_server 18 | \author Stefan Zickler, 2009 19 | \author Jan Segre, 2012 20 | */ 21 | //======================================================================== 22 | #ifndef ROBOCUP_SSL_SERVER_H 23 | #define ROBOCUP_SSL_SERVER_H 24 | #include 25 | #include 26 | #include 27 | #include "ssl_vision_detection.pb.h" 28 | #include "ssl_vision_geometry.pb.h" 29 | #include "ssl_vision_wrapper.pb.h" 30 | using namespace std; 31 | 32 | class QUdpSocket; 33 | class QHostAddress; 34 | class QNetworkInterface; 35 | 36 | class RoboCupSSLServer 37 | { 38 | friend class MultiStackRoboCupSSL; 39 | public: 40 | RoboCupSSLServer(QObject *parent=0, 41 | const quint16 &port=10002, 42 | const string &net_address="224.5.23.2", 43 | const string &net_interface=""); 44 | 45 | ~RoboCupSSLServer(); 46 | 47 | bool send(const SSL_WrapperPacket & packet); 48 | bool send(const SSL_DetectionFrame & frame); 49 | bool send(const SSL_GeometryData & geometry); 50 | void change_port(const quint16 &port); 51 | void change_address(const string & net_address); 52 | void change_interface(const string & net_interface); 53 | 54 | protected: 55 | QUdpSocket * _socket; 56 | QMutex mutex; 57 | quint16 _port; 58 | QHostAddress * _net_address; 59 | QNetworkInterface * _net_interface; 60 | }; 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /include/physics/pball.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PBALL_H 20 | #define PBALL_H 21 | 22 | #include "pobject.h" 23 | 24 | class PBall : public PObject 25 | { 26 | private: 27 | dReal m_radius; 28 | public: 29 | PBall(dReal x,dReal y,dReal z,dReal radius,dReal mass,dReal red,dReal green,dReal blue); 30 | virtual ~PBall(); 31 | virtual void setMass(dReal mass); 32 | virtual void init(); 33 | virtual void draw(); 34 | }; 35 | 36 | #endif // PBALL_H 37 | -------------------------------------------------------------------------------- /include/physics/pbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PBOX_H 20 | #define PBOX_H 21 | 22 | 23 | #include "pobject.h" 24 | 25 | class PBox : public PObject 26 | { 27 | private: 28 | dReal m_w,m_h,m_l; 29 | public: 30 | PBox(dReal x,dReal y,dReal z,dReal w,dReal h,dReal l,dReal mass,dReal r,dReal g,dReal b); 31 | virtual ~PBox(); 32 | virtual void setMass(dReal mass); 33 | virtual void init(); 34 | virtual void draw(); 35 | }; 36 | 37 | #endif // PBOX_H 38 | -------------------------------------------------------------------------------- /include/physics/pcylinder.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PCYLINDER_H 20 | #define PCYLINDER_H 21 | 22 | #include "pobject.h" 23 | 24 | class PCylinder : public PObject 25 | { 26 | private: 27 | dReal m_radius,m_length; 28 | GLuint m_gllistid; 29 | int m_texid; 30 | bool m_robot; 31 | public: 32 | PCylinder(dReal x,dReal y,dReal z,dReal radius,dReal length,dReal mass,dReal red,dReal green,dReal blue,int tex_id=-1,bool robot=false); 33 | virtual ~PCylinder(); 34 | virtual void setMass(dReal mass); 35 | virtual void init(); 36 | virtual void draw(); 37 | }; 38 | 39 | #endif // PCYLINDER_H 40 | -------------------------------------------------------------------------------- /include/physics/pfixedbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PFIXEDBOX_H 20 | #define PFIXEDBOX_H 21 | 22 | #include "pobject.h" 23 | 24 | class PFixedBox : public PObject 25 | { 26 | private: 27 | dReal m_w,m_h,m_l; 28 | public: 29 | PFixedBox(dReal x,dReal y,dReal z,dReal w,dReal h,dReal l,dReal r,dReal g,dReal b); 30 | virtual ~PFixedBox(); 31 | virtual void init(); 32 | virtual void draw(); 33 | }; 34 | 35 | #endif // PFIXEDBOX_H 36 | -------------------------------------------------------------------------------- /include/physics/pground.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PGROUND_H 20 | #define PGROUND_H 21 | 22 | #include "pobject.h" 23 | 24 | class PGround : public PObject 25 | { 26 | private: 27 | dReal rad,len,wid,pdep,pwid,ppoint,lwidth; 28 | int tex; 29 | public: 30 | PGround(dReal field_radius,dReal field_length,dReal field_width,dReal field_penalty_rad,dReal field_penalty_line_length,dReal field_penalty_point, dReal field_line_width,int tex_id); 31 | virtual ~PGround(); 32 | virtual void init(); 33 | virtual void draw(); 34 | }; 35 | 36 | #endif // PGROUND_H 37 | -------------------------------------------------------------------------------- /include/physics/pobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef POBJECT_H 20 | #define POBJECT_H 21 | #include 22 | #include "graphics.h" 23 | 24 | class PObject 25 | { 26 | private: 27 | bool isQSet; 28 | protected: 29 | dReal m_x,m_y,m_z,m_red,m_green,m_blue; 30 | dReal m_mass; 31 | dMatrix3 local_Rot; 32 | dVector3 local_Pos; 33 | dQuaternion q; 34 | void initPosBody(); 35 | void initPosGeom(); 36 | bool visible; 37 | public: 38 | PObject(dReal x,dReal y,dReal z,dReal red,dReal green,dReal blue,dReal mass); 39 | virtual ~PObject(); 40 | void setRotation(dReal x_axis,dReal y_axis,dReal z_axis,dReal ang); //Must be called before init() 41 | void setBodyPosition(dReal x,dReal y,dReal z,bool local=false); 42 | void setBodyRotation(dReal x_axis,dReal y_axis,dReal z_axis,dReal ang,bool local=false); 43 | void getBodyPosition(dReal &x,dReal &y,dReal &z,bool local=false); 44 | void getBodyDirection(dReal &x,dReal &y,dReal &z); 45 | void getBodyDirection(dReal &x,dReal &y,dReal &z, dReal &k); 46 | void getBodyRotation(dMatrix3 r,bool local=false); 47 | void setVisibility(bool v); 48 | void setColor(dReal r,dReal g,dReal b); 49 | void setColor(const QColor& color); 50 | void getColor(dReal& r,dReal& g,dReal& b); 51 | bool getVisibility(); 52 | virtual void setMass(dReal mass); 53 | virtual void init()=0; 54 | virtual void glinit(); 55 | virtual void draw(); 56 | 57 | dBodyID body; 58 | dGeomID geom; 59 | dWorldID world; 60 | dSpaceID space; 61 | CGraphics *g; 62 | int tag; 63 | int id; 64 | }; 65 | 66 | #endif // POBJECT_H 67 | -------------------------------------------------------------------------------- /include/physics/pray.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PRAY_H 20 | #define PRAY_H 21 | 22 | #include "pobject.h" 23 | 24 | class PRay : public PObject 25 | { 26 | private: 27 | dReal _length; 28 | public: 29 | PRay(dReal length); 30 | virtual void init(); 31 | void setPose(dReal x,dReal y,dReal z,dReal dx,dReal dy,dReal dz); 32 | }; 33 | 34 | #endif // PRAY_H 35 | -------------------------------------------------------------------------------- /include/physics/pworld.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PWORLD_H 20 | #define PWORLD_H 21 | 22 | #include "pobject.h" 23 | #include 24 | #include 25 | 26 | class PSurface; 27 | class PWorld 28 | { 29 | private: 30 | dJointGroupID contactgroup; 31 | QVector objects; 32 | QVector surfaces; 33 | dReal delta_time; 34 | int **sur_matrix; 35 | int objects_count; 36 | public: 37 | PWorld(dReal dt,dReal gravity,CGraphics* graphics, int robot_count); 38 | ~PWorld(); 39 | void setGravity(dReal gravity); 40 | void addObject(PObject* o); 41 | void initAllObjects(); 42 | PSurface* createSurface(PObject* o1,PObject* o2); 43 | PSurface* findSurface(PObject* o1,PObject* o2); 44 | void step(dReal dt=-1); 45 | void glinit(); 46 | void draw(); 47 | void handleCollisions(dGeomID o1, dGeomID o2); 48 | dWorldID world; 49 | dSpaceID space; 50 | CGraphics* g; 51 | int robot_count; 52 | }; 53 | 54 | typedef bool PSurfaceCallback(dGeomID o1,dGeomID o2,PSurface* s,int robot_count); 55 | class PSurface 56 | { 57 | public: 58 | PSurface(); 59 | dSurfaceParameters surface; 60 | bool isIt(dGeomID i1,dGeomID i2); 61 | dGeomID id1,id2; 62 | bool usefdir1; //if true use fdir1 instead of ODE value 63 | dVector3 fdir1; //fdir1 is a normalized vector tangent to friction force vector 64 | dVector3 contactPos,contactNormal; 65 | PSurfaceCallback* callback; 66 | }; 67 | #endif // PWORLD_H 68 | -------------------------------------------------------------------------------- /include/robot.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef ROBOT_H 20 | #define ROBOT_H 21 | 22 | #include "physics/pworld.h" 23 | #include "physics/pcylinder.h" 24 | #include "physics/pbox.h" 25 | #include "physics/pball.h" 26 | #include "configwidget.h" 27 | 28 | enum KickStatus { 29 | NO_KICK = 0, 30 | FLAT_KICK = 1, 31 | CHIP_KICK = 2, 32 | }; 33 | 34 | class Robot { 35 | PWorld* w; 36 | PBall* m_ball; 37 | dReal m_x,m_y,m_z; 38 | dReal m_r,m_g,m_b; 39 | dReal m_dir; 40 | int m_rob_id; 41 | bool firsttime; 42 | bool last_state{}; 43 | 44 | dReal AccSpeedupAbsoluteMax; 45 | dReal AccSpeedupAngularMax; 46 | dReal AccBrakeAbsoluteMax; 47 | dReal AccBrakeAngularMax; 48 | dReal VelAbsoluteMax; 49 | dReal VelAngularMax; 50 | public: 51 | ConfigWidget* cfg; 52 | dSpaceID space; 53 | PCylinder* chassis; 54 | PBall* dummy; 55 | dJointID dummy_to_chassis; 56 | PBox* boxes[3]{}; 57 | bool on; 58 | //these values are not controled by this class 59 | bool selected{}; 60 | dReal select_x{},select_y{},select_z{}; 61 | QImage *img{},*number{}; 62 | class Wheel 63 | { 64 | public: 65 | int id; 66 | Wheel(Robot* robot,int _id,dReal ang,dReal ang2,int wheeltexid); 67 | void step(); 68 | dJointID joint; 69 | dJointID motor; 70 | PCylinder* cyl; 71 | dReal speed; 72 | Robot* rob; 73 | } *wheels[4]{}; 74 | class Kicker 75 | { 76 | private: 77 | KickStatus kicking; 78 | int rolling; 79 | int kickstate; 80 | dReal m_kickspeed,m_kicktime; 81 | bool holdingBall; 82 | public: 83 | Kicker(Robot* robot); 84 | void step(); 85 | void kick(dReal kickspeedx, dReal kickspeedz); 86 | void setRoller(int roller); 87 | int getRoller(); 88 | void toggleRoller(); 89 | bool isTouchingBall(); 90 | KickStatus isKicking(); 91 | void holdBall(); 92 | void unholdBall(); 93 | dJointID joint; 94 | dJointID robot_to_ball; 95 | PBox* box; 96 | Robot* rob; 97 | } *kicker; 98 | 99 | Robot(PWorld* world,PBall* ball,ConfigWidget* _cfg,dReal x,dReal y,dReal z,dReal r,dReal g,dReal b,int rob_id,int wheeltexid,int dir); 100 | ~Robot(); 101 | void step(); 102 | void drawLabel(); 103 | void setSpeed(int i,dReal s); //i = 0,1,2,3 104 | void setSpeed(dReal vx, dReal vy, dReal vw); 105 | dReal getSpeed(int i); 106 | void incSpeed(int i,dReal v); 107 | void resetSpeeds(); 108 | void resetRobot(); 109 | void getXY(dReal& x,dReal& y); 110 | dReal getDir(); 111 | dReal getDir(dReal &k); 112 | void setXY(dReal x,dReal y); 113 | void setDir(dReal ang); 114 | int getID(); 115 | PBall* getBall(); 116 | PWorld* getWorld(); 117 | }; 118 | 119 | 120 | #define ROBOT_START_Z(cfg) (cfg->robotSettings.RobotHeight*0.5 + cfg->robotSettings.WheelRadius*1.1 + cfg->robotSettings.BottomHeight) 121 | 122 | #endif // ROBOT_H 123 | -------------------------------------------------------------------------------- /include/robotwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef ROBOTWIDGET_H 20 | #define ROBOTWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "configwidget.h" 28 | #include "getpositionwidget.h" 29 | 30 | class RobotWidget : public QDockWidget 31 | { 32 | Q_OBJECT 33 | public: 34 | RobotWidget(QWidget* parent, ConfigWidget* cfg); 35 | void setPicture(QImage* img); 36 | void changeRobotCount(int newRobotCount); 37 | void changeCurrentRobot(int CurrentRobotID); 38 | QComboBox *teamCombo,*robotCombo; 39 | QLabel *robotpic; 40 | QLabel *vellabel,*acclabel; 41 | QPushButton *resetBtn,*locateBtn; 42 | QPushButton *onOffBtn,*setPoseBtn; 43 | GetPositionWidget* getPoseWidget; 44 | int id; 45 | public slots: 46 | void changeRobotOnOff(int,bool); 47 | void setPoseBtnClicked(); 48 | }; 49 | 50 | #endif // ROBOTWIDGET_H 51 | -------------------------------------------------------------------------------- /include/sslworld.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SSLWORLD_H 20 | #define SSLWORLD_H 21 | 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | #include "graphics.h" 30 | #include "physics/pworld.h" 31 | #include "physics/pball.h" 32 | #include "physics/pground.h" 33 | #include "physics/pfixedbox.h" 34 | #include "physics/pray.h" 35 | 36 | #include "net/robocup_ssl_server.h" 37 | 38 | #include "robot.h" 39 | #include "configwidget.h" 40 | 41 | #include "config.h" 42 | 43 | #include "grSim_Robotstatus.pb.h" 44 | #include "ssl_simulation_config.pb.h" 45 | #include "ssl_simulation_control.pb.h" 46 | #include "ssl_simulation_robot_control.pb.h" 47 | #include "ssl_simulation_robot_feedback.pb.h" 48 | 49 | #define WALL_COUNT 10 50 | 51 | 52 | class RobotsFormation; 53 | class SendingPacket { 54 | public: 55 | SendingPacket(SSL_WrapperPacket* _packet,int _t); 56 | SSL_WrapperPacket* packet; 57 | int t; 58 | }; 59 | 60 | class SSLWorld : public QObject 61 | { 62 | Q_OBJECT 63 | private: 64 | QGLWidget* m_parent; 65 | int frame_num; 66 | dReal last_dt; 67 | dReal sim_time = 0; 68 | QList sendQueue; 69 | bool lastInfraredState[TEAM_COUNT][MAX_ROBOT_COUNT]{}; 70 | KickStatus lastKickState[TEAM_COUNT][MAX_ROBOT_COUNT]{}; 71 | void processSimControl(const SimulatorCommand &simulatorCommand, SimulatorResponse &simulatorResponse); 72 | void processRobotControl(const RobotControl &robotControl, RobotControlResponse &robotControlResponse, Team team); 73 | void processRobotSpec(const RobotSpecs &robotSpec) const; 74 | static void processRobotLimits(const RobotSpecs &robotSpec, RobotSettings *settings); 75 | static void processMoveCommand(RobotControlResponse &robotControlResponse, const RobotMoveCommand &robotCommand, 76 | Robot *robot) ; 77 | void processTeleportBall(SimulatorResponse &simulatorResponse, const TeleportBall &teleBall) const; 78 | static void processTeleportRobot(const TeleportRobot &teleBot, Robot *robot); 79 | public: 80 | dReal customDT; 81 | bool isGLEnabled; 82 | SSLWorld(QGLWidget* parent, ConfigWidget* _cfg, RobotsFormation *form1, RobotsFormation *form2); 83 | ~SSLWorld() override; 84 | void glinit(); 85 | void step(dReal dt=-1); 86 | SSL_WrapperPacket* generatePacket(int cam_id=0); 87 | void addFieldLinesArcs(SSL_GeometryFieldSize *field); 88 | static void addFieldLine(SSL_GeometryFieldSize *field, const std::string &name, float p1_x, float p1_y, float p2_x, float p2_y, float thickness); 89 | static void addFieldArc(SSL_GeometryFieldSize *field, const string &name, float c_x, float c_y, float radius, float a1, float a2, float thickness); 90 | void sendVisionBuffer(); 91 | static bool visibleInCam(int id, double x, double y); 92 | QPair cameraPosition(int id); 93 | int robotIndex(int robot,int team); 94 | static void addRobotStatus(Robots_Status& robotsPacket, int robotID, bool infrared, KickStatus kickStatus); 95 | void sendRobotStatus(Robots_Status& robotsPacket, const QHostAddress& sender, int team); 96 | 97 | ConfigWidget* cfg; 98 | CGraphics* g; 99 | PWorld* p; 100 | PBall* ball; 101 | PGround* ground; 102 | PRay* ray; 103 | PFixedBox* walls[WALL_COUNT]{}; 104 | int selected{}; 105 | bool show3DCursor; 106 | dReal cursor_x{},cursor_y{},cursor_z{}; 107 | dReal cursor_radius{}; 108 | RoboCupSSLServer *visionServer{}; 109 | QUdpSocket *commandSocket{}; 110 | QUdpSocket *blueStatusSocket{},*yellowStatusSocket{}; 111 | QUdpSocket *simControlSocket; 112 | QUdpSocket *blueControlSocket; 113 | QUdpSocket *yellowControlSocket; 114 | 115 | QElapsedTimer elapsedLastPackageBlue; 116 | QElapsedTimer elapsedLastPackageYellow; 117 | 118 | bool updatedCursor; 119 | Robot* robots[MAX_ROBOT_COUNT*2]{}; 120 | int sendGeomCount; 121 | bool restartRequired; 122 | public slots: 123 | void recvActions(); 124 | void simControlSocketReady(); 125 | void blueControlSocketReady(); 126 | void yellowControlSocketReady(); 127 | signals: 128 | void fpsChanged(int newFPS); 129 | }; 130 | 131 | 132 | enum E_FORMATION { 133 | FORMATION_OUTSIDE = 0, 134 | FORMATION_INSIDE_1 = 1, 135 | FORMATION_INSIDE_2 = 2, 136 | FORMATION_OUTSIDE_FIELD = 3 137 | }; 138 | 139 | class RobotsFormation { 140 | public: 141 | dReal x[MAX_ROBOT_COUNT]{}; 142 | dReal y[MAX_ROBOT_COUNT]{}; 143 | RobotsFormation(E_FORMATION type, ConfigWidget* _cfg); 144 | void setAll(const dReal *xx,const dReal *yy); 145 | void loadFromFile(const QString& filename); 146 | void resetRobots(Robot** r,int team); 147 | private: 148 | ConfigWidget* cfg; 149 | }; 150 | 151 | dReal fric(dReal f); 152 | int robotIndex(int robot,int team); 153 | 154 | #endif // SSLWORLD_H 155 | -------------------------------------------------------------------------------- /include/statuswidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef CSTATUSWIDGET_H 20 | #define CSTATUSWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | class CStatusText 34 | { 35 | public: 36 | CStatusText(QString _text = "", QColor _color = QColor("black"), int _size = 12) 37 | { 38 | text= _text; 39 | color = _color; 40 | size = _size; 41 | } 42 | 43 | QString text; 44 | QColor color; 45 | int size; 46 | }; 47 | 48 | class CStatusPrinter 49 | { 50 | public: 51 | CStatusPrinter() {} 52 | 53 | QQueue textBuffer; 54 | }; 55 | 56 | 57 | class CStatusWidget : public QDockWidget 58 | { 59 | Q_OBJECT 60 | public: 61 | CStatusWidget(CStatusPrinter* _statusPrinter); 62 | QTextEdit *statusText; 63 | QLabel *titleLbl; 64 | QTextDocument content; 65 | 66 | public slots: 67 | void write(QString str, QColor color = QColor("black")); 68 | void update(); 69 | 70 | private: 71 | CStatusPrinter *statusPrinter; 72 | QTime logTime; 73 | 74 | }; 75 | 76 | #endif // CSTATUSWIDGET_H 77 | -------------------------------------------------------------------------------- /include/winmain.h: -------------------------------------------------------------------------------- 1 | #ifndef WINMAIN_H 2 | #define WINMAIN_H 3 | #ifdef HAVE_WINDOWS 4 | 5 | int main(int, char**); 6 | 7 | int CALLBACK WinMain( 8 | __in HINSTANCE hInstance, 9 | __in HINSTANCE hPrevInstance, 10 | __in LPSTR lpCmdLine, 11 | __in int nCmdShow) 12 | { 13 | wchar_t **wargv;//wargv is an array of LPWSTR (wide-char string) 14 | char **argv; 15 | int argc; 16 | // we have to convert each arg to a char* 17 | wargv = CommandLineToArgvW(GetCommandLineW(), &argc); 18 | // here and then we allocate one more cell to make it a NULL-end array 19 | argv = (char **)calloc(argc + 1, sizeof(char *)); 20 | for(int i = 0; i < argc; i++) { 21 | size_t origSize = wcslen(wargv[i]) + 1; 22 | size_t converted = 0; 23 | argv[i] = (char *)calloc(origSize + 1, sizeof(char)); 24 | // we use the truncate strategy, it won't handle non latin chars correctly 25 | // but hey we don't even use args, right? 26 | wcstombs_s(&converted, argv[i], origSize, wargv[i], _TRUNCATE); 27 | } 28 | return main(argc, argv); 29 | } 30 | #endif 31 | #endif 32 | -------------------------------------------------------------------------------- /resources/grsim.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Version=2.2 4 | Name=grSim 5 | Comment=Robocup Small Size Robot Soccer Simulator 6 | Exec=grSim 7 | Icon=grsim 8 | Terminal=false 9 | Categories=Utility;Physics;Robotics;Application 10 | -------------------------------------------------------------------------------- /resources/grsim.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON "icons/grsim.ico" -------------------------------------------------------------------------------- /resources/icons/grsim.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/icons/grsim.icns -------------------------------------------------------------------------------- /resources/icons/grsim.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/icons/grsim.ico -------------------------------------------------------------------------------- /resources/icons/grsim.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 20 | 23 | 24 | 25 | 28 | 30 | 32 | 33 | 35 | 36 | 38 | 39 | 41 | 43 | 45 | 47 | 48 | 49 | 50 | 52 | 54 | 55 | 57 | 58 | 59 | 62 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /resources/textures.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ../resources/textures/y0.png 5 | ../resources/textures/y1.png 6 | ../resources/textures/y2.png 7 | ../resources/textures/y3.png 8 | ../resources/textures/y4.png 9 | ../resources/textures/y5.png 10 | ../resources/textures/y6.png 11 | ../resources/textures/y7.png 12 | ../resources/textures/y8.png 13 | ../resources/textures/y9.png 14 | ../resources/textures/y10.png 15 | ../resources/textures/y11.png 16 | ../resources/textures/y12.png 17 | ../resources/textures/y13.png 18 | ../resources/textures/y14.png 19 | ../resources/textures/y15.png 20 | ../resources/textures/b0.png 21 | ../resources/textures/b1.png 22 | ../resources/textures/b2.png 23 | ../resources/textures/b3.png 24 | ../resources/textures/b4.png 25 | ../resources/textures/b5.png 26 | ../resources/textures/b6.png 27 | ../resources/textures/b7.png 28 | ../resources/textures/b8.png 29 | ../resources/textures/b9.png 30 | ../resources/textures/b10.png 31 | ../resources/textures/b11.png 32 | ../resources/textures/b12.png 33 | ../resources/textures/b13.png 34 | ../resources/textures/b14.png 35 | ../resources/textures/b15.png 36 | ../resources/textures/wheel.png 37 | ../resources/textures/grass.png 38 | ../resources/textures/sky/arabian_nights_rt.png 39 | ../resources/textures/sky/arabian_nights_bk.png 40 | ../resources/textures/sky/arabian_nights_dn.png 41 | ../resources/textures/sky/arabian_nights_lf.png 42 | ../resources/textures/sky/arabian_nights_ft.png 43 | ../resources/textures/sky/arabian_nights_up.png 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /resources/textures/b0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b0.png -------------------------------------------------------------------------------- /resources/textures/b1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b1.png -------------------------------------------------------------------------------- /resources/textures/b10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b10.png -------------------------------------------------------------------------------- /resources/textures/b11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b11.png -------------------------------------------------------------------------------- /resources/textures/b12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b12.png -------------------------------------------------------------------------------- /resources/textures/b13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b13.png -------------------------------------------------------------------------------- /resources/textures/b14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b14.png -------------------------------------------------------------------------------- /resources/textures/b15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b15.png -------------------------------------------------------------------------------- /resources/textures/b2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b2.png -------------------------------------------------------------------------------- /resources/textures/b3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b3.png -------------------------------------------------------------------------------- /resources/textures/b4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b4.png -------------------------------------------------------------------------------- /resources/textures/b5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b5.png -------------------------------------------------------------------------------- /resources/textures/b6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b6.png -------------------------------------------------------------------------------- /resources/textures/b7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b7.png -------------------------------------------------------------------------------- /resources/textures/b8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b8.png -------------------------------------------------------------------------------- /resources/textures/b9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/b9.png -------------------------------------------------------------------------------- /resources/textures/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/grass.png -------------------------------------------------------------------------------- /resources/textures/qt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/qt.png -------------------------------------------------------------------------------- /resources/textures/sky/arabian_nights_bk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/sky/arabian_nights_bk.png -------------------------------------------------------------------------------- /resources/textures/sky/arabian_nights_dn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/sky/arabian_nights_dn.png -------------------------------------------------------------------------------- /resources/textures/sky/arabian_nights_ft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/sky/arabian_nights_ft.png -------------------------------------------------------------------------------- /resources/textures/sky/arabian_nights_lf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/sky/arabian_nights_lf.png -------------------------------------------------------------------------------- /resources/textures/sky/arabian_nights_rt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/sky/arabian_nights_rt.png -------------------------------------------------------------------------------- /resources/textures/sky/arabian_nights_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/sky/arabian_nights_up.png -------------------------------------------------------------------------------- /resources/textures/wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/wheel.png -------------------------------------------------------------------------------- /resources/textures/y0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y0.png -------------------------------------------------------------------------------- /resources/textures/y1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y1.png -------------------------------------------------------------------------------- /resources/textures/y10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y10.png -------------------------------------------------------------------------------- /resources/textures/y11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y11.png -------------------------------------------------------------------------------- /resources/textures/y12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y12.png -------------------------------------------------------------------------------- /resources/textures/y13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y13.png -------------------------------------------------------------------------------- /resources/textures/y14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y14.png -------------------------------------------------------------------------------- /resources/textures/y15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y15.png -------------------------------------------------------------------------------- /resources/textures/y2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y2.png -------------------------------------------------------------------------------- /resources/textures/y3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y3.png -------------------------------------------------------------------------------- /resources/textures/y4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y4.png -------------------------------------------------------------------------------- /resources/textures/y5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y5.png -------------------------------------------------------------------------------- /resources/textures/y6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y6.png -------------------------------------------------------------------------------- /resources/textures/y7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y7.png -------------------------------------------------------------------------------- /resources/textures/y8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y8.png -------------------------------------------------------------------------------- /resources/textures/y9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoboCup-SSL/grSim/56203d1c13a89307c4ca5ee0af76868d4edd91aa/resources/textures/y9.png -------------------------------------------------------------------------------- /src/getpositionwidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "getpositionwidget.h" 20 | #include 21 | #include 22 | #include 23 | 24 | GetPositionWidget::GetPositionWidget() 25 | { 26 | QGridLayout *layout = new QGridLayout(this); 27 | okBtn = new QPushButton("&Ok",this); 28 | cancelBtn = new QPushButton("&Cancel",this); 29 | x = new QLineEdit(this); 30 | y = new QLineEdit(this); 31 | a = new QLineEdit(this); 32 | layout->addWidget(new QLabel("X"),0,0); 33 | layout->addWidget(new QLabel("Y"),1,0); 34 | layout->addWidget(new QLabel("Angle"),2,0); 35 | layout->addWidget(okBtn,3,1); 36 | layout->addWidget(cancelBtn,3,0); 37 | layout->addWidget(x,0,1); 38 | layout->addWidget(y,1,1); 39 | layout->addWidget(a,2,1); 40 | setLayout(layout); 41 | connect(cancelBtn,SIGNAL(clicked()),this,SLOT(cancelBtnClicked())); 42 | } 43 | 44 | void GetPositionWidget::cancelBtnClicked() 45 | { 46 | close(); 47 | } 48 | -------------------------------------------------------------------------------- /src/logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "logger.h" 20 | #include "statuswidget.h" 21 | CStatusPrinter *printer; 22 | void initLogger(void* v) 23 | { 24 | printer = (CStatusPrinter*) v; 25 | } 26 | 27 | void logStatus(QString s,QColor c) 28 | { 29 | printer->textBuffer.enqueue(CStatusText(s,c)); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #include 19 | #include "mainwindow.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | std::locale::global( std::locale( "" ) ); 24 | 25 | QCoreApplication::setOrganizationName("Parsian"); 26 | QCoreApplication::setOrganizationDomain("parsian-robotics.com"); 27 | QCoreApplication::setApplicationName("grSim"); 28 | QApplication a(argc, argv); 29 | 30 | QCommandLineParser parser; 31 | parser.setApplicationDescription("RoboCup Small Size League Simulator"); 32 | parser.addHelpOption(); 33 | QCommandLineOption headlessOption(QStringList() << "H" << "headless", 34 | QCoreApplication::translate("main", "Run without a UI")); 35 | parser.addOption(headlessOption); 36 | parser.process(a); 37 | 38 | MainWindow w; 39 | if (parser.isSet(headlessOption)) { 40 | // enable headless mode 41 | w.hide(); 42 | w.setIsGlEnabled(false); 43 | } else { 44 | // Run normally 45 | w.show(); 46 | } 47 | return a.exec(); 48 | } 49 | -------------------------------------------------------------------------------- /src/net/robocup_ssl_client.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This software is free: you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License Version 3, 4 | // as published by the Free Software Foundation. 5 | // 6 | // This software is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // Version 3 in the file COPYING that came with this distribution. 13 | // If not, see . 14 | //======================================================================== 15 | /*! 16 | \file robocup_ssl_client.cpp 17 | \brief C++ Implementation: robocup_ssl_client 18 | \author Stefan Zickler, 2009 19 | \author Jan Segre, 2012 20 | */ 21 | //======================================================================== 22 | #include "robocup_ssl_client.h" 23 | #include 24 | #include 25 | 26 | using namespace std; 27 | 28 | RoboCupSSLClient::RoboCupSSLClient(const quint16 & port, const string & net_address, const string & net_interface) : 29 | _socket(new QUdpSocket()), 30 | _port(port), 31 | _net_address(new QHostAddress(QString(net_address.c_str()))), 32 | _net_interface(new QNetworkInterface(QNetworkInterface::interfaceFromName(QString(net_interface.c_str())))) 33 | { 34 | } 35 | 36 | RoboCupSSLClient::RoboCupSSLClient(const quint16 & port, const QHostAddress & addr, const QNetworkInterface & iface) : 37 | _socket(new QUdpSocket()), 38 | _port(port), 39 | _net_address(new QHostAddress(addr)), 40 | _net_interface(new QNetworkInterface(iface)) 41 | { 42 | } 43 | 44 | RoboCupSSLClient::~RoboCupSSLClient() 45 | { 46 | delete _socket; 47 | delete _net_address; 48 | delete _net_interface; 49 | } 50 | 51 | void RoboCupSSLClient::close() 52 | { 53 | if(_socket->state() == QUdpSocket::BoundState) 54 | _socket->leaveMulticastGroup(*_net_address, *_net_interface); 55 | } 56 | 57 | bool RoboCupSSLClient::open() 58 | { 59 | close(); 60 | if(!_socket->bind(_port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { 61 | cerr << "Unable to bind UDP socket on port " << _port << ". " 62 | << _socket->errorString().toStdString() << '.' << endl; 63 | return false; 64 | } 65 | 66 | if(!_socket->joinMulticastGroup(*_net_address, *_net_interface)) { 67 | cerr << "Unable to join UDP multicast on " 68 | << _net_address->toString().toStdString() << ':' << _port << ". " 69 | << _socket->errorString().toStdString().c_str() << '.' << endl; 70 | return false; 71 | } 72 | 73 | return true; 74 | } 75 | 76 | bool RoboCupSSLClient::receive(SSL_WrapperPacket & packet) 77 | { 78 | if(_socket->state() == QUdpSocket::BoundState && _socket->hasPendingDatagrams()) { 79 | QByteArray datagram; 80 | mutex.lock(); 81 | datagram.resize(_socket->pendingDatagramSize()); 82 | _socket->readDatagram(datagram.data(), datagram.size()); 83 | mutex.unlock(); 84 | //decode packet: 85 | return packet.ParseFromArray(datagram.data(), datagram.size()); 86 | } else { 87 | return false; 88 | } 89 | } 90 | 91 | -------------------------------------------------------------------------------- /src/net/robocup_ssl_server.cpp: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This software is free: you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License Version 3, 4 | // as published by the Free Software Foundation. 5 | // 6 | // This software is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // Version 3 in the file COPYING that came with this distribution. 13 | // If not, see . 14 | //======================================================================== 15 | /*! 16 | \file robocup_ssl_server.cpp 17 | \brief C++ Implementation: robocup_ssl_server 18 | \author Stefan Zickler, 2009 19 | \author Jan Segre, 2012 20 | */ 21 | //======================================================================== 22 | #include "robocup_ssl_server.h" 23 | #include 24 | #include 25 | #include "logger.h" 26 | 27 | using namespace std; 28 | 29 | RoboCupSSLServer::RoboCupSSLServer(QObject *parent, const quint16 &port, const string &net_address, const string &net_interface) : 30 | _socket(new QUdpSocket(parent)), 31 | _port(port), 32 | _net_address(new QHostAddress(QString(net_address.c_str()))), 33 | _net_interface(new QNetworkInterface(QNetworkInterface::interfaceFromName(QString(net_interface.c_str())))) 34 | { 35 | _socket->setSocketOption(QAbstractSocket::MulticastTtlOption, 1); 36 | } 37 | 38 | RoboCupSSLServer::~RoboCupSSLServer() 39 | { 40 | mutex.lock(); 41 | mutex.unlock(); 42 | delete _socket; 43 | delete _net_address; 44 | delete _net_interface; 45 | } 46 | 47 | void RoboCupSSLServer::change_port(const quint16 & port) 48 | { 49 | _port = port; 50 | } 51 | 52 | void RoboCupSSLServer::change_address(const string & net_address) 53 | { 54 | delete _net_address; 55 | _net_address = new QHostAddress(QString(net_address.c_str())); 56 | } 57 | 58 | void RoboCupSSLServer::change_interface(const string & net_interface) 59 | { 60 | delete _net_interface; 61 | _net_interface = new QNetworkInterface(QNetworkInterface::interfaceFromName(QString(net_interface.c_str()))); 62 | } 63 | 64 | bool RoboCupSSLServer::send(const SSL_WrapperPacket & packet) 65 | { 66 | QByteArray datagram; 67 | 68 | datagram.resize(packet.ByteSize()); 69 | bool success = packet.SerializeToArray(datagram.data(), datagram.size()); 70 | if(!success) { 71 | //TODO: print useful info 72 | logStatus(QString("Serializing packet to array failed."), QColor("red")); 73 | return false; 74 | } 75 | 76 | mutex.lock(); 77 | quint64 bytes_sent = _socket->writeDatagram(datagram, *_net_address, _port); 78 | mutex.unlock(); 79 | if (bytes_sent != datagram.size()) { 80 | logStatus(QString("Sending UDP datagram failed (maybe too large?). Size was: %1 byte(s).").arg(datagram.size()), QColor("red")); 81 | return false; 82 | } 83 | 84 | return true; 85 | } 86 | 87 | bool RoboCupSSLServer::send(const SSL_DetectionFrame & frame) 88 | { 89 | SSL_WrapperPacket pkt; 90 | SSL_DetectionFrame * nframe = pkt.mutable_detection(); 91 | nframe->CopyFrom(frame); 92 | return send(pkt); 93 | } 94 | 95 | bool RoboCupSSLServer::send(const SSL_GeometryData & geometry) 96 | { 97 | SSL_WrapperPacket pkt; 98 | SSL_GeometryData * gdata = pkt.mutable_geometry(); 99 | gdata->CopyFrom(geometry); 100 | return send(pkt); 101 | } 102 | 103 | -------------------------------------------------------------------------------- /src/physics/pball.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pball.h" 20 | 21 | PBall::PBall(dReal x,dReal y,dReal z,dReal radius,dReal mass,dReal red,dReal green,dReal blue) 22 | : PObject(x,y,z,red,green,blue,mass) 23 | { 24 | m_radius = radius; 25 | } 26 | 27 | PBall::~PBall() 28 | { 29 | } 30 | 31 | void PBall::init() 32 | { 33 | body = dBodyCreate (world); 34 | initPosBody(); 35 | setMass(m_mass); 36 | geom = dCreateSphere (0,m_radius); 37 | dGeomSetBody (geom,body); 38 | dSpaceAdd(space,geom); 39 | } 40 | 41 | void PBall::setMass(dReal mass) 42 | { 43 | 44 | m_mass = mass; 45 | dMass m; 46 | dMassSetSphereTotal(&m,m_mass,m_radius); 47 | dBodySetMass (body,&m); 48 | } 49 | 50 | void PBall::draw() 51 | { 52 | PObject::draw(); 53 | g->drawSphere(dBodyGetPosition(body),dBodyGetRotation(body),m_radius); 54 | } 55 | -------------------------------------------------------------------------------- /src/physics/pbox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pbox.h" 20 | 21 | PBox::PBox(dReal x,dReal y,dReal z,dReal w,dReal h,dReal l,dReal mass,dReal r,dReal g,dReal b) 22 | : PObject(x,y,z,r,g,b,mass) 23 | { 24 | 25 | m_w = w; 26 | m_h = h; 27 | m_l = l; 28 | } 29 | 30 | PBox::~PBox() 31 | { 32 | } 33 | 34 | void PBox::init() 35 | { 36 | body = dBodyCreate (world); 37 | initPosBody(); 38 | setMass(m_mass); 39 | geom = dCreateBox (0,m_w,m_h,m_l); 40 | dGeomSetBody (geom,body); 41 | dSpaceAdd (space,geom); 42 | } 43 | 44 | void PBox::setMass(dReal mass) 45 | { 46 | m_mass = mass; 47 | dMass m; 48 | dMassSetBoxTotal (&m,m_mass,m_w,m_h,m_l); 49 | dBodySetMass (body,&m); 50 | } 51 | 52 | void PBox::draw() 53 | { 54 | PObject::draw(); 55 | dReal dim[3] = {m_w,m_h,m_l}; 56 | g->drawBox (dGeomGetPosition(geom),dGeomGetRotation(geom),dim); 57 | } 58 | -------------------------------------------------------------------------------- /src/physics/pcylinder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pcylinder.h" 20 | 21 | PCylinder::PCylinder(dReal x,dReal y,dReal z,dReal radius,dReal length,dReal mass,dReal red,dReal green,dReal blue,int texid,bool robot) 22 | : PObject(x,y,z,red,green,blue,mass) 23 | { 24 | m_radius = radius; 25 | m_length = length; 26 | m_texid = texid; 27 | m_robot = robot; 28 | } 29 | 30 | PCylinder::~PCylinder() 31 | { 32 | } 33 | 34 | 35 | void PCylinder::setMass(dReal mass) 36 | { 37 | m_mass = mass; 38 | dMass m; 39 | dMassSetCylinderTotal (&m,m_mass,1,m_radius,m_length); 40 | dBodySetMass (body,&m); 41 | } 42 | 43 | void PCylinder::init() 44 | { 45 | body = dBodyCreate (world); 46 | initPosBody(); 47 | setMass(m_mass); 48 | /* if (m_texid!=-1) 49 | { 50 | dTriMeshDataID g = dGeomTriMeshDataCreate(); 51 | const int vertexcount = 19*3+1; 52 | const int indexcount = 19*9; 53 | dVector3* vertices = new dVector3[vertexcount]; 54 | dTriIndex* indices = new dTriIndex[indexcount]; 55 | 56 | const int n = 24; // number of sides to the cylinder (divisible by 4) 57 | 58 | dReal l = m_length*0.5; 59 | dReal a = dReal(M_PI*2.0)/dReal(n); 60 | dReal sa = (dReal) sin(a); 61 | dReal ca = (dReal) cos(a); 62 | dReal r = m_radius; 63 | 64 | dReal ny=1,nz=0,tmp; 65 | int v=0,f=0; 66 | int i; 67 | for (i=0; i<=n; i++) { 68 | if (i>2 && i2 && i=2 && idrawCylinder(dBodyGetPosition(body),dBodyGetRotation(body),m_length,m_radius); 143 | else 144 | g->drawCylinder_TopTextured(dBodyGetPosition(body),dBodyGetRotation(body),m_length,m_radius,m_texid,m_robot); 145 | 146 | /* glColor3f(1.0, 1.0, 1.0); 147 | glPushMatrix(); 148 | 149 | g->setTransform(dBodyGetPosition(body),dBodyGetRotation(body)); 150 | glScaled(m_radius, m_radius, m_radius); 151 | glColor3d(0.1, 0.1, 0.1); 152 | glRasterPos3f(-0.25, 1.5, 0.0); 153 | //glutStrokeCharacter(GLUT_STROKE_ROMAN, c); 154 | glutBitmapCharacter(GLUT_BITMAP_8_BY_13,c); 155 | glPopMatrix();*/ 156 | } 157 | -------------------------------------------------------------------------------- /src/physics/pfixedbox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pfixedbox.h" 20 | 21 | PFixedBox::PFixedBox(dReal x,dReal y,dReal z,dReal w,dReal h,dReal l,dReal r,dReal g,dReal b) 22 | : PObject(x,y,z,r,g,b,0) 23 | { 24 | m_w = w; 25 | m_h = h; 26 | m_l = l; 27 | } 28 | 29 | PFixedBox::~PFixedBox() 30 | { 31 | } 32 | 33 | void PFixedBox::init() 34 | { 35 | geom = dCreateBox (space,m_w,m_h,m_l); 36 | initPosGeom(); 37 | } 38 | 39 | void PFixedBox::draw() 40 | { 41 | PObject::draw(); 42 | dReal dim[3] = {m_w,m_h,m_l}; 43 | g->drawBox (dGeomGetPosition(geom),dGeomGetRotation(geom),dim); 44 | } 45 | -------------------------------------------------------------------------------- /src/physics/pground.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pground.h" 20 | 21 | PGround::PGround(dReal field_radius,dReal field_length,dReal field_width,dReal field_penalty_rad,dReal field_penalty_line_length,dReal field_penalty_point, dReal field_line_width,int tex_id) 22 | : PObject(0,0,0,0,1,0,0) 23 | { 24 | rad = field_radius; 25 | len = field_length; 26 | wid = field_width; 27 | pdep = field_penalty_rad; 28 | pwid = field_penalty_line_length; 29 | ppoint = field_penalty_point; 30 | tex = tex_id; 31 | lwidth = field_line_width; 32 | 33 | } 34 | 35 | void PGround::init() 36 | { 37 | geom = dCreatePlane (space,0,0,1,0); 38 | } 39 | 40 | void PGround::draw() 41 | { 42 | PObject::draw(); 43 | g->useTexture(tex); 44 | g->drawGround(); 45 | g->noTexture(); 46 | g->drawSSLGround(rad,len,wid,pdep,pwid,ppoint,lwidth,0.0001); 47 | } 48 | 49 | PGround::~PGround() 50 | { 51 | } 52 | -------------------------------------------------------------------------------- /src/physics/pobject.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pobject.h" 20 | 21 | PObject::PObject(dReal x,dReal y,dReal z,dReal red,dReal green,dReal blue,dReal mass) 22 | { 23 | geom = NULL; 24 | body = NULL; 25 | world = NULL; 26 | space = NULL; 27 | m_x = x; 28 | m_y = y; 29 | m_z = z; 30 | m_red = red; 31 | m_green = green; 32 | m_blue = blue; 33 | m_mass = mass; 34 | visible = true; 35 | isQSet = false; 36 | tag = 0; 37 | } 38 | 39 | void PObject::setVisibility(bool v) 40 | { 41 | visible = v; 42 | } 43 | 44 | bool PObject::getVisibility() 45 | { 46 | return visible; 47 | } 48 | 49 | void PObject::setColor(dReal r,dReal g,dReal b) 50 | { 51 | m_red = r; 52 | m_green = g; 53 | m_blue = b; 54 | } 55 | 56 | void PObject::setColor(const QColor &color) 57 | { 58 | m_red = color.redF()*4; 59 | m_green = color.greenF()*4; 60 | m_blue = color.blueF()*4; 61 | } 62 | 63 | void PObject::getColor(dReal& r,dReal& g,dReal& b) 64 | { 65 | r = m_red; 66 | g = m_green; 67 | b = m_blue; 68 | } 69 | 70 | 71 | PObject::~PObject() 72 | { 73 | if (geom!=NULL) dGeomDestroy(geom); 74 | if (body!=NULL) dBodyDestroy(body); 75 | } 76 | 77 | void PObject::setRotation(dReal x_axis,dReal y_axis,dReal z_axis,dReal ang) 78 | { 79 | dQFromAxisAndAngle (q,x_axis,y_axis,z_axis,ang); 80 | isQSet = true; 81 | } 82 | 83 | void PObject::setBodyPosition(dReal x,dReal y,dReal z,bool local) 84 | { 85 | if (!local) dBodySetPosition(body,x,y,z); 86 | else {local_Pos[0]=x;local_Pos[1]=y;local_Pos[2]=z;} 87 | } 88 | 89 | void PObject::setBodyRotation(dReal x_axis,dReal y_axis,dReal z_axis,dReal ang,bool local) 90 | { 91 | if (!local) 92 | { 93 | dQFromAxisAndAngle (q,x_axis,y_axis,z_axis,ang); 94 | dBodySetQuaternion(body,q); 95 | } 96 | else { 97 | dRFromAxisAndAngle(local_Rot,x_axis,y_axis,z_axis,ang); 98 | } 99 | } 100 | 101 | void PObject::getBodyPosition(dReal &x,dReal &y,dReal &z,bool local) 102 | { 103 | if (local) { 104 | x = local_Pos[0]; 105 | y = local_Pos[1]; 106 | z = local_Pos[2]; 107 | return; 108 | } 109 | const dReal *r=dBodyGetPosition(body); 110 | x = r[0]; 111 | y = r[1]; 112 | z = r[2]; 113 | } 114 | 115 | void PObject::getBodyDirection(dReal &x,dReal &y,dReal &z) 116 | { 117 | const dReal *r=dBodyGetRotation(body); 118 | dVector3 v={1,0,0}; 119 | dVector3 axis; 120 | dMultiply0(axis,r,v,4,3,1); 121 | x = axis[0]; 122 | y = axis[1]; 123 | z = axis[2]; 124 | } 125 | 126 | void PObject::getBodyDirection(dReal &x,dReal &y,dReal &z, dReal &k) 127 | { 128 | const dReal *r=dBodyGetRotation(body); 129 | dVector3 v={1,0,0}; 130 | dVector3 axis; 131 | dMultiply0(axis,r,v,4,3,1); 132 | x = axis[0]; 133 | y = axis[1]; 134 | z = axis[2]; 135 | k = r[10]; 136 | } 137 | 138 | void PObject::getBodyRotation(dMatrix3 r,bool local) 139 | { 140 | if (local) 141 | { 142 | for (int k=0;k<12;k++) r[k] = local_Rot[k]; 143 | } 144 | else { 145 | const dReal* rr = dBodyGetRotation(body); 146 | for (int k=0;k<12;k++) r[k] = rr[k]; 147 | } 148 | } 149 | 150 | void PObject::initPosBody() 151 | { 152 | dBodySetPosition(body,m_x,m_y,m_z); 153 | if (isQSet) dBodySetQuaternion(body,q); 154 | } 155 | 156 | void PObject::initPosGeom() 157 | { 158 | dGeomSetPosition(geom,m_x,m_y,m_z); 159 | if (isQSet) dGeomSetQuaternion(geom,q); 160 | } 161 | 162 | 163 | void PObject::setMass(dReal mass) 164 | { 165 | m_mass = mass; 166 | } 167 | 168 | void PObject::glinit() 169 | { 170 | } 171 | 172 | void PObject::draw() 173 | { 174 | g->setColor(m_red,m_green,m_blue,1); 175 | } 176 | 177 | -------------------------------------------------------------------------------- /src/physics/pray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pray.h" 20 | 21 | PRay::PRay(dReal length) 22 | : PObject(0,0,0,0,0,0,0) 23 | { 24 | _length = length; 25 | } 26 | 27 | void PRay::init() 28 | { 29 | geom = dCreateRay(space,_length); 30 | } 31 | 32 | void PRay::setPose(dReal x,dReal y,dReal z,dReal dx,dReal dy,dReal dz) 33 | { 34 | dGeomRaySet(geom,x,y,z,dx,dy,dz); 35 | } 36 | -------------------------------------------------------------------------------- /src/physics/pworld.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "pworld.h" 20 | PSurface::PSurface() 21 | { 22 | callback = NULL; 23 | usefdir1 = false; 24 | surface.mode = dContactApprox1; 25 | surface.mu = 0.5; 26 | } 27 | bool PSurface::isIt(dGeomID i1,dGeomID i2) 28 | { 29 | return ((i1==id1) && (i2==id2)) || ((i1==id2) && (i2==id1)); 30 | } 31 | 32 | 33 | void nearCallback (void *data, dGeomID o1, dGeomID o2) 34 | { 35 | ((PWorld*) data)->handleCollisions(o1,o2); 36 | } 37 | 38 | 39 | PWorld::PWorld(dReal dt,dReal gravity,CGraphics* graphics, int _robot_count) 40 | { 41 | robot_count = _robot_count; 42 | //dInitODE2(0); 43 | dInitODE(); 44 | world = dWorldCreate(); 45 | space = dHashSpaceCreate (0); 46 | contactgroup = dJointGroupCreate (0); 47 | dWorldSetGravity (world,0,0,-gravity); 48 | objects_count = 0; 49 | sur_matrix = NULL; 50 | //dAllocateODEDataForThread(dAllocateMaskAll); 51 | delta_time = dt; 52 | g = graphics; 53 | } 54 | 55 | PWorld::~PWorld() 56 | { 57 | dJointGroupDestroy (contactgroup); 58 | dSpaceDestroy (space); 59 | dWorldDestroy (world); 60 | dCloseODE(); 61 | } 62 | 63 | void PWorld::setGravity(dReal gravity) 64 | { 65 | dWorldSetGravity (world,0,0,-gravity); 66 | } 67 | 68 | void PWorld::handleCollisions(dGeomID o1, dGeomID o2) 69 | { 70 | PSurface* sur; 71 | int j=sur_matrix[*((int*)(dGeomGetData(o1)))][*((int*)(dGeomGetData(o2)))]; 72 | if (j!=-1) 73 | { 74 | const int N = 10; 75 | dContact contact[N]; 76 | int n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact)); 77 | if (n > 0) { 78 | sur = surfaces[j]; 79 | sur->contactPos [0] = contact[0].geom.pos[0]; 80 | sur->contactPos [1] = contact[0].geom.pos[1]; 81 | sur->contactPos [2] = contact[0].geom.pos[2]; 82 | sur->contactNormal[0] = contact[0].geom.normal[0]; 83 | sur->contactNormal[1] = contact[0].geom.normal[1]; 84 | sur->contactNormal[2] = contact[0].geom.normal[2]; 85 | bool flag=true; 86 | if (sur->callback!=NULL) flag = sur->callback(o1,o2,sur,robot_count); 87 | if (flag) 88 | for (int i=0; isurface; 90 | if (sur->usefdir1) 91 | { 92 | contact[i].fdir1[0] = sur->fdir1[0]; 93 | contact[i].fdir1[1] = sur->fdir1[1]; 94 | contact[i].fdir1[2] = sur->fdir1[2]; 95 | contact[i].fdir1[3] = sur->fdir1[3]; 96 | } 97 | dJointID c = dJointCreateContact (world,contactgroup,&contact[i]); 98 | 99 | dJointAttach (c, 100 | dGeomGetBody(contact[i].geom.g1), 101 | dGeomGetBody(contact[i].geom.g2)); 102 | } 103 | } 104 | } 105 | 106 | } 107 | 108 | void PWorld::addObject(PObject* o) 109 | { 110 | int id = objects.count(); 111 | o->id = id; 112 | if (o->world==NULL) o->world = world; 113 | if (o->space==NULL) o->space = space; 114 | o->g = g; 115 | o->init(); 116 | dGeomSetData(o->geom,(void*)(&(o->id))); 117 | objects.append(o); 118 | } 119 | 120 | void PWorld::initAllObjects() 121 | { 122 | objects_count = objects.count(); 123 | int c = objects_count; 124 | bool flag = false; 125 | if (sur_matrix!=NULL) 126 | { 127 | for (int i=0;iid1)))][*((int*)(dGeomGetData(surfaces[i]->id2)))] = 143 | sur_matrix[(*(int*)(dGeomGetData(surfaces[i]->id2)))][*((int*)(dGeomGetData(surfaces[i]->id1)))] = i; 144 | } 145 | } 146 | 147 | PSurface* PWorld::createSurface(PObject* o1,PObject* o2) 148 | { 149 | PSurface *s = new PSurface(); 150 | s->id1 = o1->geom; 151 | s->id2 = o2->geom; 152 | surfaces.append(s); 153 | sur_matrix[o1->id][o2->id] = 154 | sur_matrix[o2->id][o1->id] = surfaces.count() - 1; 155 | return s; 156 | } 157 | 158 | PSurface* PWorld::findSurface(PObject* o1,PObject* o2) 159 | { 160 | for (int i=0;iisIt(o1->geom,o2->geom)) return (surfaces[i]); 163 | } 164 | return NULL; 165 | } 166 | 167 | void PWorld::step(dReal dt) 168 | { 169 | try { 170 | dSpaceCollide (space,this,&nearCallback); 171 | dWorldStep(world,(dt<0) ? delta_time : dt); 172 | dJointGroupEmpty (contactgroup); 173 | } 174 | catch (...) { 175 | //qDebug() << "Some Error Happened;"; 176 | } 177 | } 178 | 179 | void PWorld::draw() 180 | { 181 | for (int i=0;igetVisibility()) objects[i]->draw(); 183 | } 184 | 185 | void PWorld::glinit() 186 | { 187 | for (int i=0;iglinit(); 189 | } 190 | 191 | -------------------------------------------------------------------------------- /src/proto/grSim_Commands.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | message grSim_Robot_Command { 4 | required uint32 id = 1; 5 | required float kickspeedx = 2; 6 | required float kickspeedz = 3; 7 | required float veltangent = 4; 8 | required float velnormal = 5; 9 | required float velangular = 6; 10 | required bool spinner = 7; 11 | required bool wheelsspeed = 8; 12 | optional float wheel1 = 9; 13 | optional float wheel2 = 10; 14 | optional float wheel3 = 11; 15 | optional float wheel4 = 12; 16 | } 17 | 18 | message grSim_Commands { 19 | required double timestamp = 1; 20 | required bool isteamyellow = 2; 21 | repeated grSim_Robot_Command robot_commands = 3; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/proto/grSim_Packet.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "grSim_Commands.proto"; 4 | import "grSim_Replacement.proto"; 5 | message grSim_Packet { 6 | optional grSim_Commands commands = 1; 7 | optional grSim_Replacement replacement = 2; 8 | } 9 | -------------------------------------------------------------------------------- /src/proto/grSim_Replacement.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | message grSim_RobotReplacement { 4 | required double x=1; 5 | required double y=2; 6 | required double dir=3; 7 | required uint32 id=4; 8 | required bool yellowteam=5; 9 | optional bool turnon=6; 10 | } 11 | 12 | message grSim_BallReplacement { 13 | optional double x=1; 14 | optional double y=2; 15 | optional double vx=3; 16 | optional double vy=4; 17 | } 18 | 19 | message grSim_Replacement { 20 | optional grSim_BallReplacement ball=1; 21 | repeated grSim_RobotReplacement robots=2; 22 | } 23 | -------------------------------------------------------------------------------- /src/proto/grSim_Robotstatus.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | message Robots_Status{ 4 | repeated Robot_Status robots_status = 1; 5 | } 6 | 7 | message Robot_Status { 8 | required int32 robot_id = 1; 9 | required bool infrared = 2; 10 | required bool flat_kick = 3; 11 | required bool chip_kick = 4; 12 | } -------------------------------------------------------------------------------- /src/proto/ssl_gc_common.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | // Team is either blue or yellow 5 | enum Team { 6 | // team not set 7 | UNKNOWN = 0; 8 | // yellow team 9 | YELLOW = 1; 10 | // blue team 11 | BLUE = 2; 12 | } 13 | 14 | // RobotId is the combination of a team and a robot id 15 | message RobotId { 16 | // the robot number 17 | optional uint32 id = 1; 18 | // the team that the robot belongs to 19 | optional Team team = 2; 20 | } 21 | 22 | // Division denotes the current division, which influences some rules 23 | enum Division { 24 | DIV_UNKNOWN = 0; 25 | DIV_A = 1; 26 | DIV_B = 2; 27 | } 28 | -------------------------------------------------------------------------------- /src/proto/ssl_simulation_config.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | import "ssl_gc_common.proto"; 5 | import "ssl_vision_geometry.proto"; 6 | import "google/protobuf/any.proto"; 7 | 8 | // Movement limits for a robot 9 | message RobotLimits { 10 | // Max absolute speed-up acceleration [m/s^2] 11 | optional float acc_speedup_absolute_max = 1; 12 | // Max angular speed-up acceleration [rad/s^2] 13 | optional float acc_speedup_angular_max = 2; 14 | // Max absolute brake acceleration [m/s^2] 15 | optional float acc_brake_absolute_max = 3; 16 | // Max angular brake acceleration [rad/s^2] 17 | optional float acc_brake_angular_max = 4; 18 | // Max absolute velocity [m/s] 19 | optional float vel_absolute_max = 5; 20 | // Max angular velocity [rad/s] 21 | optional float vel_angular_max = 6; 22 | } 23 | 24 | // Robot wheel angle configuration 25 | // all angles are relative to looking forward, 26 | // all wheels / angles are clockwise 27 | message RobotWheelAngles { 28 | // Angle front right [rad] 29 | required float front_right = 1; 30 | // Angle back right [rad] 31 | required float back_right = 2; 32 | // Angle back left [rad] 33 | required float back_left = 3; 34 | // Angle front left [rad] 35 | required float front_left = 4; 36 | } 37 | 38 | // Specs of a robot 39 | message RobotSpecs { 40 | // Id of the robot 41 | required RobotId id = 1; 42 | // Robot radius [m] 43 | optional float radius = 2 [default = 0.09]; 44 | // Robot height [m] 45 | optional float height = 3 [default = 0.15]; 46 | // Robot mass [kg] 47 | optional float mass = 4; 48 | // Max linear kick speed [m/s] (unset = unlimited) 49 | optional float max_linear_kick_speed = 7; 50 | // Max chip kick speed [m/s] (unset = unlimited) 51 | optional float max_chip_kick_speed = 8; 52 | // Distance from robot center to dribbler [m] (implicitly defines the opening angle and dribbler width) 53 | optional float center_to_dribbler = 9; 54 | // Movement limits 55 | optional RobotLimits limits = 10; 56 | // Wheel angle configuration 57 | optional RobotWheelAngles wheel_angles = 13; 58 | // Custom robot spec for specific simulators (the protobuf files are managed by the simulators) 59 | optional google.protobuf.Any custom = 14; 60 | } 61 | 62 | message RealismConfig { 63 | // Custom config for specific simulators (the protobuf files are managed by the simulators) 64 | optional google.protobuf.Any custom = 1; 65 | } 66 | 67 | // Change the simulator configuration 68 | message SimulatorConfig { 69 | // Update the geometry 70 | optional SSL_GeometryData geometry = 1; 71 | // Update the robot specs 72 | repeated RobotSpecs robot_specs = 2; 73 | // Update realism configuration 74 | optional RealismConfig realism_config = 3; 75 | // Change the vision publish port 76 | optional uint32 vision_port = 4; 77 | } -------------------------------------------------------------------------------- /src/proto/ssl_simulation_control.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | import "ssl_gc_common.proto"; 5 | import "ssl_simulation_config.proto"; 6 | import "ssl_simulation_error.proto"; 7 | 8 | // Teleport the ball to a new location and optionally set it to some velocity 9 | message TeleportBall { 10 | // x-coordinate [m] 11 | optional float x = 1; 12 | // y-coordinate [m] 13 | optional float y = 2; 14 | // z-coordinate (height) [m] 15 | optional float z = 3; 16 | // Velocity in x-direction [m/s] 17 | optional float vx = 4; 18 | // Velocity in y-direction [m/s] 19 | optional float vy = 5; 20 | // Velocity in z-direction [m/s] 21 | optional float vz = 6; 22 | // Teleport the ball safely to the target, for example by 23 | // moving robots out of the way in case of collision and set speed of robots close-by to zero 24 | optional bool teleport_safely = 7 [default = false]; 25 | // Adapt the angular ball velocity such that the ball is rolling 26 | optional bool roll = 8 [default = false]; 27 | } 28 | 29 | // Teleport a robot to some location and give it a velocity 30 | message TeleportRobot { 31 | // Robot id to teleport 32 | required RobotId id = 1; 33 | // x-coordinate [m] 34 | optional float x = 2; 35 | // y-coordinate [m] 36 | optional float y = 3; 37 | // Orientation [rad], measured from the x-axis counter-clockwise 38 | optional float orientation = 4; 39 | // Global velocity [m/s] towards x-axis 40 | optional float v_x = 5 [default = 0]; 41 | // Global velocity [m/s] towards y-axis 42 | optional float v_y = 6 [default = 0]; 43 | // Angular velocity [rad/s] 44 | optional float v_angular = 7 [default = 0]; 45 | // Robot should be present on the field? 46 | // true -> robot will be added, if it does not exist yet 47 | // false -> robot will be removed, if it is present 48 | optional bool present = 8; 49 | } 50 | 51 | // Control the simulation 52 | message SimulatorControl { 53 | // Teleport the ball 54 | optional TeleportBall teleport_ball = 1; 55 | // Teleport robots 56 | repeated TeleportRobot teleport_robot = 2; 57 | // Change the simulation speed 58 | optional float simulation_speed = 3; 59 | } 60 | 61 | // Command from the connected client to the simulator 62 | message SimulatorCommand { 63 | // Control the simulation 64 | optional SimulatorControl control = 1; 65 | // Configure the simulation 66 | optional SimulatorConfig config = 2; 67 | } 68 | 69 | // Response of the simulator to the connected client 70 | message SimulatorResponse { 71 | // List of errors, like using unsupported features 72 | repeated SimulatorError errors = 1; 73 | } 74 | -------------------------------------------------------------------------------- /src/proto/ssl_simulation_error.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | // Errors in the simulator 5 | message SimulatorError { 6 | // Unique code of the error for automatic handling on client side 7 | optional string code = 1; 8 | // Human readable description of the error 9 | optional string message = 2; 10 | } 11 | -------------------------------------------------------------------------------- /src/proto/ssl_simulation_robot_control.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | // Full command for a single robot 5 | message RobotCommand { 6 | // Id of the robot 7 | required uint32 id = 1; 8 | // Movement command 9 | optional RobotMoveCommand move_command = 2; 10 | // Absolute (3 dimensional) kick speed [m/s] 11 | optional float kick_speed = 3; 12 | // Kick angle [degree] (defaults to 0 degrees for a straight kick) 13 | optional float kick_angle = 4 [default = 0]; 14 | // Dribbler speed in rounds per minute [rpm] 15 | optional float dribbler_speed = 5; 16 | } 17 | 18 | // Wrapper for different kinds of movement commands 19 | message RobotMoveCommand { 20 | oneof command { 21 | // Move with wheel velocities 22 | MoveWheelVelocity wheel_velocity = 1; 23 | // Move with local velocity 24 | MoveLocalVelocity local_velocity = 2; 25 | // Move with global velocity 26 | MoveGlobalVelocity global_velocity = 3; 27 | } 28 | } 29 | 30 | // Move robot with wheel velocities 31 | message MoveWheelVelocity { 32 | // Velocity [m/s] of front right wheel 33 | required float front_right = 1; 34 | // Velocity [m/s] of back right wheel 35 | required float back_right = 2; 36 | // Velocity [m/s] of back left wheel 37 | required float back_left = 3; 38 | // Velocity [m/s] of front left wheel 39 | required float front_left = 4; 40 | } 41 | 42 | // Move robot with local velocity 43 | message MoveLocalVelocity { 44 | // Velocity forward [m/s] (towards the dribbler) 45 | required float forward = 1; 46 | // Velocity to the left [m/s] 47 | required float left = 2; 48 | // Angular velocity counter-clockwise [rad/s] 49 | required float angular = 3; 50 | } 51 | 52 | // Move robot with global velocity 53 | message MoveGlobalVelocity { 54 | // Velocity on x-axis of the field [m/s] 55 | required float x = 1; 56 | // Velocity on y-axis of the field [m/s] 57 | required float y = 2; 58 | // Angular velocity counter-clockwise [rad/s] 59 | required float angular = 3; 60 | } 61 | 62 | // Command from the connected client to the simulator 63 | message RobotControl { 64 | // Control the robots 65 | repeated RobotCommand robot_commands = 1; 66 | } 67 | -------------------------------------------------------------------------------- /src/proto/ssl_simulation_robot_feedback.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | import "ssl_simulation_error.proto"; 5 | import "google/protobuf/any.proto"; 6 | 7 | // Feedback from a robot 8 | message RobotFeedback { 9 | // Id of the robot 10 | required uint32 id = 1; 11 | // Has the dribbler contact to the ball right now 12 | optional bool dribbler_ball_contact = 2; 13 | // Custom robot feedback for specific simulators (the protobuf files are managed by the simulators) 14 | optional google.protobuf.Any custom = 3; 15 | } 16 | 17 | // Response to RobotControl from the simulator to the connected client 18 | message RobotControlResponse { 19 | // List of errors, like using unsupported features 20 | repeated SimulatorError errors = 1; 21 | // Feedback of the robots 22 | repeated RobotFeedback feedback = 2; 23 | } 24 | -------------------------------------------------------------------------------- /src/proto/ssl_simulation_synchronous.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | import "ssl_vision_detection.proto"; 5 | import "ssl_simulation_robot_feedback.proto"; 6 | import "ssl_simulation_robot_control.proto"; 7 | import "ssl_simulation_control.proto"; 8 | 9 | // Request from the team to the simulator 10 | message SimulationSyncRequest { 11 | // The simulation step [s] to perform 12 | optional float sim_step = 1; 13 | // An optional simulator command 14 | optional SimulatorCommand simulator_command = 2; 15 | // An optional robot control command 16 | optional RobotControl robot_control = 3; 17 | } 18 | 19 | // Response to last SimulationSyncRequest 20 | message SimulationSyncResponse { 21 | // List of detection frames for all cameras with the state after the simulation step in the request was performed 22 | repeated SSL_DetectionFrame detection = 1; 23 | // An optional robot control response 24 | optional RobotControlResponse robot_control_response = 2; 25 | } 26 | -------------------------------------------------------------------------------- /src/proto/ssl_vision_detection.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | message SSL_DetectionBall { 5 | required float confidence = 1; 6 | optional uint32 area = 2; 7 | required float x = 3; 8 | required float y = 4; 9 | optional float z = 5; 10 | required float pixel_x = 6; 11 | required float pixel_y = 7; 12 | } 13 | 14 | message SSL_DetectionRobot { 15 | required float confidence = 1; 16 | optional uint32 robot_id = 2; 17 | required float x = 3; 18 | required float y = 4; 19 | optional float orientation = 5; 20 | required float pixel_x = 6; 21 | required float pixel_y = 7; 22 | optional float height = 8; 23 | } 24 | 25 | message SSL_DetectionFrame { 26 | required uint32 frame_number = 1; 27 | required double t_capture = 2; 28 | required double t_sent = 3; 29 | required uint32 camera_id = 4; 30 | repeated SSL_DetectionBall balls = 5; 31 | repeated SSL_DetectionRobot robots_yellow = 6; 32 | repeated SSL_DetectionRobot robots_blue = 7; 33 | } 34 | -------------------------------------------------------------------------------- /src/proto/ssl_vision_geometry.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "github.com/RoboCup-SSL/ssl-simulation-protocol/pkg/sim"; 3 | 4 | // A 2D float vector. 5 | message Vector2f { 6 | required float x = 1; 7 | required float y = 2; 8 | } 9 | 10 | // Represents a field marking as a line segment represented by a start point p1, 11 | // and end point p2, and a line thickness. The start and end points are along 12 | // the center of the line, so the thickness of the line extends by thickness / 2 13 | // on either side of the line. 14 | message SSL_FieldLineSegment { 15 | // Name of this field marking. 16 | required string name = 1; 17 | // Start point of the line segment. 18 | required Vector2f p1 = 2; 19 | // End point of the line segment. 20 | required Vector2f p2 = 3; 21 | // Thickness of the line segment. 22 | required float thickness = 4; 23 | // The type of this shape 24 | optional SSL_FieldShapeType type = 5; 25 | } 26 | 27 | // Represents a field marking as a circular arc segment represented by center point, a 28 | // start angle, an end angle, and an arc thickness. 29 | message SSL_FieldCircularArc { 30 | // Name of this field marking. 31 | required string name = 1; 32 | // Center point of the circular arc. 33 | required Vector2f center = 2; 34 | // Radius of the arc. 35 | required float radius = 3; 36 | // Start angle in counter-clockwise order. 37 | required float a1 = 4; 38 | // End angle in counter-clockwise order. 39 | required float a2 = 5; 40 | // Thickness of the arc. 41 | required float thickness = 6; 42 | // The type of this shape 43 | optional SSL_FieldShapeType type = 7; 44 | } 45 | 46 | message SSL_GeometryFieldSize { 47 | required int32 field_length = 1; 48 | required int32 field_width = 2; 49 | required int32 goal_width = 3; 50 | required int32 goal_depth = 4; 51 | required int32 boundary_width = 5; 52 | repeated SSL_FieldLineSegment field_lines = 6; 53 | repeated SSL_FieldCircularArc field_arcs = 7; 54 | optional int32 penalty_area_depth = 8; 55 | optional int32 penalty_area_width = 9; 56 | } 57 | 58 | message SSL_GeometryCameraCalibration { 59 | required uint32 camera_id = 1; 60 | required float focal_length = 2; 61 | required float principal_point_x = 3; 62 | required float principal_point_y = 4; 63 | required float distortion = 5; 64 | required float q0 = 6; 65 | required float q1 = 7; 66 | required float q2 = 8; 67 | required float q3 = 9; 68 | required float tx = 10; 69 | required float ty = 11; 70 | required float tz = 12; 71 | optional float derived_camera_world_tx = 13; 72 | optional float derived_camera_world_ty = 14; 73 | optional float derived_camera_world_tz = 15; 74 | optional uint32 pixel_image_width = 16; 75 | optional uint32 pixel_image_height = 17; 76 | } 77 | 78 | // Two-Phase model for straight-kicked balls. 79 | // There are two phases with different accelerations during the ball kicks: 80 | // 1. Sliding 81 | // 2. Rolling 82 | // The full model is described in the TDP of ER-Force from 2016, which can be found here: 83 | // https://ssl.robocup.org/wp-content/uploads/2019/01/2016_ETDP_ER-Force.pdf 84 | message SSL_BallModelStraightTwoPhase { 85 | // Ball sliding acceleration [m/s^2] (should be negative) 86 | required double acc_slide = 1; 87 | // Ball rolling acceleration [m/s^2] (should be negative) 88 | required double acc_roll = 2; 89 | // Fraction of the initial velocity where the ball starts to roll 90 | required double k_switch = 3; 91 | } 92 | 93 | // Fixed-Loss model for chipped balls. 94 | // Uses fixed damping factors for xy and z direction per hop. 95 | message SSL_BallModelChipFixedLoss { 96 | // Chip kick velocity damping factor in XY direction for the first hop 97 | required double damping_xy_first_hop = 1; 98 | // Chip kick velocity damping factor in XY direction for all following hops 99 | required double damping_xy_other_hops = 2; 100 | // Chip kick velocity damping factor in Z direction for all hops 101 | required double damping_z = 3; 102 | } 103 | 104 | message SSL_GeometryModels { 105 | optional SSL_BallModelStraightTwoPhase straight_two_phase = 1; 106 | optional SSL_BallModelChipFixedLoss chip_fixed_loss = 2; 107 | } 108 | 109 | message SSL_GeometryData { 110 | required SSL_GeometryFieldSize field = 1; 111 | repeated SSL_GeometryCameraCalibration calib = 2; 112 | optional SSL_GeometryModels models = 3; 113 | } 114 | 115 | enum SSL_FieldShapeType { 116 | Undefined = 0; 117 | CenterCircle = 1; 118 | TopTouchLine = 2; 119 | BottomTouchLine = 3; 120 | LeftGoalLine = 4; 121 | RightGoalLine = 5; 122 | HalfwayLine = 6; 123 | CenterLine = 7; 124 | LeftPenaltyStretch = 8; 125 | RightPenaltyStretch = 9; 126 | LeftFieldLeftPenaltyStretch = 10; 127 | LeftFieldRightPenaltyStretch = 11; 128 | RightFieldLeftPenaltyStretch = 12; 129 | RightFieldRightPenaltyStretch = 13; 130 | } -------------------------------------------------------------------------------- /src/proto/ssl_vision_wrapper.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "ssl_vision_detection.proto"; 4 | import "ssl_vision_geometry.proto"; 5 | 6 | message SSL_WrapperPacket { 7 | optional SSL_DetectionFrame detection = 1; 8 | optional SSL_GeometryData geometry = 2; 9 | } 10 | -------------------------------------------------------------------------------- /src/robotwidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "config.h" 20 | #include "robotwidget.h" 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | RobotWidget::RobotWidget(QWidget* parent, ConfigWidget* cfg) 29 | : QDockWidget("Current Robot",parent) 30 | { 31 | QGridLayout *layout = new QGridLayout; 32 | robotpic = new QLabel; 33 | teamCombo = new QComboBox(this); 34 | teamCombo->addItem("Blue"); 35 | teamCombo->addItem("Yellow"); 36 | robotCombo = new QComboBox(this); 37 | 38 | // Add items to the combo box dynamically 39 | changeRobotCount(cfg->Robots_Count()); 40 | 41 | vellabel = new QLabel; 42 | acclabel = new QLabel; 43 | resetBtn = new QPushButton("Reset"); 44 | locateBtn = new QPushButton("Locate"); 45 | onOffBtn = new QPushButton("Turn Off"); 46 | setPoseBtn = new QPushButton("Set Position"); 47 | layout->addWidget(robotpic,0,0,5,1); 48 | layout->addWidget(new QLabel("Team"),0,1); 49 | layout->addWidget(teamCombo,0,2); 50 | layout->addWidget(new QLabel("Index"),1,1); 51 | layout->addWidget(robotCombo,1,2); 52 | layout->addWidget(new QLabel("Velocity"),2,1); 53 | layout->addWidget(vellabel,2,2); 54 | layout->addWidget(resetBtn,3,1); 55 | layout->addWidget(locateBtn,3,2); 56 | layout->addWidget(onOffBtn,4,1); 57 | layout->addWidget(setPoseBtn,4,2); 58 | QWidget *widget = new QWidget(this); 59 | widget->setLayout(layout); 60 | widget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); 61 | setWidget(widget); 62 | getPoseWidget = new GetPositionWidget(); 63 | QObject::connect(setPoseBtn,SIGNAL(clicked()),this,SLOT(setPoseBtnClicked())); 64 | } 65 | 66 | void RobotWidget::changeRobotCount(int newRobotCount) { 67 | // block signal emitting to avoid segmentation fault 68 | // if don't do this, CurrentIndexChange() signal will be emitted everytime adding/deleting item 69 | // and MainWindow::changeCurrentRobot() will be called 70 | robotCombo->blockSignals(true); 71 | 72 | // increase comboBox element 73 | if(newRobotCount > robotCombo->count()) { 74 | for (int i=robotCombo->count(); iaddItem(item); 77 | } 78 | } 79 | // decrease comboBox element 80 | else { 81 | for (int i=robotCombo->count(); i>=newRobotCount; i--) { 82 | robotCombo->removeItem(i); 83 | } 84 | } 85 | robotCombo->blockSignals(false); 86 | } 87 | 88 | void RobotWidget::changeCurrentRobot(int CurrentRobotID) { 89 | CurrentRobotID = std::min(CurrentRobotID, robotCombo->count()-1); 90 | robotCombo->setCurrentIndex(CurrentRobotID); 91 | } 92 | 93 | void RobotWidget::setPicture(QImage* img) 94 | { 95 | robotpic->setPixmap(QPixmap::fromImage(*img).scaled(128, 128, Qt::IgnoreAspectRatio, Qt::FastTransformation)); 96 | } 97 | 98 | void RobotWidget::changeRobotOnOff(int _id,bool a) 99 | { 100 | if (_id==id) { 101 | if (a) onOffBtn->setText("Turn off"); 102 | else onOffBtn->setText("Turn on"); 103 | } 104 | } 105 | 106 | void RobotWidget::setPoseBtnClicked() 107 | { 108 | getPoseWidget->show(); 109 | } 110 | -------------------------------------------------------------------------------- /src/statuswidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | grSim - RoboCup Small Size Soccer Robots Simulator 3 | Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "statuswidget.h" 20 | 21 | CStatusWidget::CStatusWidget(CStatusPrinter* _statusPrinter) 22 | { 23 | statusPrinter = _statusPrinter; 24 | logTime.start(); 25 | 26 | this->setAllowedAreas(Qt::BottomDockWidgetArea); 27 | this->setFeatures(QDockWidget::NoDockWidgetFeatures); 28 | 29 | statusText = new QTextEdit(this); 30 | statusText->setReadOnly(true); 31 | titleLbl = new QLabel(tr("Messages")); 32 | 33 | 34 | this->setWidget(statusText); 35 | this->setTitleBarWidget(titleLbl); 36 | 37 | } 38 | 39 | void CStatusWidget::write(QString str, QColor color) 40 | { 41 | if( statusText->textCursor().blockNumber() > 2000 ) 42 | statusText->clear(); 43 | 44 | statusText->setTextColor(color); 45 | //statusText->append(QString::number(statusText->textCursor().blockNumber()) + " : " + str); 46 | //statusText->append(QString::number(logTime.elapsed()) + " : " + str); 47 | statusText->append(str); 48 | 49 | 50 | statusText->setTextColor(QColor("black")); 51 | } 52 | 53 | void CStatusWidget::update() 54 | { 55 | CStatusText text; 56 | while(!statusPrinter->textBuffer.isEmpty()) 57 | { 58 | text = statusPrinter->textBuffer.dequeue(); 59 | write(text.text, text.color); 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grsim", 3 | "version-string": "0.0.1", 4 | "dependencies": [ 5 | "qt5-base", 6 | "ode", 7 | "protobuf" 8 | ] 9 | } 10 | --------------------------------------------------------------------------------