Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RawCamBehavior Class Reference

#include <RawCamBehavior.h>

Inheritance diagram for RawCamBehavior:

Inheritance graph
[legend]
List of all members.

Detailed Description

Forwards images from camera over wireless.

The format used for serialization is basically defined by the subclass of FilterBankGenerator being used. I suggest looking at that classes's documentation to determine the format used. (Generally either RawCameraGenerator or JPEGGenerator)

However, RawCamBehavior will add a few fields at the beginning of each packet to assist in processing the image stream.

I emphasize: beginning of each Vision packet, before the FilterBankGenerator header.

  • <string:"TekkotsuImage">
  • <Config::vision_config::encoding_t: rawcam_encoding> (expect single or multiple channels, 0 means color (3 channels), 1 means intensity (1 channel))
  • <Config::vision_config::compression_t: rawcam_compression> (0==none, 1==jpeg, 2==rle)
  • <unsigned int: width> (this is the width of the largest channel - note different channels can be sent at different resolutions! Provides cheap "compression" of chromaticity channels)
  • <unsigned int: height> (similarly, height of largest channel)
  • <unsigned int: timestamp> (time image was taken, milliseconds since boot)
  • <unsigned int: framenumber> (incremented for each frame, so we can tell if/when we drop one)

Alternatively, RawCameraGenerator may send a "Close Connection" packet when the server is shutting down. This is to help UDP connections, which otherwise wouldn't realize that they need to start trying to reconnect.

  • <string:"CloseConnection">

This is exactly the same protocol that is followed by the SegCamBehavior as well - the same code can parse either stream.

This is a binary protocol -- the fields listed indicate binary values in the AIBO's byte order (little endian). Strings are encoded using the LoadSave::encode(char*,unsigned int, unsigned int) method.

Definition at line 41 of file RawCamBehavior.h.

Public Member Functions

 RawCamBehavior ()
 constructor
virtual void DoStart ()
 By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.
virtual void DoStop ()
 By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).
virtual void processEvent (const EventBase &e)
 By defining here, allows you to get away with not supplying a processEvent() function for the EventListener interface. By default, does nothing.
virtual std::string getDescription () const
 Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).

Static Public Member Functions

static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).
static unsigned int getSourceLayer (unsigned int chan, unsigned int numLayers)
 returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)
static unsigned int getSourceYLayer (unsigned int numLayers)
 returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)
static unsigned int getSourceULayer (unsigned int numLayers)
 returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)
static unsigned int getSourceVLayer (unsigned int numLayers)
 returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)

Static Public Attributes

static const unsigned int TCP_WIRELESS_BUFFER_SIZE = 200000
 200000 bytes for use up to 416x320 + 2*208x160 (double res Y, full res UV on ERS-7)
static const unsigned int UDP_WIRELESS_BUFFER_SIZE = 64*1024
 64KB is the max udp packet size

Protected Member Functions

bool openPacket (FilterBankGenerator &fbkgen, unsigned int time, unsigned int layer)
 opens a new packet, writes header info; returns true if open, false if otherwise open (check cur==NULL for error)
bool writeColor (const FilterBankEvent &fbke)
 writes a color image
bool writeSingleChannel (const FilterBankEvent &fbke)
 writes a single channel
void closePacket ()
 closes and sends a packet, does nothing if no packet open
bool sendCloseConnectionPacket ()
 sends a packet signaling the server is closing the connection (good for UDP connections)

Protected Attributes

SocketvisRaw
 socket for sending the image stream
char * packet
 point to the current buffer being prepared to be sent
char * cur
 current location within that buffer
unsigned int avail
 the number of bytes remaining in the buffer
unsigned int max_buf
 the buffer size requested from Wireless when the socket was allocated
unsigned int lastProcessedTime
 the time that the last event was processed

Private Member Functions

 RawCamBehavior (const RawCamBehavior &)
 don't call
RawCamBehavioroperator= (const RawCamBehavior &)
 don't call


Constructor & Destructor Documentation

RawCamBehavior::RawCamBehavior  ) 
 

constructor

Definition at line 10 of file RawCamBehavior.cc.

RawCamBehavior::RawCamBehavior const RawCamBehavior  )  [private]
 

don't call


Member Function Documentation

void RawCamBehavior::closePacket  )  [protected]
 

closes and sends a packet, does nothing if no packet open

Definition at line 317 of file RawCamBehavior.cc.

Referenced by writeColor(), and writeSingleChannel().

void RawCamBehavior::DoStart  )  [virtual]
 

By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.

Reimplemented from BehaviorBase.

Definition at line 15 of file RawCamBehavior.cc.

void RawCamBehavior::DoStop  )  [virtual]
 

By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).

Reimplemented from BehaviorBase.

Definition at line 45 of file RawCamBehavior.cc.

static std::string RawCamBehavior::getClassDescription  )  [inline, static]
 

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented from BehaviorBase.

Definition at line 55 of file RawCamBehavior.h.

Referenced by getDescription().

