SimulatedController.h
Go to the documentation of this file.
00001 /*
00002  * SimulatedController.h
00003  *
00004  *  Created on: Oct 10, 2012
00005  *      Author: coky
00006  */
00007 
00008 /*
00009  * Software License Agreement (BSD License)
00010  *
00011  * Copyright (c) 2011, Southwest Research Institute
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  *       * Redistributions of source code must retain the above copyright
00018  *       notice, this list of conditions and the following disclaimer.
00019  *       * Redistributions in binary form must reproduce the above copyright
00020  *       notice, this list of conditions and the following disclaimer in the
00021  *       documentation and/or other materials provided with the distribution.
00022  *       * Neither the name of the Southwest Research Institute, nor the names
00023  *       of its contributors may be used to endorse or promote products derived
00024  *       from this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  */
00038 
00039 #ifndef SIMULATEDCONTROLLER_H_
00040 #define SIMULATEDCONTROLLER_H_
00041 
00042 #include <ros/ros.h>
00043 #include <actionlib/server/action_server.h>
00044 
00045 #include <trajectory_msgs/JointTrajectory.h>
00046 #include <pr2_controllers_msgs/JointTrajectoryAction.h>
00047 #include <pr2_controllers_msgs/JointTrajectoryControllerState.h>
00048 #include <sensor_msgs/JointState.h>
00049 #include <control_msgs/FollowJointTrajectoryFeedback.h>
00050 #include <boost/foreach.hpp>
00051 
00052 const std::string CONTROLLER_STATE_TOPIC_NAME = "state";
00053 const std::string CONTROLLER_FEEDBACK_TOPIC_NAME = "feedback_states";
00054 const std::string JOINT_TRAJECTORY_TOPIC_NAME = "command";
00055 const std::string JOINT_STATE_TOPIC_NAME = "joint_states";
00056 const std::string JOINT_NAMES_PARAM_NAME = "/joint_trajectory_action/joints";
00057 
00058 class SimulatedController
00059 {
00060 public:
00061         SimulatedController();
00062 
00063         ~SimulatedController();
00064 
00065         void init();
00066 
00067         void broadcastState(const ros::TimerEvent &evnt);
00068 
00069         void callbackJointTrajectory(const trajectory_msgs::JointTrajectory::ConstPtr &msg);
00070 
00071 protected:
00072 
00073         void updateLastStateFeedbackMessages(const sensor_msgs::JointState &st);
00074 
00075         // ros comm
00076         ros::Subscriber _JointTrajSubscriber;
00077         ros::Publisher _ControllerStatePublisher;
00078         ros::Publisher _JointStatePublisher;
00079         ros::Publisher _ControllerFeedbackPublisher;
00080         ros::Timer _StatusUpdateTimer;
00081 
00082         // topic names
00083         std::string _CntrlStatePubTopic;
00084         std::string _ControlFeedbackPubTopic;
00085         std::string _JointStatePubTopic;
00086         std::string _JointTrajSubsTopic;
00087 
00088         // ros parameters
00089         std::vector<std::string> _JointNames;
00090 
00091         // last states
00092         sensor_msgs::JointState _LastJointState;
00093         control_msgs::FollowJointTrajectoryFeedback _LastControllerTrajState;
00094         pr2_controllers_msgs::JointTrajectoryControllerState _LastControllerJointState;
00095 
00096         // others
00097         bool _ProcessingRequest;
00098 };
00099 
00100 #endif /* SIMULATEDCONTROLLER_H_ */


object_manipulation_tools
Author(s): Jnicho
autogenerated on Mon Oct 6 2014 00:56:17