Exemple #1
0
    public void SwitchRobotCamera()
    {
        activeRobotCamera.enabled   = false;
        inactiveRobotCamera.enabled = true;

        var tmp = activeRobotCamera;

        activeRobotCamera   = inactiveRobotCamera;
        inactiveRobotCamera = tmp;
    }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                // Specify VIPER IP here
                using (CvmDevice module = new CvmDevice("http://192.168.1.157:11311", null))
                {
                    module.RosNode = "ReadTopicsSample";
                    module.Connect();
                    if (!module.IsConnected)
                    {
                        throw new InvalidOperationException("Cannot connect to VIPER!");
                    }

                    // Each image stream is associated with specific named topic. To receive images on needs to subscribe to the topic
                    // and attach a sink where images must be cached when received. Since there are several image types in .NET, use
                    // a corresponding sink type, e.g. BitmapSink for System.Drawing.Bitmap.
                    // One image subscriber can have multiple sinks, if multiple types of the same topic image are needed.
                    foreach (var topic in module.ImageTopics)
                    {
                        log.InfoFormat("Getting image from topic '{0}'", topic);
                        using (ImageSubscriber <ImageHandler> subscriber = new ImageSubscriber <ImageHandler>())
                        {
                            BitmapSink sink = new BitmapSink();
                            subscriber.AddSink(sink);
                            AutoResetEvent waitHandle = new AutoResetEvent(false);

                            // Once subsribed, this event shall notify when there are new images available in the topic. If event is not raised, it means image
                            // has not been published for some reason.
                            sink.Updated += (s, e) =>
                            {
                                log.InfoFormat("Received image of size {0}", sink.Bitmap.Size);
                                waitHandle.Set();
                            };

                            subscriber.Subscribe(topic);
                            if (!waitHandle.WaitOne(3000))
                            {
                                log.WarnFormat("Topic has no images published");
                            }
                        }
                    }

                    module.Disconnect();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemple #3
0
    private void Awake()
    {
        activeRobotCamera = rosConnector[0].GetComponent <ImageSubscriber>();
        if (Settings.SettingsInstance.MultiRobot != null)
        {
            robotModel[1].SetActive(true);
            rosConnector[1].SetActive(true);

            inactiveRobotCamera         = rosConnector[1].GetComponent <ImageSubscriber>();
            inactiveRobotCamera.enabled = false;
        }
        else
        {
            multiRobotButton.interactable = false;
        }
    }