00001 #include <ros/ros.h> 00002 #include <iri_checkpoint_nav/Checkpoint.h> 00003 #include <iri_checkpoint_nav/ActionCheckpointNav.h> 00004 00005 #include <vector> 00006 #include <iostream> 00007 00008 int main(int argc, char **argv) 00009 { 00010 ros::init(argc, argv, "checkpoint_marker_example"); 00011 ros::NodeHandle n; 00012 int count = 0; 00013 00014 iri_checkpoint_nav::ActionCheckpointNav reset_msg, start_msg; 00015 00016 reset_msg.request.action = iri_checkpoint_nav::ActionCheckpointNav::Request::RESET_CHECKPOINTS; 00017 start_msg.request.action = iri_checkpoint_nav::ActionCheckpointNav::Request::START_NAV; 00018 00019 ros::ServiceClient add_client = n.serviceClient<iri_checkpoint_nav::Checkpoint> 00020 ("add_nav_checkpoint"); 00021 00022 ros::ServiceClient action_client = n.serviceClient<iri_checkpoint_nav::ActionCheckpointNav> 00023 ("action_checkpoint_nav"); 00024 00025 action_client.call(reset_msg); 00026 00027 while (1) { 00028 iri_checkpoint_nav::Checkpoint checkpoint; 00029 char option; 00030 count++; 00031 00032 checkpoint.request.id = count; 00033 checkpoint.request.ref_frame = "/map"; 00034 00035 std::cout << "New navigation checkpoint" << std::endl << std::endl; 00036 std::cout << "Position X: "; 00037 std::cin >> checkpoint.request.position.x; 00038 std::cout << std::endl << "Position Y: "; 00039 std::cin >> checkpoint.request.position.y; 00040 std::cout << std::endl; 00041 00042 add_client.call(checkpoint); 00043 std::cout << "Another checkpoint (Y/n)? "; 00044 std::cin >> option; 00045 00046 if (option == 'n') 00047 break; 00048 } 00049 00050 std::cout << "Starting navigation:"; 00051 action_client.call(start_msg); 00052 00053 return 0; 00054 }