zpt::rest::client zpt::RESTClientPtr::launch(int argc, char* argv[]) { zpt::json _options = zpt::conf::init(argc, argv)->obj()->begin()->second; if (!_options["rest"]->ok() || !_options["zmq"]->ok()) { std::cout << "unable to start client: unsufficient configurations" << endl << flush; exit(-10); } zpt::conf::setup(_options); zpt::rest::client _client(_options); return _client; }
int main(int argc, char ** argv) { ros::init(argc, argv, "markerclient"); Client _client("marker", true); ROS_INFO("marker_client started - waiting for server to start."); _client.waitForServer(); ROS_INFO("markerserver started."); ip_msgs::markerGoal _goal; _goal.order = DETECT_MARKER; _client.sendGoal(_goal,&done_cb, &activeCb , &feedback_cb); bool _actionStatus = _client.waitForResult(ros::Duration(300.0)); if(_actionStatus == true) { actionlib::SimpleClientGoalState _state = _client.getState(); ROS_INFO("marker_client : Action finished: %s",_state.toString().c_str()); } else { ROS_INFO("marker_client : Action did not finish within specified time."); _client.cancelGoal(); } _goal.order = ALIGN_MARKER; _client.sendGoal(_goal); _actionStatus = _client.waitForResult(ros::Duration(300.0)); if(_actionStatus == true) { actionlib::SimpleClientGoalState _state = _client.getState(); ROS_INFO("marker_client : Action finished: %s",_state.toString().c_str()); } else { ROS_INFO("marker_client : Action did not finish within specified time."); _client.cancelGoal(); } return 0; }
int main(int argc, char ** argv) { ros::init(argc, argv, "markerclient"); Client _client("marker", true); ROS_INFO("The Client has started and waiting for server to start ...."); _client.waitForServer(); ROS_INFO("The server has started ..."); actionmsg::markerGoal _goal; _goal.order = ALLIGN_MARKER; _client.sendGoal(_goal); bool _actionStatus = _client.waitForResult(ros::Duration(15.0)); if(_actionStatus == true) { actionlib::SimpleClientGoalState _state = _client.getState(); ROS_INFO("Action finished: %s",_state.toString().c_str()); } else { ROS_INFO("The action did not finish within the specified time"); _client.cancelGoal(); } _goal.order = DETECT_MARKER; _client.sendGoal(_goal); _actionStatus = _client.waitForResult(ros::Duration(15.0)); if(_actionStatus == true) { actionlib::SimpleClientGoalState _state = _client.getState(); ROS_INFO("Action finished: %s",_state.toString().c_str()); } else { ROS_INFO("The action did not finish within the specified time"); _client.cancelGoal(); } return 0; }
int main(void) { close(STDOUT_FILENO); drizzle_st drizzle; drizzle_con_st listen_con; drizzle_con_st client; drizzle_con_st server; drizzle_return_t ret; bool server_accepted = false; server_state_st server_state; client_state_st client_state; drizzle_test("drizzle_create"); if (drizzle_create(&drizzle) == NULL) { drizzle_test_error("returned NULL"); } drizzle_test("drizzle_con_add_tcp_listen"); if (drizzle_con_add_tcp_listen(&drizzle, &listen_con, DRIZZLE_TEST_HOST, DRIZZLE_TEST_PORT, 1, DRIZZLE_CON_NONE) == NULL) { drizzle_test_error("returned NULL"); } drizzle_test("drizzle_con_listen"); ret= drizzle_con_listen(&listen_con); if (ret != DRIZZLE_RETURN_OK) { drizzle_test_error("returned %s (%d)", drizzle_error(&drizzle), ret); } drizzle_test("drizzle_con_add_tcp"); if (drizzle_con_add_tcp(&drizzle, &client, DRIZZLE_TEST_HOST, DRIZZLE_TEST_PORT, NULL, NULL, NULL, DRIZZLE_CON_NONE) == NULL) { drizzle_test_error("returned NULL"); } drizzle_test("drizzle_add_options"); drizzle_add_options(&drizzle, DRIZZLE_NON_BLOCKING); server_state.state= SERVER_STATE_START; client_state.state= CLIENT_STATE_START; while (true) { if (server_accepted == false) { drizzle_test("drizzle_con_accept"); (void)drizzle_con_accept(&drizzle, &server, &ret); if (ret == DRIZZLE_RETURN_OK) { server_accepted = true; } else if (ret == DRIZZLE_RETURN_COULD_NOT_CONNECT || ret == DRIZZLE_RETURN_NO_ACTIVE_CONNECTIONS) { break; } else if (ret != DRIZZLE_RETURN_IO_WAIT) { drizzle_test_error("returned %s (%s)", drizzle_error(&drizzle), drizzle_strerror(ret)); } } if (server_accepted) { _server(&server, &server_state); } _client(&client, &client_state); if (server_state.state == SERVER_STATE_DONE && client_state.state == CLIENT_STATE_DONE) { break; } drizzle_test("drizzle_con_wait"); ret= drizzle_con_wait(&drizzle); if (ret == DRIZZLE_RETURN_COULD_NOT_CONNECT || ret == DRIZZLE_RETURN_NO_ACTIVE_CONNECTIONS) { break; } else if (ret != DRIZZLE_RETURN_OK) { drizzle_test_error("returned %s (%d)", drizzle_error(&drizzle), ret); } } if (server_accepted) { drizzle_test("drizzle_con_free"); drizzle_con_free(&server); } drizzle_test("drizzle_con_free"); drizzle_con_free(&client); drizzle_test("drizzle_con_free"); drizzle_con_free(&listen_con); drizzle_test("drizzle_free"); drizzle_free(&drizzle); return 0; }