Fawkes API
Fawkes Development Version
|
Worker thread for the PanTiltRX28Thread. More...
#include "robotis/rx28_thread.h"
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. |
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).
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.
ptu_name | name of the pan/tilt unit |
logger | logger |
rx28 | RX28 chain |
pan_servo_id | servo ID of the pan servo |
tilt_servo_id | servo ID of the tilt servo |
pan_min | minimum pan in rad |
pan_max | maximum pan in rad |
tilt_min | minimum tilt in rad |
tilt_max | maximum tilt in rad |
pan_offset | pan offset from zero in servo ticks |
tilt_offset | tilt 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.
void PanTiltRX28Thread::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 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.
pan | upon return contains the current pan value |
tilt | upon return contains the current tilt value |
time | upon 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.
pan_vel | upon return contains current pan velocity |
tilt_vel | upon 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.
pan | pan in radians |
tilt | tilt 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.
pan | pan in radians |
tilt | tilt in radians |
time_sec | time 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.
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.
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.
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.
Reimplemented from fawkes::Thread.
Definition at line 145 of file rx28_thread.h.
void PanTiltRX28Thread::WorkerThread::set_enabled | ( | bool | enabled | ) |
Enable or disable servo.
enabled | true 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.
enabled | true 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.
pan_margin | pan margin |
tilt_margin | tilt 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.
pan_vel | pan velocity |
tilt_vel | tilt 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().