vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Radamec_SPI Class Reference

#include <vrpn_Analog_Radamec_SPI.h>

Inheritance diagram for vrpn_Radamec_SPI:
Collaboration diagram for vrpn_Radamec_SPI:

Public Member Functions

 vrpn_Radamec_SPI (const char *name, vrpn_Connection *c, const char *port, int baud=38400)
 
 ~vrpn_Radamec_SPI ()
 
virtual void mainloop ()
 Called once through each main loop iteration to handle updates. More...
 
- Public Member Functions inherited from vrpn_Serial_Analog
 vrpn_Serial_Analog (const char *name, vrpn_Connection *connection, const char *port, int baud=9600, int bits=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE, bool rts_flow=false)
 
 ~vrpn_Serial_Analog ()
 
- Public Member Functions inherited from vrpn_Analog
 vrpn_Analog (const char *name, vrpn_Connection *c=NULL)
 
void print (void)
 
vrpn_int32 getNumChannels (void) const
 
- Public Member Functions inherited from vrpn_BaseClass
 vrpn_BaseClass (const char *name, vrpn_Connection *c=NULL)
 Names the device and assigns or opens connection, calls registration methods. More...
 
virtual ~vrpn_BaseClass ()
 
- Public Member Functions inherited from vrpn_BaseClassUnique
 vrpn_BaseClassUnique ()
 
virtual ~vrpn_BaseClassUnique ()
 Unregister all of the message handlers that were to be autodeleted. More...
 
vrpn_ConnectionconnectionPtr ()
 Returns a pointer to the connection this object is using. More...
 

Protected Member Functions

virtual int reset (void)
 
virtual int get_report (void)
 
virtual void clear_values (void)
 
unsigned char compute_crc (const unsigned char *head, int len)
 Compute the CRC for the message or report starting at head with length len. More...
 
vrpn_uint32 convert_24bit_unsigned (const unsigned char *buf)
 Convert a 24-bit value from a buffer into an unsigned integer value. More...
 
vrpn_int32 convert_16bit_unsigned (const unsigned char *buf)
 Convert a 16-bit unsigned value from a buffer into an integer. More...
 
double int_to_pan (vrpn_uint32 val)
 ----------------— Conversion of encoder indices to values -------------— Pan and tilt axis have an encoder index pulse which resets the value to 7FFFF hex each time the head passes through 0 degrees, the centre of range of the head. More...
 
double int_to_tilt (vrpn_uint32 val)
 
double int_to_zoom (vrpn_uint32 val)
 
double int_to_focus (vrpn_uint32 val)
 
double int_to_height (vrpn_uint32 val)
 
double int_to_X (vrpn_uint32 mm, vrpn_uint32 frac)
 Convert from the millimeter and fraction-of-millimeter values returned by the device into meters. More...
 
double int_to_Y (vrpn_uint32 mm, vrpn_uint32 frac)
 
double int_to_orientation (vrpn_uint32 val)
 Convert from the 1/100 degree increments into degrees. More...
 
int send_command (const unsigned char *cmd, int len)
 Compute the CRC for the message, append it, and send message. Returns 0 on success, -1 on failure. More...
 
