|
LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
|
communication message encoder/decorder More...
#include <audio_codec.h>
Public Types | |
| typedef std::unordered_map< char, int > | CharToIntCont |
| map from char to int | |
| typedef std::vector< char > | IntToCharCont |
| map from int to char | |
Public Member Functions | |
| void | createMap (const int shift) |
| const CharToIntCont & | charToIntMap () const |
| get character to interger map object More... | |
| const IntToCharCont & | intToCharMap () const |
| get integer to character map object More... | |
| bool | encodeInt64ToStr (const std::int64_t &ival, const int len, std::string &to) const |
| encode decimal (64bit) integer to the encoded string. More... | |
| bool | decodeStrToInt64 (const std::string &from, std::int64_t *to) const |
| decode the message string to the decimal (64bit) integer More... | |
| char | encodePercentageToChar (const double &value) const |
| encode % value to 1 character More... | |
| double | decodeCharToPercentage (const char ch) const |
| decode 1 character to the real number [0,1] More... | |
| bool | encodePosVelToStr5 (const Vector2D &pos, const Vector2D &vel, std::string &to) const |
| encode position and velocity to 5 characters. More... | |
| bool | decodeStr5ToPosVel (const std::string &from, Vector2D *pos, Vector2D *vel) const |
| decode 5 characters to position and velocity More... | |
| bool | encodePosToStr3 (const Vector2D &pos, std::string &to) const |
| encode position to 3 characters. More... | |
| bool | decodeStr3ToPos (const std::string &from, Vector2D *pos) const |
| decode 3 characters to and position More... | |
| bool | encodeUnumPosToStr4 (const int unum, const Vector2D &pos, std::string &to) const |
| encode uniform number and position to 4 characters. More... | |
| bool | decodeStr4ToUnumPos (const std::string &from, int *unum, Vector2D *pos) const |
| decode 4 characters to uniform number and position More... | |
| std::string | encodeCoordToStr2 (const double &xy, const double &norm_factor) const |
| encode coordinate value( x or y ) to 2 characters. More... | |
| double | decodeStr2ToCoord (const char ch1, const char ch2, const double &norm_factor) const |
| decode 2 characters to coordinate value( x or y ) More... | |
| std::string | encodePosToStr4 (const Vector2D &pos) const |
| encode position value to 4 characters with 0.1 step More... | |
| Vector2D | decodeStr4ToPos (const std::string &from) const |
| decode 4 characters to position value More... | |
| char | encodeSpeedToChar (const double &xy) const |
| encode speed value to 1 character. More... | |
| double | decodeCharToSpeed (const char ch) const |
| decode 1 character to speed value More... | |
Static Public Member Functions | |
| static AudioCodec & | instance () |
| singleton interface More... | |
| static const AudioCodec & | i () |
| singleton interface More... | |
| static char | unum2hex (const int unum) |
| convert decimal uniform number to hex number More... | |
| static int | hex2unum (const char hex) |
| convert hex number character to decimal uniform number. More... | |
Static Public Attributes | |
| static const double | ERROR_VALUE |
| constant error value (= std::numeric_limits< double >::max()) | |
communication message encoder/decorder
|
inline |
get character to interger map object
| double rcsc::AudioCodec::decodeCharToPercentage | ( | const char | ch | ) | const |
decode 1 character to the real number [0,1]
| ch | character to be decoded |
| double rcsc::AudioCodec::decodeCharToSpeed | ( | const char | ch | ) | const |
decode 1 character to speed value
| ch | character to be decoded |
| double rcsc::AudioCodec::decodeStr2ToCoord | ( | const char | ch1, |
| const char | ch2, | ||
| const double & | norm_factor | ||
| ) | const |
decode 2 characters to coordinate value( x or y )
| ch1 | first character to be decoded |
| ch2 | second character to be decoded |
| norm_factor | normalize factor for coordinate value |
norm_factor must be same as the value used by encodeCoordL2() norm_factor will be changed depending on the type of target coordinate value, i.e. field length or field width.
| bool rcsc::AudioCodec::decodeStr3ToPos | ( | const std::string & | from, |
| Vector2D * | pos | ||
| ) | const |
decode 3 characters to and position
| from | string to be decoded |
| pos | pointer to the result variable |
The length of 'from' must be 3.
| Vector2D rcsc::AudioCodec::decodeStr4ToPos | ( | const std::string & | from | ) | const |
decode 4 characters to position value
| from | message string to be decoded |
| bool rcsc::AudioCodec::decodeStr4ToUnumPos | ( | const std::string & | from, |
| int * | unum, | ||
| Vector2D * | pos | ||
| ) | const |
decode 4 characters to uniform number and position
| from | string to be decoded |
| unum | pointer to the result variable |
| pos | pointer to the result variable |
The length of 'from' must be 4.
| bool rcsc::AudioCodec::decodeStr5ToPosVel | ( | const std::string & | from, |
| Vector2D * | pos, | ||
| Vector2D * | vel | ||
| ) | const |
decode 5 characters to position and velocity
| from | string to be decoded |
| pos | variable pointer to store the decoded position value |
| vel | variable pointer to store the decoded velocity value |
The length of 'from' must be 5.
| bool rcsc::AudioCodec::decodeStrToInt64 | ( | const std::string & | from, |
| std::int64_t * | to | ||
| ) | const |
decode the message string to the decimal (64bit) integer
| from | input message string |
| to | pointer to the result instance |
| std::string rcsc::AudioCodec::encodeCoordToStr2 | ( | const double & | xy, |
| const double & | norm_factor | ||
| ) | const |
encode coordinate value( x or y ) to 2 characters.
| xy | coordinate value to be encoded, X or Y. This value should be within [-norm_factor, norm_factor] |
| norm_factor | normalize factor for xy |
Following condition must be satisfied:
norm_factor must be same as the value used by decodeCoordL2() norm_factor will be changed depending on the type of target coordinate value, i.e. field length or field width.
| bool rcsc::AudioCodec::encodeInt64ToStr | ( | const std::int64_t & | ival, |
| const int | len, | ||
| std::string & | to | ||
| ) | const |
encode decimal (64bit) integer to the encoded string.
| ival | input value |
| len | desired string length |
| to | reference to the result instance |
| char rcsc::AudioCodec::encodePercentageToChar | ( | const double & | value | ) | const |
encode % value to 1 character
| value | real number [0,1] |
| bool rcsc::AudioCodec::encodePosToStr3 | ( | const Vector2D & | pos, |
| std::string & | to | ||
| ) | const |
encode position to 3 characters.
| pos | position value to be encoded |
| to | reference to the result variable |
The length of result string must be 3.
| std::string rcsc::AudioCodec::encodePosToStr4 | ( | const Vector2D & | pos | ) | const |
encode position value to 4 characters with 0.1 step
| pos | position value to be encoded |
| bool rcsc::AudioCodec::encodePosVelToStr5 | ( | const Vector2D & | pos, |
| const Vector2D & | vel, | ||
| std::string & | to | ||
| ) | const |
encode position and velocity to 5 characters.
| pos | position value to be encoded |
| vel | velocity value to be encoded |
| to | reference to the result variable |
The length of result string must be 5.
| char rcsc::AudioCodec::encodeSpeedToChar | ( | const double & | xy | ) | const |
encode speed value to 1 character.
| xy | velocity element to be encoded, X or Y |
speed value is normalized by SPEED_NORM_FACTOR
| bool rcsc::AudioCodec::encodeUnumPosToStr4 | ( | const int | unum, |
| const Vector2D & | pos, | ||
| std::string & | to | ||
| ) | const |
encode uniform number and position to 4 characters.
| unum | uniform number |
| pos | position value to be encoded |
| to | reference to the result variable |
The length of result string must be 4.
|
static |
convert hex number character to decimal uniform number.
| hex | hex number character, that must be within [0, B], case sensitive! |
|
static |
singleton interface
|
static |
singleton interface
|
inline |
get integer to character map object
|
static |
convert decimal uniform number to hex number
| unum | decimal uniform number, that must be within [1, 11] |