- Creator: Bakustar (獏☆)
- Release: 2017/July/23
Contents
- Overview
- How to use in .NET
- How to use in Unity
- Contact
UArmDotNet
is the library to use uArm Swift in .NET, Mono, and Unity application.
User of this library can:
- Call uArm gCode APIs written in Quick Start Guide, by
async/await
manner, via SerialPort communication. - Check raw send/recv message conten
Below is the example to use beep API.
using System.Threading.Tasks;
using Baku.UArmDotNet;
namespace HelloUArm
{
class Program
{
static void Main(string[] args)
{
MainTask().Wait();
}
static async Task MainTask()
{
// port name depends on the environment
// NOTE: UArmSearch class supports (and also be an example) to search uArm's serial port name
var uArm = new UArm("COM1");
uArm.Connector.Connect();
// HACK: currently dummy data must be sent for the first message...
uArm.Connector.Post("dummy");
// 440Hz, 1000ms beep for hello world
await uArm.BeepAsync(440, 1000);
uArm.Connector.Disconnect();
}
}
}
See ExampleUArmDotNet project, in which almost all API is used.
See ExampleUArmDotNet project, to understand how the APIs are wrapped.
You can use the UArmDotNet in Unity 2017, by following step.
- In
File>Build Settings>Player Settings
:- Set scripting runtime version to
Experimental(.NET 4.6 Equivalent)
- Set scripting runtime version to
- Add the UArmDotNet source file folders to the asset. The folder structure will be like:
- UArmDotNet
- Connector
- Core
- DataTypes
- UArmDotNet
And there are some points to remember when use UArmDotNet
in Unity.
- uArm's XYZ coordinate correspondes to Unity's XZY, NOT XYZ directly.
- UArmDotNet (and original uArm gCode also) uses milimeter the unit of length, while Unity is based on meter expression.
- Unity has some thread constraints to do
async/await
in main thread. In some cases you have to cache game layer data (liketransform.position
) to other variable, and use it fromasync
function in which you operate uArm Swift.