Ejemplo n.º 1
0
        public static bool CreateVirtualVehicleAtOrigin(this IFleetManagerClient fleetManager, IPAddress ipAddress)
        {
            PoseData pose = new PoseData()
            {
                X = 0, Y = 0, Heading = 0
            };

            return(fleetManager.CreateVirtualVehicle(ipAddress, pose));
        }
Ejemplo n.º 2
0
        public void CreateVirtual_NaNPose()
        {
            PoseDto pose = new PoseDto()
            {
                X       = double.NaN,
                Y       = double.NaN,
                Heading = double.NaN
            };

            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);
            IServiceCallResult  result = client.CreateVirtualVehicle("192.168.0.1", pose);

            Assert.AreEqual(0, result.ServiceCode);
        }
Ejemplo n.º 3
0
        public void TestVirtual(string ipV4String)
        {
            IFleetManagerClient client = ClientFactory.CreateTcpFleetManagerClient(settings);

            PoseDto poseDto = new PoseDto()
            {
                X       = 0,
                Y       = 0,
                Heading = 0
            };

            var result = client.CreateVirtualVehicle(IPAddress.Parse(ipV4String), poseDto);

            Assert.AreEqual(0, result.ServiceCode);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Attempts to create virtual vehicles in the fleet manager for every AGV template in the collection.
        /// </summary>
        /// <param name="fleetManagerClient">Fleet manager client to use</param>
        public void Populate(IFleetManagerClient fleetManagerClient)
        {
            if (fleetManagerClient == null)
            {
                throw new ArgumentNullException("fleetManagerClient");
            }

            lock (lockObject)
            {
                foreach (AGVTemplate agvTemplate in AGVTemplates.ToList())
                {
                    _ = fleetManagerClient.CreateVirtualVehicle(agvTemplate.GetIPV4Address(), agvTemplate.ToPoseDto());
                }
            }
        }
Ejemplo n.º 5
0
        public void CreateVirtual()
        {
            PoseDto pose = new PoseDto()
            {
                X       = -3,
                Y       = -2,
                Heading = 0
            };

            IPAddress           ipAddress = IPAddress.Parse("192.0.2.5");
            IFleetManagerClient client    = ClientFactory.CreateTcpFleetManagerClient(settings);

            var result = client.CreateVirtualVehicle(ipAddress, pose);

            Assert.AreEqual(0, result.ServiceCode);
        }
Ejemplo n.º 6
0
        private static void Main(string[] args)
        {
            // Here we create an endpoint settings object that defines where the fleet manager service is currently running
            // For this demo we are assuming it is running on localhost, using the default TCP port of 41917.
            EndpointSettings endpointSettings = new EndpointSettings(IPAddress.Loopback, 41916, 41917);

            // Now we create a fleet manager client using the client factory;
            IFleetManagerClient fleetManagerClient = ClientFactory.CreateTcpFleetManagerClient(endpointSettings);

            Console.WriteLine("Press <any> key to create a virtual vehicle 192.168.0.1 at 0,0,0");
            Console.ReadKey(true);

            IPAddress          virtualVehicle = IPAddress.Parse("192.168.0.1");
            IServiceCallResult result         = fleetManagerClient.CreateVirtualVehicle(virtualVehicle, 0, 0, 0);

            if (!result.IsSuccessful())
            {
                Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
            }

            // Now we can subscribe to new fleet updates
            Console.WriteLine("Press <any> key to subscribe to fleet updates");
            Console.ReadKey(true);

            Console.Clear();
            Console.CursorVisible = false;
            Console.WriteLine("Press <any> key to quit");

            fleetManagerClient.Connected         += FleetManagerClient_Connected;
            fleetManagerClient.Disconnected      += FleetManagerClient_Disconnected;
            fleetManagerClient.FleetStateUpdated += FleetManagerClient_FleetStateUpdated;

            Console.Title = (fleetManagerClient.IsConnected) ? "Connected" : "Disconnected";

            Console.ReadKey(true);

            fleetManagerClient.Connected         -= FleetManagerClient_Connected;
            fleetManagerClient.Disconnected      -= FleetManagerClient_Disconnected;
            fleetManagerClient.FleetStateUpdated -= FleetManagerClient_FleetStateUpdated;

            // The fleet manager client has its own thread which must be disposed.
            fleetManagerClient.Dispose();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new virtual vehicle.
        /// </summary>
        /// <param name="client">The fleet manager client to use.</param>
        /// <param name="ipAddress">IPv4 address of the vehicle to be created.</param>
        /// <param name="x">X position in meters.</param>
        /// <param name="y">Y position in meters.</param>
        /// <param name="heading">Heading in radians.</param>
        /// <returns>Successful service call result on creation.</returns>
        public static IServiceCallResult CreateVirtualVehicle(this IFleetManagerClient client, IPAddress ipAddress, double x, double y, double heading)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (ipAddress == null)
            {
                throw new ArgumentNullException("ipAddress");
            }

            PoseDto poseDto = new PoseDto()
            {
                X       = x,
                Y       = y,
                Heading = heading
            };

            return(client.CreateVirtualVehicle(ipAddress, poseDto));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new virtual vehicle.
        /// </summary>
        /// <param name="client">The fleet manager client to use.</param>
        /// <param name="ipV4string">IPv4 address of the vehicle to be created.</param>
        /// <param name="pose">The initialization pose.</param>
        /// <returns></returns>
        public static IServiceCallResult CreateVirtualVehicle(this IFleetManagerClient client, string ipV4string, PoseDto pose)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (string.IsNullOrEmpty(ipV4string))
            {
                throw new ArgumentOutOfRangeException("ipV4string");
            }

            if (pose == null)
            {
                throw new ArgumentNullException("pose");
            }

            IPAddress ipAddress = IPAddress.Parse(ipV4string);

            return(client.CreateVirtualVehicle(ipAddress, pose));
        }
Ejemplo n.º 9
0
        private static void HandleCreateVehicle(EndpointSettings endpointSettings)
        {
            // Now we create a fleet manager client using the client factory, and create a virtual vehicle at pose at the node defined as origin.
            //  see: https://github.com/GuidanceAutomation/FleetClients
            using (IFleetManagerClient fleetManagerClient = FleetClients.Core.ClientFactory.CreateTcpFleetManagerClient(endpointSettings))
            {
                IServiceCallResult result = fleetManagerClient.CreateVirtualVehicle(IPAddress.Parse("192.168.0.1"), 0, 0, 0);

                if (!result.IsSuccessful())
                {
                    Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
                }

                IServiceCallResult enableResult = fleetManagerClient.SetKingpinState(IPAddress.Parse("192.168.0.1"), VehicleControllerState.Enabled);

                if (!enableResult.IsSuccessful())
                {
                    Console.WriteLine($"Failed to enable virtual vehicle serviceCode:{result.ServiceCode}");
                }
            }
        }
Ejemplo n.º 10
0
        private static void Main(string[] args)
        {
            // Here we create an endpoint settings object that defines where the fleet manager service is currently running
            // For this demo we are assuming it is running on localhost, using the default TCP port of 41917.

            EndpointSettings endpointSettings = new EndpointSettings(IPAddress.Loopback, 41916, 41917);

            // Now we create a fleet manager client using the client factory;
            IFleetManagerClient fleetManagerClient = ClientFactory.CreateTcpFleetManagerClient(endpointSettings);

            Console.WriteLine("Press <any> key to create a virtual vehicle 192.168.0.1 at 0,0,0");
            Console.ReadKey(true);

            IPAddress          virtualVehicle = IPAddress.Parse("192.168.0.1");
            IServiceCallResult result         = fleetManagerClient.CreateVirtualVehicle(virtualVehicle, 0, 0, 0);

            if (!result.IsSuccessful())
            {
                Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
            }

            // Now we can update the vehicles pose
            Console.WriteLine("Press <any> key to set the pose of the vehicle to 1,1,1.57");
            Console.ReadKey(true);

            result = fleetManagerClient.SetPose(virtualVehicle, 1, 1, 1.57);
            if (!result.IsSuccessful())
            {
                Console.WriteLine($"Failed to set pose serviceCode:{result.ServiceCode}");
            }

            Console.WriteLine("Press <any> key to quit");
            Console.ReadKey(true);

            // The fleet manager client has its own thread which must be disposed.
            fleetManagerClient.Dispose();
        }
Ejemplo n.º 11
0
        private static void Main(string[] args)
        {
            // Here we create an endpoint settings object that defines where the fleet manager service is currently running
            // For this demo we are assuming it is running on localhost, using the default TCP port of 41917.
            EndpointSettings endpointSettings = new EndpointSettings(IPAddress.Loopback, 41916, 41917);

            IEnumerable <int> nodeIds = Enumerable.Empty <int>(); // Create an array to store node ids in

            NodeDto startNode = null;

            // Using the map manager client, get the ids of all nodes in the map
            using (IMapClient mapClient = SchedulingClients.Core.ClientFactory.CreateTcpMapClient(endpointSettings))
            {
                IServiceCallResult <NodeDto[]> nodeResults = mapClient.GetAllNodes();

                if (!nodeResults.IsSuccessful())
                {
                    Console.WriteLine($"Failed to get nodes, serviceCode:{nodeResults.ServiceCode}");
                }
                else
                {
                    nodeIds = nodeResults.Value.Select(e => e.Id);
                }

                startNode = nodeResults.Value.First();
            }

            // Now we create a fleet manager client using the client factory, and create a virtual vehicle at pose at the first node.
            //  see: https://github.com/GuidanceAutomation/FleetClients
            using (IFleetManagerClient fleetManagerClient = FleetClients.Core.ClientFactory.CreateTcpFleetManagerClient(endpointSettings))
            {
                IServiceCallResult result = fleetManagerClient.CreateVirtualVehicle(IPAddress.Parse("192.168.0.1"), startNode.Pose.X, startNode.Pose.Y, startNode.Pose.Heading);

                if (!result.IsSuccessful())
                {
                    Console.WriteLine($"Failed to create virtual vehicle serviceCode:{result.ServiceCode}");
                }
            }


            Random random       = new Random(); // Random number generator
            bool   continueFlag = true;

            while (continueFlag)
            {
                Console.WriteLine("Press <any> key to create a random GoTo job, 'q' to quit");

                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.Q:
                {
                    continueFlag = false;
                    break;
                }

                default:
                {
                    // Use the job builder client to create a new goto job.
                    using (IJobBuilderClient jobBuilder = SchedulingClients.Core.ClientFactory.CreateTcpJobBuilderClient(endpointSettings))
                    {
                        // Boiler plate code to pick a random node from the array of nodes.
                        int index  = random.Next(0, nodeIds.Count());
                        int nodeId = nodeIds.ElementAt(index);

                        Console.WriteLine($"Sending to node:{nodeId}");

                        IServiceCallResult <JobDto> createResult = jobBuilder.CreateJob();
                        if (!createResult.IsSuccessful())
                        {
                            Console.WriteLine($"Failed to create job, serviceCode:{createResult.ServiceCode}");
                        }

                        IServiceCallResult <int> gotoResult = jobBuilder.CreateGoToNodeTask(createResult.Value.RootOrderedListTaskId, nodeId);
                        if (!gotoResult.IsSuccessful())
                        {
                            Console.WriteLine($"Failed to create goto task, serviceCode:{gotoResult.ServiceCode}");
                        }

                        IServiceCallResult commitResult = jobBuilder.CommitJob(createResult.Value.JobId);
                        if (!commitResult.IsSuccessful())
                        {
                            Console.WriteLine($"Failed to commit job, serviceCode:{commitResult.ServiceCode}");
                        }
                    }

                    break;
                }
                }
            }
        }
Ejemplo n.º 12
0
        public void CreateVirtualVehicle_ClientExceptionNull()
        {
            var result = FleetManagerClient.CreateVirtualVehicle(IPAddress.Loopback, new PoseDto());

            Assert.IsNotNull(result.ExceptionMessage);
        }