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 #include <string> 00041 00042 class SrBoardMk2GIO : public EthercatDevice 00043 { 00044 public: 00045 virtual void construct(EtherCAT_SlaveHandler *sh, int &start_address); 00046 virtual int initialize(hardware_interface::HardwareInterface *hw, bool allow_unprogrammed = true); 00047 00048 SrBoardMk2GIO(); 00049 virtual ~SrBoardMk2GIO(); 00050 00051 void dynamic_reconfigure_cb(sr_ronex_drivers::GeneralIOConfig &config, uint32_t level); 00052 00053 protected: 00055 static const std::string product_alias_; 00056 00058 std::string ronex_id_; 00059 00060 string reason_; 00061 int level_; 00062 00063 int command_base_; 00064 int status_base_; 00065 00066 ros::NodeHandle node_; 00067 00069 ronex::GeneralIO *general_io_; 00070 00075 int16_t cycle_count_; 00076 00078 int32u digital_commands_; 00079 00081 std::string device_name_; 00082 std::string serial_number_; 00083 00085 int device_offset_; 00086 00088 bool has_stacker_; 00089 00091 std::vector<bool> input_mode_; 00092 00093 void packCommand(unsigned char *buffer, bool halt, bool reset); 00094 bool unpackState(unsigned char *this_buffer, unsigned char *prev_buffer); 00095 00096 void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned char *buffer); 00097 00099 boost::scoped_ptr<realtime_tools::RealtimePublisher<sr_ronex_msgs::GeneralIOState> > state_publisher_; 00101 sr_ronex_msgs::GeneralIOState state_msg_; 00102 00104 boost::scoped_ptr<dynamic_reconfigure::Server<sr_ronex_drivers::GeneralIOConfig> > dynamic_reconfigure_server_; 00105 00106 dynamic_reconfigure::Server<sr_ronex_drivers::GeneralIOConfig>::CallbackType function_cb_; 00107 00109 void build_topics_(); 00110 00112 int parameter_id_; 00113 }; 00114 00115 /* For the emacs weenies in the crowd. 00116 Local Variables: 00117 c-basic-offset: 2 00118 End: 00119 */ 00120 00121 #endif /* _SR_BOARD_MK2_GIO_HPP_ */ 00122