fake_calibration_controller.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
36 #include "ros/time.h"
38 
39 using namespace std;
40 using namespace controller;
41 
43 
44 namespace controller
45 {
46 
47 FakeCalibrationController::FakeCalibrationController()
48  : last_publish_time_(0), joint_(NULL)
49 {
50 }
51 
53 {
54 }
55 
57  ros::NodeHandle &n)
58 {
59  assert(robot);
60  robot_ = robot;
61  node_ = n;
62 
63  std::string joint_name;
64  if (!node_.getParam("joint", joint_name))
65  {
66  ROS_ERROR("No joint given (namespace: %s)", node_.getNamespace().c_str());
67  return false;
68  }
69  if (!(joint_ = robot->getJointState(joint_name)))
70  {
71  ROS_ERROR("Could not find joint \"%s\" (namespace: %s)",
72  joint_name.c_str(), node_.getNamespace().c_str());
73  return false;
74  }
75 
76  // advertise service to check calibration
78 
79  // "Calibrated" topic
81 
82  return true;
83 }
84 
85 
87 {
88 }
89 
90 
91 bool FakeCalibrationController::isCalibrated(pr2_controllers_msgs::QueryCalibrationState::Request& req,
92  pr2_controllers_msgs::QueryCalibrationState::Response& resp)
93 {
94  resp.is_calibrated = joint_->calibrated_;
95  return true;
96 }
97 
98 
100 {
101  assert(joint_);
102  joint_->calibrated_ = true;
103 }
104 
105 }
PLUGINLIB_EXPORT_CLASS(my_controller_ns::MyControllerClass, pr2_controller_interface::Controller)
pr2_mechanism_model::RobotState * robot_
pr2_mechanism_model::JointState * joint_
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
const std::string & getNamespace() const
JointState * getJointState(const std::string &name)
boost::scoped_ptr< realtime_tools::RealtimePublisher< std_msgs::Empty > > pub_calibrated_
bool getParam(const std::string &key, std::string &s) const
virtual bool init(pr2_mechanism_model::RobotState *robot, ros::NodeHandle &n)
#define ROS_ERROR(...)
bool isCalibrated(pr2_controllers_msgs::QueryCalibrationState::Request &req, pr2_controllers_msgs::QueryCalibrationState::Response &resp)


pr2_calibration_controllers
Author(s): Stuart Glaser
autogenerated on Wed Jun 5 2019 19:34:11