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, 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. |
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, | ||
int & | pan_zero_offset, | ||
int & | tilt_zero_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_min | maximum pan in rad |
tilt_min | minimum tilt in rad |
tilt_max | maximum tilt in rad |
pan_zero_offset | pan offset from zero in servo ticks |
tilt_zero_offset | tilt 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.
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 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.
pan_vel | upon return contains current pan velocity |
tilt_vel | upon 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.
pan | pan in radians |
tilt | tilt 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.
pan | pan in radians |
tilt | tilt 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.
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.
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.
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.
enabled | true 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.
enabled | true 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.
pan_vel | pan velocity |
tilt_vel | tilt 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.
pan_vel | pan velocity |
tilt_vel | tilt 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.