Git Product home page Git Product logo

armorial-psel's Introduction

Armorial-PSEL

This repository contains the base implementation for the Maracatronics Robotics Programming Selective Proccess. The core objective of this project is to provide a simple interface (simmilar to the used in our main project) that allows to receive data from the simulated environments and send control packets to the robots inside it.

Project Requirements

Currently, the known supported OS is Ubuntu in both 20.04 and 22.04 versions (check the github actions to see the build workflow for both of them). You will need to install the dependencies by just following the above command:

sudo apt-get update && sudo apt-get install build-essential cmake qtbase5-dev qt5-qmake libprotobuf-dev protobuf-compiler libprotoc-dev protobuf-compiler-grpc libgrpc++-dev libgrpc-dev libqt5serialport5-dev google-mock libgmock-dev libgtest-dev libspdlog-dev libfmt-dev && sudo apt-get upgrade

Project Structure

As mentioned above, this project contains a structure that is heavily based in our main project. When navigating to the src folder, you will found the entities and utils folders.

Entity

An Entity is a module of our code. They generally provides interfaces to allow communication for between both outside (with the simulated environment for example) or inside (with the Player and Actuator integration, where the players can send control information through it).

Currently, we have the implementation of 5 entities in our project:

  • Actuator: Provides an interface for the communication with the simulated environment to control the robots.
  • Vision: Provides an interface for the reception of detection packets from the simulated environment.
  • Player: Provides an interface for a robot in the simulated environment, allowing to get information and control it.
  • WorldMap: Provides an interface to get information about some field RoI (region of interests) and also ball data.
  • Coach: Provides an interface to manage and control all the robots in the simulated environment.

Utils

The Utils folder contains methods and classes that are commonly used in our project modules. Commonly, you will find here the types folders along with a Utils class itself. The types folder contains interfaces to enhance the data transfer along the integrations between the Entities and the Utils class contains static useful generic methods that can be used everywhere in the code, generally related to math calculus.

Workflow Diagram

img

Controlling the Robots

In the coach main code, you can find a method called runCoach. Here, you can find a base implementation which shows how to control the robots in the field, but let's take a deep look inside:

void Coach::runCoach() {
    // Here you can control the robots freely.
    // Remember that the getPlayer(color, id) function can return a std::nullopt object, so
    // be careful when you use it (remember to only use ids from 0-2 and the BLUE and YELLOW
    // defines).

    // Example 1: here we get the ball position and set the BLUE and YELLOW player 0 to follow it
    QVector2D ballPosition = getWorldMap()->ballPosition();
    getPlayer(BLUE, 0).value()->goTo(ballPosition);
    getPlayer(YELLOW, 0).value()->goTo(ballPosition);

    // Example 2: here we set the BLUE and YELLOW players 1 and 2 to rotate to the ball
    getPlayer(BLUE, 1).value()->rotateTo(ballPosition);
    getPlayer(BLUE, 2).value()->rotateTo(ballPosition);
    getPlayer(YELLOW, 1).value()->rotateTo(ballPosition);
    getPlayer(YELLOW, 2).value()->rotateTo(ballPosition);
}

To control any robot in the field, first you need to call the getPlayer(isTeamBlue, playerId) method. It provides a std::optional return, which means that sometimes you will not receive the pointer for the Player that you want if the player is not registered in the code, so be careful with that. Just for note, you can use the BLUE and YELLOW defines to refers to the blue and yellow teams, respectively, and can use the players id from 0-2 for both teams.

After cast the getPlayer method successfully, you will get it's value that will refers to a Player pointer. With that on hand, you will be able to cast the Player class public and protected methods (note that the Coach class is registered as friend class on Player). So, you can call the goTo and rotateTo methods along with getters for the player position / orientation and identifiers.

In this coach method you can also get the WorldMap class by using the getWorldMap() method. With that on hand you will be able to use all the available methods in WorldMap class, such as position of some region of interests and the ball position.

armorial-psel's People

Contributors

zsmn avatar

Watchers

 avatar

armorial-psel's Issues

Designing the Actuator entity

Is your task related to a feature or bug? Please describe.

Related to #8.
This task aims to design the Actuator entity, developing its integration with the network and with the Player entity providing methods to control the robots in the simulated environment.

Describe the solution you'd like

  • Create the Actuator class as instance of QObject to allow signal/slot design.
  • Create methods to control the simulated robots (params: color, id, wheel_left, wheel_right)
  • Use QTimer object and use QMutex logic to store and send the control packets synchronously to the socket.
  • Create and connect the QUdpSocket with the host network.
  • Create Vision -> Actuator module integration to provide host address (broadcast from the vision multicast network interface).

