Fawkes API  Fawkes Development Version
PanTiltRX28Thread::WorkerThread Class Reference

Worker thread for the PanTiltRX28Thread. More...

#include "robotis/rx28_thread.h"

Inheritance diagram for PanTiltRX28Thread::WorkerThread:

List of all members.

Public Member Functions

 WorkerThread (std::string ptu_name, fawkes::Logger *logger, fawkes::RefPtr< RobotisRX28 > rx28, unsigned char pan_servo_id, unsigned char tilt_servo_id, float &pan_min, float &pan_max, float &tilt_min, float &tilt_max, int &pan_zero_offset, int &tilt_zero_offset)
 Constructor.
 ~WorkerThread ()
 Destructor.
void goto_pantilt (float pan, float tilt)
 Goto desired pan/tilt values.
void goto_pantilt_timed (float pan, float tilt, float time_sec)
 Goto desired pan/tilt values in a specified time.
void get_pantilt (float &pan, float &tilt)
 Get pan/tilt value.
void set_velocities (float pan_vel, float tilt_vel)
 Set desired velocities.
void get_velocities (float &pan_vel, float &tilt_vel)
 Get current velocities.
void set_margins (float pan_margin, float tilt_margin)
 Set desired velocities.
bool is_final ()
 Check if motion is final.
bool is_enabled ()
 Check if PTU is enabled.
void set_enabled (bool enabled)
 Enable or disable servo.
void set_led_enabled (bool enabled)
 Enable or disable LED.
void stop_motion ()
 Stop currently running motion.
bool has_fresh_data ()
 Check is fresh sensor data is available.
virtual void loop ()
 Code to execute in the thread.

Detailed Description

Worker thread for the PanTiltRX28Thread.

This continuous thread issues commands to the RX28 chain. 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

PanTiltRX28Thread::WorkerThread::WorkerThread ( std::string  ptu_name,
fawkes::Logger logger,
fawkes::RefPtr< RobotisRX28 rx28,
unsigned char  pan_servo_id,
unsigned char  tilt_servo_id,
float &  pan_min,
float &  pan_max,
float &  tilt_min,
float &  tilt_max,
int &  pan_zero_offset,
int &  tilt_zero_offset 
)

Constructor.

Parameters:
ptu_namename of the pan/tilt unit
loggerlogger
rx28RX28 chain
pan_servo_idservo ID of the pan servo
tilt_servo_idservo ID of the tilt servo
pan_minminimum pan in rad
pan_minmaximum pan in rad
tilt_minminimum tilt in rad
tilt_maxmaximum tilt in rad
pan_zero_offsetpan offset from zero in servo ticks
tilt_zero_offsettilt offset from zero in servo ticks

Definition at line 337 of file rx28_thread.cpp.

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

PanTiltRX28Thread::WorkerThread::~WorkerThread ( )

Destructor.

Definition at line 379 of file rx28_thread.cpp.


Member Function Documentation

void PanTiltRX28Thread::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 559 of file rx28_thread.cpp.

Referenced by PanTiltRX28Thread::update_sensor_values().

void PanTiltRX28Thread::WorkerThread::get_velocities ( float &  pan_vel,
float &  tilt_vel 
)

Get current velocities.

Parameters:
pan_velupon return contains current pan velocity
tilt_velupon return contains current tilt velocity

Definition at line 531 of file rx28_thread.cpp.

References RobotisRX28::MAX_SPEED.

Referenced by PanTiltRX28Thread::update_sensor_values().

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

Goto desired pan/tilt values.

Parameters:
panpan in radians
tilttilt in radians

Definition at line 436 of file rx28_thread.cpp.

References fawkes::Thread::wakeup().

Referenced by PanTiltRX28Thread::loop().

void PanTiltRX28Thread::WorkerThread::goto_pantilt_timed ( float  pan,
float  tilt,
float  time_sec 
)

Goto desired pan/tilt values in a specified time.

Parameters:
panpan in radians
tilttilt in radians

Definition at line 451 of file rx28_thread.cpp.

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

Referenced by PanTiltRX28Thread::loop().

bool PanTiltRX28Thread::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 604 of file rx28_thread.cpp.

Referenced by PanTiltRX28Thread::update_sensor_values().

bool PanTiltRX28Thread::WorkerThread::is_enabled ( )

Check if PTU is enabled.

Returns:
true if torque is enabled for both servos, false otherwise

Definition at line 591 of file rx28_thread.cpp.

Referenced by PanTiltRX28Thread::update_sensor_values().

bool PanTiltRX28Thread::WorkerThread::is_final ( )

Check if motion is final.

Returns:
true if motion is final, false otherwise

Definition at line 573 of file rx28_thread.cpp.

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

void PanTiltRX28Thread::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 613 of file rx28_thread.cpp.

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

void PanTiltRX28Thread::WorkerThread::set_enabled ( bool  enabled)

Enable or disable servo.

Parameters:
enabledtrue to enable servos, false to turn them off

Definition at line 389 of file rx28_thread.cpp.

References fawkes::Thread::wakeup().

Referenced by PanTiltRX28Thread::loop().

void PanTiltRX28Thread::WorkerThread::set_led_enabled ( bool  enabled)

Enable or disable LED.

Parameters:
enabledtrue to enable LED, false to turn it off

Definition at line 407 of file rx28_thread.cpp.

References fawkes::Thread::wakeup().

Referenced by PanTiltRX28Thread::loop().

void PanTiltRX28Thread::WorkerThread::set_margins ( float  pan_margin,
float  tilt_margin 
)

Set desired velocities.

Parameters:
pan_velpan velocity
tilt_veltilt velocity

Definition at line 546 of file rx28_thread.cpp.

Referenced by PanTiltRX28Thread::loop().

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

Set desired velocities.

Parameters:
pan_velpan velocity
tilt_veltilt velocity

Definition at line 499 of file rx28_thread.cpp.

References RobotisRX28::MAX_SPEED, and fawkes::Thread::name().

Referenced by PanTiltRX28Thread::loop().

void PanTiltRX28Thread::WorkerThread::stop_motion ( )

Stop currently running motion.

Definition at line 423 of file rx28_thread.cpp.


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