// Use this for initialization
    void Start()
    {
        _oscManager = GameObject.Find("OscManager").GetComponent <OscManager>();

        _sceneManager = GameObject.Find("SceneManager").GetComponent <SceneManager>();
        _lpsManager   = GameObject.Find("LpsManager").GetComponent <LpsManager>();

        _oscClient = _oscManager.CreateClient("drones");
    }
Esempio n. 2
0
 /// <summary>
 /// Creates an instance for managing each aspect of a user session.
 /// </summary>
 public UserSession()
 {
     Implants  = new ImplantManager(this);
     Devices   = new DeviceManager(this);
     MidiMap   = new MidiMappingManager(this);
     OSC       = new OscManager(this);
     Modes     = new ModeManager(this);
     Sync      = new SyncManager(this);
     Console   = new ConsoleManager(this);
     Gui       = new GuiManager(this);
     Cluster   = new ClusterManager(this);
     _saveTask = new SaveTask(this);
 }
Esempio n. 3
0
    // Use this for initialization
    public void Awake()
    {
        this.findNodes();

        this.oscManager = GameObject.Find("OscManager").GetComponent <OscManager> ();
        this.oscClient  = this.oscManager.CreateClient("drones");

        if (Application.isPlaying)
        {
            if (this._lpsNodes.Count < this.lpsNodesPositions.Length)
            {
                this.RecreateNodes();
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        oscManager  = GameObject.Find("OscManager").GetComponent <OscManager>();
        droneScript = gameObject.GetComponent <Drone>();

        _oscClient = oscManager.CreateClient("drones");

        // On connection : send params
        gameObject.GetComponent <Drone>().ConnectionEvent += (Drone drone) =>
        {
            foreach (PidVariable variable in variables)
            {
                SetVariable(variable.name, variable.value);
            }
        };
    }
Esempio n. 5
0
    // Start is called before the first frame update
    private void Start()
    {
        // set up Address Handlers
        oscManager = FindObjectOfType <OscManager>();
        osc        = oscManager.osc;

        osc.SetAddressHandler("/sphere_type", OnSphereTypeUpdate);
        osc.SetAddressHandler("/curr_sphere_type_id", OnRecentSphereTypeIdUpdate);
        osc.SetAddressHandler("/sphere_type_live_update", OnSphereTypeLiveUpdate);
        osc.SetAddressHandler("/surface_type", OnReceiveSurfaceType);
        osc.SetAddressHandler("/get_room_info", OnReceiveGetRoomInfo);
        osc.SetAddressHandler("/shoot_speed", OnReceiveShootSpeed);
        osc.SetAddressHandler("/shoot_sphere", OnReceiveShootSphere);
        osc.SetAddressHandler("/delete_sphere", OnReceiveDeleteSphere);
        osc.SetAddressHandler("/gravity", OnReceiveGravity);
    }
Esempio n. 6
0
File: Form1.cs Progetto: sbst/code
        public Form1()
        {
            InitializeComponent();
            vol = new float[6] { 1F, 1F, 0F, 1F, 0.5F, 0F };
            textVolume.Text = vol[3].ToString();
            textSpeed.Text = vol[0].ToString();
            textPanorama.Text = vol[4].ToString();
            thread = new System.Threading.Thread(DoRecognition);
            flag = 0;
            oscManager1 = new OscManager();
            oscManager1.DestIP = "127.0.0.1";

            // Create the SenseManager instance
            sm = PXCMSenseManager.CreateInstance();
            // Enable hand tracking
            sm.EnableHand();
            // Get a hand instance here for configuration
            PXCMHandModule hand = sm.QueryHand();
            // Initialize and stream data.
            PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler
            {
                onModuleProcessedFrame = OnModuleProcessedFrame
            };
            sm.Init(handler);

            PXCMHandConfiguration handConfiguration = sm.QueryHand().CreateActiveConfiguration();
            handConfiguration.EnableGesture("thumb_down");
            handConfiguration.EnableGesture("thumb_up");
            handConfiguration.EnableGesture("v_sign");
            handConfiguration.EnableGesture("spreadfingers");
            handConfiguration.EnableGesture("fist");
            handConfiguration.EnableGesture("full_pinch");
            handConfiguration.ApplyChanges();
            if (handConfiguration == null)
            {
                Console.WriteLine("Failed Create Configuration");
                Console.WriteLine("That`s all...");
                Console.ReadKey();
            }
            logTextBox.Text = DateTime.Now.ToString("hh:mm:ss") + " Started" + "\n" + logTextBox.Text;
        }
Esempio n. 7
0
    // Use this for initialization
    public void Start()
    {
        this.system_initialized = false;
        this._oscManager        = GameObject.Find("OscManager").GetComponent <OscManager> ();
        this._lpsManager        = GameObject.Find("LpsManager").GetComponent <LpsManager> ();
        this._dronesManager     = GameObject.Find("DronesManager").GetComponent <DronesManager> ();

        if (shouldHidePositionAndBatteryLogs)
        {
            this._oscManager.OscSubscribe("/log/*/position/*",
                                          delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
            });
            this._oscManager.OscSubscribe("/log/*/battery/*",
                                          delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
            });
        }

        StartCoroutine(StartingCoroutine());
    }
