@@ -15,7 +15,7 @@ use std::collections::HashMap;
1515use std:: convert:: { TryFrom , TryInto } ;
1616use std:: sync:: Arc ;
1717use unified_planning as up;
18- use unified_planning:: Assignment ;
18+ use unified_planning:: { Assignment , TimedEffect } ;
1919use up:: atom:: Content ;
2020use up:: effect_expression:: EffectKind ;
2121use up:: metric:: MetricKind ;
@@ -211,6 +211,7 @@ pub fn problem_to_chronicles(problem: &Problem) -> Result<aries_planning::chroni
211211 let mut factory = ChronicleFactory :: new ( & mut context, init_ch, Container :: Base , vec ! [ ] ) ;
212212
213213 factory. add_initial_state ( & problem. initial_state ) ?;
214+ factory. add_timed_effects ( & problem. timed_effects ) ?;
214215 factory. add_goals ( & problem. goals ) ?;
215216
216217 if let Some ( hierarchy) = & problem. hierarchy {
@@ -572,6 +573,33 @@ impl<'a> ChronicleFactory<'a> {
572573 Ok ( ( ) )
573574 }
574575
576+ fn add_timed_effects ( & mut self , timed_effects : & [ TimedEffect ] ) -> Result < ( ) , Error > {
577+ for timed_eff in timed_effects {
578+ let at = timed_eff
579+ . occurrence_time
580+ . as_ref ( )
581+ . context ( "Missing time on timed-effect" ) ?;
582+ let at = self . read_timing ( at) ?;
583+ let span = Span :: interval ( at, at + FAtom :: EPSILON ) ;
584+ let eff = timed_eff. effect . as_ref ( ) . context ( "Missing effect in timed-effect" ) ?;
585+
586+ let sv = eff
587+ . fluent
588+ . as_ref ( )
589+ . with_context ( || format ! ( "Effect expression has no fluent: {eff:?}" ) ) ?;
590+
591+ let value = eff
592+ . value
593+ . as_ref ( )
594+ . with_context ( || format ! ( "Effect has no value: {eff:?}" ) ) ?;
595+
596+ let effect_kind =
597+ EffectKind :: from_i32 ( eff. kind ) . with_context ( || format ! ( "Unknown effect kind: {}" , eff. kind) ) ?;
598+ self . add_effect ( span, sv, value, effect_kind) ?;
599+ }
600+ Ok ( ( ) )
601+ }
602+
575603 /// Goals are translated to conditions at the chronicle end time
576604 fn add_goals ( & mut self , goals : & [ up:: Goal ] ) -> Result < ( ) , Error > {
577605 for goal in goals {
0 commit comments