mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
Merge branch 'main' of https://git.uwaterloo.ca/capstone-group2/ui into main
This commit is contained in:
@@ -17,7 +17,7 @@ public class ControlLibrary : MonoBehaviour
|
||||
public static extern int send_angle_control(int module_id, int angle);
|
||||
|
||||
[DllImport("libc_control")]
|
||||
private static extern IntPtr get_configuration(out int module_id); // the data this points to will be invalidated when called again
|
||||
private static extern IntPtr get_configuration(out int module_id, int leader_id); // the data this points to will be invalidated when called again
|
||||
|
||||
[DllImport("libc_control")]
|
||||
public static extern int send_string_control(int module_id, string s);
|
||||
@@ -41,11 +41,27 @@ public class ControlLibrary : MonoBehaviour
|
||||
[DllImport("libc_control")]
|
||||
public static extern void control_sentry_shutdown();
|
||||
|
||||
[DllImport("libc_control")]
|
||||
private static extern IntPtr get_leaders(out int length);
|
||||
|
||||
public static Frontend.RobotConfiguration getRobotConfiguration() // this is not thread safe
|
||||
public static int[] getRobotLeaders() {
|
||||
int length;
|
||||
IntPtr ptr = get_leaders(out length);
|
||||
|
||||
byte[] bytes = new byte[length];
|
||||
Marshal.Copy(ptr, bytes, 0, length);
|
||||
|
||||
int[] ints = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ints[i] = bytes[i];
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
public static Frontend.RobotConfiguration getRobotConfiguration(int leader_id) // this is not thread safe
|
||||
{
|
||||
int size;
|
||||
IntPtr ptr = get_configuration(out size);
|
||||
IntPtr ptr = get_configuration(out size, leader_id);
|
||||
|
||||
byte[] buffer = new byte[size];
|
||||
Marshal.Copy(ptr, buffer, 0, size);
|
||||
|
||||
Binary file not shown.
@@ -62,7 +62,7 @@ public class TopologyBuilder : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
RobotConfiguration config = ControlLibrary.getRobotConfiguration();
|
||||
RobotConfiguration config = ControlLibrary.getRobotConfiguration(100); // todo: change to actual leader id
|
||||
int moduleCount = config.ModulesLength;
|
||||
for (int i = 0; i < moduleCount; i++)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ public class TopologyBuilder : MonoBehaviour
|
||||
Debug.Log("Adding module " + module.Id);
|
||||
ModuleType moduleType = Enum.Parse<ModuleType>(module.ModuleType.ToString());
|
||||
float degree = module.ConfigurationAsMotorState().Angle;
|
||||
if (moduleType == ModuleType.SERVO_1 || moduleType == moduleType.SERVO_2)
|
||||
if (moduleType == ModuleType.SERVO_1 || moduleType == ModuleType.SERVO_2)
|
||||
{
|
||||
degree = 90;
|
||||
}
|
||||
@@ -93,7 +93,8 @@ public class TopologyBuilder : MonoBehaviour
|
||||
if (n_connection != null)
|
||||
{
|
||||
var connection = n_connection.Value;
|
||||
Debug.Log("orientation: " + connection.Orientation);
|
||||
if (connection.FromSocket == 0) { continue; }
|
||||
Debug.Log("Connection: from (socket): " + connection.FromModuleId + " (" + connection.FromSocket + ")" + " to " + connection.ToModuleId + " ("+ connection.ToSocket + ")" + " orientation: " + connection.Orientation);
|
||||
graph.Connections.Add(new Connection
|
||||
{
|
||||
FromModuleId = connection.FromModuleId,
|
||||
|
||||
Reference in New Issue
Block a user