Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();
            //bridgeLogic.currentVelocityState = new RosBridgeUtility.VelocityState();
            stackControls.Visibility = System.Windows.Visibility.Hidden;
            this.DataContext         = _responseObj;
            this.bridgeLogic         = new RosBridgeUtility.RosBridgeLogic();
            this.connectionState     = (int)ConnectionState.Disconnected;
            this.subscriptionState   = (int)SubscriptionState.Unsubscribed;
            bridgeLogic.setSubject(this);
            this.bridgeConfig = new RosBridgeUtility.RosBridgeConfig();
            bridgeConfig.readConfig("XMLFile1.xml");
            Console.WriteLine("Ipaddress: {0}", bridgeConfig.ipaddress);
            bridgeLogic.currentTarget = bridgeConfig.target;
            bridgeLogic.initVelocityThreshold(bridgeConfig.min_vel, bridgeConfig.max_vel,
                                              bridgeConfig.inc_vel, bridgeConfig.init_vel);
            bridgeLogic.initAngularVelocityThreshold(bridgeConfig.min_ang, bridgeConfig.max_ang,
                                                     bridgeConfig.inc_ang, bridgeConfig.init_ang);
            txtLgth.Text  = bridgeLogic.current_velocity.ToString();
            txtIP.Text    = bridgeConfig.ipaddress;
            txtPort.Text  = bridgeConfig.port.ToString();
            txtTheta.Text = bridgeLogic.current_angVelocity.ToString();
            bridgeLogic.currentVelocityState.inc_vel      = bridgeConfig.inc_vel;
            bridgeLogic.currentVelocityState.max_vel      = bridgeConfig.max_vel;
            bridgeLogic.currentVelocityState.min_vel      = bridgeConfig.min_vel;
            bridgeLogic.currentVelocityState.current_vel  = bridgeConfig.init_vel;
            bridgeLogic.currentVelocityState.currentTheta = bridgeConfig.init_ang;
            try
            {
                showState   = bridgeConfig.showState;
                laserScan   = bridgeConfig.laserFieldTopic;
                odometry    = bridgeConfig.odometryTopic;
                scaleFactor = bridgeConfig.vis_scaleFactor;
                wcon        = new WebController(bridgeConfig, bridgeLogic);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Error during read: {0}", e.Data);
            }
            wcon.updateVelocityState(bridgeLogic.currentVelocityState);
            var         u1   = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "test1.jpg"));
            BitmapImage img1 = new BitmapImage(u1);

            kinect_screen.Source = img1;

            BitmapSource source = kinect_screen.Source as BitmapSource;

            //NeobotixStateServer = new WebSocketServer("ws://localhost:9091");
            wcon.updateRGBState(ref source, img1.PixelHeight, img1.PixelWidth);
            source = kinect_depth_screen.Source as BitmapSource;
            //NeobotixStateServer = new WebSocketServer("ws://localhost:9091");
            //wcon.updateDepthState(ref source, img1.PixelHeight, img1.PixelWidth);
            // Kinect refresher timer
        }