Fawkes API  Fawkes Development Version
PanTiltSonyEviD100PThread::WorkerThread Class Reference

Worker thread for the PanTiltSonyEviD100PThread. More...

#include "sony/evid100p_thread.h"

Inheritance diagram for PanTiltSonyEviD100PThread::WorkerThread:

List of all members.

Public Member Functions

 WorkerThread (std::string ptu_name, fawkes::Logger *logger, fawkes::RefPtr< SonyEviD100PVisca > cam, const float &pan_min, const float &pan_max, const float &tilt_min, const float &tilt_max)
 Constructor.
 ~WorkerThread ()
 Destructor.
void goto_pantilt (float pan, float tilt)
 Goto desired pan/tilt values.
void get_pantilt (float &pan, float &tilt)
 Get pan/tilt value.
void set_velocities (float pan_vel, float tilt_vel)
 Set desired velocities.
bool is_final ()
 Check if motion is final.
void stop_motion ()
 Stop currently running motion.
bool has_fresh_data ()
 Check is fresh sensor data is available.
virtual void once ()
 Execute an action exactly once.
virtual void loop ()
 Code to execute in the thread.

Detailed Description

Worker thread for the PanTiltSonyEviD100PThread.

This continuous thread issues commands to the camera. In each loop it will first execute pending operations, and then update the sensor data (lengthy operation). Sensor data will only be updated while either a servo in the chain is still moving or torque is disabled (so the motor can be move manually).

Author:
Tim Niemueller

Constructor & Destructor Documentation

PanTiltSonyEviD100PThread::WorkerThread::WorkerThread ( std::string  ptu_name,
fawkes::Logger logger,
fawkes::RefPtr< SonyEviD100PVisca cam,
const float &  pan_min,
const float &  pan_max,
const float &  tilt_min,
const float &  tilt_max 
)

Constructor.

Parameters:
ptu_namename of the pan/tilt unit
loggerlogger
camVisca controller object
pan_minminimum pan in rad
pan_minmaximum pan in rad
tilt_minminimum tilt in rad
tilt_maxmaximum tilt in rad

Definition at line 248 of file evid100p_thread.cpp.

References fawkes::Thread::set_name(), fawkes::Thread::set_coalesce_wakeups(), and fawkes::LoggingAspect::logger.

PanTiltSonyEviD100PThread::WorkerThread::~WorkerThread ( )

Destructor.

Definition at line 281 of file evid100p_thread.cpp.


Member Function Documentation

void PanTiltSonyEviD100PThread::WorkerThread::get_pantilt ( float &  pan,
float &  tilt 
)

Get pan/tilt value.

Parameters:
panupon return contains the current pan value
tiltupon return contains the current tilt value

Definition at line 317 of file evid100p_thread.cpp.

Referenced by PanTiltSonyEviD100PThread::update_sensor_values().

void PanTiltSonyEviD100PThread::WorkerThread::goto_pantilt ( float  pan,
float  tilt 
)

Goto desired pan/tilt values.

Parameters:
panpan in radians
tilttilt in radians

Definition at line 302 of file evid100p_thread.cpp.

References fawkes::Thread::wakeup().

Referenced by PanTiltSonyEviD100PThread::loop().

bool PanTiltSonyEviD100PThread::WorkerThread::has_fresh_data ( )

Check is fresh sensor data is available.

Note that this method will return true at once per sensor update cycle.

Returns:
true if fresh data is available, false otherwise

Definition at line 353 of file evid100p_thread.cpp.

Referenced by PanTiltSonyEviD100PThread::update_sensor_values().

bool PanTiltSonyEviD100PThread::WorkerThread::is_final ( )

Check if motion is final.

Returns:
true if motion is final, false otherwise

Definition at line 341 of file evid100p_thread.cpp.

References Visca::NONBLOCKING_PANTILT.

Referenced by PanTiltSonyEviD100PThread::update_sensor_values(), and PanTiltSonyEviD100PThread::loop().

void PanTiltSonyEviD100PThread::WorkerThread::loop ( ) [virtual]

Code to execute in the thread.

Implement this method to hold the code you want to be executed continously. If you do not implement this method, the default is that the thread will exit. This is useful if you choose to only implement once().

Reimplemented from fawkes::Thread.

Definition at line 375 of file evid100p_thread.cpp.

References fawkes::Thread::name(), and fawkes::Thread::wakeup().

void PanTiltSonyEviD100PThread::WorkerThread::once ( ) [virtual]

Execute an action exactly once.

This code is executed once and only once right after the thread is started before loop() is called. This is useful if you want to implement an one-shot background job. Just implement once() and leave once() untouched. Start the thread and detach it and it will just do its job and then die automatically. If you use set_delete_on_exit(true) even the Thread instance will be automatically deleted.

Reimplemented from fawkes::Thread.

Definition at line 362 of file evid100p_thread.cpp.

void PanTiltSonyEviD100PThread::WorkerThread::set_velocities ( float  pan_vel,
float  tilt_vel 
)

Set desired velocities.

Parameters:
pan_velpan velocity
tilt_veltilt velocity

Definition at line 329 of file evid100p_thread.cpp.

Referenced by PanTiltSonyEviD100PThread::init(), and PanTiltSonyEviD100PThread::loop().

void PanTiltSonyEviD100PThread::WorkerThread::stop_motion ( )

Stop currently running motion.

Definition at line 289 of file evid100p_thread.cpp.


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