virtual void report_changes (vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
 send report iff changed More...
 
virtual void report (vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
 send report whether or not changed More...
 
- Protected Member Functions inherited from vrpn_Serial_Analog
int read_available_characters (char *buffer, int bytes)
 
- Protected Member Functions inherited from vrpn_Analog
virtual int register_types (void)
 Register the types of messages this device sends/receives. Return 0 on success, -1 on fail. More...
 
virtual vrpn_int32 encode_to (char *buf)
 
virtual void report_changes (vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
 Send a report only if something has changed (for servers) Optionally, tell what time to stamp the value with. More...
 
virtual void report (vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
 Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp the value with. More...
 
- Protected Member Functions inherited from vrpn_BaseClass
virtual int init (void)
 Initialize things that the constructor can't. Returns 0 on success, -1 on failure. More...
 
virtual int register_senders (void)
 Register the sender for this device (by default, the name of the device). Return 0 on success, -1 on fail. More...
 
- Protected Member Functions inherited from vrpn_BaseClassUnique
int register_autodeleted_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
 Registers a handler with the connection, and remembers to delete at destruction. More...
 
int send_text_message (const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
 Sends a NULL-terminated text message from the device d_sender_id. More...
 
SendTextMessageBoundCall send_text_message (vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL)
 Returns an object you can stream into to send a text message from the device like send_text_message(vrpn_TEXT_WARNING) << "Value of i is: " << i; This use requires including vrpn_SendTextMessageStreamProxy.h. More...
 
void server_mainloop (void)
 Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should be called by all servers in their mainloop() More...
 
void client_mainloop (void)
 Handles functions that all clients should provide in their mainloop() (warning of no server, for example) Should be called by all clients in their mainloop() More...
 

Protected Attributes

int _status
 
int _camera_id
 
int _numchannels
 
unsigned _expected_chars
 
unsigned char _buffer [512]
 
unsigned _bufcount
 
struct timeval timestamp
 
- Protected Attributes inherited from vrpn_Serial_Analog
int serial_fd
 
char portname [1024]
 
int baudrate
 
unsigned char buffer [1024]
 
int bufcounter
 
- Protected Attributes inherited from vrpn_Analog
vrpn_float64 channel [vrpn_CHANNEL_MAX]
 
vrpn_float64 last [vrpn_CHANNEL_MAX]
 
vrpn_int32 num_channel
 
struct timeval timestamp
 
vrpn_int32 channel_m_id
 
int status
 
- Protected Attributes inherited from vrpn_BaseClassUnique
vrpn_Connectiond_connection
 Connection that this object talks to. More...
 
char * d_servicename
 Name of this device, not including the connection part. More...
 
vrpn_int32 d_sender_id
 Sender ID registered with the connection. More...
 
vrpn_int32 d_text_message_id
 ID for text messages. More...
 
vrpn_int32 d_ping_message_id
 Ask the server if they are there. More...
 
vrpn_int32 d_pong_message_id
 Server telling that it is there. More...
 

Additional Inherited Members

- Public Attributes inherited from vrpn_BaseClassUnique
bool shutup
 
vrpn_MESSAGEHANDLER handler
 
vrpn_int32 sender
 
vrpn_int32 type
 
void * userdata
 
- Static Protected Member Functions inherited from vrpn_BaseClassUnique
static int encode_text_message_to_buffer (char *buf, vrpn_TEXT_SEVERITY severity, vrpn_uint32 level, const char *msg)
 Encodes the body of the text message into a buffer, preparing for sending. More...
 
static int decode_text_message_from_buffer (char *msg, vrpn_TEXT_SEVERITY *severity, vrpn_uint32 *level, const char *buf)
 Decodes the body of the text message from a buffer from the connection. More...
 

Detailed Description

Definition at line 10 of file vrpn_Analog_Radamec_SPI.h.

Constructor & Destructor Documentation

◆ vrpn_Radamec_SPI()

vrpn_Radamec_SPI::vrpn_Radamec_SPI ( const char *  name,
vrpn_Connection c,
const char *  port,
int  baud = 38400 
)

Definition at line 41 of file vrpn_Analog_Radamec_SPI.C.

References _numchannels, _status, clear_values(), vrpn_Analog::num_channel, and STATUS_RESETTING.

Here is the call graph for this function:

◆ ~vrpn_Radamec_SPI()

vrpn_Radamec_SPI::~vrpn_Radamec_SPI ( )
inline

Definition at line 16 of file vrpn_Analog_Radamec_SPI.h.

Member Function Documentation

◆ clear_values()

void vrpn_Radamec_SPI::clear_values ( void  )
protectedvirtual

Definition at line 57 of file vrpn_Analog_Radamec_SPI.C.

References _numchannels, vrpn_Analog::channel, and vrpn_Analog::last.

Referenced by vrpn_Radamec_SPI().

◆ compute_crc()

unsigned char vrpn_Radamec_SPI::compute_crc ( const unsigned char *  head,
int  len 
)
protected

Compute the CRC for the message or report starting at head with length len.

This routine will compute the CRC for the message that starts at head and is of length len.

This needs to be added to each message sent to the device, and should be checked for each command received by the device.

The manual states that the CRC is "calculated by subtracting the total sum of each byte of the block from 40H."

Definition at line 75 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report(), and send_command().

◆ convert_16bit_unsigned()

vrpn_int32 vrpn_Radamec_SPI::convert_16bit_unsigned ( const unsigned char *  buf)
protected

Convert a 16-bit unsigned value from a buffer into an integer.

Convert a 16-bit unsigned value from a buffer into an integer value.

The value has the most significant byte first in the buffer.

Definition at line 145 of file vrpn_Analog_Radamec_SPI.C.

References vrpn_unbuffer().

Referenced by get_report().

Here is the call graph for this function:

◆ convert_24bit_unsigned()

vrpn_uint32 vrpn_Radamec_SPI::convert_24bit_unsigned ( const unsigned char *  buf)
protected

Convert a 24-bit value from a buffer into an unsigned integer value.

The value has the most significant byte first in the buffer.

Definition at line 123 of file vrpn_Analog_Radamec_SPI.C.

References vrpn_unbuffer().

Referenced by get_report().

Here is the call graph for this function:

◆ get_report()

◆ int_to_focus()

double vrpn_Radamec_SPI::int_to_focus ( vrpn_uint32  val)
protected

Definition at line 191 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report().

◆ int_to_height()

double vrpn_Radamec_SPI::int_to_height ( vrpn_uint32  val)
protected

Definition at line 197 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report().

◆ int_to_orientation()

double vrpn_Radamec_SPI::int_to_orientation ( vrpn_uint32  val)
protected

Convert from the 1/100 degree increments into degrees.

Definition at line 213 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report().

◆ int_to_pan()

double vrpn_Radamec_SPI::int_to_pan ( vrpn_uint32  val)
protected

----------------— Conversion of encoder indices to values -------------— Pan and tilt axis have an encoder index pulse which resets the value to 7FFFF hex each time the head passes through 0 degrees, the centre of range of the head.

This is indicated by two red dots on the pan axis, which when aligned show the head is at 0 degrees. Tilt 0 position is when the camera is horizontal. There are 900 encoder counts per degree and the direction corresponding to an increase in count depends on the mechanical orientation of the head and camera but is configurable using the configuration block anyway.

Zoom and focus return an encoder count corresponding to the barrel rotation of the lens. You will have to calibrate this to give a value for field of view for the virtual set. This is not an easy task as lens characteristics are non-linear. All virtual studio system suppliers have varying methods of doing lens calibration, including our own proprietary method used for Radamec Virtual Scenario.

Definition at line 180 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report().

◆ int_to_tilt()

double vrpn_Radamec_SPI::int_to_tilt ( vrpn_uint32  val)
inlineprotected

Definition at line 47 of file vrpn_Analog_Radamec_SPI.h.

Referenced by get_report().

◆ int_to_X()

double vrpn_Radamec_SPI::int_to_X ( vrpn_uint32  mm,
vrpn_uint32  frac 
)
protected

Convert from the millimeter and fraction-of-millimeter values returned by the device into meters.

Definition at line 206 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report().

◆ int_to_Y()

double vrpn_Radamec_SPI::int_to_Y ( vrpn_uint32  mm,
vrpn_uint32  frac 
)
inlineprotected

Definition at line 53 of file vrpn_Analog_Radamec_SPI.h.

◆ int_to_zoom()

double vrpn_Radamec_SPI::int_to_zoom ( vrpn_uint32  val)
protected

Definition at line 185 of file vrpn_Analog_Radamec_SPI.C.

Referenced by get_report().

◆ mainloop()

void vrpn_Radamec_SPI::mainloop ( void  )
virtual

Called once through each main loop iteration to handle updates.

This routine is called each time through the server's main loop.

It will take a course of action depending on the current status of the device, either trying to reset it or trying to get a reading from it. It will try to reset the device if no data has come from it for a couple of seconds

Implements vrpn_BaseClass.

Definition at line 518 of file vrpn_Analog_Radamec_SPI.C.

References get_report(), MAX_TIME_INTERVAL, reset(), vrpn_BaseClassUnique::server_mainloop(), vrpn_Analog::status, STATUS_READING, STATUS_RESETTING, STATUS_SYNCING, timestamp, vrpn_gettimeofday, VRPN_MSG_ERROR, and vrpn_TimevalDuration().

Here is the call graph for this function:

◆ report()

void vrpn_Radamec_SPI::report ( vrpn_uint32  class_of_service = vrpn_CONNECTION_LOW_LATENCY)
protectedvirtual

send report whether or not changed

Definition at line 504 of file vrpn_Analog_Radamec_SPI.C.

References vrpn_Analog::report(), timestamp, and vrpn_Analog::timestamp.

Referenced by get_report().

Here is the call graph for this function:

◆ report_changes()

void vrpn_Radamec_SPI::report_changes ( vrpn_uint32  class_of_service = vrpn_CONNECTION_LOW_LATENCY)
protectedvirtual

send report iff changed

Definition at line 497 of file vrpn_Analog_Radamec_SPI.C.

References vrpn_Analog::report_changes(), timestamp, and vrpn_Analog::timestamp.

Here is the call graph for this function:

◆ reset()

int vrpn_Radamec_SPI::reset ( void  )
protectedvirtual

◆ send_command()

int vrpn_Radamec_SPI::send_command ( const unsigned char *  cmd,
int  len 
)
protected

Compute the CRC for the message, append it, and send message. Returns 0 on success, -1 on failure.

Compute the CRC for the command that is being sent, append that to the message, and send the message.

Returns 0 on success, -1 on failure.

Definition at line 96 of file vrpn_Analog_Radamec_SPI.C.

References compute_crc(), vrpn_Serial_Analog::serial_fd, and vrpn_write_characters().

Referenced by reset().

Here is the call graph for this function:

Member Data Documentation

◆ _bufcount

unsigned vrpn_Radamec_SPI::_bufcount
protected

Definition at line 28 of file vrpn_Analog_Radamec_SPI.h.

Referenced by get_report().

◆ _buffer

unsigned char vrpn_Radamec_SPI::_buffer[512]
protected

Definition at line 27 of file vrpn_Analog_Radamec_SPI.h.

Referenced by get_report().

◆ _camera_id

int vrpn_Radamec_SPI::_camera_id
protected

Definition at line 23 of file vrpn_Analog_Radamec_SPI.h.

Referenced by get_report(), and reset().

◆ _expected_chars

unsigned vrpn_Radamec_SPI::_expected_chars
protected

Definition at line 26 of file vrpn_Analog_Radamec_SPI.h.

Referenced by get_report().

◆ _numchannels

int vrpn_Radamec_SPI::_numchannels
protected

Definition at line 24 of file vrpn_Analog_Radamec_SPI.h.

Referenced by clear_values(), get_report(), and vrpn_Radamec_SPI().

◆ _status

int vrpn_Radamec_SPI::_status
protected

Definition at line 22 of file vrpn_Analog_Radamec_SPI.h.

Referenced by vrpn_Radamec_SPI().

◆ timestamp

struct timeval vrpn_Radamec_SPI::timestamp
protected

Definition at line 30 of file vrpn_Analog_Radamec_SPI.h.

Referenced by get_report(), mainloop(), report(), report_changes(), and reset().


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