Fawkes API
Fawkes Development Version
|
JoystickInterface Fawkes BlackBoard Interface. More...
#include <>>
Classes | |
class | StartRumbleMessage |
StartRumbleMessage Fawkes BlackBoard Interface Message. More... | |
class | StopAllMessage |
StopAllMessage Fawkes BlackBoard Interface Message. More... | |
class | StopRumbleMessage |
StopRumbleMessage Fawkes BlackBoard Interface Message. More... | |
Public Types | |
enum | Direction { DIRECTION_DOWN = 0, DIRECTION_LEFT = 16384, DIRECTION_UP = 32768, DIRECTION_RIGHT = 49152 } |
Effect direction. More... | |
Public Member Functions | |
const char * | tostring_Direction (Direction value) const |
Convert Direction constant to string. More... | |
virtual bool | message_valid (const Message *message) const |
Check if message is valid and can be enqueued. More... | |
uint8_t | num_axes () const |
Get num_axes value. More... | |
void | set_num_axes (const uint8_t new_num_axes) |
Set num_axes value. More... | |
size_t | maxlenof_num_axes () const |
Get maximum length of num_axes value. More... | |
uint8_t | num_buttons () const |
Get num_buttons value. More... | |
void | set_num_buttons (const uint8_t new_num_buttons) |
Set num_buttons value. More... | |
size_t | maxlenof_num_buttons () const |
Get maximum length of num_buttons value. More... | |
uint8_t | supported_ff_effects () const |
Get supported_ff_effects value. More... | |
void | set_supported_ff_effects (const uint8_t new_supported_ff_effects) |
Set supported_ff_effects value. More... | |
size_t | maxlenof_supported_ff_effects () const |
Get maximum length of supported_ff_effects value. More... | |
uint32_t | pressed_buttons () const |
Get pressed_buttons value. More... | |
void | set_pressed_buttons (const uint32_t new_pressed_buttons) |
Set pressed_buttons value. More... | |
size_t | maxlenof_pressed_buttons () const |
Get maximum length of pressed_buttons value. More... | |
float * | axis () const |
Get axis value. More... | |
float | axis (unsigned int index) const |
Get axis value at given index. More... | |
void | set_axis (unsigned int index, const float new_axis) |
Set axis value at given index. More... | |
void | set_axis (const float *new_axis) |
Set axis value. More... | |
size_t | maxlenof_axis () const |
Get maximum length of axis value. More... | |
uint8_t | ff_effects () const |
Get ff_effects value. More... | |
void | set_ff_effects (const uint8_t new_ff_effects) |
Set ff_effects value. More... | |
size_t | maxlenof_ff_effects () const |
Get maximum length of ff_effects value. More... | |
virtual Message * | create_message (const char *type) const |
Create message based on type name. More... | |
virtual void | copy_values (const Interface *other) |
Copy values from other interface. More... | |
virtual const char * | enum_tostring (const char *enumtype, int val) const |
Convert arbitrary enum value to string. More... | |
![]() | |
virtual | ~Interface () |
Destructor. More... | |
bool | oftype (const char *interface_type) const |
Check if interface is of given type. More... | |
const void * | datachunk () const |
Get data chunk. More... | |
unsigned int | datasize () const |
Get data size. More... | |
const char * | type () const |
Get type of interface. More... | |
const char * | id () const |
Get identifier of interface. More... | |
const char * | uid () const |
Get unique identifier of interface. More... | |
unsigned short | serial () const |
Get instance serial of interface. More... | |
unsigned int | mem_serial () const |
Get memory serial of interface. More... | |
bool | operator== (Interface &comp) const |
Check equality of two interfaces. More... | |
const unsigned char * | hash () const |
Get interface hash. More... | |
size_t | hash_size () const |
Get size of interface hash. More... | |
const char * | hash_printable () const |
Get printable interface hash. More... | |
bool | is_writer () const |
Check if this is a writing instance. More... | |
void | set_validity (bool valid) |
Mark this interface invalid. More... | |
bool | is_valid () const |
Check validity of interface. More... | |
const char * | owner () const |
Get owner of interface. More... | |
void | set_from_chunk (void *chunk) |
Set from a raw data chunk. More... | |
void | resize_buffers (unsigned int num_buffers) |
Resize buffer array. More... | |
unsigned int | num_buffers () const |
Get number of buffers. More... | |
void | copy_shared_to_buffer (unsigned int buffer) |
Copy data from private memory to buffer. More... | |
void | copy_private_to_buffer (unsigned int buffer) |
Copy data from private memory to buffer. More... | |
void | read_from_buffer (unsigned int buffer) |
Copy data from buffer to private memory. More... | |
int | compare_buffers (unsigned int buffer) |
Compare buffer to private memory. More... | |
Time | buffer_timestamp (unsigned int buffer) |
Get time of a buffer. More... | |
void | buffer_timestamp (unsigned int buffer, Time *timestamp) |
Get time of a buffer. More... | |
void | read () |
Read from BlackBoard into local copy. More... | |
void | write () |
Write from local copy into BlackBoard memory. More... | |
bool | has_writer () const |
Check if there is a writer for the interface. More... | |
unsigned int | num_readers () const |
Get the number of readers. More... | |
std::string | writer () const |
Get owner name of writing interface instance. More... | |
std::list< std::string > | readers () const |
Get owner names of reading interface instances. More... | |
bool | changed () const |
Check if data has been changed. More... | |
const Time * | timestamp () const |
Get timestamp of last write. More... | |
void | set_auto_timestamping (bool enabled) |
Enable or disable automated timestamping. More... | |
void | set_timestamp (const Time *t=NULL) |
Set timestamp. More... | |
void | set_clock (Clock *clock) |
Set clock to use for timestamping. More... | |
void | mark_data_changed () |
Mark data as changed. More... | |
std::list< const char * > | get_message_types () |
Obtain a list of textual representations of the message types available for this interface. More... | |
unsigned int | msgq_enqueue (Message *message) |
Enqueue message at end of queue. More... | |
unsigned int | msgq_enqueue_copy (Message *message) |
Enqueue copy of message at end of queue. More... | |
void | msgq_remove (Message *message) |
Remove message from queue. More... | |
void | msgq_remove (unsigned int message_id) |
Remove message from queue. More... | |
unsigned int | msgq_size () |
Get size of message queue. More... | |
void | msgq_flush () |
Flush all messages. More... | |
void | msgq_lock () |
Lock message queue. More... | |
bool | msgq_try_lock () |
Try to lock message queue. More... | |
void | msgq_unlock () |
Unlock message queue. More... | |
void | msgq_pop () |
Erase first message from queue. More... | |
Message * | msgq_first () |
Get the first message from the message queue. More... | |
bool | msgq_empty () |
Check if queue is empty. More... | |
void | msgq_append (Message *message) |
Enqueue message. More... | |
template<class MessageType > | |
bool | msgq_first_is () |
Check if first message has desired type. More... | |
template<class MessageType > | |
MessageType * | msgq_first () |
Get first message casted to the desired type. More... | |
template<class MessageType > | |
MessageType * | msgq_first (MessageType *&msg) |
Get first message casted to the desired type. More... | |
template<class MessageType > | |
MessageType * | msgq_first_safe (MessageType *&msg) throw () |
Get first message casted to the desired type without exceptions. More... | |
MessageQueue::MessageIterator | msgq_begin () |
Get start iterator for message queue. More... | |
MessageQueue::MessageIterator | msgq_end () |
Get end iterator for message queue. More... | |
InterfaceFieldIterator | fields () |
Get iterator over all fields of this interface instance. More... | |
InterfaceFieldIterator | fields_end () |
Invalid iterator. More... | |
unsigned int | num_fields () |
Get the number of fields in the interface. More... | |
Static Public Attributes | |
static const uint32_t | BUTTON_1 = 1u |
BUTTON_1 constant. More... | |
static const uint32_t | BUTTON_2 = 2u |
BUTTON_2 constant. More... | |
static const uint32_t | BUTTON_3 = 4u |
BUTTON_3 constant. More... | |
static const uint32_t | BUTTON_4 = 8u |
BUTTON_4 constant. More... | |
static const uint32_t | BUTTON_5 = 16u |
BUTTON_5 constant. More... | |
static const uint32_t | BUTTON_6 = 32u |
BUTTON_6 constant. More... | |
static const uint32_t | BUTTON_7 = 64u |
BUTTON_7 constant. More... | |
static const uint32_t | BUTTON_8 = 128u |
BUTTON_8 constant. More... | |
static const uint32_t | BUTTON_9 = 256u |
BUTTON_9 constant. More... | |
static const uint32_t | BUTTON_10 = 512u |
BUTTON_10 constant. More... | |
static const uint32_t | BUTTON_11 = 1024u |
BUTTON_11 constant. More... | |
static const uint32_t | BUTTON_12 = 2048u |
BUTTON_12 constant. More... | |
static const uint32_t | BUTTON_13 = 4096u |
BUTTON_13 constant. More... | |
static const uint32_t | BUTTON_14 = 8192u |
BUTTON_14 constant. More... | |
static const uint32_t | BUTTON_15 = 16384u |
BUTTON_15 constant. More... | |
static const uint32_t | BUTTON_16 = 32768u |
BUTTON_16 constant. More... | |
static const uint32_t | BUTTON_17 = 65536u |
BUTTON_17 constant. More... | |
static const uint32_t | BUTTON_18 = 131072u |
BUTTON_18 constant. More... | |
static const uint32_t | BUTTON_19 = 262144u |
BUTTON_19 constant. More... | |
static const uint32_t | BUTTON_20 = 524288u |
BUTTON_20 constant. More... | |
static const uint32_t | BUTTON_21 = 1048576u |
BUTTON_21 constant. More... | |
static const uint32_t | BUTTON_22 = 2097152u |
BUTTON_22 constant. More... | |
static const uint32_t | BUTTON_23 = 4194304u |
BUTTON_23 constant. More... | |
static const uint32_t | BUTTON_24 = 8388608u |
BUTTON_24 constant. More... | |
static const uint32_t | BUTTON_25 = 16777216u |
BUTTON_25 constant. More... | |
static const uint32_t | BUTTON_26 = 33554432u |
BUTTON_26 constant. More... | |
static const uint32_t | BUTTON_27 = 67108864u |
BUTTON_27 constant. More... | |
static const uint32_t | BUTTON_28 = 134217728u |
BUTTON_28 constant. More... | |
static const uint32_t | BUTTON_29 = 268435456u |
BUTTON_29 constant. More... | |
static const uint32_t | BUTTON_30 = 536870912u |
BUTTON_30 constant. More... | |
static const uint32_t | BUTTON_31 = 1073741824u |
BUTTON_31 constant. More... | |
static const uint32_t | BUTTON_32 = 2147483648u |
BUTTON_32 constant. More... | |
static const uint8_t | JFF_RUMBLE = 1 |
JFF_RUMBLE constant. More... | |
static const uint8_t | JFF_PERIODIC = 2 |
JFF_PERIODIC constant. More... | |
static const uint8_t | JFF_RAMP = 4 |
JFF_RAMP constant. More... | |
static const uint8_t | JFF_SPRING = 8 |
JFF_SPRING constant. More... | |
static const uint8_t | JFF_FRICTION = 16 |
JFF_FRICTION constant. More... | |
static const uint8_t | JFF_DAMPER = 32 |
JFF_DAMPER constant. More... | |
static const uint8_t | JFF_INERTIA = 64 |
JFF_INERTIA constant. More... | |
static const uint8_t | JFF_CONSTANT = 128 |
JFF_CONSTANT constant. More... | |
Additional Inherited Members | |
![]() | |
static void | parse_uid (const char *uid, std::string &type, std::string &id) |
Parse UID to type and ID strings. More... | |
![]() | |
Interface () | |
Constructor. More... | |
void | set_hash (unsigned char *ihash) |
Set hash. More... | |
void | add_fieldinfo (interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0) |
Add an entry to the field info list. More... | |
void | add_messageinfo (const char *name) |
Add an entry to the message info list. More... | |
![]() | |
void * | data_ptr |
Pointer to local memory storage. More... | |
unsigned int | data_size |
Minimal data size to hold data storage. More... | |
bool | data_changed |
Indicator if data has changed. More... | |
interface_data_ts_t * | data_ts |
Pointer to data casted to timestamp struct. More... | |
JoystickInterface Fawkes BlackBoard Interface.
This interface provides access to a joystick. It provides up to five axes, where each has a X and a Y value between -1.0 and 1.0. Up to 32 buttons are support via an uint32 bit field.
Definition at line 33 of file JoystickInterface.h.
Effect direction.
Enumerator | |
---|---|
DIRECTION_DOWN | Down. |
DIRECTION_LEFT | Left. |
DIRECTION_UP | Up. |
DIRECTION_RIGHT | Right. |
Definition at line 82 of file JoystickInterface.h.
float * fawkes::JoystickInterface::axis | ( | ) | const |
Get axis value.
Values of axes.
Definition at line 322 of file JoystickInterface.cpp.
Referenced by JoystickTeleOpThread::loop(), and RoombaJoystickThread::loop().
float fawkes::JoystickInterface::axis | ( | unsigned int | index | ) | const |
Get axis value at given index.
Values of axes.
index | index of value |
Exception | thrown if index is out of bounds |
Definition at line 334 of file JoystickInterface.cpp.
|
virtual |
Copy values from other interface.
other | other interface to copy values from |
Implements fawkes::Interface.
Definition at line 435 of file JoystickInterface.cpp.
References fawkes::Interface::type().
|
virtual |
Create message based on type name.
This will create a new message of the given type. The type must be given without the InterfaceName:: prefix but just the plain class name of the message.
type | message type |
UnknownTypeException | thrown if this interface cannot create a message of the given type. |
Implements fawkes::Interface.
Definition at line 416 of file JoystickInterface.cpp.
|
virtual |
Convert arbitrary enum value to string.
Given the string representation of the enum type and the value this method returns the string representation of the specific value, or the string UNKNOWN if the value is not defined. An exception is thrown if the enum type is invalid.
enumtype | enum type as string |
val | value to convert |
UnknownTypeException | thrown if enumtype is not specified for interface. |
Implements fawkes::Interface.
Definition at line 446 of file JoystickInterface.cpp.
uint8_t fawkes::JoystickInterface::ff_effects | ( | ) | const |
Get ff_effects value.
Currently running effects. Either 0 if no effect is running, or a bit-wise ored field of the JFF constants.
Definition at line 385 of file JoystickInterface.cpp.
Referenced by JoystickActThread::MessageProcessor::process_message().
size_t fawkes::JoystickInterface::maxlenof_axis | ( | ) | const |
Get maximum length of axis value.
Definition at line 347 of file JoystickInterface.cpp.
Referenced by RoombaJoystickThread::init().
size_t fawkes::JoystickInterface::maxlenof_ff_effects | ( | ) | const |
Get maximum length of ff_effects value.
Definition at line 395 of file JoystickInterface.cpp.
size_t fawkes::JoystickInterface::maxlenof_num_axes | ( | ) | const |
Get maximum length of num_axes value.
Definition at line 190 of file JoystickInterface.cpp.
size_t fawkes::JoystickInterface::maxlenof_num_buttons | ( | ) | const |
Get maximum length of num_buttons value.
Definition at line 225 of file JoystickInterface.cpp.
size_t fawkes::JoystickInterface::maxlenof_pressed_buttons | ( | ) | const |
Get maximum length of pressed_buttons value.
Definition at line 297 of file JoystickInterface.cpp.
size_t fawkes::JoystickInterface::maxlenof_supported_ff_effects | ( | ) | const |
Get maximum length of supported_ff_effects value.
Definition at line 260 of file JoystickInterface.cpp.
|
virtual |
Check if message is valid and can be enqueued.
message | Message to check |
Implements fawkes::Interface.
Definition at line 798 of file JoystickInterface.cpp.
uint8_t fawkes::JoystickInterface::num_axes | ( | ) | const |
Get num_axes value.
The number of axes of this joystick
Definition at line 180 of file JoystickInterface.cpp.
Referenced by JoystickTeleOpThread::loop(), and RoombaJoystickThread::loop().
uint8_t fawkes::JoystickInterface::num_buttons | ( | ) | const |
Get num_buttons value.
The number of buttons of this joystick.
Definition at line 215 of file JoystickInterface.cpp.
uint32_t fawkes::JoystickInterface::pressed_buttons | ( | ) | const |
Get pressed_buttons value.
A bit field of enabled buttons. For each currently clicked button the corresponding bit is set to 1. Use the BUTTON_* constants for bit-wise comparisons.
Definition at line 287 of file JoystickInterface.cpp.
Referenced by JoystickTeleOpThread::loop(), and RoombaJoystickThread::loop().
void fawkes::JoystickInterface::set_axis | ( | unsigned int | index, |
const float | new_axis | ||
) |
Set axis value at given index.
Values of axes.
new_axis | new axis value |
index | index for of the value |
Definition at line 369 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by JoystickRemoteBlackBoardPoster::joystick_changed(), and JoystickSensorThread::loop().
void fawkes::JoystickInterface::set_axis | ( | const float * | new_axis | ) |
Set axis value.
Values of axes.
new_axis | new axis value |
Definition at line 357 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
void fawkes::JoystickInterface::set_ff_effects | ( | const uint8_t | new_ff_effects | ) |
Set ff_effects value.
Currently running effects. Either 0 if no effect is running, or a bit-wise ored field of the JFF constants.
new_ff_effects | new ff_effects value |
Definition at line 408 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by JoystickActThread::MessageProcessor::process_message().
void fawkes::JoystickInterface::set_num_axes | ( | const uint8_t | new_num_axes | ) |
Set num_axes value.
The number of axes of this joystick
new_num_axes | new num_axes value |
Definition at line 202 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by JoystickRemoteBlackBoardPoster::joystick_plugged(), JoystickRemoteBlackBoardPoster::joystick_unplugged(), and JoystickSensorThread::loop().
void fawkes::JoystickInterface::set_num_buttons | ( | const uint8_t | new_num_buttons | ) |
Set num_buttons value.
The number of buttons of this joystick.
new_num_buttons | new num_buttons value |
Definition at line 237 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by JoystickRemoteBlackBoardPoster::joystick_plugged(), JoystickRemoteBlackBoardPoster::joystick_unplugged(), and JoystickSensorThread::loop().
void fawkes::JoystickInterface::set_pressed_buttons | ( | const uint32_t | new_pressed_buttons | ) |
Set pressed_buttons value.
A bit field of enabled buttons. For each currently clicked button the corresponding bit is set to 1. Use the BUTTON_* constants for bit-wise comparisons.
new_pressed_buttons | new pressed_buttons value |
Definition at line 311 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by JoystickRemoteBlackBoardPoster::joystick_changed(), and JoystickSensorThread::loop().
void fawkes::JoystickInterface::set_supported_ff_effects | ( | const uint8_t | new_supported_ff_effects | ) |
Set supported_ff_effects value.
Bit field indicating available force-feedback effects.
new_supported_ff_effects | new supported_ff_effects value |
Definition at line 272 of file JoystickInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by JoystickActThread::MessageProcessor::process().
uint8_t fawkes::JoystickInterface::supported_ff_effects | ( | ) | const |
Get supported_ff_effects value.
Bit field indicating available force-feedback effects.
Definition at line 250 of file JoystickInterface.cpp.
Referenced by JoystickTeleOpThread::loop(), and RoombaJoystickThread::loop().
const char * fawkes::JoystickInterface::tostring_Direction | ( | Direction | value | ) | const |
Convert Direction constant to string.
value | value to convert to string |
Definition at line 162 of file JoystickInterface.cpp.
|
static |
BUTTON_1 constant.
Definition at line 40 of file JoystickInterface.h.
|
static |
BUTTON_10 constant.
Definition at line 49 of file JoystickInterface.h.
|
static |
BUTTON_11 constant.
Definition at line 50 of file JoystickInterface.h.
|
static |
BUTTON_12 constant.
Definition at line 51 of file JoystickInterface.h.
|
static |
BUTTON_13 constant.
Definition at line 52 of file JoystickInterface.h.
|
static |
BUTTON_14 constant.
Definition at line 53 of file JoystickInterface.h.
|
static |
BUTTON_15 constant.
Definition at line 54 of file JoystickInterface.h.
|
static |
BUTTON_16 constant.
Definition at line 55 of file JoystickInterface.h.
|
static |
BUTTON_17 constant.
Definition at line 56 of file JoystickInterface.h.
|
static |
BUTTON_18 constant.
Definition at line 57 of file JoystickInterface.h.
|
static |
BUTTON_19 constant.
Definition at line 58 of file JoystickInterface.h.
|
static |
BUTTON_2 constant.
Definition at line 41 of file JoystickInterface.h.
|
static |
BUTTON_20 constant.
Definition at line 59 of file JoystickInterface.h.
|
static |
BUTTON_21 constant.
Definition at line 60 of file JoystickInterface.h.
|
static |
BUTTON_22 constant.
Definition at line 61 of file JoystickInterface.h.
|
static |
BUTTON_23 constant.
Definition at line 62 of file JoystickInterface.h.
|
static |
BUTTON_24 constant.
Definition at line 63 of file JoystickInterface.h.
|
static |
BUTTON_25 constant.
Definition at line 64 of file JoystickInterface.h.
|
static |
BUTTON_26 constant.
Definition at line 65 of file JoystickInterface.h.
|
static |
BUTTON_27 constant.
Definition at line 66 of file JoystickInterface.h.
|
static |
BUTTON_28 constant.
Definition at line 67 of file JoystickInterface.h.
|
static |
BUTTON_29 constant.
Definition at line 68 of file JoystickInterface.h.
|
static |
BUTTON_3 constant.
Definition at line 42 of file JoystickInterface.h.
|
static |
BUTTON_30 constant.
Definition at line 69 of file JoystickInterface.h.
|
static |
BUTTON_31 constant.
Definition at line 70 of file JoystickInterface.h.
|
static |
BUTTON_32 constant.
Definition at line 71 of file JoystickInterface.h.
|
static |
BUTTON_4 constant.
Definition at line 43 of file JoystickInterface.h.
|
static |
BUTTON_5 constant.
Definition at line 44 of file JoystickInterface.h.
|
static |
BUTTON_6 constant.
Definition at line 45 of file JoystickInterface.h.
|
static |
BUTTON_7 constant.
Definition at line 46 of file JoystickInterface.h.
|
static |
BUTTON_8 constant.
Definition at line 47 of file JoystickInterface.h.
|
static |
BUTTON_9 constant.
Definition at line 48 of file JoystickInterface.h.
|
static |
JFF_CONSTANT constant.
Definition at line 79 of file JoystickInterface.h.
|
static |
JFF_DAMPER constant.
Definition at line 77 of file JoystickInterface.h.
|
static |
JFF_FRICTION constant.
Definition at line 76 of file JoystickInterface.h.
|
static |
JFF_INERTIA constant.
Definition at line 78 of file JoystickInterface.h.
|
static |
JFF_PERIODIC constant.
Definition at line 73 of file JoystickInterface.h.
|
static |
JFF_RAMP constant.
Definition at line 74 of file JoystickInterface.h.
|
static |
JFF_RUMBLE constant.
Definition at line 72 of file JoystickInterface.h.
|
static |
JFF_SPRING constant.
Definition at line 75 of file JoystickInterface.h.