コード例 #1
0
 public Robot()
 {
     rsiAdapter   = new RSIAdapter();
     generator    = new TrajectoryGenerator();
     position     = RobotVector.Zero;
     axisPosition = RobotAxisVector.Zero;
     HomePosition = RobotVector.Zero;
 }
コード例 #2
0
ファイル: KUKARobot.cs プロジェクト: kborowicz/PingPong
        /// <param name="port">Port defined in RSI_EthernetConfig.xml</param>
        /// <param name="limits">robot limits</param>
        public KUKARobot(int port, RobotLimits limits)
        {
            rsiAdapter = new RSIAdapter(port);
            Limits     = limits;

            worker = new BackgroundWorker()
            {
                WorkerSupportsCancellation = true
            };

            worker.DoWork += async(sender, args) => {
                // Connect with the robot
                InputFrame receivedFrame = await rsiAdapter.Connect();

                generator = new TrajectoryGenerator5(receivedFrame.Position);

                lock (receivedDataSyncLock) {
                    IPOC         = receivedFrame.IPOC;
                    position     = receivedFrame.Position;
                    HomePosition = receivedFrame.Position;
                }

                // Send first response (prevent connection timeout)
                rsiAdapter.SendData(new OutputFrame()
                {
                    Correction = new RobotVector(),
                    IPOC       = IPOC
                });

                isInitialized = true;
                Initialized?.Invoke();

                // Start loop for receiving and sending data
                while (!worker.CancellationPending)
                {
                    await ReceiveDataAsync();

                    SendData();
                }

                isInitialized = false;
                rsiAdapter.Disconnect();
            };
        }