srAlmende::SocketALM Class Reference

#include <socketALM.h>

List of all members.

Public Member Functions

 SocketALM (dtGame::GameActorProxy &proxy)
 Constructs the robot actor.
virtual void TickLocal (const dtGame::Message &tickMessage)
 This method is an invokable called when an object is local and receives a tick.
virtual void ProcessMessage (const dtGame::Message &message)
 This method is an invokable called when an object is remote and receives a tick.
virtual void OnEnteredWorld ()

Static Public Attributes

static const std::string EVENT_HANDLER_NAME
 Constant identifier for our game event handler method.

Protected Member Functions

virtual ~SocketALM ()
 Destructor.
void Initialize ()
void SetMaxDistance (float distanceValue)

Detailed Description

This is a socket actor. It can't move or do anything else. However, we might need to change that in the future. For example, by deciding that we won't use sockets, but more a robot-like docking unit attached to the socket. Then it would be convenient if certain properties are derived from the RobotActorBase, it might for example contain a hinge element or certain sensors or actuators, such as microphones or speakers.

Author:
Anne C. van Rossum
Date:
Oct 2, 2009

Definition at line 31 of file socketALM.h.


Constructor & Destructor Documentation

srAlmende::SocketALM::SocketALM ( dtGame::GameActorProxy &  proxy  ) 

Constructs the robot actor.

The constructor derives from RobotActorBase so that it can be extended with robot functionality if needed.

Definition at line 25 of file socketALM.cpp.

srAlmende::SocketALM::~SocketALM (  )  [protected, virtual]

Destructor.

Empty destructor.

Todo:
Check if things have to be deallocated if a socket ceases to exist. For example in a scenario where sockets are dynamically placed on different locations in the arena.

Definition at line 39 of file socketALM.cpp.


Member Function Documentation

void srAlmende::SocketALM::Initialize (  )  [protected]

Builds the socket starting from a .3ds mesh. And attaches a sensor to it, to measure if there is anything nearby / approaching. This method is called from OnEnteredWorld(), so you have to call the SetTranslation & SetRotation methods before the AddActor call.

In the initialisation all objects: bodies, sensors, actuators are pushed on the existing arrays. It might be the place to initialise a Led object on a certain position at the power outlet surface. For now, there is one "sensor", namely a distance sensor. This sensor is necessary to measure if a robot has come close to the socket, which might trigger an event indicating that the robot "semi-docked" with the socket.

The power socket uses a distance sensor that is based on the depth image camera class. However, the former does not use a proper MaxDistance, so this is adjusted by a call to setParameter("MaxDistance", ...). Moreover, it does not seem to scale the image pixels properly from MinDistance to MaxDistance. A ClearDistance is set in CameraSensorBase::setup() which is the default value for distance in a new image. In cameraSensorBase.h is chosen for a DEPTH_CAMERA image format. In the derived class DistanceSensor::getNewSensorValue() are all pixels iterated to calculated one value for the closest visible object.

Add a distance sensor in the centre of the socket hole, a little to the south. It uses an apertureAngle of 0.5 at a position [5,0,3] and orientation [0,0,0]. This can be checked by exchanging DISTANCE_SENSOR for LIGHT_SENSOR. If the aperture is not small enough, the socket will detect the floor instead of a robot. The floor should be visible as a gradient from intense to vague if the image is visualised, which can be checked by using a DEPTH_IMAGE_SENSOR.

Definition at line 58 of file socketALM.cpp.

References srAlmende::BodyFactory::createBody(), and SetMaxDistance().

Referenced by OnEnteredWorld().

Here is the call graph for this function:

void srAlmende::SocketALM::OnEnteredWorld (  )  [virtual]

Called when the actor has been added to the game manager. You can respond to OnEnteredWorld on either the proxy or actor or both.

Initialize our robot then enter the world

Definition at line 194 of file socketALM.cpp.

References Initialize().

Here is the call graph for this function:

void srAlmende::SocketALM::ProcessMessage ( const dtGame::Message &  message  )  [virtual]

This method is an invokable called when an object is remote and receives a tick.

Generic handler for messages. Overridden from base class. This is the default invokable on GameActorProxy.

The socket can get different game messages. For now it can be turned on/off or toggled. When it is off it does not transmit energy to a robot nearby and does neither detect if there is a robot nearby by its distance sensor.

Parameters:
&message This message is a Game engine message defined by Delta3D.

Definition at line 156 of file socketALM.cpp.

void srAlmende::SocketALM::SetMaxDistance ( float  distanceValue  )  [protected]

Set the maximum distance for which the power outlet acknowledges docking.

This method iterates through all the sensors attached to a power outlet. And it sets the distance sensors to a certain maximum value.

Todo:
The distance sensor has changed, so the cast to CameraSensorBase doesn't work anymore.

Definition at line 108 of file socketALM.cpp.

Referenced by Initialize().

void srAlmende::SocketALM::TickLocal ( const dtGame::Message &  tickMessage  )  [virtual]

This method is an invokable called when an object is local and receives a tick.

The tickMessage is just forwarded to RobotActorBase.

Parameters:
&tickMessage A Game Message which is sent locally.

Definition at line 133 of file socketALM.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations

Generated on Thu Feb 4 16:32:08 2010 for Delta3D Plugin by  doxygen 1.6.1