int main() { lcm_t * lcm = lcm_create(NULL); BotParam * param = bot_param_new_from_server(lcm, 1); if (param == NULL) { fprintf(stderr, "could not get params!\n"); exit(1); } bot_param_add_update_subscriber(param,param_update_handler,lcm); char * s; int ret = bot_param_write_to_string(param, &s); fprintf(stderr, "%s", s); free(s); // double foo = bot_param_get_double_or_fail(param, "foo"); // double bar = bot_param_get_double_or_fail(param, "bar"); // printf("foo=%f, bar = %f\n", foo, bar); bot_param_write(param, stderr); while (1) { lcm_handle(lcm); char * key = "coordinate_frames.body.history"; fprintf(stderr, "%s = %d\n", key, bot_param_get_int_or_fail(param, key)); } return 0; }
void ParamManager:: initialize() { BotParam* botParam = mBotWrapper->getBotParam(); if (botParam == NULL) return; bot_param_add_update_subscriber(mBotWrapper->getBotParam(), ::onParamChange, this); onParamChange(); }
void getParamFromServer() { if (mBotParam != NULL) return; mBotParam = bot_param_get_global(mLcm->getUnderlyingLCM(), 1); // mBotParam = bot_param_new_from_server(mLcm->getUnderlyingLCM(), 1); if (mBotParam == NULL) { mexPrintf("BotParam not received; is server running?\n"); return; } bot_param_add_update_subscriber(mBotParam, onParamUpdate, this); }