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, float &pan_offset, float &tilt_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 get_pantilt (float &pan, float &tilt, fawkes::Time &time)
 Get pan/tilt value with time.
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.
void wait_for_fresh_data ()
 Wait for fresh data to be received.
virtual void loop ()
 Code to execute in the thread.

Protected Member Functions

virtual void run ()
 Stub to see name in backtrace for easier debugging.

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,
float &  pan_offset,
float &  tilt_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_maxmaximum pan in rad
tilt_minminimum tilt in rad
tilt_maxmaximum tilt in rad
pan_offsetpan offset from zero in servo ticks
tilt_offsettilt offset from zero in servo ticks

Definition at line 420 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 464 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 646 of file rx28_thread.cpp.

References RobotisRX28::CENTER_POSITION.

Referenced by PanTiltRX28Thread::update_sensor_values().

void PanTiltRX28Thread::WorkerThread::get_pantilt ( float &  pan,
float &  tilt,
fawkes::Time time 
)

Get pan/tilt value with time.

Parameters:
panupon return contains the current pan value
tiltupon return contains the current tilt value
timeupon return contains the time the pan and tilt values were read

Definition at line 664 of file rx28_thread.cpp.

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 618 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 524 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
time_sectime when to reach the desired pan/tilt values

Definition at line 540 of file rx28_thread.cpp.

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

Referenced by PanTiltRX28Thread::prepare_finalize_user(), and 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 716 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 704 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 676 of file rx28_thread.cpp.

Referenced by PanTiltRX28Thread::prepare_finalize_user(), 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 727 of file rx28_thread.cpp.

References fawkes::Thread::wakeup().

virtual void PanTiltRX28Thread::WorkerThread::run ( ) [inline, protected, virtual]

Stub to see name in backtrace for easier debugging.

See also:
Thread::run()

Reimplemented from fawkes::Thread.

Definition at line 145 of file rx28_thread.h.

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

Enable or disable servo.

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

Definition at line 477 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 495 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_marginpan margin
tilt_margintilt margin

Definition at line 633 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 586 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 511 of file rx28_thread.cpp.

void PanTiltRX28Thread::WorkerThread::wait_for_fresh_data ( )

Wait for fresh data to be received.

Blocks the calling thread.

Definition at line 860 of file rx28_thread.cpp.

Referenced by PanTiltRX28Thread::prepare_finalize_user().


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