class Roby::DeltaEvent

Generic implementation of events which emit when a given delta is reached in the state. Subclasses must implement the following methods:

#has_sample

must return true if the state variable can be read

#delta

must return the delta between the current value and the value at the last emission (last_value). The returned value must be comparable with threshold.

#read

must return the current value.

Attributes

last_value[R]

The last value for the considered state, the last time this event has been emitted

threshold[RW]

A value expressing the delta in state for which the event should be emitted.

Public Class Methods

event_types() click to toggle source

The set of event types which

# File lib/roby/state/events.rb, line 214
def self.event_types; @@event_types end
or(spec, base_event) click to toggle source
# File lib/roby/state/events.rb, line 244
def self.or(spec, base_event)
    new = State.on_delta(spec)
    result = OrGenerator.new
    result << base_event
    result << new
    result.on { |ev| result.reset }
    def result.or(spec); DeltaEvent.or(spec, self) end
    result
end
register_as(name) click to toggle source

Declare that the currently defined delta event has to be registered as a name option for StateSpace#on_delta. For instance, the TimeDeltaEvent is registered by using

class TimeDeltaEvent < DeltaEvent
  register_as :t
end

which allows to use it with

Roby.state.on_delta t: 10
# File lib/roby/state/events.rb, line 226
def self.register_as(name)
    event_types[name] = self
end

Public Instance Methods

or(spec) click to toggle source
# File lib/roby/state/events.rb, line 254
def or(spec)
    DeltaEvent.or(spec, self)
end
reset() click to toggle source

Reset last_value to the current value of the state variable, making the event emit at current_value + threshold

Calls superclass method Roby::StateEvent#reset
# File lib/roby/state/events.rb, line 239
def reset
    @last_value = read
    super
end