File tree Expand file tree Collapse file tree 2 files changed +61
-5
lines changed Expand file tree Collapse file tree 2 files changed +61
-5
lines changed Original file line number Diff line number Diff line change @@ -62,26 +62,35 @@ enum class PostCond
62
62
COUNT_
63
63
};
64
64
65
+ template <>
66
+ std::string toStr<BT::PostCond>(BT::PostCond status);
67
+
68
+ template <>
69
+ std::string toStr<BT::PreCond>(BT::PreCond status);
70
+
65
71
using ScriptingEnumsRegistry = std::unordered_map<std::string, int >;
66
72
67
73
struct NodeConfig
68
74
{
69
75
NodeConfig ()
70
76
{}
71
77
78
+ // Pointer to the blackboard used by this node
72
79
Blackboard::Ptr blackboard;
80
+ // List of enums available for scripting
73
81
std::shared_ptr<ScriptingEnumsRegistry> enums;
82
+ // input ports
74
83
PortsRemapping input_ports;
84
+ // output ports
75
85
PortsRemapping output_ports;
76
86
77
87
std::map<PreCond, std::string> pre_conditions;
78
88
std::map<PostCond, std::string> post_conditions;
79
89
};
80
90
81
- #ifdef USE_BTCPP3_OLD_NAMES
82
91
// back compatibility
83
92
using NodeConfiguration = NodeConfig;
84
- # endif
93
+
85
94
86
95
template <typename T>
87
96
inline constexpr bool hasNodeNameCtor ()
@@ -360,7 +369,7 @@ inline Result TreeNode::getInput(const std::string& key, T& destination) const
360
369
return nonstd::make_unexpected (" getInput(): trying to access an invalid Blackboard" );
361
370
}
362
371
363
- std::unique_lock<std::mutex> entry_lock (config_.blackboard ->entryMutex ());
372
+ std::unique_lock entry_lock (config_.blackboard ->entryMutex ());
364
373
const Any* val = config_.blackboard ->getAny (static_cast <std::string>(remapped_key));
365
374
if (val && !val->empty ())
366
375
{
Original file line number Diff line number Diff line change @@ -170,8 +170,19 @@ void TreeNode::checkPostConditions(NodeStatus status)
170
170
171
171
void TreeNode::resetStatus ()
172
172
{
173
- std::unique_lock<std::mutex> lock (state_mutex_);
174
- status_ = NodeStatus::IDLE;
173
+ NodeStatus prev_status;
174
+ {
175
+ std::unique_lock<std::mutex> lock (state_mutex_);
176
+ prev_status = status_;
177
+ status_ = NodeStatus::IDLE;
178
+ }
179
+
180
+ if (prev_status != NodeStatus::IDLE)
181
+ {
182
+ state_condition_variable_.notify_all ();
183
+ state_change_signal_.notify (std::chrono::high_resolution_clock::now (), *this ,
184
+ prev_status, NodeStatus::IDLE);
185
+ }
175
186
}
176
187
177
188
NodeStatus TreeNode::status () const
@@ -323,4 +334,40 @@ void TreeNode::modifyPortsRemapping(const PortsRemapping& new_remapping)
323
334
}
324
335
}
325
336
337
+ template <>
338
+ std::string toStr<PreCond>(PreCond pre)
339
+ {
340
+ switch (pre)
341
+ {
342
+ case PreCond::SUCCESS_IF:
343
+ return " _successIf" ;
344
+ case PreCond::FAILURE_IF:
345
+ return " _failureIf" ;
346
+ case PreCond::SKIP_IF:
347
+ return " _skipIf" ;
348
+ case PreCond::WHILE_TRUE:
349
+ return " _while" ;
350
+ default :
351
+ return " Undefined" ;
352
+ }
353
+ }
354
+
355
+ template <>
356
+ std::string toStr<PostCond>(PostCond pre)
357
+ {
358
+ switch (pre)
359
+ {
360
+ case PostCond::ON_SUCCESS:
361
+ return " _onSuccess" ;
362
+ case PostCond::ON_FAILURE:
363
+ return " _onFailure" ;
364
+ case PostCond::ALWAYS:
365
+ return " _post" ;
366
+ case PostCond::ON_HALTED:
367
+ return " _onHalted" ;
368
+ default :
369
+ return " Undefined" ;
370
+ }
371
+ }
372
+
326
373
} // namespace BT
You can’t perform that action at this time.
0 commit comments