make slightly resilient to missing sensors
This commit is contained in:
parent
c817430c6d
commit
f216ebd6db
|
@ -39,7 +39,7 @@ class FixedDutyCycle(controllers.Controller):
|
|||
|
||||
def fixed_duty_wrapper(args):
|
||||
name, duty, period = stringify(args.car, quote=False), args.cdr.car, args.cdr.cdr.car
|
||||
print('name, duty, period', name, duty, period)
|
||||
print('name, duty, period', name, duty*100, period)
|
||||
return (name, FixedDutyCycle(
|
||||
target=None, # reach_period_s=60*60,
|
||||
duty_perc=duty*100, period=period,
|
||||
|
|
|
@ -126,9 +126,13 @@ class State():
|
|||
for sensor in self.envdata.get('sensors', ()):
|
||||
_, ctrl, target = self.envdata['sensors'][sensor]
|
||||
self.envdata['sensors'][sensor] = (get_sensor_value(sensor), ctrl, target)
|
||||
print(self.envdata)
|
||||
# Apply actuators
|
||||
for controller in self.envdata.get('controllers', {}).keys():
|
||||
ctrl = self.envdata['controllers'][controller]
|
||||
if ctrl.input_label not in self.envdata['sensors'].keys():
|
||||
print(f'Missing sensor {ctrl.input_label}')
|
||||
continue
|
||||
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
|
||||
if self.check():
|
||||
if self.next() is None:
|
||||
|
|
Loading…
Reference in New Issue