Skip to content

Commit 239d1fd

Browse files
authored
clad 2.1.0 sdk update (anki#5)
Updated for use with clad 2.1.0 - All robotIds removed from actions and connections - Connection satisfied with RobotState, rather than checking for robotId
1 parent ee385ba commit 239d1fd

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

clad_library/CladCSharp.dll

24 KB
Binary file not shown.

csharp_interface/cozmoInterface/action.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public class Action
2222
{
2323
private SdkConnection _connection = null;
2424
private ExternalInterface.QueueSingleAction _message = null;
25-
private byte _robotId = 0;
2625
private uint _id = 0;
2726
private bool _completed = false;
2827

@@ -31,10 +30,9 @@ public class Action
3130
public uint ID { get { return _id; } }
3231
public ExternalInterface.QueueSingleAction Message { get { return _message; } }
3332

34-
public Action(SdkConnection connection, byte robotId)
33+
public Action(SdkConnection connection)
3534
{
3635
_connection = connection;
37-
_robotId = robotId;
3836

3937
_id = _nextActionId;
4038
_nextActionId++;
@@ -46,7 +44,7 @@ public Action(SdkConnection connection, byte robotId)
4644

4745
public void Abort()
4846
{
49-
_connection.SendMessage(new ExternalInterface.CancelActionByIdTag(_id, _robotId));
47+
_connection.SendMessage(new ExternalInterface.CancelActionByIdTag(_id));
5048
}
5149

5250
public void MarkAsComplete()
@@ -67,7 +65,7 @@ public void Initialize<T>(T state, int numRetries, bool inParallel)
6765
Cozmo.QueueActionPosition position = inParallel ? Cozmo.QueueActionPosition.IN_PARALLEL : Cozmo.QueueActionPosition.NOW;
6866
ExternalInterface.RobotActionUnion action = new ExternalInterface.RobotActionUnion();
6967
action.Initialize(state);
70-
_message = new ExternalInterface.QueueSingleAction(robotID: _robotId, idTag: _id, numRetries: (byte)numRetries, position: position, action: action);
68+
_message = new ExternalInterface.QueueSingleAction(idTag: _id, numRetries: (byte)numRetries, position: position, action: action);
7169
}
7270
}
7371
} // namespace Cozmo

csharp_interface/cozmoInterface/connection.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ public class SdkConnection
3838
private Dictionary<System.Type, Dictionary<object, iCallback>> _callbacks = new Dictionary<System.Type, Dictionary<object, iCallback>>();
3939
private List<Action> _inFlightActions = new List<Action>();
4040
private bool _open = false;
41-
private byte _currentRobotId = byte.MaxValue;
42-
43-
public byte CurrentRobotId { get { return _currentRobotId; } }
41+
private bool _robotIsConnected = false;
4442

4543
public SdkConnection(string ip, int socket, bool verboseLogging = false)
4644
{
@@ -62,7 +60,7 @@ public SdkConnection(string ip, int socket, bool verboseLogging = false)
6260
_open = true;
6361

6462
// wait for robot
65-
while (_currentRobotId == byte.MaxValue)
63+
while (!_robotIsConnected)
6664
{
6765
Thread.Sleep(5);
6866
}
@@ -85,7 +83,7 @@ public void Close()
8583

8684
public Action SendAction<T>(T state, int numRetries = 0, bool inParallel = false)
8785
{
88-
Action result = new Action(this, _currentRobotId);
86+
Action result = new Action(this);
8987
result.Initialize(state, numRetries, inParallel);
9088

9189
_inFlightActions.Add(result);
@@ -136,7 +134,6 @@ private void SendMessageInternal(SDKMessageOut messageOut)
136134
private void ReceiveMessage(SDKMessageIn messageIn)
137135
{
138136
var message = messageIn.Message;
139-
140137
if (_verboseLogging) { System.Console.WriteLine("Recieved Message - " + message.GetTag()); }
141138

142139
// since the property to access individual message data in a CLAD message shares its name
@@ -154,13 +151,10 @@ private void ReceiveMessage(SDKMessageIn messageIn)
154151
}
155152
}
156153

157-
// does this give us a robot id?
158-
string robotIDPropertyName = "robotID";
159-
if (_currentRobotId == byte.MaxValue && messageData.GetType().GetProperty(robotIDPropertyName) != null)
154+
if (!_robotIsConnected && message.GetTag() == Anki.Cozmo.ExternalInterface.MessageEngineToGame.Tag.RobotState)
160155
{
161-
uint robotId = (uint)messageData.GetType().GetProperty(robotIDPropertyName).GetValue(messageData, null);
162-
_currentRobotId = (byte)robotId;
163-
System.Console.WriteLine("Robot connected with id " + _currentRobotId.ToString());
156+
_robotIsConnected = true;
157+
System.Console.WriteLine("Robot connected!");
164158
}
165159
}
166160

csharp_interface/cozmoInterface/version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Cozmo
2020
{
2121
public static class SDKVersion
2222
{
23-
public static readonly string _Data = "0.1.0";
23+
public static readonly string _Data = "0.4.0";
2424
}
2525
} // namespace Cozmo
2626
} // namespace Anki

0 commit comments

Comments
 (0)