void OnDestroy() { DisconnectRobot(); if (_connector != null) { _connector.Dispose(); } _connector = null; }
void _robotLinked() { if (RobotConnector != null) { _txeyes = RobotConnector.GetComponent <TxKitEyes> (); _txbody = RobotConnector.GetComponent <TxKitBody> (); _txmouth = RobotConnector.GetComponent <TxKitMouth> (); _txears = RobotConnector.GetComponent <TxKitEars> (); } }
private void OpenTCPPort() { try { TCPPort = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); TCPPort.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1); TCPPort.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); TCPPort.Connect(host, port); } catch (Exception e) { } ur5eConnection = new RobotConnector(host.ToString(), true); }
// Use this for initialization void Start() { AppManager.Instance.Init(); Settings.Instance.Init(); _connector = new RobotConnector(); _connector.DataCommunicator.OnMessage += OnMessage; _connector.DataCommunicator.OnRobotInfoDetected += OnRobotInfoDetected; _connector.DataCommunicator.OnRobotStatus += OnRobotStatus; _connector.DataCommunicator.OnBumpSensor += OnBumpSensor; _connector.DataCommunicator.OnServiceNetValue += _OnServiceNetValue; _connector.DataCommunicator.OnRobotCapabilties += OnRobotCapabilties; _connector.StartDataCommunicator(); OVRManager.HMDUnmounted += OnHMDUnmounted; if (RobotIndex >= 0) { _RobotIP = AppManager.Instance.RobotManager.GetRobotInfo(RobotIndex); } //Send Detect Message to scan network for the available robots /* * _connector.RobotCommunicator.SetData ("detect", _connector.DataCommunicator.GetPort().ToString(), true,false); * _connector.RobotCommunicator.BroadcastMessage (Settings.Instance.GetPortValue("CommPort",6000)); * _connector.RobotCommunicator.RemoveData ("detect"); */ if (Debugger == null) { Debugger = GameObject.FindObjectOfType <DebugInterface> (); } if (Debugger != null) { Debugger.AddDebugElement(new DebugRobotStatus(this)); } //VideoStream.SetConnectionComponent (this); _OnStarted(); }
void OnRobotConnected(RobotConnector.TargetPorts ports) { HandController c=GameObject.FindObjectOfType<HandController> (); if (c == null || !c.IsConnected ()) { return; } _imageGrabber = new GstUnityImageGrabber (); _imageGrabber.SetTexture2D (HandRenderer.LeapRetrival [0].MainTextureData,HandRenderer.LeapRetrival [0].Width,HandRenderer.LeapRetrival [0].Height,TextureFormat.Alpha8); _imageGrabber.Update();//update once _handsPort=Settings.Instance.GetPortValue("HandsPort",0); _streamer = new GstNetworkImageStreamer (); _streamer.SetBitRate (300); _streamer.SetResolution (640, 240, 30); _streamer.SetGrabber (_imageGrabber); _streamer.SetIP (ports.RobotIP, _handsPort, false); RobotConnector.Connector.SendData("HandPorts",_handsPort.ToString(),false); _streamer.CreateStream (); _streamer.Stream (); _isConnected = true; }
public string GetDebugString() { RobotConnector _connector = Robot.Connector; string str = ""; str += "Is Connected: " + Robot.IsConnected + "\n"; if (Robot.IsConnected) { str += "Is Robot Connected: " + Robot.IsRobotConnected + "\n"; str += "Robot Status: " + Robot.RobotStatus + "\n"; } if (Body != null) { str += "Head Position= " + Body.BodyJoints.Head.Position.ToString("F3") + "\n"; str += "Head Rotation= " + Body.BodyJoints.Head.Rotation.eulerAngles.ToString("F2") + "\n"; //str += "Rotation Speed= " + Body.BaseRotation.ToString () + "\n"; //str += "Motion Speed= " + Body.BaseSpeed.ToString () + "\n"; float[] jv = Body.RobotJointValues; if (jv != null) { str += "Robot Joint Values: \n"; for (int i = 0; i < jv.Length;) { str += jv [i].ToString() + "/ " + jv [i + 1]; if (i != jv.Length - 2) { str += "\n"; } i += 2; } } } return(str); }
public virtual void OnRobotUpdated(RobotConnector connector) { }
void _OnRobotUpdated(RobotConnector connector) { OnRobotUpdated(connector); }
public override void OnRobotUpdated(RobotConnector connector) { // Drive (_robotHandler,connector.Speed.x,connector.Speed.y,(int)connector.Rotation); }
static void Main(string[] args) { RobotConnector rc = new RobotConnector(); // Artec.Studuino.BoardType res = rc.checkBoardType(); // Debug.WriteLine(res); }
void OnRobotConnected(RobotConnector.TargetPorts ports) { SetRemoteHost (ports.RobotIP, ports); }
public void SetRemoteHost(string IP,RobotConnector.TargetPorts ports) { _remoteHostIP = IP; /* MultipleNetworkCameraSource c; _cameraSource = (c=new MultipleNetworkCameraSource()); c.TargetNode=gameObject; c.Host = IP; c.port = port; c.Init();*/ if(this.CameraType==CameraSourceType.Remote) { if (_cameraSource != null) { _cameraSource.Close(); _cameraSource=null; } MultipleNetworkCameraSource c; _cameraSource = (c = new MultipleNetworkCameraSource ()); c.StreamsCount = 2; c.TargetNode = gameObject; c.Host = IP; c.port = Settings.Instance.GetPortValue("VideoPort",0); c.Init (); _cameraSource.GetBaseTexture ().OnFrameGrabbed += OnFrameGrabbed; m_grabbedFrames=0; //disable the renderes until we video stream starts //_camRenderer[0].Disable(); //_camRenderer[1].Disable(); _videoPorts=new uint[2]{0,0}; _videoPorts[0]=c.Texture.Player.GetVideoPort(0); _videoPorts[1]=c.Texture.Player.GetVideoPort(1); RobotConnector.Connector.SendData("VideoPorts",_videoPorts[0].ToString()+","+_videoPorts[1].ToString(),true); if(_audioPlayer!=null) { int port= Settings.Instance.GetPortValue("AudioPort",0); _audioPlayer.SetIP(IP,0,false); _audioPlayer.CreateStream(); _audioPlayer.Play(); _audioPort=_audioPlayer.GetAudioPort(); RobotConnector.Connector.SendData("AudioPort",_audioPort.ToString(),true); } if(_audioStreamer!=null) { _audioStreamer.SetIP(IP,7010,false);//port should be dynamically assigned from remote side _audioStreamer.Stream(); } for(int i=0;i<2;++i) _camRenderer[i].CamSource=_cameraSource; if (Debugger) { Debugger.RemoveDebugElement(_cameraDebugElem);; _cameraDebugElem=new DebugCameraCaptureElement(_cameraSource.GetBaseTexture()); Debugger.AddDebugElement(_cameraDebugElem);; } } { //request camera settings RobotConnector.Connector.SendData("CameraParameters","",false); //request netvalue port RobotConnector.Connector.RobotCommunicator.SetData ("NetValuePort", "AVStreamServiceModule,"+RobotConnector.Connector.DataCommunicator.Port.ToString(), false,false); } }
// Use this for initialization void Start() { _connector = new RobotConnector (); switch (HeadControllerType) { case AppManager.HeadControllerType.Oculus: default: _connector.HeadController=new OculusHeadController(); break; } switch (BaseControllerType) { case AppManager.BaseControllerType.Oculus: default: _connector.BaseController=new OculusBaseController(); break; } _connector.RobotCommunicator = new RemoteRobotCommunicator (); _connector.DataCommunicator.OnMessage += OnMessage; _connector.DataCommunicator.OnRobotInfoDetected += OnRobotInfoDetected; _connector.DataCommunicator.OnRobotStatus += OnRobotStatus; _connector.DataCommunicator.OnJointValues += OnJointValues; _connector.DataCommunicator.OnBumpSensor += OnBumpSensor; _connector.DataCommunicator.OnServiceNetValue += _OnServiceNetValue; _connector.StartDataCommunicator (); if(RobotIndex>=0) _RobotIP=AppManager.Instance.RobotManager.GetRobotInfo(RobotIndex); //Send Detect Message to scan network for the available robots _connector.RobotCommunicator.SetData ("detect", _connector.DataCommunicator.Port.ToString(), true,false); _connector.RobotCommunicator.BroadcastMessage (Settings.Instance.GetPortValue("CommPort",6000)); _connector.RobotCommunicator.RemoveData ("detect"); if (Debugger != null) { Debugger.AddDebugElement(new DebugRobotStatus(this)); } //VideoStream.SetConnectionComponent (this); _OnStarted (); }
void OnDestroy() { _connector.Dispose(); _connector = null; }