-
Notifications
You must be signed in to change notification settings - Fork 20
Creating Platforms (C)
C++ Guides: GAMS Primer | Creating Algorithms | Creating Platforms
GAMS provides an extensible platforms infrastructure for encoding robotics platforms, simulated agents, or software agents. The platforms interface is reasonably expressive, though the more extensible aspects are centered around movement rather than grabbing with arms, kicking, etc. In this wiki, we take a look at how to extend the Base_Platform class and the features that GAMS provides to platform developers.
The GAMS controller directly calls two platform method during normal execution (sense and analyze) and these are the first two methods called at the top of the MAPE-K loop. The majority of calls to platform methods are actually made by algorithms during their analyze and execute phases. Developers will need to provide implementations of each of the methods in the Base_Platform base class, and the intentions of these methods are the following:
- analyze: Analyzes the state of the platform
- home: Returns to a home location
- get_id: Returns the unique id of the platform. This should be alphanumeric with no special characters or spaces. This id is used in creating underlying platform variables in the knowledge base.
- get_name: Returns the name of the platform. This can be a verbose name with capitalization.
- get_min_sensor_range: Returns the minimum sensor range of sensor payloads. This is used for discretization of search regions, generally.
- get_move_speed: Returns the maximum move speed of the platform
- get_sensor: Override-able method for getting sensor information
- get_sensor_names: Override-able method for retrieving all sensors on the platform
- land: Lands the platform. Can be left stubbed for vehicles that cannot take off
- move Moves the platform to a position in a x, y, z coordinate system (can be GPS)
- pause_move Pauses an ongoing movement
- sense: Polls the platform's sensors and records any useful information
- set_move_speed: Sets the movement speed of the platform
- stop_move: Cancels an ongoing movement
- takeoff: Lifts the platform into the air. Can be left stubbed for vehicles incapable of lifting off.
All methods should be non-blocking to allow for platform.sense (), platform.analyze (), and algorithm.analyze () to be called frequently and for updates to the knowledge base to be sent out to other agents or human overseers. If you must use blocking calls, the best way to support them is to create a polling class/infrastructure that launches a thread for the blocking operation and provides a polling mechanism for checking if the blocking operation has completed.
For instance, if you already have a move function for your robotic platform that currently blocks until the movement is finished, you can still use this function. However, you will probably want to launch a thread that can be polled from the analyze method to see if the movement is complete and immediate return control back to the GAMS controller to perform its next task.
GAMS provides pre-configured variables based on the invocation of init_vars on the Base_Controller. The init_vars function provides the id of the agent along with the estimated number of processes, and this information is used to populate a set of variables in the knowledge base for usage in algorithms and platforms.
The key variables you should know about are the following:
-
self_: the Self class is a self-referencing variable based on the id of the agent.self_->deviceis a container for all variables that begin withdevice.{.id}in the knowledge base (where.idis the id passed in through init_vars).self_->idis an Integer container that directly maps to.idin the knowledge base. -
status_: Platform status is a set of flags that may be useful for algorithms, especially ones implemented as finite state machines. There are flags here that may be enabled to let other agents know you are deadlocked, waiting, ok, etc. -
sensors_: Sensor is a facade for representing sensor readings, typically over a geographic area. Sensors can be configured with ranges to aid with discretization of search spaces, for instance.
C++ Guides: GAMS Primer | Creating Algorithms | Creating Platforms