ptu_manager.cpp
Go to the documentation of this file.
00001 
00018 #include "CameraUtils/ptu_manager.h"
00019 
00020 #ifndef Q_MOC_RUN
00021 #include <sensor_msgs/JointState.h>
00022 #include <ros/init.h>
00023 #include <ptu_controller/PTUControllerClient.h>
00024 #endif
00025 
00026 
00027 PTU_Manager::PTU_Manager(double pan_min_angle, double pan_max_angle, double tilt_min_angle, double tilt_max_angle, int pan_step_count, int tilt_step_count)
00028 {  
00029     ros::NodeHandle n_ = ros::NodeHandle();
00030     controller = new asr_flir_ptu_controller::PTUController(n_, "ptu_controller");
00031     //PTUMovementEndedCallback test( boost::bind( &PTU_Manager::ptu_callback, this, _1, _2) );
00032     //callbackPtr = PTUMovementEndedCallbackPtr(boost::make_shared<PTUMovementEndedCallback>(test));
00033     pan_step = 0;
00034     tilt_step = 0;
00035     pan_step_add = 1;
00036     this->pan_min_angle = pan_min_angle;
00037     this->pan_max_angle = pan_max_angle;
00038     this-> tilt_min_angle = tilt_min_angle;
00039     this->tilt_max_angle = tilt_max_angle;
00040     this->pan_stepsize = (pan_max_angle - pan_min_angle) / (double)pan_step_count;
00041     this->tilt_stepsize = (tilt_max_angle - tilt_min_angle) / (double)tilt_step_count;
00042 }
00043 
00044 void PTU_Manager::ptu_callback(double pan, double tilt)
00045 {
00046     currentPan = pan;
00047     currentTilt = tilt;
00048     ptu_moved(pan, tilt);
00049 }
00050 
00051 bool PTU_Manager::setStartPose()
00052 {
00053     pan_step = 0;
00054     tilt_step = 0;
00055     sendJoint(pan_min_angle, tilt_min_angle, true);
00056     return true ;
00057 }
00058 
00059 bool PTU_Manager::setNeutralPose()
00060 {
00061     sendJoint(0,0,true);
00062     return true;
00063 }
00064 
00065 bool PTU_Manager::nextPose()
00066 {
00067     pan_step += pan_step_add;
00068     if (pan_step*pan_stepsize + pan_min_angle > pan_max_angle || pan_step < 0)
00069     {
00070         pan_step_add *= -1;
00071         pan_step += pan_step_add;
00072         tilt_step ++;
00073     }
00074     if (tilt_step*tilt_stepsize + tilt_min_angle <= tilt_max_angle)
00075     {
00076 
00077         sendJoint(pan_min_angle + pan_step*pan_stepsize, tilt_min_angle + tilt_step*tilt_stepsize, false);
00078         return true;
00079     }
00080     else
00081     {
00082         return false;
00083     }
00084 }
00085 
00086 void PTU_Manager::sendJoint(double pan, double tilt, bool wait)
00087 {
00088     ROS_DEBUG_STREAM("PTU: Sending joint to " << pan<< ", " << tilt);
00089     if (wait)
00090     {
00091         //controller->moveTo(pan, tilt);
00092     }
00093     else
00094     {
00095         //controller->asyncMoveTo(pan, tilt, callbackPtr);
00096     }
00097 }
00098 
00099 double PTU_Manager::getPan()
00100 {
00101     return currentPan;
00102 }
00103 
00104 double PTU_Manager::getTilt()
00105 {
00106    return currentTilt;
00107 }
00108 


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Thu Jun 6 2019 21:22:44