ncd_parser.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011, Ivan Dryanovski, William Morris
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  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the CCNY Robotics Lab nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef NCD_PARSER_NCD_PARSER
00031 #define NCD_PARSER_NCD_PARSER
00032 
00033 #include <iostream>
00034 #include <fstream>
00035 
00036 #include <ros/ros.h>
00037 #include <tf/transform_broadcaster.h>
00038 #include <sensor_msgs/LaserScan.h>
00039 
00040 const double DEG_TO_RAD = 3.14159 / 180.0;
00041 
00042 const double RANGE_MIN = 0.20;
00043 const double RANGE_MAX = 50.0;
00044 
00045 const std::string worldFrame_      = "map";
00046 const std::string odomFrame_       = "odom";
00047 const std::string leftLaserFrame_  = "laser_left";
00048 const std::string rightLaserFrame_ = "laser_right";
00049 
00050 class NCDParser
00051 {
00052   private:
00053 
00054     char* filename_;
00055     double rate_;
00056     double start_, end_;
00057     double lastTime_;
00058 
00059     ros::Publisher  leftLaserPublisher_;
00060     ros::Publisher  rightLaserPublisher_;
00061 
00062     tf::TransformBroadcaster tfBroadcaster_;
00063 
00064     tf::Transform worldToOdom_;
00065     tf::Transform  odomToLeftLaser_;
00066     tf::Transform  odomToRightLaser_;
00067 
00068     void publishLaserMessage(const std::vector<std::string>& tokens,
00069                              const std::string& laserFrame,
00070                              const ros::Publisher& publisher);
00071 
00072     void publishTfMessages(const std::vector<std::string>& tokens);
00073 
00074     void tokenize (const std::string& str, 
00075                          std::vector <std::string> &tokens, 
00076                          std::string sentinel);
00077 
00078     std::vector<float> extractArray(std::string s, std::string pattern);
00079 
00080     double extractValue(std::string s, std::string pattern);
00081 
00082     void createOdomToLeftLaserTf();
00083     void createOdomToRightLaserTf();
00084   
00085   public:
00086 
00087     NCDParser(char* filename);
00088     virtual ~NCDParser();
00089 
00090     void launch();
00091 };
00092 
00093 #endif


ncd_parser
Author(s): Ivan Dryanovski
autogenerated on Thu Jun 6 2019 22:03:35