00001 /* 00002 * Copyright (c) 2016, 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_RONEX_CONTROLLERS_DC_MOTOR_SMALL_PASSTHROUGH_CONTROLLER_H 00025 #define SR_RONEX_CONTROLLERS_DC_MOTOR_SMALL_PASSTHROUGH_CONTROLLER_H 00026 00027 #include <ros/node_handle.h> 00028 00029 #include <controller_interface/controller.h> 00030 #include <ros_ethercat_model/robot_state_interface.hpp> 00031 #include <sr_ronex_hardware_interface/DC_motor_small_hardware_interface.hpp> 00032 #include <realtime_tools/realtime_publisher.h> 00033 #include <sr_ronex_utilities/sr_ronex_utilities.hpp> 00034 00035 #include <std_msgs/Bool.h> 00036 #include "sr_ronex_msgs/MotorPacketStatus.h" 00037 #include "sr_ronex_msgs/MotorPacketCommand.h" 00038 #include <vector> 00039 00040 namespace ronex 00041 { 00042 class DCMotorSmallPassthroughController 00043 : public controller_interface::Controller<ros_ethercat_model::RobotStateInterface> 00044 { 00045 public: 00046 DCMotorSmallPassthroughController(); 00047 00048 virtual bool init(ros_ethercat_model::RobotStateInterface* robot, ros::NodeHandle &n); 00049 00053 virtual void update(const ros::Time&, const ros::Duration&) {} 00054 00055 virtual void stopping(const ros::Time& time); 00056 00057 void digital_commands_cb(const std_msgs::BoolConstPtr& msg, int index); 00058 00059 void motor_packet_cb(const sr_ronex_msgs::MotorPacketCommandConstPtr &msg, int index); 00060 00061 private: 00062 ros::NodeHandle node_; 00063 00064 int loop_count_; 00065 00066 ronex::DCMotor* dc_motor_small_; 00067 00069 std::vector<ros::Subscriber> digital_subscribers_; 00070 00072 std::vector<ros::Subscriber> motor_command_subscribers_; 00073 }; 00074 } // namespace ronex 00075 #endif // SR_RONEX_CONTROLLERS_DC_MOTOR_SMALL_PASSTHROUGH_CONTROLLER_H