virtual std::string RawCamBehavior::getDescription  )  const [inline, virtual]
 

Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).

By default simply returns getName(), because any calls from a BehaviorBase function to getClassDescription() are going to call BehaviorBase::getClassDescription(), not ~YourSubClass~getClassDescription(), because static functions can't be virtual in C++ (doh!)

This means that getDescription called on a pointer to a BehaviorBase of unknown subtype would always return an empty string, which is pretty useless. So instead we return the name in this situation. If you want getDescription to return getClassDescription, you'll have to override it in your subclass to do so.

Reimplemented from BehaviorBase.

Definition at line 60 of file RawCamBehavior.h.

unsigned int RawCamBehavior::getSourceLayer unsigned int  chan,
unsigned int  numLayers
[static]
 

returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)

Definition at line 83 of file RawCamBehavior.cc.

Referenced by getSourceULayer(), getSourceVLayer(), getSourceYLayer(), StareAtPawBehavior2::processEvent(), and DrawSkeletonBehavior::processEvent().

unsigned int RawCamBehavior::getSourceULayer unsigned int  numLayers  )  [static]
 

returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)

Definition at line 111 of file RawCamBehavior.cc.

unsigned int RawCamBehavior::getSourceVLayer unsigned int  numLayers  )  [static]
 

returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)

Definition at line 114 of file RawCamBehavior.cc.

unsigned int RawCamBehavior::getSourceYLayer unsigned int  numLayers  )  [static]
 

returns the layer which will be used out of the source, based on current config settings (i.e. compression, skip, etc)

Definition at line 108 of file RawCamBehavior.cc.

bool RawCamBehavior::openPacket FilterBankGenerator fbkgen,
unsigned int  time,
unsigned int  layer
[protected]
 

opens a new packet, writes header info; returns true if open, false if otherwise open (check cur==NULL for error)

see the class documentation for RawCamBehavior for the protocol documentation

Definition at line 119 of file RawCamBehavior.cc.

Referenced by writeColor(), and writeSingleChannel().

RawCamBehavior& RawCamBehavior::operator= const RawCamBehavior  )  [private]
 

don't call

void RawCamBehavior::processEvent const EventBase e  )  [virtual]
 

By defining here, allows you to get away with not supplying a processEvent() function for the EventListener interface. By default, does nothing.

Reimplemented from BehaviorBase.

Definition at line 59 of file RawCamBehavior.cc.

bool RawCamBehavior::sendCloseConnectionPacket  )  [protected]
 

sends a packet signaling the server is closing the connection (good for UDP connections)

Definition at line 333 of file RawCamBehavior.cc.

Referenced by DoStop().

bool RawCamBehavior::writeColor const FilterBankEvent fbke  )  [protected]
 

writes a color image

Definition at line 158 of file RawCamBehavior.cc.

Referenced by processEvent().

bool RawCamBehavior::writeSingleChannel const FilterBankEvent fbke  )  [protected]
 

writes a single channel

Definition at line 290 of file RawCamBehavior.cc.

Referenced by processEvent().


Member Data Documentation

unsigned int RawCamBehavior::avail [protected]
 

the number of bytes remaining in the buffer

Definition at line 81 of file RawCamBehavior.h.

Referenced by closePacket(), openPacket(), writeColor(), and writeSingleChannel().

char* RawCamBehavior::cur [protected]
 

current location within that buffer

Definition at line 80 of file RawCamBehavior.h.

Referenced by closePacket(), openPacket(), writeColor(), and writeSingleChannel().

unsigned int RawCamBehavior::lastProcessedTime [protected]
 

the time that the last event was processed

Definition at line 83 of file RawCamBehavior.h.

Referenced by closePacket(), and processEvent().

unsigned int RawCamBehavior::max_buf [protected]
 

the buffer size requested from Wireless when the socket was allocated

Definition at line 82 of file RawCamBehavior.h.

Referenced by DoStart(), and openPacket().

char* RawCamBehavior::packet [protected]
 

point to the current buffer being prepared to be sent

Definition at line 79 of file RawCamBehavior.h.

Referenced by closePacket(), and openPacket().

const unsigned int RawCamBehavior::TCP_WIRELESS_BUFFER_SIZE = 200000 [static]
 

200000 bytes for use up to 416x320 + 2*208x160 (double res Y, full res UV on ERS-7)

Definition at line 46 of file RawCamBehavior.h.

Referenced by DoStart().

const unsigned int RawCamBehavior::UDP_WIRELESS_BUFFER_SIZE = 64*1024 [static]
 

64KB is the max udp packet size

Definition at line 47 of file RawCamBehavior.h.

Referenced by DoStart().

Socket* RawCamBehavior::visRaw [protected]
 

socket for sending the image stream

Definition at line 78 of file RawCamBehavior.h.

Referenced by closePacket(), DoStart(), DoStop(), openPacket(), processEvent(), and sendCloseConnectionPacket().


The documentation for this class was generated from the following files:

Tekkotsu v2.4.1
Generated Tue Aug 16 16:35:07 2005 by Doxygen 1.4.4