forked from vislab-tecnico-lisboa/KinectBody2Yarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKinectTrackedPeopleMessage.h
217 lines (193 loc) · 7.22 KB
/
KinectTrackedPeopleMessage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// This is an automatically generated file.
// Generated from this KinectTrackedPeopleMessage.msg definition:
// # Message header for Kinect tracked people's message
// #
// #
//
// # The floor plane
// FloorPlane floorPlane
//
// # The tracked people
// Body[] bodies
//
// #Two-integer timestamp that is expressed as:
// # * header.stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
// # * header.stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
// # The other fields of header are always zero
// std_msgs/Header header
//
// Instances of this class can be read and written with YARP ports,
// using a ROS-compatible format.
#ifndef YARPMSG_TYPE_KinectTrackedPeopleMessage
#define YARPMSG_TYPE_KinectTrackedPeopleMessage
#include <string>
#include <vector>
#include <yarp/os/Wire.h>
#include <yarp/os/idl/WireTypes.h>
#include "FloorPlane.h"
#include "geometry_msgs_Point.h"
#include "geometry_msgs_Quaternion.h"
#include "geometry_msgs_Pose.h"
#include "JointROSmsg.h"
#include "Body.h"
#include "TickTime.h"
#include "std_msgs_Header.h"
class KinectTrackedPeopleMessage : public yarp::os::idl::WirePortable {
public:
FloorPlane floorPlane;
std::vector<Body> bodies;
std_msgs_Header header;
KinectTrackedPeopleMessage() {
}
bool readBare(yarp::os::ConnectionReader& connection) {
// *** floorPlane ***
if (!floorPlane.read(connection)) return false;
// *** bodies ***
int len = connection.expectInt();
bodies.resize(len);
for (int i=0; i<len; i++) {
if (!bodies[i].read(connection)) return false;
}
// *** header ***
if (!header.read(connection)) return false;
return !connection.isError();
}
bool readBottle(yarp::os::ConnectionReader& connection) {
connection.convertTextMode();
yarp::os::idl::WireReader reader(connection);
if (!reader.readListHeader(3)) return false;
// *** floorPlane ***
if (!floorPlane.read(connection)) return false;
// *** bodies ***
if (connection.expectInt()!=BOTTLE_TAG_LIST) return false;
int len = connection.expectInt();
bodies.resize(len);
for (int i=0; i<len; i++) {
if (!bodies[i].read(connection)) return false;
}
// *** header ***
if (!header.read(connection)) return false;
return !connection.isError();
}
bool read(yarp::os::ConnectionReader& connection) {
if (connection.isBareMode()) return readBare(connection);
return readBottle(connection);
}
bool writeBare(yarp::os::ConnectionWriter& connection) {
// *** floorPlane ***
if (!floorPlane.write(connection)) return false;
// *** bodies ***
connection.appendInt(bodies.size());
for (size_t i=0; i<bodies.size(); i++) {
if (!bodies[i].write(connection)) return false;
}
// *** header ***
if (!header.write(connection)) return false;
return !connection.isError();
}
bool writeBottle(yarp::os::ConnectionWriter& connection) {
connection.appendInt(BOTTLE_TAG_LIST);
connection.appendInt(3);
// *** floorPlane ***
if (!floorPlane.write(connection)) return false;
// *** bodies ***
connection.appendInt(BOTTLE_TAG_LIST);
connection.appendInt(bodies.size());
for (size_t i=0; i<bodies.size(); i++) {
if (!bodies[i].write(connection)) return false;
}
// *** header ***
if (!header.write(connection)) return false;
connection.convertTextMode();
return !connection.isError();
}
bool write(yarp::os::ConnectionWriter& connection) {
if (connection.isBareMode()) return writeBare(connection);
return writeBottle(connection);
}
// This class will serialize ROS style or YARP style depending on protocol.
// If you need to force a serialization style, use one of these classes:
typedef yarp::os::idl::BareStyle<KinectTrackedPeopleMessage> rosStyle;
typedef yarp::os::idl::BottleStyle<KinectTrackedPeopleMessage> bottleStyle;
// Give source text for class, ROS will need this
yarp::os::ConstString getTypeText() {
return "# Message header for Kinect tracked people's message\n\
#\n\
#\n\
\n\
# The floor plane\n\
FloorPlane floorPlane\n\
\n\
# The tracked people\n\
Body[] bodies\n\
\n\
#Two-integer timestamp that is expressed as:\n\
# * header.stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
# * header.stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
# The other fields of header are always zero\n\
std_msgs/Header header\n\
\n================================================================================\n\
MSG: FloorPlane\n\
# This represents the floor plane.\n\
#\n\
#Floor Determination\n\
#Each skeleton frame also contains a floor-clipping-plane vector, which contains the coefficients of an estimated floor-plane equation. The skeleton tracking system updates this estimate for each frame and uses it as a clipping plane for removing the background and segmenting players. The general plane equation is:\n\
# Ax + By + Cz + D = 0\n\
# \n\
#where:\n\
# A = vFloorClipPlane.x\n\
# B = vFloorClipPlane.y\n\
# C = vFloorClipPlane.z\n\
# D = vFloorClipPlane.w\n\
# \n\
#The equation is normalized so that the physical interpretation of D is the height of the camera from the floor, in meters. Note that the floor might not always be visible or detectable. In this case, the floor clipping plane is a zero vector.\n\
#The floor clipping plane is used in the vFloorClipPlane member of the NUI_SKELETON_FRAME structure (for C++) and in the FloorClipPlane property in managed code.\n\
\n\
float64 x\n\
float64 y\n\
float64 z\n\
float64 w\n================================================================================\n\
MSG: Body\n\
# A tracked person\n\
\n\
# The person's track ID, usually very large numbers, converted to string just because historical reasons\n\
string trackID\n\
\n\
# The 25 joints to be tracked that compose a person\n\
JointROSmsg[25] joints\n================================================================================\n\
MSG: JointROSmsg\n\
# A body joint that is tracked by kinect\n\
\n\
# The joint number and description\n\
int64 typeNum\n\
string typeStr\n\
\n\
# Position in space and orientation\n\
geometry_msgs/Pose pose\n\
\n================================================================================\n\
MSG: geometry_msgs/Pose\n\
geometry_msgs/Point position\n\
geometry_msgs/Quaternion orientation\n================================================================================\n\
MSG: geometry_msgs/Point\n\
float64 x\n\
float64 y\n\
float64 z\n================================================================================\n\
MSG: geometry_msgs/Quaternion\n\
float64 x\n\
float64 y\n\
float64 z\n\
float64 w\n================================================================================\n\
MSG: std_msgs/Header\n\
uint32 seq\n\
time stamp\n\
string frame_id";
}
// Name the class, ROS will need this
yarp::os::Type getType() {
yarp::os::Type typ = yarp::os::Type::byName("KinectTrackedPeopleMessage","KinectTrackedPeopleMessage");
typ.addProperty("md5sum",yarp::os::Value("cfea7ab13a7f712a0dd20a9761106322"));
typ.addProperty("message_definition",yarp::os::Value(getTypeText()));
return typ;
}
};
#endif