mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
switch from Unity version control to git
This commit is contained in:
35
Assets/ControlLibrary/ControlLibrary.cs
Normal file
35
Assets/ControlLibrary/ControlLibrary.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using Google.FlatBuffers;
|
||||
|
||||
public class ControlLibrary : MonoBehaviour
|
||||
{
|
||||
[DllImport("libcontrol")]
|
||||
public static extern void init();
|
||||
|
||||
[DllImport("libcontrol")]
|
||||
public static extern void cleanup();
|
||||
|
||||
[DllImport("libcontrol")]
|
||||
public static extern int send_angle_control(int module_id, int angle);
|
||||
|
||||
[DllImport("libcontrol")]
|
||||
private static extern IntPtr get_configuration(out int module_id); // the data this points to will be invalidated when called again
|
||||
|
||||
|
||||
public static Frontend.RobotConfiguration getRobotConfiguration() // this is not thread safe
|
||||
{
|
||||
int size;
|
||||
IntPtr ptr = get_configuration(out size);
|
||||
|
||||
byte[] buffer = new byte[size];
|
||||
Marshal.Copy(ptr, buffer, 0, size);
|
||||
|
||||
ByteBuffer bb = new ByteBuffer(buffer);
|
||||
var myObject = Frontend.RobotConfiguration.GetRootAsRobotConfiguration(bb);
|
||||
return myObject;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user