More About Combination Objects - northern-bites/nbites GitHub Wiki

Combination Objects, found in CombinationObjects.cpp and CombinationObjects.h, are C++ classes that tie together vision and localization information about objects. Although they are written in C++, they are primarily for use in Python, so they are wrapped. They were written in C++ to keep computations fast and to allow for easy access to the C++ vision and loc systems. To use them in Python, either import objects or from objects import ([classes]).

On the C++ Side

The available classes are:

  • Location: The base class for several others. Holds x and y values that represent a location on the field. Provides methods to return a Python tuple (for wrapping), to compute the distance and heading to another Location, and to determine if the location is in various parts of the field. Also provides hasattr and toString methods so that Locations function more naturally as Python objects.
  • RobotLocation: Derived from Location; also contains a heading (where the robot is facing). Provides additional methods to get relative bearings and spin directions.
  • RelLocation: Derived from RobotLocation; x, y, and h here are all relative to another RobotLocation.
  • LocObject: Derived from Location; holds the distance, bearing, and relative x and y values of a object from the robot's point of view. Helps with tracking.
  • LocBall: Derived from Location; similar to a LocObject, but with many specialized fields that apply only to the ball. Can access the ball information from the actual Localization system.
  • FieldObject: Holds pointers to a VisualFieldObject and LocObject, which should represent the same object. Provides methods to get the best-estimate distance and bearing (between the loc and vision values). Also contains methods for ease of use on the Python side.
  • MyInfo: Derived from RobotLocation; stores the robot's own loc information along with team color and player number.
  • Ball: Like FieldObject, holds pointers to a VisualBall and LocBall.

On the Python Side

  • The goalposts are FieldObjects. They are created here and connect the appropriate vision and loc objects. They can be accessed via their names (yglp, ygrp, bglp, bgrp) through Brain. [name].dist or [name].bearing gives a best-estimate distance or bearing, while [name].loc.[property] allows access to localization properties and [name].vis.[property] gives access to vision properties.
  • Similarly, the ball is a Ball. It is created here. The same rules for vis/loc apply.
  • The robot's own info is stored as an instance of MyInfo; see here.
  • RobotLocations are used as destinations for the navigator.