outside the if cycles everything works fine/* RECEIVE DATA FROM MASTER */
int recv_len = server->receive_data(buf,512);
if(recv_len == -2){
schunk->setJointsPositionAndWait(init_joint, 0.1);
server->returnToListen();
}else if(recv_len > 0){
msgpack::unpacked result;
msgpack:: unpack (&result, buf, recv_len);
msgpack::object deserialized = result.get();
msgpack::type::tuple<int> dst;
deserialized.convert(&dst);
input_mode = msgpack::type::get<0>(dst);
}
printf("MODALITY: %d\n", input_mode);
recv_len = server->receive_data(buf, 512);
printf("length: %d\n", recv_len);
if (recv_len == -2) {
schunk->setJointsPositionAndWait(init_joint, 0.1);
server->returnToListen();
continue;
}
msgpack::unpacked result;
msgpack::unpack (&result, buf, recv_len);
msgpack::object deserialized = result.get();
if(input_mode == 0){
msgpack::type::tuple<float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, int, int> dst1;
deserialized.convert(&dst1); <---------- here is the problem: always return me a bad cast
T(0,0) = (float)msgpack::type::get<0>(dst1);
T(0,1) = (float)msgpack::type::get<1>(dst1);
T(0,2) = (float)msgpack::type::get<2>(dst1);
T(0,3) = (float)msgpack::type::get<3>(dst1);
T(1,0) = (float)msgpack::type::get<4>(dst1);
T(1,1) = (float)msgpack::type::get<5>(dst1);
T(1,2) = (float)msgpack::type::get<6>(dst1);
T(1,3) = (float)msgpack::type::get<7>(dst1);
T(2,0) = (float)msgpack::type::get<8>(dst1);
T(2,1) = (float)msgpack::type::get<9>(dst1);
T(2,2) = (float)msgpack::type::get<10>(dst1);
T(2,3) = (float)msgpack::type::get<11>(dst1);
T(3,0) = (float)msgpack::type::get<12>(dst1);
T(3,1) = (float)msgpack::type::get<13>(dst1);
T(3,2) = (float)msgpack::type::get<14>(dst1);
T(3,3) = (float)msgpack::type::get<15>(dst1);
int gripper_state = (int)msgpack::type::get<16>(dst1);
int modality = (int)msgpack::type::get<17>(dst1);
T.print();
if(modality != 2 && modality != 3) {
//next_joint = schunk->Phantom_move(modality,T,gripper_state);
} else if(modality = 2) {
schunk->Screw();
} else if(modality = 3) {
schunk->unScrew();
}
printf("INPUT COMMAND: PHANTOM\n");
} else if(input_mode == 1){
//msgpack::unpacked result;
//msgpack::unpack (&result, buf, recv_len);
//msgpack::object deserialized = result.get();
msgpack::type::tuple<float,float,float,float,float,float> dst;
deserialized.convert(&dst); <---------- here is the problem: always return me a bad cast
joints(0,0) = msgpack::type::get<0>(dst);
joints(1,0) = msgpack::type::get<1>(dst);
joints(2,0) = msgpack::type::get<2>(dst);
joints(3,0) = msgpack::type::get<3>(dst);
joints(4,0) = msgpack::type::get<4>(dst);
joints(5,0) = msgpack::type::get<5>(dst);
joints.print();
//next_joint = schunk->JointByJoint();
printf("INPUT COMMAND: JOINT-BY-JOINT\n");
}