00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2011 LAR-DEM-University of Aveiro. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of LAR-DEM-University of Aveiro nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00041 #ifndef _LASER_ROTATE3D_CPP_ 00042 #define _LASER_ROTATE3D_CPP_ 00043 00044 //system includes 00045 00046 #include <termios.h> 00047 #include <stdio.h> 00048 #include <fcntl.h> 00049 #include <termio.h> 00050 #include <unistd.h> 00051 #include <stdlib.h> 00052 #include <sys/ioctl.h> 00053 #include <stdint.h> 00054 #include <stdlib.h> 00055 00056 #include <string.h> 00057 #include <errno.h> 00058 #include <math.h> 00059 #include <poll.h> 00060 #include <signal.h> 00061 #include <iostream> 00062 #include <fstream> 00063 00064 // ROS 00065 #include <ros/ros.h> 00066 #include <sensor_msgs/JointState.h> 00067 #include <std_msgs/String.h> 00068 #include <tf/transform_broadcaster.h> 00069 00070 //LAR3 includes 00071 #include <serialcom/SerialCom.h> 00072 00073 //Local includes 00074 #include "laser_rotate3D.h" 00075 00076 //using namespace std; 00077 00078 //void RotateLaser::RotateLaserCallback(std::string* readdata) 00079 // this function is called back once the readline thread is invoked 00080 //void RotateLaserCallback(std::string* readdata) 00081 //{ 00082 // int thesize; 00083 // thesize = readdata->size(); 00084 // // for now print on screen what has been read 00085 // printf("string size %s \n", readdata->c_str());//readdata->c_str); 00086 // 00087 // have to pass the information in order to safely allow publishing 00088 00089 //}; 00090 00091 int main(int argc, char ** argv) 00092 { 00093 00094 ros::init(argc,argv,"RotateLaser"); 00095 ros::Time::init(); // only to be used in testing and standalone. 00096 ros::Rate loop_rate(200); //it was 100 00097 00098 //int baudrate = 9600; 00099 00100 // instatiate the RotateLaser 00101 RotateLaser RotateTheLaser; 00102 00103 /* assign a callback for reading the serial port: use binding because we are 00104 invoking a member function and boost does not support that directly 00105 http://www.boost.org/doc/libs/1_48_0/doc/html/function/tutorial.html 00106 http://www.boost.org/doc/libs/1_48_0/libs/bind/bind.html#with_member_pointers */ 00107 RotateTheLaser.BoostRotateLaserCallback = std::bind1st(std::mem_fun(&RotateLaser::RotateLaserCallback), &RotateTheLaser); //&RotateLaserCallback; 00108 00109 // has to read from the PIC via serial port and publish 00110 // start a thread for reading the serial port 00111 RotateTheLaser.ReadLinesSerialPort(RotateTheLaser.BoostRotateLaserCallback); 00112 00113 00114 // while(ros::ok()) //this was uncomment 00115 // { //this was uncomment 00116 ros::spin(); 00117 // printf("this is %s \n", "test"); 00118 // RotateTheLaser.SendCommand(); 00119 // RotateTheLaser.Publish(); // this will publish the angle at the desired rate //this was uncomment 00120 // ros::spinOnce(); //this was uncomment 00121 // loop_rate.sleep(); //this was uncomment 00122 // }; 00123 00124 return 0; 00125 00126 } 00127 00128 #endif //EOF