LIDAR#

Warning

Deprecated. The LIDAR service will be removed in a future release. Use SpaceCenter.RaycastDistance instead.

Provides functionality to interact with the LiDAR mod.

LiDAR Replacement#

A LiDAR casts a fan of rays from its part. SpaceCenter.RaycastDistance casts one ray. This example casts 8 rays below the root part of the active vessel:

using System;
using System.Collections.Generic;
using System.Linq;
using KRPC.Client;
using KRPC.Client.Services.SpaceCenter;

class RaycastExample
{
    public static void Main ()
    {
        using (var connection = new Connection ("Raycast Example")) {
            var sc = connection.SpaceCenter ();
            var part = sc.ActiveVessel.Parts.Root;
            var frame = part.ReferenceFrame;

            // A fan of 8 rays below the part, 10 degrees apart
            var origin = Tuple.Create (0.0, 0.0, 0.0);
            var directions = new List<Tuple<double, double, double>> ();
            for (int i = 0; i < 8; i++) {
                var angle = (10 * i - 35) * Math.PI / 180;
                directions.Add (Tuple.Create (
                    Math.Sin (angle), -Math.Cos (angle), 0.0));
            }

            // Cast every ray in the same physics tick
            var distances = connection.AddStream (
                () => directions.Select (
                    d => sc.RaycastDistance (origin, d, frame)).ToList ());
            foreach (var distance in distances.Get ())
                Console.WriteLine (distance);
        }
    }
}

The function stream casts every ray in the same physics tick, as a LiDAR does.