35 katana_(katana), action_server_(
ros::NodeHandle(),
"katana_arm_controller/joint_movement_action",
52 for (
size_t i = 0; i < jointGoalNames.size(); i++)
56 for (
size_t j = 0; j <
joints_.size(); j++)
58 if (jointGoalNames[i] ==
joints_[j])
69 ROS_ERROR(
"joint name %s is not one of our controlled joints", jointGoalNames[i].c_str());
78 const sensor_msgs::JointState &jointGoal)
80 sensor_msgs::JointState adjustedJointGoal;
82 adjustedJointGoal.name = jointGoal.name;
83 adjustedJointGoal.position = jointGoal.position;
85 for (
size_t i = 0; i < jointGoal.name.size(); i++)
87 ROS_DEBUG(
"%s - min: %f - max: %f - curr: % f - req: %f", jointGoal.name[i].c_str(),
katana_->getMotorLimitMin(jointGoal.name[i]),
katana_->getMotorLimitMax(jointGoal.name[i]),
katana_->getMotorAngles()[
katana_->getJointIndex(jointGoal.name[i])], jointGoal.position[i]);
90 for (
size_t i = 0; i < jointGoal.name.size(); i++)
93 if (jointGoal.position[i] <
katana_->getMotorLimitMin(jointGoal.name[i]))
95 adjustedJointGoal.position[i] =
katana_->getMotorLimitMin(jointGoal.name[i]);
97 ROS_INFO(
"%s - requested JointGoalPosition: %f exceeded MotorLimit: %f - adjusted JointGoalPosition to MotorLimit", jointGoal.name[i].c_str(), jointGoal.position[i],
katana_->getMotorLimitMin(jointGoal.name[i]));
100 if (jointGoal.position[i] >
katana_->getMotorLimitMax(jointGoal.name[i]))
102 adjustedJointGoal.position[i] =
katana_->getMotorLimitMax(jointGoal.name[i]);
103 ROS_INFO(
"%s - requested JointGoalPosition: %f exceeded MotorLimit: %f - adjusted JointGoalPosition to MotorLimit", jointGoal.name[i].c_str(), jointGoal.position[i],
katana_->getMotorLimitMax(jointGoal.name[i]));
107 return adjustedJointGoal;
118 ROS_ERROR(
"Joints on incoming goal don't match our joints/gripper_joints");
120 for (
size_t i = 0; i < goal->jointGoal.name.size(); i++)
122 ROS_INFO(
" incoming joint %d: %s", (
int)i, goal->jointGoal.name[i].c_str());
125 for (
size_t i = 0; i <
joints_.size(); i++)
140 ROS_WARN(
"New action goal already seems to have been cancelled!");
148 ROS_INFO(
"Sending movement to Katana arm...");
150 for (
size_t i = 0; i < adjustedJointGoal.name.size(); i++)
152 if (!
katana_->moveJoint(
katana_->getJointIndex(adjustedJointGoal.name[i]), adjustedJointGoal.position[i]))
154 ROS_ERROR(
"Problem while transferring movement to Katana arm. Aborting...");
167 if (
katana_->someMotorCrashed())
169 ROS_ERROR(
"Some motor has crashed! Aborting...");
176 ROS_INFO(
"...movement successfully executed.");
183 ROS_WARN(
"Goal canceled by client while waiting for movement to finish, aborting!");
sensor_msgs::JointState adjustJointGoalPositionsToMotorLimits(const sensor_msgs::JointState &jointGoal)
boost::shared_ptr< AbstractKatana > katana_
virtual ~JointMovementActionController()
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
bool suitableJointGoal(const std::vector< std::string > &jointGoalNames)
std::vector< std::string > gripper_joints_
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
bool isPreemptRequested()
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
JointMovementActionController(boost::shared_ptr< AbstractKatana > katana)
void executeCB(const JMAS::GoalConstPtr &goal)
std::vector< std::string > joints_