Fawkes API
Fawkes Development Version
|
Worker thread for the PanTiltSonyEviD100PThread. More...
#include "sony/evid100p_thread.h"
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. |
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).
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.
ptu_name | name of the pan/tilt unit |
logger | logger |
cam | Visca controller object |
pan_min | minimum pan in rad |
pan_max | maximum pan in rad |
tilt_min | minimum tilt in rad |
tilt_max | maximum 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.
void PanTiltSonyEviD100PThread::WorkerThread::get_pantilt | ( | float & | pan, |
float & | tilt | ||
) |
Get pan/tilt value.
pan | upon return contains the current pan value |
tilt | upon 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.
pan | pan in radians |
tilt | tilt 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.
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.
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.
pan_vel | pan velocity |
tilt_vel | tilt 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.