Esempio n. 8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string settingsJSON = File.ReadAllText("settings.json");
            dynamic settings = JsonConvert.DeserializeObject(settingsJSON);

            try
            {
                textHost.Text = settings.host;
                textPort.Text = settings.port;
                textId.Text = settings.id;
                textOSC.Text = settings.oscaddress;

                oscmanager = new OscManager();
                oscmanager.DestIP = textHost.Text;
                oscmanager.DestPort = int.Parse(textPort.Text);

                startUp();
            }
            catch (FormatException exeption)
            {
                textOSC.Text = "JSON LOAD ERROR";
            }
        }
Esempio n. 9
0
    private void Start()
    {
        // retrieve objects from the scene
        _oscManager    = GameObject.Find("OscManager").GetComponent <OscManager>();
        _dronesManager = GameObject.Find("DronesManager").GetComponent <DronesManager>();

        Debug.Assert(_handDroneID >= 0, "hand drone ID not set");
        _handDrone = _dronesManager.GetDroneGameObjectById(_handDroneID);
        Debug.Assert(_bodyDroneID >= 0, "body drone ID not set");
        _bodyDrone = _dronesManager.GetDroneGameObjectById(_bodyDroneID);

        _dronesIds = new List <int>(_dronesManager
                                    .GetDrones()
                                    .Select(d_go => d_go.Id)
                                    .Where(id => id != _handDroneID && id != _bodyDroneID));

        // soft "emergency" : do not need to reboot the drone nor the server
        _handDrone.GetComponent <Drone>().UseAsInput = true;
        _bodyDrone.GetComponent <Drone>().UseAsInput = true;

        // Subscribe to the specktr OSC topic
        _oscManager.OscSubscribe(specktrOscTopic, this.onButtons);
    }
Esempio n. 10
0
    /// <summary>
    /// Initializes the specified identifier.
    /// </summary>
    /// <param name="id">The drone ID.</param>
    /// <param name="radio_uri">The radio URI.</param>
    /// <param name="baseTopic">optional : the topic for the Crazyflie module.</param>
    /// <exception cref="System.Exception">Drone initialized with bad ID or radio URI. Make sure they are set in the inspector</exception>
    public void Initialize(int id, string radio_uri, string baseTopic = null)
    {
        if (!_initialized)
        {
            if (id == -1 || radio_uri == null)
            {
                throw new System.Exception("Drone initialized with bad ID or radio URI. Make sure they are set in the inspector");
            }

            this.id       = id;
            this.radioUri = radio_uri;
            if (baseTopic != null)
            {
                this.baseTopic = baseTopic;
            }

            _oscManager = GameObject.Find("OscManager").GetComponent <OscManager>();
            _oscClient  = _oscManager.CreateClient("drones");

            #region Link OSC packets to events
            _oscManager.OscSubscribe(string.Format("{0}/{1}/connection", this.baseTopic, this.id),
                                     delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
                bool success = (int)packet.Data[0] > 0;
                if (success)
                {
                    OnConnection();
                }
                else
                {
                    OnConnectionFailed();
                }
            });

            _oscManager.OscSubscribe(string.Format("{0}/{1}/disconnection", this.baseTopic, this.id),
                                     delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
                OnDisconnection();
            });

            _oscManager.OscSubscribe(string.Format("{0}/{1}/link_quality", this.baseTopic, this.id),
                                     delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
                float quality = (float)packet.Data[0];
                OnLinkQuality(quality);
            });

            _oscManager.OscSubscribe(string.Format("/log/{0}/position", this.id),
                                     delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
                Vector3 pos = new Vector3(
                    (float)packet.Data[0],
                    (float)packet.Data[2], // As always, y and z are inverted
                    (float)packet.Data[1]);

                OnPosition(pos);
            });

            _oscManager.OscSubscribe(string.Format("/log/{0}/rpy", this.id),
                                     delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
                Vector3 rpy = new Vector3(
                    (float)packet.Data[0],
                    (float)packet.Data[1],
                    (float)packet.Data[2]);

                OnRollPitchYaw(rpy);
            });

            _oscManager.OscSubscribe(string.Format("/log/{0}/battery", this.id),
                                     delegate(string topic, OSCPacket packet, System.Text.RegularExpressions.GroupCollection path_args)
            {
                float voltage = (float)packet.Data[0];

                OnBattery(voltage);
            });
            #endregion

            _positionEstimationLowPassFilter = new LowPassFilter(PositionEstimationLowPassFilterWindowSize);

            _initialized = true;
        }
    }
