sr_board_mk2_gio.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2013, Shadow Robot Company, All rights reserved.
00003  * 
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 3.0 of the License, or (at your option) any later version.
00008  * 
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012  * Lesser General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library.
00016  */
00017 
00024 #ifndef _SR_BOARD_MK2_GIO_HPP_
00025 #define _SR_BOARD_MK2_GIO_HPP_
00026 
00027 #include <ros_ethercat_hardware/ethercat_device.h>
00028 #include <realtime_tools/realtime_publisher.h>
00029 #include <sr_ronex_msgs/GeneralIOState.h>
00030 
00031 #include <sr_ronex_external_protocol/Ronex_Protocol_0x02000001_GIO_00.h>
00032 #include <sr_ronex_hardware_interface/mk2_gio_hardware_interface.hpp>
00033 
00034 #include <boost/ptr_container/ptr_vector.hpp>
00035 #include <boost/scoped_ptr.hpp>
00036 #include <vector>
00037 
00038 #include <dynamic_reconfigure/server.h>
00039 #include "sr_ronex_drivers/GeneralIOConfig.h"
00040 
00041 using namespace std;
00042 
00043 class SrBoardMk2GIO : public EthercatDevice
00044 {
00045 public:
00046   virtual void construct(EtherCAT_SlaveHandler *sh, int &start_address);
00047   virtual int initialize(hardware_interface::HardwareInterface *hw, bool allow_unprogrammed=true);
00048 
00049   SrBoardMk2GIO();
00050   virtual ~SrBoardMk2GIO();
00051 
00052   void dynamic_reconfigure_cb(sr_ronex_drivers::GeneralIOConfig &config, uint32_t level);
00053 
00054 protected:
00056   static const std::string product_alias_;
00057 
00059   std::string ronex_id_;
00060 
00061   string reason_;
00062   int level_;
00063 
00064   int command_base_;
00065   int status_base_;
00066 
00067   ros::NodeHandle node_;
00068 
00070   ronex::GeneralIO *general_io_;
00071 
00076   short cycle_count_;
00077 
00079   int32u digital_commands_;
00080 
00082   std::string device_name_;
00083   std::string serial_number_;
00084 
00086   int device_offset_;
00087 
00089   bool has_stacker_;
00090 
00092   std::vector<bool> input_mode_;
00093 
00094   void packCommand(unsigned char *buffer, bool halt, bool reset);
00095   bool unpackState(unsigned char *this_buffer, unsigned char *prev_buffer);
00096 
00097   void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned char *buffer);
00098 
00100   boost::scoped_ptr<realtime_tools::RealtimePublisher<sr_ronex_msgs::GeneralIOState> > state_publisher_;
00102   sr_ronex_msgs::GeneralIOState state_msg_;
00103 
00105   boost::scoped_ptr<dynamic_reconfigure::Server<sr_ronex_drivers::GeneralIOConfig> > dynamic_reconfigure_server_;
00106 
00107   dynamic_reconfigure::Server<sr_ronex_drivers::GeneralIOConfig>::CallbackType function_cb_;
00108 
00110   void build_topics_();
00111 
00113   int parameter_id_;
00114 };
00115 
00116 /* For the emacs weenies in the crowd.
00117    Local Variables:
00118    c-basic-offset: 2
00119    End:
00120 */
00121 
00122 #endif /* _SR_BOARD_MK2_GIO_HPP_ */
00123 


sr_ronex_drivers
Author(s): Ugo Cupcic, Toni Oliver, Mark Pitchless
autogenerated on Fri Aug 28 2015 13:12:23