netft_rdt_driver.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2008, Willow Garage, Inc.
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 the Willow Garage 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 
00035 #ifndef NETFT_RDT_DRIVER
00036 #define NETFT_RDT_DRIVER
00037 
00038 #include <boost/asio.hpp>
00039 #include <boost/thread/mutex.hpp>
00040 #include <boost/thread/thread.hpp>
00041 #include <boost/thread/condition.hpp>
00042 #include <string>
00043 
00044 #include "diagnostic_updater/DiagnosticStatusWrapper.h"
00045 #include "geometry_msgs/WrenchStamped.h"
00046 
00047 namespace netft_rdt_driver
00048 {
00049 
00050 class NetFTRDTDriver
00051 {
00052 public:
00053   // Start receiving data from NetFT device
00054   NetFTRDTDriver(const std::string &address);
00055 
00056   ~NetFTRDTDriver();
00057 
00059   void getData(geometry_msgs::WrenchStamped &data);
00060 
00062   void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d);
00063 
00065   // Returns true if new data has arrived, false it function times out
00066   bool waitForNewData(void);
00067 
00068 protected:
00069   void recvThreadFunc(void);
00070 
00072   void startStreaming(void);
00073 
00074   enum {RDT_PORT=49152};
00075   std::string address_;
00076 
00077   boost::asio::io_service io_service_;
00078   boost::asio::ip::udp::socket socket_;
00079   boost::mutex mutex_;
00080   boost::thread recv_thread_;
00081   boost::condition condition_;
00082   volatile bool stop_recv_thread_;
00084   bool recv_thread_running_;
00086   std::string recv_thread_error_msg_; 
00087 
00089   geometry_msgs::WrenchStamped new_data_;
00091   unsigned packet_count_;
00093   unsigned lost_packets_;
00095   unsigned out_of_order_count_;
00097   unsigned seq_counter_;
00098 
00100   double force_scale_;
00102   double torque_scale_;
00103 
00105   unsigned diag_packet_count_;
00107   ros::Time last_diag_pub_time_;
00108   
00110   uint32_t last_rdt_sequence_;
00112   uint32_t system_status_;
00113 };
00114 
00115 
00116 } // end namespace netft_rdt_driver
00117 
00118 
00119 #endif // NETFT_RDT_DRIVER


netft_rdt_driver
Author(s): Derek King
autogenerated on Tue Apr 22 2014 19:17:54