@@ -54,10 +54,10 @@ class SetPositionTargetLocalNEDMixin
54
54
std::is_base_of<plugin::Plugin, D>::value,
55
55
" SetPositionTargetLocalNEDMixin should be used by mavros::plugin::Plugin child" );
56
56
57
- plugin::UASPtr uas_ = static_cast <D *>(this )->uas ;
57
+ auto uas = static_cast <D *>(this )->uas_ . lock () ;
58
58
59
59
mavlink::common::msg::SET_POSITION_TARGET_LOCAL_NED sp = {};
60
- uas_ ->msg_set_target (sp);
60
+ uas ->msg_set_target (sp);
61
61
62
62
// [[[cog:
63
63
// for f in ('time_boot_ms', 'coordinate_frame', 'type_mask', 'yaw', 'yaw_rate'):
@@ -82,7 +82,7 @@ class SetPositionTargetLocalNEDMixin
82
82
sp.afz = af.z ();
83
83
// [[[end]]] (checksum: f8942bb13a7463a2cbadc9b745df25d0)
84
84
85
- uas_ ->send_message (sp);
85
+ uas ->send_message (sp);
86
86
}
87
87
};
88
88
@@ -106,10 +106,10 @@ class SetPositionTargetGlobalIntMixin
106
106
std::is_base_of<plugin::Plugin, D>::value,
107
107
" SetPositionTargetGlobalIntMixin should be used by mavros::plugin::Plugin child" );
108
108
109
- plugin::UASPtr uas_ = static_cast <D *>(this )->uas ;
109
+ plugin::UASPtr uas = static_cast <D *>(this )->uas_ . lock () ;
110
110
111
111
mavlink::common::msg::SET_POSITION_TARGET_GLOBAL_INT sp = {};
112
- uas_ ->msg_set_target (sp);
112
+ uas ->msg_set_target (sp);
113
113
114
114
// [[[cog:
115
115
// for f in ('time_boot_ms', 'coordinate_frame', 'type_mask',
@@ -135,7 +135,7 @@ class SetPositionTargetGlobalIntMixin
135
135
sp.afz = af.z ();
136
136
// [[[end]]] (checksum: 82301ecd7936657d65e006cf7525e82a)
137
137
138
- uas_ ->send_message (sp);
138
+ uas ->send_message (sp);
139
139
}
140
140
};
141
141
@@ -158,11 +158,11 @@ class SetAttitudeTargetMixin
158
158
std::is_base_of<plugin::Plugin, D>::value,
159
159
" SetAttitudeTargetMixin should be used by mavros::plugin::Plugin child" );
160
160
161
- plugin::UASPtr uas_ = static_cast <D *>(this )->uas ;
161
+ plugin::UASPtr uas = static_cast <D *>(this )->uas_ . lock () ;
162
162
163
163
mavlink::common::msg::SET_ATTITUDE_TARGET sp = {};
164
164
165
- uas_ ->msg_set_target (sp);
165
+ uas ->msg_set_target (sp);
166
166
mavros::ftf::quaternion_to_mavlink (orientation, sp.q );
167
167
168
168
// [[[cog:
@@ -179,7 +179,7 @@ class SetAttitudeTargetMixin
179
179
sp.body_yaw_rate = body_rate.z ();
180
180
// [[[end]]] (checksum: d0910b0f92d233024163ebf957a3d642)
181
181
182
- uas_ ->send_message (sp);
182
+ uas ->send_message (sp);
183
183
}
184
184
};
185
185
@@ -211,28 +211,29 @@ class TF2ListenerMixin
211
211
auto tf_transform_cb = std::bind (cbp, base, std::placeholders::_1);
212
212
213
213
auto timer_callback = [this , base, tf_transform_cb]() -> void {
214
- plugin::UASPtr _uas = base->uas ;
214
+ plugin::UASPtr uas = base->uas_ . lock () ;
215
215
std::string & _frame_id = base->tf_frame_id ;
216
216
std::string & _child_frame_id = base->tf_child_frame_id ;
217
- if (_uas ->tf2_buffer .canTransform (
217
+ if (uas ->tf2_buffer .canTransform (
218
218
_frame_id, _child_frame_id, tf2::TimePoint (),
219
219
tf2::durationFromSec (3.0 )))
220
220
{
221
221
try {
222
- auto transform = _uas ->tf2_buffer .lookupTransform (
222
+ auto transform = uas ->tf2_buffer .lookupTransform (
223
223
_frame_id, _child_frame_id, tf2::TimePoint (), tf2::durationFromSec (3.0 ));
224
224
tf_transform_cb (transform);
225
225
} catch (tf2::LookupException & ex) {
226
226
RCLCPP_ERROR (
227
- _uas ->get_logger (), " %s: %s" , tf_thd_name.c_str (),
227
+ uas ->get_logger (), " %s: %s" , tf_thd_name.c_str (),
228
228
ex.what ());
229
229
}
230
230
}
231
231
};
232
232
233
+ auto uas = base->uas_ .lock ();
233
234
timer_ =
234
235
create_timer (
235
- base->node , base-> uas ->get_clock (),
236
+ base->node , uas->get_clock (),
236
237
rclcpp::Duration::from_seconds (1.0 / base->tf_rate ), timer_callback);
237
238
}
238
239
0 commit comments