int main(int argc, char **argv) { ros::init(argc, argv, "test_pointer"); ros::NodeHandle n; ros::Subscriber thePoint = n.subscribe("/thePoint", 1, inPointCallback); //could separately subscribe to the normal topic, "/the_plane_normal" if (do_inits()!=0) return 1; //poor-man's constructor actionlib::SimpleActionClient<davinci_traj_streamer::trajAction> g_action_client("trajActionServer", true); // attempt to connect to the server: ROS_INFO("waiting for server: "); bool server_exists = false; int max_tries = 0; while (!server_exists) { server_exists = g_action_client.waitForServer(ros::Duration(5.0)); // wait for up to 5 seconds // something odd in above: does not seem to wait for 5 seconds, but returns rapidly if server not running ros::spinOnce(); ros::Duration(0.1).sleep(); ROS_INFO("retrying..."); max_tries++; if (max_tries > 100) break; } if (!server_exists) { ROS_WARN("could not connect to server; quitting"); return 1; // bail out; optionally, could print a warning message and retry } ROS_INFO("connected to action server"); // if here, then we connected to the server; while (ros::ok()) { ros::spinOnce(); if (g_got_new_pose) { ROS_INFO("sending new goal"); g_got_new_pose = false; // stuff a goal message: g_count++; g_goal.traj_id = g_count; // this merely sequentially numbers the goals sent ROS_INFO("sending traj_id %d", g_count); //g_action_client.sendGoal(g_goal, &doneCb); g_action_client.sendGoal(g_goal); bool finished_before_timeout = g_action_client.waitForResult(ros::Duration(5.0)); //bool finished_before_timeout = action_client.waitForResult(); // wait forever... if (!finished_before_timeout) { ROS_WARN("giving up waiting on result for goal number %d", g_count); return 0; } else { ROS_INFO("finished before timeout"); } ros::Duration(0.5).sleep(); } } return 0; // should never get here, unless roscore dies }
int main(int argc, char** argv) { ros::init(argc, argv, "demo_action_server_node"); // name this node ros::NodeHandle n; do_inits(n); ROS_INFO("instantiating the demo action server: "); ExampleActionServer as_object; // create an instance of the class "ExampleActionServer" ROS_INFO("going into spin"); // from here, all the work is done in the action server, with the interesting stuff done within "executeCB()" // you will see 5 new topics under example_action: cancel, feedback, goal, result, status //while (!g_count_failure) { // ros::spinOnce(); //normally, can simply do: ros::spin(); // for debug, induce a halt if we ever get our client/server communications out of sync //} ros::spin(); return 0; }
int main(int argc, char *argv[]) { int found = 0; FILE *fd; #ifdef WIN3264 int i; struct stat st; char icon[BUFSIZE]; char path[BUFSIZE]; char popup_path[BUFSIZE]; /* The nsis uninstaller calls us with a "-nsis" argument. */ if (argc == 2 && stricmp(argv[1], "-nsis") == 0) interactive = FALSE; else #endif interactive = TRUE; /* Initialize this program. */ do_inits(argv); printf("This program will remove the following items:\n"); #ifdef WIN3264 if (popup_gvim_path(popup_path)) { printf(" - the \"Edit with Vim\" entry in the popup menu\n"); printf(" which uses \"%s\"\n", popup_path); if (interactive) printf("\nRemove it (y/n)? "); if (!interactive || confirm()) { remove_popup(); /* Assume the "Open With" entry can be removed as well, don't * bother the user with asking him again. */ remove_openwith(); } } else if (openwith_gvim_path(popup_path)) { printf(" - the Vim \"Open With...\" entry in the popup menu\n"); printf(" which uses \"%s\"\n", popup_path); printf("\nRemove it (y/n)? "); if (confirm()) remove_openwith(); } if (get_shell_folder_path(path, "desktop")) { printf("\n"); for (i = 0; i < ICON_COUNT; ++i) { sprintf(icon, "%s\\%s", path, icon_link_names[i]); if (stat(icon, &st) == 0) { printf(" - the \"%s\" icon on the desktop\n", icon_names[i]); ++found; } } if (found > 0) { if (interactive) printf("\nRemove %s (y/n)? ", found > 1 ? "them" : "it"); if (!interactive || confirm()) remove_icons(); } } if (get_shell_folder_path(path, VIM_STARTMENU) && stat(path, &st) == 0) { printf("\n - the \"%s\" entry in the Start Menu\n", VIM_STARTMENU); if (interactive) printf("\nRemove it (y/n)? "); if (!interactive || confirm()) remove_start_menu(); } #endif printf("\n"); found = remove_batfiles(0); if (found > 0) { if (interactive) printf("\nRemove %s (y/n)? ", found > 1 ? "them" : "it"); if (!interactive || confirm()) remove_batfiles(1); } fd = fopen("gvim.exe", "r"); if (fd != NULL) { fclose(fd); printf("gvim.exe detected. Attempting to unregister gvim with OLE\n"); system("gvim.exe -silent -unregister"); } delete_uninstall_key(); if (interactive) { printf("\nYou may now want to delete the Vim executables and runtime files.\n"); printf("(They are still where you unpacked them.)\n"); } if (interactive) { rewind(stdin); printf("\nPress Enter to exit..."); (void)getchar(); } else sleep(3); return 0; }