laser_robot_calibration_node.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  * Copyright (c) 2014 Markus Bader <markus.bader@tuwien.ac.at>
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 1. Redistributions of source code must retain the above copyright
00008  *    notice, this list of conditions and the following disclaimer.
00009  * 2. Redistributions in binary form must reproduce the above copyright
00010  *    notice, this list of conditions and the following disclaimer in the
00011  *    documentation and/or other materials provided with the distribution.
00012  * 3. All advertising materials mentioning features or use of this software
00013  *    must display the following acknowledgement:
00014  *    This product includes software developed by the TU-Wien.
00015  * 4. Neither the name of the TU-Wien nor the
00016  *    names of its contributors may be used to endorse or promote products
00017  *    derived from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY Markus Bader ''AS IS'' AND ANY
00020  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL Markus Bader BE LIABLE FOR ANY
00023  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  ***************************************************************************/
00030 
00031 #include "ros/ros.h"
00032 #include <sensor_msgs/LaserScan.h>
00033 #include <geometry_msgs/Twist.h>
00034 #include <geometry_msgs/Pose2D.h>
00035 #include <geometry_msgs/PoseArray.h>
00036 #include <opencv2/opencv.hpp>
00037 
00038 #ifndef V4R_LASER_ROBOT_CALIBRATION_NODE
00039 #define V4R_LASER_ROBOT_CALIBRATION_NODE
00040 
00041 
00043 class LaserRobotCalibrationNode {
00044     cv::Matx<float, 3, 3 > Mr2v_;
00045     enum States{
00046       INIT,
00047       ROTATE_TO_MARKER,
00048       ROTATE_NORMAL_TO_MARKER,
00049     };
00050 public:
00051     LaserRobotCalibrationNode ( ros::NodeHandle &n );
00052     void callbackLaser (const sensor_msgs::LaserScan::ConstPtr& msg);
00053     void callbackMarker (const geometry_msgs::PoseArray::ConstPtr& msg);
00054     void stateMashine();
00055 private: // variables
00056     ros::NodeHandle n_;
00057     ros::NodeHandle n_param_;
00058     unsigned callbackCount;
00059     ros::Subscriber sub_laser_;
00060     ros::Subscriber sub_marker_;
00061     ros::Publisher pub_cmd_;
00062     cv::Mat debug_view_;
00063     sensor_msgs::LaserScan msg_scan_;
00064     geometry_msgs::PoseArray msg_marker_;
00065     void draw_debug_view();
00066     void rotateToMarkerNearPoint(cv::Point2f anchor);
00067     cv::Point2f anchor_;
00068     cv::Vec3f marker_;
00069     States state_;
00070 
00071     static void mouseCallBack ( int evt, int c, int r, int flags, void *param ) {
00072         if ( evt == CV_EVENT_LBUTTONDOWN ) {
00073             LaserRobotCalibrationNode *pLaserRobotCalibrationNode = (LaserRobotCalibrationNode *) param;
00074             cv::Matx<float, 3, 3 > M = pLaserRobotCalibrationNode->Mr2v_.inv();
00075             cv::Point2f p(c,r);
00076             cv::Point2f anchor(M(0,0)*p.x+M(0,1)*p.y+M(0,2), M(1,0)*p.x+M(1,1)*p.y+M(1,2));
00077             pLaserRobotCalibrationNode->rotateToMarkerNearPoint(anchor);
00078         }
00079         if ( evt == CV_EVENT_MBUTTONDOWN ) {
00080         }
00081     }
00082 };
00083 
00084 #endif //V4R_LASER_ROBOT_CALIBRATION_NODE
00085 


v4r_laser_robot_calibration
Author(s):
autogenerated on Wed Aug 26 2015 16:42:08