bool playRandomReactionService(nao_animation_srvs::AnimationRandomPlay::Request &req, nao_animation_srvs::AnimationRandomPlay::Response &res) { string body_status = req.animation_body_status; string type = req.animation_motion_type; string subtype = req.animation_motion_subtype; if(body_status.compare(motion_state::body_state::STAND) == 0) { if(type.compare(motion_state::motion_type::REACTION) == 0) { if(subtype.compare(reaction_names::reaction_subtype::TOUCH_HEAD) == 0) { last_touch_head_index = touch_head_index; touch_head_index = touch_head_random.uniformInteger(0, reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_TOUCH_HEAD -1); if(reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_TOUCH_HEAD > 1) { while(last_touch_head_index == touch_head_index) { touch_head_index = touch_head_random.uniformInteger(0, reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_TOUCH_HEAD -1); } } string motion = reaction_names::reaction_motion_names::reaction_motion_lists::stand_touch_head_list[touch_head_index]; motionProxy->angleInterpolationBezier(reactionMotions.getMotionNames(motion), reactionMotions.getMotionTimes(motion), reactionMotions.getMotionKeys(motion)); } else if(subtype.compare(reaction_names::reaction_subtype::BUMPER_LEFT) == 0) { last_bumper_left_index = bumper_left_index; bumper_left_index = bumper_left_random.uniformInteger(0, reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_BUMPER_LEFT -1); if(reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_BUMPER_LEFT > 1) { while(last_bumper_left_index == bumper_left_index) { bumper_left_index = bumper_left_random.uniformInteger(0, reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_BUMPER_LEFT -1); } } string motion = reaction_names::reaction_motion_names::reaction_motion_lists::stand_bumper_left_list[bumper_left_index]; motionProxy->angleInterpolationBezier(reactionMotions.getMotionNames(motion), reactionMotions.getMotionTimes(motion), reactionMotions.getMotionKeys(motion)); } else if(subtype.compare(reaction_names::reaction_subtype::BUMPER_RIGHT) == 0) { last_bumper_right_index = bumper_right_index; bumper_right_index = bumper_right_random.uniformInteger(0, reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_BUMPER_RIGHT -1); if(reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_BUMPER_RIGHT > 1) { while(last_bumper_right_index == bumper_right_index) { bumper_right_index = bumper_right_random.uniformInteger(0, reaction_names::reaction_motion_names::reaction_motion_lists::NUM_STAND_BUMPER_RIGHT -1); } } string motion = reaction_names::reaction_motion_names::reaction_motion_lists::stand_bumper_right_list[bumper_right_index]; motionProxy->angleInterpolationBezier(reactionMotions.getMotionNames(motion), reactionMotions.getMotionTimes(motion), reactionMotions.getMotionKeys(motion)); } } } return true; }