Skip to main content

Install AR51.Net and Run Your First Program

Add AR51.Net to a .NET project, connect to your AR 51 system, and print the people it tracks — in about five minutes. When you finish, you'll have a console app that prints every tracked person's hip position, live.

Before you start​

You need:

  • The .NET 8 SDK or later.
  • A running AR 51 system with tracking started, reachable from your computer over the local network (same subnet for automatic discovery).
  • Someone in the capture area — skeletons arrive only while a person is tracked.
  • Outgoing UDP 1500 and TCP to the AR 51 machines allowed by your firewall (see the checklist).

1. Create a project​

dotnet new console -n MyAr51App
cd MyAr51App

2. Add the AR51.Net package​

dotnet add package AR51.Net

That's it — the package and its dependencies come from nuget.org. There are no native libraries to install. Adding the package means you accept the AR51.Net license; Visual Studio shows it for you to accept.

Can't use nuget.org? Install from the download page instead

AR51.Net is also on the AR 51 download page.

  1. Download AR51.Net (3.0.3.2R) — the file AR51.Net.3.0.302.nupkg.

  2. In your project folder, create a folder named packages and put the file in it.

  3. Next to your project file, add a file named nuget.config:

    nuget.config
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="ar51" value="packages" />
    </packageSources>
    <packageSourceMapping>
    <packageSource key="ar51">
    <package pattern="AR51.*" />
    </packageSource>
    <packageSource key="nuget.org">
    <package pattern="*" />
    </packageSource>
    </packageSourceMapping>
    </configuration>
  4. Add the package:

    dotnet add package AR51.Net

The nuget.config makes AR51.* packages come only from your packages folder. AR51.Net's few dependencies (Google.Protobuf, Grpc.Net.Client, Microsoft.Extensions.Logging.Abstractions) still come from nuget.org; on a computer with no internet at all, those must already be in its package cache. To update later, put the new .nupkg in packages and change the version in your project file.

Your project file then looks like this:

MyAr51App.csproj
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AR51.Net" Version="3.0.302" />
</ItemGroup>

</Project>

TargetFramework is your SDK's version — net8.0 on the .NET 8 SDK, net10.0 on .NET 10. AR51.Net supports both.

3. Write the program​

Replace Program.cs with:

Program.cs
// Connect to the AR 51 system and print the skeletons that arrive. Press Ctrl+C to quit.
using AR51.Net;

await using IAR51Client ar51 = AR51Client.Create(); // finds the AR 51 server on the local network

ar51.Skeletons.SkeletonReceived += (_, e) =>
{
Skeleton skeleton = e.Skeleton;
Console.WriteLine($"{skeleton.Id}: hips at {skeleton.GetPosition(Joint.MidHip)} m");
};

Console.WriteLine("Looking for the AR 51 server...");
await ar51.StartAsync();
Console.WriteLine($"Connected to {ar51.ServerEndPoint}. Press Ctrl+C to quit.");

using var quit = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) => { e.Cancel = true; quit.Cancel(); };
try { await Task.Delay(Timeout.Infinite, quit.Token); } catch (OperationCanceledException) { }

View this sample on Bitbucket — clone the samples repository to run it.

AR51Client.Create() makes a client that finds the AR 51 server on your local network by itself. StartAsync returns once it's connected; from then on SkeletonReceived fires for every tracked person, many times per second.

4. Run it​

dotnet run

The program finds the server and connects — this is a real run on Linux:

Looking for the AR 51 server...
Connected to 192.168.0.199:1501. Press Ctrl+C to quit.

The address is your AR 51 server's. Then, while someone is in the tracked area, one line per tracked person arrives many times per second, in the form <id>: hips at <X, Y, Z> m. The first lines can appear just before Connected to …. If no skeleton lines arrive, nobody is being tracked yet — see the checklist below. Press Ctrl+C to quit.

No live system? Use the emulator

The Mocap Studio emulator replays recorded captures and streams them as if a live system were running, so you can develop and test without cameras or people in the area. It streams skeletons and objects only: servers, cameras, calibration, recording and devices aren't available.

First-run checklist​

If nothing arrives, check these in order:

  1. The AR 51 system is running and tracking — check in Mocap Studio, or list the machines with ar51.Servers.
  2. Same network. Your computer is on the same local network (subnet) as the AR 51 machines. If it isn't, connect to a fixed host.
  3. Firewall. Your computer allows outgoing UDP on port 1500 (discovery) and TCP to the AR 51 machines (port 1501 and the ports the system assigns to its services).
  4. Someone is in view. Skeletons arrive only while a person is in the tracked area.
  5. One client. Create one IAR51Client for the whole application and dispose it at the end (await using).

Still stuck? See Troubleshooting.

Get all the samples​

Every guide ends with a complete program. They're all in the AR51.Net samples repository, ready to run — clone it and dotnet run any of them. It also includes a full web dashboard sample.

git clone https://bitbucket.org/ar51/ar51-net-samples.git

Next steps​

Was this page helpful?