示例#1
0
    /// <summary>
    /// Add a new camera to the robot
    /// </summary>
    /// <param name="anchor"></param> The robot node to which the camera attaches
    /// <param name="positionOffset"></param>
    /// <param name="rotationOffset"></param>
    /// <returns></returns>
    public GameObject AddCamera(Robot robot, Transform anchor, Vector3 positionOffset, Vector3 rotationOffset)
    {
        GameObject newCamera = new GameObject("RobotCamera_" + robotCameraList.Count);

        newCamera.AddComponent <Camera>();

        newCamera.transform.parent        = anchor;
        newCamera.transform.localPosition = positionOffset;
        newCamera.transform.localRotation = Quaternion.Euler(rotationOffset);

        RobotCamera configuration = newCamera.AddComponent <RobotCamera>();

        configuration.UpdateConfiguration();
        configuration.SetParentRobot(robot);

        newCamera.SetActive(false);
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }

        robotCameraList.Add(newCamera);

        return(newCamera);
    }
示例#2
0
    /// <summary>
    /// Add a new camera to the robot using the default position and rotation
    /// </summary>
    /// <returns></returns>
    public GameObject AddCamera(Robot robot, Transform anchor)
    {
        GameObject newCamera = new GameObject("RobotCamera_" + robotCameraList.Count);

        newCamera.AddComponent <Camera>();

        newCamera.transform.parent        = anchor;
        newCamera.transform.localPosition = new Vector3(0f, 0.5f, 0f);
        newCamera.transform.localRotation = Quaternion.identity;

        RobotCamera configuration = newCamera.AddComponent <RobotCamera>();

        configuration.UpdateConfiguration();
        configuration.SetParentRobot(robot);

        newCamera.SetActive(false);
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }

        robotCameraList.Add(newCamera);
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }
        return(newCamera);
    }
示例#3
0
    /// <summary>
    /// Add a new camera to the robot using the default position (0, 0.5, 0) and rotation
    /// </summary>
    /// <returns></returns>
    public GameObject AddCamera(Robot robot, Transform anchor)
    {
        GameObject newCamera = new GameObject("RobotCamera_" + robotCameraList.Count);

        newCamera.AddComponent <Camera>();

        newCamera.transform.parent        = anchor;
        newCamera.transform.localPosition = new Vector3(0f, 0.5f, 0f);
        newCamera.transform.localRotation = Quaternion.identity;

        RobotCamera configuration = newCamera.AddComponent <RobotCamera>();

        configuration.UpdateConfiguration();
        //Set the camera parent robot, which is necessary when changing robot and restoring the configuration
        configuration.SetParentRobot(robot);

        newCamera.SetActive(false);
        //Make sure current camera is the first one on the list
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }

        robotCameraList.Add(newCamera);

        return(newCamera);
    }
示例#4
0
 public override void Init()
 {
     RobotIdSensor        = new RobotIdSensor(this);
     MapSensor            = new MapSensor(this);
     PositionSensor       = new LightHouseSensor(this);
     DestinationMapSensor = new DestinationMapSensor(this);
     RobotCamera          = new RobotCamera(this);
     GripSensor           = new GripSensor(this);
 }
示例#5
0
 public override void Init()
 {
     RobotIdSensor = new RobotIdSensor(this);
     MapSensor = new MapSensor(this);
     PositionSensor = new LightHouseSensor(this);
     DestinationMapSensor = new DestinationMapSensor(this);
     RobotCamera = new RobotCamera(this);
     GripSensor = new GripSensor(this);
 }
示例#6
0
 public override T GetSensorsData <T>()
 {
     return(new ImageSensorsData
     {
         RobotId = RobotIdSensor.Measure(),
         Position = PositionSensor.Measure(),
         Image = RobotCamera.Measure(),
         DetailsInfo = GripSensor.Measure()
     } as T);
 }
