Skip to content

Commit f8e488f

Browse files
tobifalkcassava
authored andcommitted
noisy_sensor: Add trigger for noise activation
1 parent d21fbd7 commit f8e488f

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

plugins/noisy_sensor/src/noisy_lane_sensor.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <cloe/plugin.hpp> // for EXPORT_CLOE_PLUGIN
3434
#include <cloe/registrar.hpp> // for Registrar
3535
#include <cloe/sync.hpp> // for Sync
36+
#include <cloe/trigger/set_action.hpp> // for actions::SetVariableActionFactory
3637
#include "noise_data.hpp" // for NoiseData, NoiseConf
3738

3839
namespace cloe {
@@ -240,6 +241,8 @@ class NoisyLaneBoundarySensor : public LaneBoundarySensor {
240241
void enroll(Registrar& r) override {
241242
r.register_action(std::make_unique<actions::ConfigureFactory>(
242243
&config_, "config", "configure noisy lane component"));
244+
r.register_action<actions::SetVariableActionFactory<bool>>(
245+
"noise_activation", "switch sensor noise on/off", "enable", &config_.enabled);
243246
}
244247

245248
protected:

plugins/noisy_sensor/src/noisy_object_sensor.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <cloe/plugin.hpp> // for EXPORT_CLOE_PLUGIN
3333
#include <cloe/registrar.hpp> // for Registrar
3434
#include <cloe/sync.hpp> // for Sync
35+
#include <cloe/trigger/set_action.hpp> // for actions::SetVariableActionFactory
3536
#include "noise_data.hpp" // for NoiseData, NoiseConf
3637

3738
namespace cloe {
@@ -210,6 +211,8 @@ class NoisyObjectSensor : public ObjectSensor {
210211
void enroll(Registrar& r) override {
211212
r.register_action(std::make_unique<actions::ConfigureFactory>(
212213
&config_, "config", "configure noisy object component"));
214+
r.register_action<actions::SetVariableActionFactory<bool>>(
215+
"noise_activation", "switch sensor noise on/off", "enable", &config_.enabled);
213216
}
214217

215218
protected:

tests/config_vtd_infinite.json

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"name": "noisy_object_sensor",
9393
"from": "cloe::default_world_sensor",
9494
"args": {
95+
"enable": false,
9596
"noise": [
9697
{
9798
"target": "translation",
@@ -111,6 +112,7 @@
111112
"name": "noisy_lane_sensor",
112113
"from": "cloe::default_lane_sensor",
113114
"args": {
115+
"enable": true,
114116
"noise": [
115117
{
116118
"target": "dy_start",

tests/config_vtd_smoketest.json

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"label": "Vehicle default should not reach 50 km/h with the vtd binding and basic controller.",
3030
"event": "default_speed/kmph=>50.0", "action": "fail"
3131
},
32+
{"event": "time=25", "action": {"name": "noisy_lane_sensor/noise_activation", "enable": false}},
33+
{"event": "time=25", "action": "noisy_object_sensor/noise_activation=true"},
3234
{"event": "time=60", "action": "succeed"}
3335
]
3436
}

0 commit comments

Comments
 (0)