int test_for_iros08_method2(void) { tl_message ("start"); JHMM *hmm1 = NULL, *hmm2 = NULL, *inter_hmm = NULL, *extra_hmm = NULL; Behavior *beh = NULL; hmm1 = new JHMM; hmm2 = new JHMM; inter_hmm = new JHMM; extra_hmm = new JHMM; hmm1->Load("./.tmp/squat/squat.hmm"); hmm2->Load("./.tmp/punch/punch.hmm"); hmm1->Show(); hmm2->Show(); tl_message ("Hellinger Distance between squat and punch = %g", hmm1->HellingerDistance(*hmm2)); tl_message ("Now generate a interpolation HMM"); inter_hmm->Interpolation (*hmm1, *hmm2, 0.5, 0.5); inter_hmm->Show(); beh = inter_hmm->GenerateBehavior(100, 30); beh->FileOut("interpolation_any2.beh"); tl_message ("Now generate a extrapolation HMM"); extra_hmm->Interpolation (*hmm1, *hmm2, -1.0, 2.0); extra_hmm->Show(); beh = extra_hmm->GenerateBehavior(100, 30); beh->FileOut("extrapolation_any2.beh"); delete beh; delete hmm1; delete hmm2; delete inter_hmm; delete extra_hmm; return TRUE; }
int test_extrapolation(void) { tl_message ("start"); JHMM *hmm1 = NULL, *hmm2 = NULL, *hmm3 = NULL, *extra_hmm = NULL; JHMM *hmm_vec[3]; double weight[3]; Behavior *beh = NULL; hmm1 = new JHMM; hmm2 = new JHMM; hmm3 = new JHMM; extra_hmm = new JHMM; hmm1->Load("./.tmp/squat/squat.hmm"); hmm2->Load("./.tmp/punch/punch.hmm"); hmm3->Load("./.tmp/kick/kick.hmm"); hmm1->Show(); hmm2->Show(); hmm3->Show(); hmm_vec[0] = hmm1; weight[0] = -1.0; hmm_vec[1] = hmm2; weight[1] = -13; hmm_vec[2] = hmm3; weight[2] = 1.3; tl_message ("Now generate a extrapolation HMM"); extra_hmm->InterpolationAny (hmm_vec, weight, 3); extra_hmm->Show(); beh = extra_hmm->GenerateBehavior(100, 30); beh->FileOut("interpolation_any.beh"); delete beh; delete hmm1; delete hmm2; delete hmm3; delete extra_hmm; return TRUE; }
int test_for_iros08(void) { tl_message ("start"); JHMM *hmm1 = NULL, *hmm2 = NULL, *inter_hmm = NULL, *extra_hmm = NULL; JHMM *hmm_vec[3]; double weight[3]; Behavior *beh = NULL; hmm1 = new JHMM; hmm2 = new JHMM; inter_hmm = new JHMM; extra_hmm = new JHMM; hmm1->Load("./.tmp/squat/squat.hmm"); hmm2->Load("./.tmp/punch/punch.hmm"); hmm1->Show(); hmm2->Show(); hmm_vec[0] = hmm1; weight[0] = 0.5; hmm_vec[1] = hmm2; weight[1] = 0.5; tl_message ("Now generate a interpolation HMM"); inter_hmm->InterpolationAny (hmm_vec, weight, 2); inter_hmm->Show(); beh = inter_hmm->GenerateBehavior(100, 30); beh->FileOut("interpolation_any.beh"); hmm_vec[0] = hmm1; weight[0] = -0.5; hmm_vec[1] = hmm2; weight[1] = 1.5; tl_message ("Now generate a extrapolation HMM"); extra_hmm->InterpolationAny (hmm_vec, weight, 2); extra_hmm->Show(); beh = extra_hmm->GenerateBehavior(100, 30); beh->FileOut("extrapolation_any.beh"); delete beh; delete hmm1; delete hmm2; delete inter_hmm; delete extra_hmm; return TRUE; }
// Created on 2006-09-07 // Trying to generate new proto-symbol by exterior division int generate_exterior_division(void) { Behavior *behavior = NULL; vector<double> tmp_dis, tmp_cord(3); vector<double> coord[NUM_MOTION], vec_sum(3); PsymbolSpace *pspace = NULL; int i, j; work = new WorkSpace(); //work->Load ("../../script/learning_scriptfile_3"); work->LoadMotionDB ("../../script/four_motions"); work->SetHTKUnitsFromMotionDB (); //work->SetLabelFromRecogUnit(); work->BeforeRecognize(); work->DistanceLoad ("../../script/symbol_data/tmp_distance_vector"); work->SpaceLoad ("../../script/symbol_data/tmp_dim.spc"); pspace = work->GetPsymbolSpace(); hmm[KICK] = new JHMM(); hmm[WALK] = new JHMM(); hmm[BANZAI] = new JHMM(); hmm[SQUAT] = new JHMM(); #if 0 hmm[THROW] = new JHMM(); hmm[DANCE] = new JHMM(); #endif hmm[KICK] ->Load ("./.tmp/kick/kick.hmm"); hmm[WALK] ->Load ("./.tmp/ashibum/ashibum.hmm"); hmm[SQUAT] ->Load ("./.tmp/squat/squat.hmm"); hmm[BANZAI]->Load ("./.tmp/banzai/banzai.hmm"); #if 0 hmm[THROW] ->Load ("./.tmp/squat/squat.hmm"); hmm[DANCE] ->Load ("./.tmp/banzai/banzai.hmm"); #endif vector<double> cops(3); // Center of Proto-symbols for (i=0; i<3; i++) { cops[i] = 0.0; vec_sum[i] = 0.0; } tl_message ("step 1"); for (i=0; i<NUM_MOTION; i++) { tl_message ("step 2-%d-1", i); coord[i].resize(3); tl_message ("step 2-%d-2", i); behavior = hmm[i]->GenerateBehavior(GEN_NUM, GEN_NUM_Q); tl_message ("step 2-%d-3", i); work->CalcDistanceOfInputBehavior(behavior, tmp_dis); tl_message ("step 2-%d-4", i); pspace->CoordinateFromDistanceData(tmp_dis, coord[i]); tl_message ("step 2-%d-5", i); for (j=0; j<3; j++) vec_sum[j] += coord[i][j]; } for (i=0; i<NUM_MOTION; i++) fprintf (stderr, "Pos of No.%d motion = (%g, %g, %g)\n", i, coord[i][0], coord[i][1], coord[i][2]); for (j=0; j<3; j++) cops[j] = vec_sum[j] / NUM_MOTION; fprintf (stderr, "Center of proto-symbol = (%g, %g, %g)\n", cops[0], cops[1], cops[2]); behavior = create_behavior_from_coord (cops); behavior->FileOut ("./center.beh"); hmm_center = new JHMM(); hmm_center->SetDefault(); hmm_center->Initialize(LEFT_TO_RIGHT); hmm_center->Verify(); // 重心から外側に向かって kick を2倍 for (j=0; j<3; j++) tmp_cord[j] = 2 * (coord[KICK][j] - cops[j]) + cops[j]; behavior = create_behavior_from_coord (tmp_cord); behavior->FileOut ("./output.beh"); return TRUE; }