Esempio n. 11
0
 private void Start()
 {
     oscManager        = FindObjectOfType <OscManager>();
     surfaceController = FindObjectOfType <SurfaceController>();
 }
Esempio n. 12
0
        private void KinectSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            var skeletons = new Skeleton[0];

            using (var skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }

            if (skeletons.Length == 0)
            {
                return;
            }

            var skel = skeletons.FirstOrDefault(x => x.TrackingState == SkeletonTrackingState.Tracked);

            if (skel == null)
            {
                return;
            }

            var rightHand = skel.Joints[JointType.WristRight];

            XValueRight.Text = rightHand.Position.X.ToString(CultureInfo.InvariantCulture);
            YValueRight.Text = rightHand.Position.Y.ToString(CultureInfo.InvariantCulture);
            ZValueRight.Text = rightHand.Position.Z.ToString(CultureInfo.InvariantCulture);

            var leftHand = skel.Joints[JointType.WristLeft];

            XValueLeft.Text = leftHand.Position.X.ToString(CultureInfo.InvariantCulture);
            YValueLeft.Text = leftHand.Position.Y.ToString(CultureInfo.InvariantCulture);
            ZValueLeft.Text = leftHand.Position.Z.ToString(CultureInfo.InvariantCulture);

            var centreHip = skel.Joints[JointType.HipCenter];

            /*
             * Below this is where the code edit was made.
             * *******************
             */
            //creates the
            var manager = new OscManager();

            //Sets up the IP address and Port to which the bundle is sending to.
            //Edit DestIP to the laptop your communicating with.
            manager.DestIP   = "192.168.0.26";
            manager.DestPort = 12000;

            //Creates the message and bundle. This is what will send the data.
            OscElement message;
            OscBundle  bundle;


            if (leftHand.Position.Y > .2)
            {
                //Lower octave
                message = new OscElement("/octave", 0);
                bundle  = new OscBundle();
                bundle.AddElement(message);
                manager.Send(bundle);
            }
            else if ((leftHand.Position.Y > .2) && (leftHand.Position.Y < .45))
            {
                //Mid octave
                message = new OscElement("/octave", 1);
                bundle  = new OscBundle();
                bundle.AddElement(message);
                manager.Send(bundle);
            }
            else if (leftHand.Position.Y > .50)
            {
                //High octave
                message = new OscElement("/octave", 2);
                bundle  = new OscBundle();
                bundle.AddElement(message);
                manager.Send(bundle);
            }

            /********
             * This ends where the code was edited
             */

            if (rightHand.Position.Y > 0.3)
            {
                RightRaised.Text = "Raised";
            }
            else if (leftHand.Position.Y > 0.3)
            {
                LeftRaised.Text = "Raised";
            }
            else
            {
                LeftRaised.Text  = "Lowered";
                RightRaised.Text = "Lowered";
            }

            //Pauses system so not too many signals are being sent.
            Thread.Sleep(10);
        }