7 #include <choreo_msgs/TaskSequenceProcessing.h> 8 #include <choreo_msgs/TaskSequencePlanning.h> 9 #include <choreo_msgs/ProcessPlanning.h> 10 #include <choreo_msgs/MoveToTargetPose.h> 11 #include <choreo_msgs/OutputProcessing.h> 14 #include <descartes_msgs/LadderGraphList.h> 96 ROS_WARN(
"Unable to load model input parameters.");
99 ROS_WARN(
"Unable to load path input parameters.");
102 ROS_WARN(
"Unable to load robot input parameters.");
105 ROS_WARN(
"Unable to load output path input parameters.");
161 loop_duration.
sleep();
170 bool success =
false;
194 ROS_WARN_STREAM(
"Unable to save model input parameters to: " << filename);
217 ROS_WARN_STREAM(
"Unable to save path input parameters to: " << filename);
240 ROS_WARN_STREAM(
"Unable to save robot input parameters to: " << filename);
263 ROS_WARN_STREAM(
"Unable to save output path input parameters to: " << filename);
269 descartes_msgs::LadderGraphList graph_list_msg;
274 return graph_list_msg.graph_list.size();
284 choreo_msgs::ChoreoParameters::Request& req,
285 choreo_msgs::ChoreoParameters::Response& res)
289 case choreo_msgs::ChoreoParameters::Request::GET_CURRENT_PARAMETERS:
296 case choreo_msgs::ChoreoParameters::Request::GET_DEFAULT_PARAMETERS:
304 case choreo_msgs::ChoreoParameters::Request::SET_PARAMETERS:
305 case choreo_msgs::ChoreoParameters::Request::SAVE_PARAMETERS:
311 if (req.action == choreo_msgs::ChoreoParameters::Request::SAVE_PARAMETERS)
322 res.succeeded =
true;
327 choreo_msgs::ElementNumberRequest::Request& req,
328 choreo_msgs::ElementNumberRequest::Response& res)
332 case choreo_msgs::ElementNumberRequest::Request::REQUEST_ELEMENT_NUMBER:
340 res.grasp_nums.clear();
341 for(
const auto& se :
as_pnp_.sequenced_elements)
343 assert(se.grasps.size() > 0);
344 res.grasp_nums.push_back(se.grasps.size());
349 case choreo_msgs::ElementNumberRequest::Request::REQUEST_SELECTED_TASK_NUMBER:
354 res.grasp_nums.clear();
355 for(
const auto& se :
as_pnp_.sequenced_elements)
357 assert(se.grasps.size() > 0);
358 res.grasp_nums.push_back(se.grasps.size());
365 res.element_number = 0;
375 choreo_msgs::VisualizeSelectedPath::Request& req,
376 choreo_msgs::VisualizeSelectedPath::Response& res)
378 if(req.index != req.CLEAN_UP)
380 if(req.PICKNPLACE == req.assembly_type)
387 if(req.SPATIAL_EXTRUSION == req.assembly_type)
394 res.succeeded =
true;
399 res.succeeded =
true;
404 choreo_msgs::GetAvailableProcessPlans::Request&,
405 choreo_msgs::GetAvailableProcessPlans::Response& res)
407 typedef choreo_core_service::TrajectoryLibrary::TrajectoryMap::const_iterator MapIter;
410 res.names.push_back(it->first);
416 choreo_msgs::OutputProcessPlans::Request& req,
417 choreo_msgs::OutputProcessPlans::Response& res)
420 choreo_msgs::OutputProcessing srv;
426 for(
auto id : req.names)
441 ROS_WARN_STREAM(
"[choreo_core_service] Unable to call output processing service");
451 choreo_msgs::QueryComputationRecord::Request &req,
452 choreo_msgs::QueryComputationRecord::Response &res)
456 ROS_INFO_STREAM(
"[CORE] saved graph query - file name: " << req.file_name);
458 res.record_found = bool(found_saved_graphs_size);
459 res.found_record_size = found_saved_graphs_size;
466 switch (goal_in->action)
469 case choreo_msgs::TaskSequenceProcessingGoal::FIND_AND_PROCESS:
475 choreo_msgs::TaskSequenceProcessing srv;
479 srv.request.action = srv.request.SPATIAL_EXTRUSION;
488 ROS_WARN_STREAM(
"[Core] Unable to call task sequence processing service or find saved task sequence.");
500 if(srv.request.PICKNPLACE == srv.request.action)
506 as_pnp_ = srv.response.assembly_sequence_pnp;
514 if(srv.request.SPATIAL_EXTRUSION == srv.request.action)
523 env_objs_ = srv.response.env_collision_objs;
540 ROS_ERROR_STREAM(
"Unknown action code '" << goal_in->action <<
"' request");
555 choreo_msgs::TaskSequencePlanning srv;
556 srv.request.action = srv.request.READ_WIREFRAME;
562 ROS_WARN_STREAM(
"[Core] task sequence planning service read wireframe failed.");
575 srv.request.action = srv.request.TASK_SEQUENCE_SEARCHING;
579 ROS_WARN_STREAM(
"[Core] task sequence planning service seq search failed.");
581 "[Core] task sequence planning service read seq search failed!\n";
600 switch (goal_in->action)
602 case choreo_msgs::ProcessPlanningGoal::GENERATE_MOTION_PLAN_AND_PREVIEW:
624 assert(
as_pnp_.sequenced_elements.size() > 0);
657 ROS_ERROR_STREAM(
"[Core] Unknown action code '" << goal_in->action <<
"' request");
714 switch (goal_in->action)
716 case choreo_msgs::SimulateMotionPlanGoal::RESET_TO_DEFAULT_POSE:
720 ROS_ERROR(
"[Core] Reset to init robot's pose planning & execution failed");
732 case choreo_msgs::SimulateMotionPlanGoal::SINGLE_PATH_RUN:
733 case choreo_msgs::SimulateMotionPlanGoal::ALL_PATHS_UNTIL_SELECTED_RUN:
735 std::string lib_sort_id = std::to_string(goal_in->index);
740 ROS_WARN_STREAM(
"[Core] Motion plan #" << lib_sort_id <<
" does not exist. Cannot execute.");
750 if (0 == goal_in->index)
755 ROS_ERROR(
"[Core] Reset to init robot's pose planning & execution failed");
762 choreo_msgs::ProcessExecutionGoal goal;
767 goal.joint_traj_array.push_back(sp.joint_array);
768 process_time += sp.joint_array.points.back().time_from_start;
771 goal.wait_for_execution = goal_in->wait_for_execution;
772 goal.simulate = goal_in->simulate;
809 ROS_ERROR_STREAM(
"[Core] Unknown action code for SimulateMotionPlan " << goal_in->action <<
"' request");
815 int main(
int argc,
char** argv)
817 ros::init(argc, argv,
"choreo_core_service");
824 ROS_INFO(
"[Core] choreo core service online.");
static const std::string TASK_SEQUENCE_PLANNING_ACTION_SERVER_NAME
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
ros::ServiceClient task_sequence_processing_srv_client_
choreo_msgs::TaskSequencePlanningFeedback task_sequence_planning_feedback_
static const std::string OUTPUT_SAVE_DIR_INPUT_PARAMS_FILE
bool moveToTargetJointPose(std::vector< double > joint_pose)
static const std::string ELEMENT_NUMBER_REQUEST_SERVICE
void publishFeedback(const FeedbackConstPtr &feedback)
int main(int argc, char **argv)
bool loadModelInputParameters(const std::string &filename)
static const std::string GET_AVAILABLE_PROCESS_PLANS_SERVICE
choreo_msgs::RobotInputParameters default_robot_input_params_
choreo_msgs::TaskSequenceInputParameters default_task_sequence_input_params_
choreo_msgs::OutputSaveDirInputParameters output_save_dir_input_params_
static const std::string TASK_SEQUENCE_PROCESSING_SERVICE
bool generateMotionLibrary(const int selected_path_index, choreo_core_service::TrajectoryLibrary &traj_lib)
static const std::string OUTPUT_PROCESS_PLANS_SERVICE
ros::ServiceClient move_to_pose_client_
static const std::string QUERY_COMPUTATION_RESULT
ros::ServiceServer choreo_parameters_server_
void saveRobotInputParameters(const std::string &filename)
bool loadBoolParam(ros::NodeHandle &nh, const std::string &name, uint8_t &value)
bool fromFile(const std::string &path, T &msg)
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
void simulateMotionPlansActionCallback(const choreo_msgs::SimulateMotionPlanGoalConstPtr &goal_in)
static const std::string PATH_VISUAL_TOPIC
bool loadParam(ros::NodeHandle &nh, const std::string &name, T &value)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
ros::ServiceClient process_planning_client_
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
std::vector< moveit_msgs::CollisionObject > env_objs_
static const std::string TASK_SEQUENCE_PLANNING_SERVICE
choreo_core_service::TrajectoryLibrary trajectory_library_
std::string assembly_type_
void taskSequencePlanningActionCallback(const choreo_msgs::TaskSequencePlanningGoalConstPtr &goal)
ros::ServiceClient output_processing_client_
choreo_msgs::TaskSequencePlanningResult task_sequence_planning_result_
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
choreo_msgs::TaskSequenceProcessingFeedback task_sequence_processing_feedback_
static const std::string MODEL_INPUT_PARAMS_FILE
choreo_msgs::OutputSaveDirInputParameters default_output_save_dir_input_params_
actionlib::SimpleActionServer< choreo_msgs::SimulateMotionPlanAction > simulate_motion_plan_server_
choreo_msgs::TaskSequenceProcessingResult task_sequence_processing_result_
static const std::string TASK_SEQUENCE_INPUT_PARAMS_FILE
bool toFile(const std::string &path, const T &msg)
ros::ServiceClient task_sequence_planning_srv_client_
bool visualizeSelectedPathServerCallback(choreo_msgs::VisualizeSelectedPath::Request &req, choreo_msgs::VisualizeSelectedPath::Response &res)
static const std::string ASSEMBLY_TYPE_PICKNPLACE
bool queryComputationResultCallback(choreo_msgs::QueryComputationRecord::Request &req, choreo_msgs::QueryComputationRecord::Response &res)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void saveOutputSaveDirInputParameters(const std::string &filename)
choreo_msgs::RobotInputParameters robot_input_params_
static const std::string MOVE_TO_TARGET_POSE_SERVICE
choreo_msgs::ModelInputParameters model_input_params_
choreo_visual_tools::ChoreoVisualTools visual_tools_
bool elementNumberRequestServerCallback(choreo_msgs::ElementNumberRequest::Request &req, choreo_msgs::ElementNumberRequest::Response &res)
void processPlanningActionCallback(const choreo_msgs::ProcessPlanningGoalConstPtr &goal)
static const std::string SAVE_DATA_BOOL_PARAM
void taskSequenceProcessingActionCallback(const choreo_msgs::TaskSequenceProcessingGoalConstPtr &goal)
choreo_msgs::TaskSequenceInputParameters task_sequence_input_params_
ros::ServiceServer element_number_sequest_server_
actionlib::SimpleActionClient< choreo_msgs::ProcessExecutionAction > choreo_exe_client_
bool choreoParametersServerCallback(choreo_msgs::ChoreoParameters::Request &req, choreo_msgs::ChoreoParameters::Response &res)
static const std::string VISUALIZE_SELECTED_PATH_SERVICE
#define ROS_WARN_STREAM(args)
static const std::string PROCESS_PLANNING_ACTION_SERVER_NAME
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
actionlib::SimpleActionServer< choreo_msgs::ProcessPlanningAction > process_planning_server_
ros::ServiceServer query_computation_result_server_
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
void saveModelInputParameters(const std::string &filename)
bool loadOutputSaveDirInputParameters(const std::string &filename)
#define ROS_INFO_STREAM(args)
bool outputProcessPlansCallback(choreo_msgs::OutputProcessPlans::Request &req, choreo_msgs::OutputProcessPlans::Response &res)
bool getAvailableProcessPlansCallback(choreo_msgs::GetAvailableProcessPlans::Request &req, choreo_msgs::GetAvailableProcessPlans::Response &res)
void saveTaskSequenceInputParameters(const std::string &filename)
static const std::string ROBOT_INPUT_PARAMS_FILE
choreo_msgs::ProcessPlanningFeedback process_planning_feedback_
actionlib::SimpleActionServer< choreo_msgs::TaskSequenceProcessingAction > task_sequence_processing_server_
static const std::string ASSEMBLY_TYPE_SPATIAL_EXTRUSION
actionlib::SimpleActionServer< choreo_msgs::TaskSequencePlanningAction > task_sequence_planning_server_
static const std::string FRAMEFAB_PARAMETERS_SERVICE
static const std::string SIMULATE_MOTION_PLAN_ACTION_SERVER_NAME
ros::ServiceServer get_available_process_plans_server_
static const std::string SAVE_LOCATION_PARAM
choreo_msgs::ModelInputParameters default_model_input_params_
static const std::string PICKNPLACE_PLANNING_SERVICE
static const std::string TASK_SEQUENCE_PROCESSING_ACTION_SERVER_NAME
#define ROS_ERROR_STREAM(args)
choreo_msgs::ProcessPlanningResult process_planning_result_
ros::ServiceServer output_process_plans_server_
choreo_msgs::SimulateMotionPlanResult simulate_motion_plan_result_
int checkSavedLadderGraphSize(const std::string &filename)
std::vector< choreo_msgs::ElementCandidatePoses > task_sequence_
static const std::string PROCESS_PLANNING_SERVICE
bool loadTaskSequenceInputParameters(const std::string &filename)
static const std::string FRAMEFAB_EXE_ACTION_SERVER_NAME
ros::ServiceServer visualize_selected_path_server_
bool loadRobotInputParameters(const std::string &filename)
static const int PROCESS_EXE_BUFFER
std::string param_cache_prefix_
ROSCPP_DECL void waitForShutdown()
static const std::string PRINT_BED_VISUAL_TOPIC
choreo_msgs::AssemblySequencePickNPlace as_pnp_
static const std::string OUTPUT_PROCESSING_SERVICE