示例#1
0
        /// <summary>
        /// Searches the network for a robot controller and establishes a connection with the specified one by position.
        /// Necessary for "online" modes.
        /// </summary>
        /// <returns></returns>
        public bool ConnectToDevice(int robotId)
        {
            if (connectionMode == ConnectionType.User)
            {
                logger.Error("Cannot search for robots automatically, please use ConnectToDevice(ip, port) instead");
                return(false);
            }

            // Sanity
            if (!_driver.ConnectToDevice(robotId))
            {
                logger.Error("Cannot connect to device");
                return(false);
            }
            else
            {
                //SetRunMode(runMode);

                //// If successful, initialize robot cursors to mirror the state of the device
                //Vector currPos = _comm.GetCurrentPosition();
                //Rotation currRot = _comm.GetCurrentOrientation();
                //Joints currJnts = _comm.GetCurrentJoints();
                //InitializeRobotCursors(currPos, currRot, currJnts);

                // If successful, initialize robot cursors to mirror the state of the device.
                // The function will initialize them based on the _comm object.
                InitializeRobotCursors();
            }

            logger.Info("Connected to " + parentRobot.Brand + " robot \"" + parentRobot.Name + "\" on " + _driver.IP + ":" + _driver.Port);

            return(true);
        }
示例#2
0
        /// <summary>
        /// Adds the defined Tool to this cursor's Tool dict, becoming avaliable for Attach/Detach Actions.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool ApplyAction(ActionDefineTool action)
        {
            // Sanity
            if (availableTools.ContainsKey(action.tool.name))
            {
                logger.Info($"Robot already had a tool defined as \"{action.tool.name}\"; this will be overwritten.");
                availableTools.Remove(action.tool.name);
            }

            availableTools.Add(action.tool.name, action.tool);

            return(true);
        }