Additional context

Note that when connecting to the host network (which hosts the simulator), we can use the same host of the vision server (because the vision server is directly linked to the simulated environment).

WorldMap class and integration with Vision Module

Is your task related to a feature or bug? Please describe.

Related to #4.
This task aims to develop the WorldMap class that will store, as it name means, informations about the whole field. Also, it will store ball information.

Describe the solution you'd like

  • #5
  • Create WorldMap class as instance of QObject to allow signal/slot design.
  • Create slots to receive upcoming network data from the Vision module.
  • Create getters for Field properties and for some important locations (such as goal posts or goal center).

Additional context

Some of the getters are using pre-defined values, this was made because the fira_message::Field packet does not provides these informations within the packet.

Vision module and integration with WorldMap and Player classes

What is your feature request related to? Please describe.

For the soccer environment we need to read upcoming detection data from the network. This feature aims to develop an interface that provides ways to get and structure this information in the project.

Describe the solution you'd like

For this feature, it is needed a class to read and manage the upcoming detection packets from the network.
Also, a WorldMap class that stores the Field and Ball data should be necessary, allowing that entities in the project access them freely.
Note that we need to make an integration between this detection data and the Player entities, so these changes are also related to this feature.

List the tasks related to this feature

Describe alternatives you've considered

N/A

Additional context

N/A

Designing and creating the Vision Entity

Is your task related to a feature or bug? Please describe.

Related to #4.
This task aims to develop the Vision module class, that will be responsible to receive and propagate the detection data.

Describe the solution you'd like

  • Create the Vision class as a QObject type to enable signal/slots design.
  • Create an instance of QUdpSocket and make connection with the Vision server.
  • Create a QTimer instance and make a connection to search for the QNetworkInterface which the vision server is located.
  • Use the QUdpSocket readyRead signal to allow the reception of upcoming packets from network and also to check when an interface network is the valid one.
  • Create signals to propagate the received data from the QNetworkDatagrams to connected objects.

Additional context

N/A

Integration between Vision -> Player entities

Is your task related to a feature or bug? Please describe.

Related to #4.
This task aims to create a integration between the Vision and Player entities, allowing Vision to pass detection data for the Player instances.

Describe the solution you'd like

  • #5
  • Create Player class as instance of QObject type to allow signal/slot design.
  • Create a slot to receive the upcoming data from network
  • Create getter methods and isMissing property to allow check if the Player is present or not in the field.

Additional context

As the fira_message::Robot packet does not implements in its data the team color of the Robot, it was also need to develop an intermediary class to receive the upcoming data from the Vision module.

Develop the Actuator entity and integration with the Player

What is your feature request related to? Please describe.

To control the robots in the simulated environment we commonly send packets through the network to our team, allowing us to control them.
This feature aims to develop an interface that which, once integrated with the Player class, provides methods to send control packets to the simulated environment and control its robots.

Describe the solution you'd like

Develop the Actuator entity class to receive upcoming data from the Player instances and send the received data to the simulated environment.

List the tasks related to this feature

Describe alternatives you've considered

N/A

Additional context

Note that is recommended to send all the received data together, it is, avoid sending one control packet just because one robot sent it... so sync using a QTimer object and send all the received packets at the timeout moment to the simulator.

Designing the Coach entity

Is your task related to a feature or bug? Please describe.

Related to #11.
This task aims to design the Coach entity, developing its integration with the Player and WorldMap entities. It should allow direct access to the WorldMap class and control the Player instances.

Describe the solution you'd like

  • Create the Coach class as instance of QObject to allow signal/slot design.
  • Create access method to get the Player instances (params: color, id), it should also use the std::optional class.
  • Create access method to get the WorldMap instance.
  • Use QTimer object to cast a runCoach() method that will contains the implementation of the control strategy.
  • Create control methods in the Player class to goTo (params: targetPosition) and rotateTo (params: targetPosition) / (params: targetAngle).
  • Provide an example in the runCoach() method, calling the control methods of the Player class in both teams.

Additional context

Note that when connecting to the host network (which hosts the simulator), we can use the same host of the vision server (because the vision server is directly linked to the simulated environment).

Coach module and integration with Player and WorldMap

What is your feature request related to? Please describe.

To control the Players we need a Coach module that will be the responsible for the management of each player behavior in the field.

Describe the solution you'd like

Create the Coach class and make its integration with the Player and WorldMap modules. It should also use a QTimer instance to cast a private slot that will further store the control implementation of the trainees.

List the tasks related to this feature

Describe alternatives you've considered

N/A

Additional context

N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.