//Line 135 //store the initial position of dynamixel cm730.ReadWord(JointData::ID_L_SHOULDER_PITCH, MX28::P_PRESENT_POSITION_L, &pitchpos, 0); cm730.ReadWord(JointData::ID_L_SHOULDER_ROLL, MX28::P_PRESENT_POSITION_L, &rollpos, 0); while (1) { //read TCP data from client and store it in disp[] array n = read(newsockfd,disp,sizeof(disp)); if (n < 0) error("ERROR reading from socket"); //new position for shoulder roll and pitch dynamixel is the sum of initial position and angle inputs from Wii remote r_pos = rollpos+11.378*disp[0]; p_pos = pitchpos+11.378*disp[1]; if (disp[7] ==1) { Action::GetInstance()->m_Joint.SetEnableBody(false, false); MotionManager::GetInstance()->SetEnable(false); //dynamixel limits if (rollpos>=2460 || rollpos<=1200) printf("Limit has been reached"); else cm730.WriteWord(JointData::ID_L_SHOULDER_ROLL, MX28::P_GOAL_POSITION_L, r_pos, 0); //move shoulder roll //dynamixel limits if (pitchpos<0 || pitchpos>3038) printf("Limit has been reached"); else cm730.WriteWord(JointData::ID_L_SHOULDER_PITCH, MX28::P_GOAL_POSITION_L, p_pos, 0); //move shoulder pitch } //disp[6] stores states of button A on Wii remote //integer stand and sit stores the state of DARwIn-OP if (disp[6] == 1) { if(stand == 0) { if(Action::GetInstance()->IsRunning() == 0) { Action::GetInstance()->m_Joint.SetEnableBody(true, true); MotionManager::GetInstance()->SetEnable(true); Action::GetInstance()->Start(9); stand = 1; sit = 0; } } } else if (disp[6] == -1) { if (sit == 0) { if(Action::GetInstance()->IsRunning() == 0) { Action::GetInstance()->m_Joint.SetEnableBody(true, true); MotionManager::GetInstance()->SetEnable(true); Action::GetInstance()->Start(15); sit = 1; stand = 0; } } } n = write(newsockfd,"0",1); if (n < 0) error("ERROR writing to socket"); }