Skip to content

Commit 04cfdb6

Browse files
author
Jan Nörtemann
committed
Fix: Time and Duration use uint instead of int like roscpp
1 parent 52189ff commit 04cfdb6

File tree

17 files changed

+291
-230
lines changed

17 files changed

+291
-230
lines changed

Uml.Robotics.Ros.MessageBase/TimeData.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ public struct TimeData
66
{
77
public static readonly TimeData Zero = new TimeData(0, 0);
88

9-
public uint sec;
10-
public uint nsec;
9+
public int sec;
10+
public int nsec;
1111

12-
public TimeData(uint s, uint ns)
12+
public TimeData(int s, int ns)
1313
{
1414
sec = s;
1515
nsec = ns;
@@ -39,7 +39,7 @@ public static TimeData FromTicks(ulong ticks)
3939
{
4040
ulong seconds = (((ulong)Math.Floor(1.0 * ticks / TimeSpan.TicksPerSecond)));
4141
ulong nanoseconds = 100 * (ticks % TimeSpan.TicksPerSecond);
42-
return new TimeData((uint)seconds, (uint)nanoseconds);
42+
return new TimeData((int)seconds, (int)nanoseconds);
4343
}
4444

4545
public static TimeData FromTimeSpan(TimeSpan value)

Uml.Robotics.Ros.MessageBase/actionlib_msgs/GoalID.cs

+18-12
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
using System.Text;
55
using System.Runtime.InteropServices;
66
using Uml.Robotics.Ros;
7+
78
using Messages.std_msgs;
89

910
namespace Messages.actionlib_msgs
1011
{
1112
public class GoalID : RosMessage
1213
{
14+
1315
public Time stamp = new Time();
1416
public string id = "";
1517

18+
1619
public override string MD5Sum() { return "302881f31927c1df708a2dbab0e80ee8"; }
1720
public override bool HasHeader() { return false; }
1821
public override bool IsMetaType() { return false; }
@@ -23,6 +26,7 @@ public class GoalID : RosMessage
2326

2427
public GoalID()
2528
{
29+
2630
}
2731

2832
public GoalID(byte[] serializedMessage)
@@ -35,15 +39,17 @@ public GoalID(byte[] serializedMessage, ref int currentIndex)
3539
Deserialize(serializedMessage, ref currentIndex);
3640
}
3741

42+
43+
3844
public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
3945
{
4046
int piecesize = 0;
4147

4248
//stamp
4349
stamp = new Time(new TimeData(
44-
BitConverter.ToUInt32(serializedMessage, currentIndex),
45-
BitConverter.ToUInt32(serializedMessage, currentIndex+Marshal.SizeOf(typeof(System.Int32)))));
46-
currentIndex += 2*Marshal.SizeOf(typeof(System.Int32));
50+
BitConverter.ToInt32(serializedMessage, currentIndex),
51+
BitConverter.ToInt32(serializedMessage, currentIndex + Marshal.SizeOf(typeof(System.Int32)))));
52+
currentIndex += 2 * Marshal.SizeOf(typeof(System.Int32));
4753
//id
4854
id = "";
4955
piecesize = BitConverter.ToInt32(serializedMessage, currentIndex);
@@ -70,12 +76,12 @@ public override byte[] Serialize(bool partofsomethingelse)
7076
Array.Copy(scratch2, thischunk, 4);
7177
pieces.Add(thischunk);
7278
// combine every array in pieces into one array and return it
73-
int __a_b__f = pieces.Sum((__a_b__c)=>__a_b__c.Length);
74-
int __a_b__e=0;
79+
int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
80+
int __a_b__e = 0;
7581
byte[] __a_b__d = new byte[__a_b__f];
76-
foreach(var __p__ in pieces)
82+
foreach (var __p__ in pieces)
7783
{
78-
Array.Copy(__p__,0,__a_b__d,__a_b__e,__p__.Length);
84+
Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
7985
__a_b__e += __p__.Length;
8086
}
8187
return __a_b__d;
@@ -89,8 +95,8 @@ public override void Randomize()
8995

9096
//stamp
9197
stamp = new Time(new TimeData(
92-
Convert.ToUInt32(rand.Next()),
93-
Convert.ToUInt32(rand.Next())));
98+
Convert.ToInt32(rand.Next()),
99+
Convert.ToInt32(rand.Next())));
94100
//id
95101
strlength = rand.Next(100) + 1;
96102
strbuf = new byte[strlength];
@@ -104,12 +110,12 @@ public override void Randomize()
104110

