// Loads the simulation scene asynchronously. public void loadSceneAsync(robotType robot) { try { simRobot = getRobot(robot); } catch (RobotNotFoundInListException e) { Debug.Log(e.Message); } Destroy(Player.instance.gameObject); SceneManager.LoadSceneAsync(1); }
private GameObject getRobot(robotType robot) { for (int i = 0; i < robots.Length; i++) { if (robots[i] != null) { if (robots[i].GetComponent <RobotInformation>().robotType == robot) { return(robots[i]); } } } throw new RobotNotFoundInListException("Robot could not be found in robot list"); }
// Modified. Incorrect representation. Maybe due to other way of improting urdf or different coordinates. Undo : newState = state. Remove type public void Write(float state, robotType type) { switch (type) { case robotType.drz_telemax: newState = -state; break; case robotType.asterix_ugv: newState = state; break; } isNewStateReceived = true; }
//Specified robot gets outlined. Outliner for the other robots in list gets deactivated. // If no robot is specified the outliner for all robots gets deactivated. private void OutlineRobot(robotType robotToOutline, GameObject[] robots) { foreach (GameObject robot in robots) { if (robotToOutline != robotType.noRobot) { if (robot.GetComponent <RobotInformation>().robotType == robotToOutline) { robot.GetComponent <Outline>().enabled = true; continue; } } robot.GetComponent <Outline>().enabled = false; } }
// Modified. Used for initializing lists. public void JointStateSubscriberInit() { var loader = GameObject.Find("ObjectLoader").GetComponent <Loader>(); this.Topic = loader.topic; JointNames = loader.jointNames; JointStateWriters = loader.jointStateWriters; if (!infoLoaded) { try { type = this.GetComponent <RobotInformation>().robotType; infoLoaded = true; } catch (NullReferenceException) { Debug.Log("Robot not loaded yet."); } } }
// Sets variables for positioning the player. Sets joints of a robot for the JointStateSubscriberMod. private void SetupSimulation(GameObject simRobot, robotType robot) { topic = ""; jointNames = new List <string>(); jointStateWriters = new List <JointStateWriterMod>(); switch (robot) { case robotType.drz_telemax: offsetFromRobot = -3f * simRobot.transform.forward; angle = simRobot.transform.rotation.eulerAngles.y - Player.instance.hmdTransform.rotation.eulerAngles.y; // Configure joints topic = "/telemax_control/joint_states"; try { jointNames.Add("arm_joint_0"); jointNames.Add("arm_joint_1"); jointNames.Add("arm_joint_2"); jointNames.Add("arm_joint_3"); jointNames.Add("arm_joint_4"); jointNames.Add("arm_joint_5"); jointNames.Add("flipper_back_left_joint"); jointNames.Add("flipper_back_right_joint"); jointNames.Add("flipper_front_left_joint"); jointNames.Add("flipper_front_right_joint"); jointNames.Add("gripper_joint"); List <JointStateWriterMod> temp = new List <JointStateWriterMod>(simRobot.GetComponentsInChildren <JointStateWriterMod>()); assignMatchingJoint(temp, jointStateWriters, "arm_link_0"); assignMatchingJoint(temp, jointStateWriters, "arm_link_1"); assignMatchingJoint(temp, jointStateWriters, "arm_link_2"); assignMatchingJoint(temp, jointStateWriters, "arm_link_3"); assignMatchingJoint(temp, jointStateWriters, "arm_link_4"); assignMatchingJoint(temp, jointStateWriters, "arm_link_5"); assignMatchingJoint(temp, jointStateWriters, "flipper_back_left_link"); assignMatchingJoint(temp, jointStateWriters, "flipper_back_right_link"); assignMatchingJoint(temp, jointStateWriters, "flipper_front_left_link"); assignMatchingJoint(temp, jointStateWriters, "flipper_front_right_link"); assignMatchingJoint(temp, jointStateWriters, "gripper_servo_link"); } catch (System.Exception e) { Debug.Log(e.Message); } break; // To make this work attach "hinge joints" and "JointSTateWriterMod" to arm links and flipper. // Position and angle of joints doesn't fit to the one of real robot yet. case robotType.asterix_ugv: offsetFromRobot = 2f * simRobot.transform.forward; angle = 180f + simRobot.transform.rotation.eulerAngles.y - Player.instance.hmdTransform.rotation.eulerAngles.y; //Configure joints /*topic = "/arm_manipulator_control/joint_states"; * * try * { * jointNames.Add("arm_link_0"); * jointNames.Add("arm_link_1"); * jointNames.Add("arm_link_2"); * jointNames.Add("arm_link_3"); * jointNames.Add("arm_link_4"); * jointNames.Add("arm_link_5"); * jointNames.Add("flipper_back_left_joint"); * jointNames.Add("flipper_back_right_joint"); * jointNames.Add("flipper_front_left_joint"); * jointNames.Add("flipper_front_right_joint"); * jointNames.Add("gripper_joint"); * * List<JointStateWriterMod> temp = new List<JointStateWriterMod>(simRobot.GetComponentsInChildren<JointStateWriterMod>()); * * assignMatchingJoint(temp, jointStateWriters, "arm_joint_0"); * assignMatchingJoint(temp, jointStateWriters, "arm_joint_1"); * assignMatchingJoint(temp, jointStateWriters, "arm_joint_3"); * assignMatchingJoint(temp, jointStateWriters, "arm_joint_3"); * assignMatchingJoint(temp, jointStateWriters, "arm_joint_4"); * assignMatchingJoint(temp, jointStateWriters, "arm_joint_5"); * assignMatchingJoint(temp, jointStateWriters, "flipper_back_left_link"); * assignMatchingJoint(temp, jointStateWriters, "flipper_back_right_link"); * assignMatchingJoint(temp, jointStateWriters, "flipper_front_left_link"); * assignMatchingJoint(temp, jointStateWriters, "flipper_front_right_link"); * assignMatchingJoint(temp, jointStateWriters, "gripper_servo_link"); * } * * catch (System.Exception e) * { * Debug.Log(e.Message); * }*/ break; } }