Skip to content

Commit 83ee4d5

Browse files
clssncassava
authored andcommitted
virtue: Add safety event
1 parent c672e06 commit 83ee4d5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

plugins/virtue/src/virtue.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ namespace controller {
4242
namespace events {
4343

4444
DEFINE_NIL_EVENT(Failure, "failure", "assertion failure in simulation")
45-
DEFINE_NIL_EVENT(Collision, "collision", "collision detected in simulation")
4645
DEFINE_NIL_EVENT(Irrational, "irrational", "irrational behavior in simulation")
46+
DEFINE_NIL_EVENT(Unsafe, "unsafe", "safety critical behavior in simulation")
4747

4848
} // namespace events
4949

@@ -166,6 +166,13 @@ class SafetyChecker : public Checker {
166166
prev_step_ = s.step();
167167
}
168168

169+
void enroll(Registrar& r) override { callback_ = r.register_event<events::UnsafeFactory>(); }
170+
171+
void fail(const Sync& s, std::string&& name, Json&& j) override {
172+
callback_->trigger(s);
173+
Checker::fail(s, std::move(name), std::move(j));
174+
}
175+
169176
void check(const Sync& s, const Vehicle& v) override {
170177
auto ego =
171178
utility::EgoSensorCanon(v.get<const EgoSensor>(CloeComponent::GROUNDTRUTH_EGO_SENSOR));
@@ -226,6 +233,8 @@ class SafetyChecker : public Checker {
226233
// State:
227234
double prev_mps_{0.0};
228235
size_t prev_step_{0};
236+
237+
std::shared_ptr<events::UnsafeCallback> callback_;
229238
};
230239

231240
struct VirtueConfiguration : public Confable {

0 commit comments

Comments
 (0)