Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 25 additions & 32 deletions com.unity.robotics.ros-tcp-connector/Editor/ROSSettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,38 @@ protected virtual void OnGUI()
}
}

prefab.ConnectOnStart = EditorGUILayout.Toggle("Connect on Startup", prefab.ConnectOnStart);

EditorGUILayout.LabelField("Settings for a new ROSConnection.instance", EditorStyles.boldLabel);
prefab.rosIPAddress = EditorGUILayout.TextField("ROS IP Address", prefab.rosIPAddress);
prefab.rosPort = EditorGUILayout.IntField("ROS Port", prefab.rosPort);
prefab.RosIPAddress = EditorGUILayout.TextField("ROS IP Address", prefab.RosIPAddress);
prefab.RosPort = EditorGUILayout.IntField("ROS Port", prefab.RosPort);
EditorGUILayout.Space();
prefab.overrideUnityIP = EditorGUILayout.TextField(
new GUIContent("Override Unity IP Address", "If blank, determine IP automatically."),
prefab.overrideUnityIP);
prefab.unityPort = EditorGUILayout.IntField("Unity Port", prefab.unityPort);
if ((prefab.overrideUnityIP != "" && !ROSConnection.IPFormatIsCorrect(prefab.overrideUnityIP)))
{
EditorGUILayout.HelpBox("Unity Override IP invalid", MessageType.Warning);
}

if(!ROSConnection.IPFormatIsCorrect(prefab.rosIPAddress))
if (!ROSConnection.IPFormatIsCorrect(prefab.RosIPAddress))
{
EditorGUILayout.HelpBox("ROS IP is invalid", MessageType.Warning);
}

EditorGUILayout.Space();
EditorGUILayout.LabelField("If awaiting a service response:", EditorStyles.boldLabel);
prefab.awaitDataMaxRetries = EditorGUILayout.IntField(
new GUIContent("Max Service Retries",
"While waiting for a service to respond, check this many times before giving up."),
prefab.awaitDataMaxRetries);
prefab.awaitDataSleepSeconds = EditorGUILayout.FloatField(
new GUIContent("Sleep (seconds)",
"While waiting for a service to respond, wait this many seconds between checks."),
prefab.awaitDataSleepSeconds);
prefab.readChunkSize = EditorGUILayout.IntField(
new GUIContent("Read chunk size",
"While reading received messages, read this many bytes at a time."),
prefab.readChunkSize);
prefab.awaitDataReadRetry = EditorGUILayout.IntField(
new GUIContent("Max Read retries",
"While waiting to read a full message, check this many times before giving up."),
prefab.awaitDataReadRetry);
prefab.timeoutOnIdle = EditorGUILayout.FloatField(
new GUIContent("Timeout on idle (seconds)",
"If no messages have been sent for this long, close the connection."),
prefab.timeoutOnIdle);

prefab.ShowHud = EditorGUILayout.Toggle("Show HUD", prefab.ShowHud);

EditorGUILayout.Space();

prefab.KeepaliveTime = EditorGUILayout.FloatField(
new GUIContent("KeepAlive time (secs)",
"If no other messages are being sent, test the connection this often. (The longer this time is, the longer it will take for ROSConnection to notice the Endpoint has stopped responding)."),
prefab.KeepaliveTime);

prefab.NetworkTimeoutSeconds = EditorGUILayout.FloatField(
new GUIContent("Network timeout (secs)",
"If a network message takes this long to send, assume the connection has failed. (The longer this time is, the longer it will take for ROSConnection to notice the Endpoint has stopped responding)."),
prefab.NetworkTimeoutSeconds);

prefab.SleepTimeSeconds = EditorGUILayout.FloatField(
new GUIContent("Sleep time (secs)",
"Sleep this long before checking for new network messages. (Decreasing this time will make it respond faster, but consume more CPU)."),
prefab.SleepTimeSeconds);

if (GUI.changed)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//Do not edit! This file was generated by Unity-ROS MessageGeneration.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Unity.Robotics.ROSTCPConnector.MessageGeneration;

namespace RosMessageTypes.RosTcpEndpoint
{
public class MRosUnitySrvMessage : Message
{
public const string RosMessageName = "ros_tcp_endpoint/RosUnitySrvMessage";

public int srv_id;
public bool is_request;
public string topic;
public byte[] payload;

public MRosUnitySrvMessage()
{
this.srv_id = 0;
this.is_request = false;
this.topic = "";
this.payload = new byte[0];
}

public MRosUnitySrvMessage(int srv_id, bool is_request, string topic, byte[] payload)
{
this.srv_id = srv_id;
this.is_request = is_request;
this.topic = topic;
this.payload = payload;
}
public override List<byte[]> SerializationStatements()
{
var listOfSerializations = new List<byte[]>();
listOfSerializations.Add(BitConverter.GetBytes(this.srv_id));
listOfSerializations.Add(BitConverter.GetBytes(this.is_request));
listOfSerializations.Add(SerializeString(this.topic));

listOfSerializations.Add(BitConverter.GetBytes(payload.Length));
listOfSerializations.Add(this.payload);

return listOfSerializations;
}

public override int Deserialize(byte[] data, int offset)
{
this.srv_id = BitConverter.ToInt32(data, offset);
offset += 4;
this.is_request = BitConverter.ToBoolean(data, offset);
offset += 1;
var topicStringBytesLength = DeserializeLength(data, offset);
offset += 4;
this.topic = DeserializeString(data, offset, topicStringBytesLength);
offset += topicStringBytesLength;

var payloadArrayLength = DeserializeLength(data, offset);
offset += 4;
this.payload= new byte[payloadArrayLength];
for(var i = 0; i < payloadArrayLength; i++)
{
this.payload[i] = data[offset];
offset += 1;
}

return offset;
}

public override string ToString()
{
return "MRosUnitySrvMessage: " +
"\nsrv_id: " + srv_id.ToString() +
"\nis_request: " + is_request.ToString() +
"\ntopic: " + topic.ToString() +
"\npayload: " + System.String.Join(", ", payload.ToList());
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Loading