42 WristCalibrationController::WristCalibrationController()
43 : robot_(NULL), last_publish_time_(0)
49 for (
size_t i = 0; i <
fake_as.size(); ++i)
51 for (
size_t i = 0; i <
fake_js.size(); ++i)
64 std::string roll_joint_name;
72 ROS_ERROR(
"Could not find roll joint \"%s\" (namespace: %s)",
78 ROS_ERROR(
"Joint \"%s\" has no calibration reference position specified (namespace: %s)",
84 std::string flex_joint_name;
92 ROS_ERROR(
"Could not find flex joint \"%s\" (namespace: %s)",
98 ROS_ERROR(
"Joint \"%s\" has no calibration reference position specified (namespace: %s)",
113 ROS_ERROR(
"No rising or falling edge is specified for calibration of joint %s. Note that the reference_position is not used any more", roll_joint_name.c_str());
117 ROS_ERROR(
"Both rising and falling edge are specified for non-continuous joint %s. This is not supported.", roll_joint_name.c_str());
122 ROS_ERROR(
"Negative search velocity is not supported for joint %s. Making the search velocity positve.", roll_joint_name.c_str());
144 ROS_ERROR(
"No rising or falling edge is specified for calibration of joint %s. Note that the reference_position is not used any more", flex_joint_name.c_str());
148 ROS_ERROR(
"Both rising and falling edge are specified for non-continuous joint %s. This is not supported.", flex_joint_name.c_str());
153 ROS_ERROR(
"Negative search velocity is not supported for joint %s. Making the search velocity positve.", flex_joint_name.c_str());
168 std::string actuator_l_name;
176 ROS_ERROR(
"Could not find actuator \"%s\" (namespace: %s)",
181 std::string actuator_r_name;
189 ROS_ERROR(
"Could not find actuator \"%s\" (namespace: %s)",
194 bool force_calibration =
false;
201 if (force_calibration)
203 ROS_INFO(
"Joints %s and %s are already calibrated but will be recalibrated. " 204 "Actuator %s was zeroed at %f and %s was zeroed at %f.",
205 flex_joint_name.c_str(), roll_joint_name.c_str(),
212 ROS_INFO(
"Wrist joints %s and %s are already calibrated", flex_joint_name.c_str(), roll_joint_name.c_str());
219 ROS_INFO(
"Not both wrist joints %s and %s are are calibrated. Will re-calibrate both of them", flex_joint_name.c_str(), roll_joint_name.c_str());
225 std::string transmission_name;
233 ROS_ERROR(
"Could not find transmission \"%s\" (namespace: %s)",
244 roll_node.
setParam(
"type", std::string(
"JointVelocityController"));
245 roll_node.
setParam(
"joint", roll_joint_name);
249 flex_node.
setParam(
"type", std::string(
"JointVelocityController"));
250 flex_node.
setParam(
"joint", flex_joint_name);
289 pr2_controllers_msgs::QueryCalibrationState::Response& resp)
352 ROS_WARN(
"Left actuator (flex joint) didn't move even though the calibration flag tripped. " 353 "This may indicate an encoder problem. (namespace: %s",
357 else if ( !(0 <= k && k <= 1) )
360 ROS_ERROR(
"k = %.4lf is outside of [0,1]. This probably indicates a hardware failure " 361 "on the left actuator or the flex joint. dl = %.4lf, dr = %.4lf, prev = %.4lf. " 362 "Broke realtime to report (namespace: %s)",
400 ROS_WARN(
"Right actuator (roll joint) didn't move even though the calibration flag tripped. " 401 "This may indicate an encoder problem. (namespace: %s",
405 else if ( !(0 <= k && k <= 1) )
408 ROS_ERROR(
"k = %.4lf is outside of [0,1]. This probably indicates a hardware failure " 409 "on the right actuator or the roll joint. dl = %.4lf, dr = %.4lf, prev = %.4lf. " 410 "Broke realtime to report (namespace: %s)",
435 double flex_joint_switch =
fake_js[FLEX_JOINT]->position_;
441 double roll_joint_switch =
fake_js[ROLL_JOINT]->position_;
444 fake_js[FLEX_JOINT]->position_ = flex_joint_switch;
445 fake_js[ROLL_JOINT]->position_ = roll_joint_switch;
450 std::isnan(
fake_as[RIGHT_MOTOR]->state_.position_))
452 ROS_ERROR(
"Restarting calibration because a computed offset was NaN. If this happens " 453 "repeatedly it may indicate a hardware failure. (namespace: %s)",
PLUGINLIB_EXPORT_CLASS(my_controller_ns::MyControllerClass, pr2_controller_interface::Controller)
double last_calibration_rising_edge_
boost::shared_ptr< pr2_mechanism_model::Transmission > getTransmission(const std::string &name) const
std::vector< pr2_hardware_interface::Actuator * > fake_as
ros::Time last_publish_time_
controller::JointVelocityController vc_flex_
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
boost::shared_ptr< const urdf::Joint > joint_
pr2_mechanism_model::RobotState * robot_
pr2_mechanism_model::JointState * roll_joint_
pr2_hardware_interface::Actuator * actuator_r_
double flex_search_velocity_
~WristCalibrationController()
controller::JointVelocityController vc_roll_
ros::ServiceServer is_calibrated_srv_
void setCommand(double cmd)
virtual bool init(pr2_mechanism_model::RobotState *robot, ros::NodeHandle &n)
const std::string & getNamespace() const
std::vector< pr2_mechanism_model::JointState * > fake_js
bool isCalibrated(pr2_controllers_msgs::QueryCalibrationState::Request &req, pr2_controllers_msgs::QueryCalibrationState::Response &resp)
boost::scoped_ptr< realtime_tools::RealtimePublisher< std_msgs::Empty > > pub_calibrated_
JointState * getJointState(const std::string &name)
double prev_actuator_l_position_
boost::shared_ptr< pr2_mechanism_model::Transmission > transmission_
double last_calibration_falling_edge_
double reference_position_
double roll_search_velocity_
bool getParam(const std::string &key, std::string &s) const
pr2_hardware_interface::Actuator * getActuator(const std::string &name) const
double prev_actuator_r_position_
pr2_hardware_interface::Actuator * actuator_l_
pr2_mechanism_model::JointState * flex_joint_
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
bool calibration_reading_
bool init(pr2_mechanism_model::RobotState *robot, const std::string &joint_name, const control_toolbox::Pid &pid)