示例#7
0
    /// <summary>
    /// Initializes physical robot based off of robot directory.
    /// </summary>
    /// <param name="directory">folder directory of robot</param>
    /// <returns></returns>
    public bool InitializeRobot(string directory, MainState source)
    {
        //Deletes all nodes if any exist
        int childCount = transform.childCount;

        for (int i = 0; i < childCount; ++i)
        {
            Destroy(transform.GetChild(i).gameObject);
        }

        mainState          = source;
        transform.position = robotStartPosition;

        RigidNode_Base.NODE_FACTORY = delegate(Guid guid)
        {
            return(new RigidNode(guid));
        };

        List <RigidNode_Base> nodes = new List <RigidNode_Base>();

        //Read .robot instead. Maybe need a RobotSkeleton class
        rootNode = BXDJSkeleton.ReadSkeleton(directory + "\\skeleton.bxdj");
        rootNode.ListAllNodes(nodes);

        foreach (RigidNode_Base n in nodes)
        {
            RigidNode node = (RigidNode)n;
            node.CreateTransform(transform);

            if (!node.CreateMesh(directory + "\\" + node.ModelFileName))
            {
                Debug.Log("Robot not loaded!");
                return(false);
            }

            node.CreateJoint();

            node.MainObject.AddComponent <Tracker>().Trace = true;
        }

        RotateRobot(robotStartOrientation);

        RobotName = new DirectoryInfo(directory).Name;

        isInitialized = true;

        robotCamera = GameObject.Find("RobotCameraList").GetComponent <RobotCamera>();
        //Attached to the main frame and face the front
        robotCamera.AddCamera(transform.GetChild(0).transform);
        //Attached to the first node and face the front
        robotCamera.AddCamera(transform.GetChild(1).transform);
        ////Attached to main frame and face the back
        robotCamera.AddCamera(transform.GetChild(0).transform, new Vector3(0, 0, 0), new Vector3(0, 180, 0));
        return(true);
    }
示例#8
0
    /// <summary>
    /// Return a list of robot cameras attached to a given robot
    /// </summary>
    /// <param name="parent"></param> A robot on which cameras are attached to
    /// <returns></returns> A list of camera attach to that robot
    public List <GameObject> GetRobotCamerasFromRobot(Robot parent)
    {
        List <GameObject> camerasOnRobot = new List <GameObject>();

        foreach (GameObject camera in robotCameraList)
        {
            RobotCamera config = camera.GetComponent <RobotCamera>();
            if (config.robot.Equals(parent))
            {
                camerasOnRobot.Add(camera);
            }
        }
        return(camerasOnRobot);
    }
示例#9
0
    /// <summary>
    /// Find all robot camera related GUI elements in the canvas
    /// </summary>
    public void FindGUIElements()
    {
        canvas = GameObject.Find("Canvas");

        //For robot camera view window
        robotCameraView       = Resources.Load("Images/RobotCameraView") as RenderTexture;
        robotCameraViewWindow = AuxFunctions.FindObject(canvas, "RobotCameraPanel");
        robotCameraViewWindow = AuxFunctions.FindObject(canvas, "RobotCameraPanelBorder");

        //For camera indicator
        robotCameraListObject = GameObject.Find("RobotCameraList");
        robotCamera           = robotCameraListObject.GetComponent <RobotCamera>();

        if (CameraIndicator == null)
        {
            CameraIndicator = AuxFunctions.FindObject(robotCameraListObject, "CameraIndicator");
        }
        showCameraButton = AuxFunctions.FindObject(canvas, "ShowCameraButton");

        //For camera position and attachment configuration
        configureRobotCameraButton    = AuxFunctions.FindObject(canvas, "CameraConfigurationButton");
        changeCameraNodeButton        = AuxFunctions.FindObject(canvas, "ChangeNodeButton");
        configureCameraPanel          = AuxFunctions.FindObject(canvas, "CameraConfigurationPanel");
        cameraConfigurationModeButton = AuxFunctions.FindObject(canvas, "ConfigurationMode");
        cameraNodeText            = AuxFunctions.FindObject(canvas, "NodeText").GetComponent <Text>();
        cancelNodeSelectionButton = AuxFunctions.FindObject(canvas, "CancelNodeSelectionButton");

        //For camera angle configuration
        cameraAnglePanel = AuxFunctions.FindObject(canvas, "CameraAnglePanel");
        xAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "xAngleEntry");
        yAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "yAngleEntry");
        zAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "zAngleEntry");
        showAngleButton  = AuxFunctions.FindObject(configureCameraPanel, "ShowCameraAngleButton");
        editAngleButton  = AuxFunctions.FindObject(cameraAnglePanel, "EditButton");

        //For field of view configuration
        cameraFOVPanel = AuxFunctions.FindObject(canvas, "CameraFOVPanel");
        FOVEntry       = AuxFunctions.FindObject(cameraFOVPanel, "FOVEntry");
        showFOVButton  = AuxFunctions.FindObject(configureCameraPanel, "ShowCameraFOVButton");
        editFOVButton  = AuxFunctions.FindObject(cameraFOVPanel, "EditButton");

        lockPositionButton = AuxFunctions.FindObject(configureCameraPanel, "LockPositionButton");
        lockAngleButton    = AuxFunctions.FindObject(configureCameraPanel, "LockAngleButton");
        lockFOVButton      = AuxFunctions.FindObject(configureCameraPanel, "LockFOVButton");
    }