ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This is a solution I implemented after reading several post online. It is working.
class ArmControl {
public:
ros::NodeHandle nh_;
string planning_group_name_;
double POS_TOLARENCE, ANG_TOLARENCE, PLANING_TIME;
// interface with MoveIt
boost::scoped_ptr<move_group_interface::MoveGroup> move_group_;
ArmControl::ArmControl() :
nh_("~"),
planning_group_name_("arm"),
POS_TOLARENCE(0.01),
ANG_TOLARENCE(0.1),
PLANING_TIME(20.0)
{
move_group_.reset(
new move_group_interface::MoveGroup(planning_group_name_));
move_group_->setPlanningTime(PLANING_TIME);
move_group_->setGoalOrientationTolerance(ANG_TOLARENCE);
move_group_->setGoalPositionTolerance(POS_TOLARENCE);
sleep(5);
}
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "arm_action_server");
ros::NodeHandle nh;
ros::AsyncSpinner spinner(0);
spinner.start();
ArmControl controller;
controller.moveToInitialPos();
ros::ServiceServer findCB_service = nh.advertiseService("find_chess_board",
&ArmControl::findCB, &controller);
ros::ServiceServer flippSW_service = nh.advertiseService("flipp_switch",
&ArmControl::flippSW, &controller);
ros::waitForShutdown();
}