Class TBody

DescriptionHierarchyFieldsMethodsProperties

Unit

Body

Declaration

type TBody = class(TTenaciousObject)

Description

Abstract base class implementing physical properties of a TRobot. When defining a robot body, be sure to implement (and override) all virtual methods in this class. See also TDifferentiallySteeredBody which is a concrete class (derived from this class). Together with the class TBrain, TBody constitutes the fundamental parts of a physical robot (TRobot).

Hierarchy

TBody > TTenaciousObject > TPersistent

Fields

 NameDescription
Protected f3DStructure

Object containing the graphical representation of the body (user-defined). See T3DStructure.

Protected fBattery

The robot's energy source (battery).

Protected fCollisionGeometry

Geometry to use when checking for collisions. See descendants of the TShape-class for available geometry.

Protected fCoordinates

Object containing the position, velocity, direction of heading, and angular velocity of the body. See TCoordinates.

Protected fDistanceTraveled

Distance (in meters) that the body has traveled.

Protected fInitialPos

3D vector containing the initial position of the body.

Protected fMotors

Container object for motors (see TMotors).

Protected fSensors

Container object for sensors (see TSensors).

Methods

Overview

Public constructor Create(BodyParameters: TBodyParameters); overload; virtual;
Public constructor Create; overload; override;
Public constructor CreateAndSet(Body: TBody); virtual;
Public destructor Destroy; override;
Public procedure ComputeMotorTorques; virtual; abstract;
Public function Copy: TBody; virtual;
Public procedure Generate3DStructure; virtual; abstract;
Public function Get3DStructure: T3DStructure; virtual; abstract;
Public function GetPosition: TVector; virtual; abstract;
Public procedure Initialize; virtual;
Public procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual;
Public procedure Move(TimeStep: real; const Arena: TArena); virtual; abstract;
Public procedure Reset; virtual;
Protected procedure Update3DStructure; virtual; abstract;

Description

Public constructor Create(BodyParameters: TBodyParameters); overload; virtual;

Constructor

parameters
BodyParameters
is a class containing parameters needed when creating a new body.
Public constructor Create; overload; override;

Constructor

Public constructor CreateAndSet(Body: TBody); virtual;

Copy constructor

parameters
Body
is the body to be copied.
returns

A copy of the supplied body (Body).

Public destructor Destroy; override;

Destructor

Public procedure ComputeMotorTorques; virtual; abstract;

Procedure for computing the torques produced by the motors (fMotors). The torque produced by the motors is commonly used during the integration of the forward dynamics (see the procedure Move).

Public function Copy: TBody; virtual;

Creates a copy of the body by calling the copy constructor CreateAndSet.

returns

A copy of the body.

Public procedure Generate3DStructure; virtual; abstract;

Procedure that creates the 3D geometry representing the body and stores the result in the variable f3DStructure.

Public function Get3DStructure: T3DStructure; virtual; abstract;

Provides access to the variable f3DStructure. Classes deriving from TBody are required to return a valid reference and since the variable f3DStructure is destroyed when calling Reset, a suitable implementation of this function is (assuming a derived class called TMyBody):

function TMyBody.Get3DStructure: T3DStructure;
begin
  if f3DStructure = nil then
    Generate3DStructure;

  Result := f3DStructure;
end;

returns

The variable f3DStructure.

Public function GetPosition: TVector; virtual; abstract;

Provides read access of the vector fCoordinates.Position.

Public procedure Initialize; virtual;

Initialization of member variables (commonly done prior to simulation). Currently, this procedure is only responsible for mapping a battery sensor to the actual energy source (as defined in the definition file).

Public procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual;

Procedure for processing the definition of a body (as parsed from the definition text file). This procedure is automatically called from link(Robot.TRobot).LoadFromFile and does not need to be called explicitly.

Public procedure Move(TimeStep: real; const Arena: TArena); virtual; abstract;

Procedure called every time step and should be used for updating the body's position and integrating the forward dynamics etc. This procedure is called from within the procedure TRobot.Move and does not need to be called explicitly.

Public procedure Reset; virtual;

Procedure for re-setting member variables. Currently, this procedure resets all sensors by calling TSensors.Reset, sets fDistanceTraveled to zero, sets the position back to it's initial values, and calls fBattery.Initialize (if there is a battery). In addition, the variable f3DStructure is destroyed and set to Nil (see Get3DStructure).

Protected procedure Update3DStructure; virtual; abstract;

Updates the 3D representation of the body (needs to be implemented in derived classes). Updates the variable f3DStructure that provides the connection between the internal geometric representation and the graphical representation used by GLScene.

Properties

Overview

Public property Battery: TEnergySource;
Public property CollisionGeometry: TShape;
Public property Coordinates: TCoordinates;
Public property DistanceTraveled: real;
Public property InitialPosition: TVector;
Public property Motors: TMotors;
Public property Sensors: TSensors;

Description

Public property Battery: TEnergySource;

Provides read access of fBattery.

Public property CollisionGeometry: TShape;

Provides read access of fCollisionGeometry.

Public property Coordinates: TCoordinates;

Provides read access of fCoordinates.

Public property DistanceTraveled: real;

Provides read access of the variable fDistanceTraveled.

Public property InitialPosition: TVector;

Provides read access of the 3D vector fInitialPos.

Public property Motors: TMotors;

Provides read access of fMotors.

Public property Sensors: TSensors;

Provides read access of fSensors.


Generated by PasDoc 0.8.8.3 on 2005-05-28 08:13:49