@@ -36,9 +36,13 @@ class gz::sensors::LogicalCameraSensorPrivate
36
36
// / \brief node to create publisher
37
37
public: transport::Node node;
38
38
39
+ public: transport::Node node_logic;
40
+
39
41
// / \brief publisher to publish logical camera messages.
40
42
public: transport::Node::Publisher pub;
41
43
44
+ public: transport::Node::Publisher pub_logic;
45
+
42
46
// / \brief true if Load() has been called and was successful
43
47
public: bool initialized = false ;
44
48
@@ -56,6 +60,8 @@ class gz::sensors::LogicalCameraSensorPrivate
56
60
57
61
// / \brief Msg containg info on models detected by logical camera
58
62
msgs::LogicalCameraImage msg;
63
+
64
+ msgs::LogicalCameraSensor msg_logic;
59
65
};
60
66
61
67
// ////////////////////////////////////////////////
@@ -104,18 +110,28 @@ bool LogicalCameraSensor::Load(sdf::ElementPtr _sdf)
104
110
return false ;
105
111
106
112
if (this ->Topic ().empty ())
107
- this ->SetTopic (" /logical_camera " );
113
+ this ->SetTopic (" /camera/logical " );
108
114
109
115
this ->dataPtr ->pub =
110
116
this ->dataPtr ->node .Advertise <msgs::LogicalCameraImage>(
111
117
this ->Topic ());
112
118
119
+ this ->dataPtr ->pub_logic =
120
+ this ->dataPtr ->node_logic .Advertise <msgs::LogicalCameraSensor>(
121
+ this ->Topic () + " /frustum" );
122
+
113
123
if (!this ->dataPtr ->pub )
114
124
{
115
125
gzerr << " Unable to create publisher on topic[" << this ->Topic () << " ].\n " ;
116
126
return false ;
117
127
}
118
128
129
+ if (!this ->dataPtr ->pub_logic )
130
+ {
131
+ gzerr << " Unable to create publisher on topic[" << this ->Topic () << " ].\n " ;
132
+ return false ;
133
+ }
134
+
119
135
gzdbg << " Logical images for [" << this ->Name () << " ] advertised on ["
120
136
<< this ->Topic () << " ]" << std::endl;
121
137
@@ -166,9 +182,22 @@ bool LogicalCameraSensor::Update(
166
182
frame->set_key (" frame_id" );
167
183
frame->add_value (this ->FrameId ());
168
184
185
+ *this ->dataPtr ->msg_logic .mutable_header ()->mutable_stamp () = msgs::Convert (_now);
186
+ this ->dataPtr ->msg_logic .mutable_header ()->clear_data ();
187
+ auto frame_log = this ->dataPtr ->msg_logic .mutable_header ()->add_data ();
188
+
189
+ frame_log->set_key (" frame_id" );
190
+ frame_log->add_value (this ->FrameId ());
191
+
169
192
// publish
193
+ this ->dataPtr ->msg_logic .set_near_clip (this ->dataPtr ->frustum .Near ());
194
+ this ->dataPtr ->msg_logic .set_far_clip (this ->dataPtr ->frustum .Far ());
195
+ this ->dataPtr ->msg_logic .set_horizontal_fov (this ->dataPtr ->frustum .FOV ().Radian ());
196
+ this ->dataPtr ->msg_logic .set_aspect_ratio (this ->dataPtr ->frustum .AspectRatio ());
170
197
this ->AddSequence (this ->dataPtr ->msg .mutable_header ());
198
+
171
199
this ->dataPtr ->pub .Publish (this ->dataPtr ->msg );
200
+ this ->dataPtr ->pub_logic .Publish (this ->dataPtr ->msg_logic );
172
201
173
202
return true ;
174
203
}
@@ -207,6 +236,6 @@ msgs::LogicalCameraImage LogicalCameraSensor::Image() const
207
236
// ////////////////////////////////////////////////
208
237
bool LogicalCameraSensor::HasConnections () const
209
238
{
210
- return this ->dataPtr ->pub && this ->dataPtr ->pub .HasConnections ();
239
+ return this ->dataPtr ->pub_logic && this ->dataPtr ->pub_logic .HasConnections ();
211
240
}
212
241
0 commit comments