105111
public override bool Equals(RosMessage ____other)
106112
{
113+
if (____other == null)
114+
return false;
115+
bool ret = true;
107116
var other = ____other as Messages.actionlib_msgs.GoalID;
108117
if (other == null)
109118
return false;
110-
111-
bool ret = true;
112-
113119
ret &= stamp.data.Equals(other.stamp.data);
114120
ret &= id == other.id;
115121
// for each SingleType st:

Uml.Robotics.Ros.MessageBase/actionlib_msgs/GoalStatus.cs

+24-20
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ namespace Messages.actionlib_msgs
99
{
1010
public class GoalStatus : RosMessage
1111
{
12-
public const byte PENDING = 0;
13-
public const byte ACTIVE = 1;
14-
public const byte PREEMPTED = 2;
15-
public const byte SUCCEEDED = 3;
16-
public const byte ABORTED = 4;
17-
public const byte REJECTED = 5;
18-
public const byte PREEMPTING = 6;
19-
public const byte RECALLING = 7;
20-
public const byte RECALLED = 8;
21-
public const byte LOST = 9;
2212

13+
public const byte PENDING = 0;
14+
public const byte ACTIVE = 1;
15+
public const byte PREEMPTED = 2;
16+
public const byte SUCCEEDED = 3;
17+
public const byte ABORTED = 4;
18+
public const byte REJECTED = 5;
19+
public const byte PREEMPTING = 6;
20+
public const byte RECALLING = 7;
21+
public const byte RECALLED = 8;
22+
public const byte LOST = 9;
2323
public Messages.actionlib_msgs.GoalID goal_id = new Messages.actionlib_msgs.GoalID();
24-
public byte status = new byte();
24+
public byte status;
2525
public string text = "";
2626

27+
2728
public override string MD5Sum() { return "d388f9b87b3c471f784434d671988d4a"; }
2829
public override bool HasHeader() { return false; }
2930
public override bool IsMetaType() { return true; }
@@ -45,6 +46,7 @@ uint8 status
4546

4647
public GoalStatus()
4748
{
49+
4850
}
4951

5052
public GoalStatus(byte[] serializedMessage)
@@ -57,14 +59,16 @@ public GoalStatus(byte[] serializedMessage, ref int currentIndex)
5759
Deserialize(serializedMessage, ref currentIndex);
5860
}
5961

62+
63+
6064
public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
6165
{
6266
int piecesize = 0;
6367

6468
//goal_id
6569
goal_id = new Messages.actionlib_msgs.GoalID(serializedMessage, ref currentIndex);
6670
//status
67-
status=serializedMessage[currentIndex++];
71+
status = serializedMessage[currentIndex++];
6872
//text
6973
text = "";
7074
piecesize = BitConverter.ToInt32(serializedMessage, currentIndex);
@@ -94,12 +98,12 @@ public override byte[] Serialize(bool partofsomethingelse)
9498
Array.Copy(scratch2, thischunk, 4);
9599
pieces.Add(thischunk);
96100
// combine every array in pieces into one array and return it
97-
int __a_b__f = pieces.Sum((__a_b__c)=>__a_b__c.Length);
98-
int __a_b__e=0;
101+
int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
102+
int __a_b__e = 0;
99103
byte[] __a_b__d = new byte[__a_b__f];
100-
foreach(var __p__ in pieces)
104+
foreach (var __p__ in pieces)
101105
{
102-
Array.Copy(__p__,0,__a_b__d,__a_b__e,__p__.Length);
106+
Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
103107
__a_b__e += __p__.Length;
104108
}
105109
return __a_b__d;
@@ -117,7 +121,7 @@ public override void Randomize()
117121
//status
118122
myByte = new byte[1];
119123
rand.NextBytes(myByte);
120-
status= myByte[0];
124+
status = myByte[0];
121125
//text
122126
strlength = rand.Next(100) + 1;
123127
strbuf = new byte[strlength];
@@ -131,12 +135,12 @@ public override void Randomize()
131135

132136
public override bool Equals(RosMessage ____other)
133137
{
138+
if (____other == null)
139+
return false;
140+
bool ret = true;
134141
var other = ____other as Messages.actionlib_msgs.GoalStatus;
135142
if (other == null)
136143
return false;
137-
138-
bool ret = true;
139-
140144
ret &= goal_id.Equals(other.goal_id);
141145
ret &= status == other.status;
142146
ret &= text == other.text;

Uml.Robotics.Ros.MessageBase/actionlib_msgs/GoalStatusArray.cs

+32-25
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
using System.Linq;
44
using System.Runtime.InteropServices;
55
using Uml.Robotics.Ros;
6-
using Messages.std_msgs;
76

87
namespace Messages.actionlib_msgs
98
{
109
public class GoalStatusArray : RosMessage
1110
{
12-
public Header header = new Header();
13-
public GoalStatus[] status_list;
11+
12+
public Messages.std_msgs.Header header = new Messages.std_msgs.Header();
13+
public Messages.actionlib_msgs.GoalStatus[] status_list;
14+
1415

1516
public override string MD5Sum() { return "8b2b82f13216d0a8ea88bd3af735e619"; }
1617
public override bool HasHeader() { return true; }
@@ -22,6 +23,7 @@ public class GoalStatusArray : RosMessage
2223

2324
public GoalStatusArray()
2425
{
26+
2527
}
2628

2729
public GoalStatusArray(byte[] serializedMessage)
@@ -34,24 +36,27 @@ public GoalStatusArray(byte[] serializedMessage, ref int currentIndex)
3436
Deserialize(serializedMessage, ref currentIndex);
3537
}
3638

39+
40+
3741
public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
3842
{
3943
int arraylength = -1;
4044
bool hasmetacomponents = false;
4145

4246
//header
43-
header = new Header(serializedMessage, ref currentIndex);
47+
header = new Messages.std_msgs.Header(serializedMessage, ref currentIndex);
4448
//status_list
45-
hasmetacomponents |= false;
49+
hasmetacomponents |= true;
4650
arraylength = BitConverter.ToInt32(serializedMessage, currentIndex);
4751
currentIndex += Marshal.SizeOf(typeof(System.Int32));
4852
if (status_list == null)
49-
status_list = new GoalStatus[arraylength];
53+
status_list = new Messages.actionlib_msgs.GoalStatus[arraylength];
5054
else
5155
Array.Resize(ref status_list, arraylength);
52-
for (int i=0;i<status_list.Length; i++) {
56+
for (int i = 0; i < status_list.Length; i++)
57+
{
5358
//status_list[i]
54-
status_list[i] = new GoalStatus(serializedMessage, ref currentIndex);
59+
status_list[i] = new Messages.actionlib_msgs.GoalStatus(serializedMessage, ref currentIndex);
5560
}
5661
}
5762

@@ -62,26 +67,27 @@ public override byte[] Serialize(bool partofsomethingelse)
6267

6368
//header
6469
if (header == null)
65-
header = new Header();
70+
header = new Messages.std_msgs.Header();
6671
pieces.Add(header.Serialize(true));
6772
//status_list
68-
hasmetacomponents |= false;
73+
hasmetacomponents |= true;
6974
if (status_list == null)
70-
status_list = new GoalStatus[0];
75+
status_list = new Messages.actionlib_msgs.GoalStatus[0];
7176
pieces.Add(BitConverter.GetBytes(status_list.Length));
72-
for (int i=0;i<status_list.Length; i++) {
77+
for (int i = 0; i < status_list.Length; i++)
78+
{
7379
//status_list[i]
7480
if (status_list[i] == null)
75-
status_list[i] = new GoalStatus();
81+
status_list[i] = new Messages.actionlib_msgs.GoalStatus();
7682
pieces.Add(status_list[i].Serialize(true));
7783
}
7884
// combine every array in pieces into one array and return it
79-
int __a_b__f = pieces.Sum((__a_b__c)=>__a_b__c.Length);
80-
int __a_b__e=0;
85+
int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
86+
int __a_b__e = 0;
8187
byte[] __a_b__d = new byte[__a_b__f];
82-
foreach(var __p__ in pieces)
88+
foreach (var __p__ in pieces)
8389
{
84-
Array.Copy(__p__,0,__a_b__d,__a_b__e,__p__.Length);
90+
Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
8591
__a_b__e += __p__.Length;
8692
}
8793
return __a_b__d;
@@ -93,33 +99,34 @@ public override void Randomize()
9399
Random rand = new Random();
94100

95101
//header
96-
header = new Header();
102+
header = new Messages.std_msgs.Header();
97103
header.Randomize();
98104
//status_list
99105
arraylength = rand.Next(10);
100106
if (status_list == null)
101-
status_list = new GoalStatus[arraylength];
107+
status_list = new Messages.actionlib_msgs.GoalStatus[arraylength];
102108
else
103109
Array.Resize(ref status_list, arraylength);
104-
for (int i=0;i<status_list.Length; i++) {
110+
for (int i = 0; i < status_list.Length; i++)
111+
{
105112
//status_list[i]
106-
status_list[i] = new GoalStatus();
113+
status_list[i] = new Messages.actionlib_msgs.GoalStatus();
107114
status_list[i].Randomize();
108115
}
109116
}
110117

111118
public override bool Equals(RosMessage ____other)
112119
{
120+
if (____other == null)
121+
return false;
122+
bool ret = true;
113123
var other = ____other as Messages.actionlib_msgs.GoalStatusArray;
114124
if (other == null)
115125
return false;
116-
117-
bool ret = true;
118-
119126
ret &= header.Equals(other.header);
120127
if (status_list.Length != other.status_list.Length)
121128
return false;
122-
for (int __i__=0; __i__ < status_list.Length; __i__++)
129+
for (int __i__ = 0; __i__ < status_list.Length; __i__++)
123130
{
124131
ret &= status_list[__i__].Equals(other.status_list[__i__]);
125132
}

0 commit comments

Comments
 (0)