1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ from typing import List
16+ from typing import Union
1517
1618from launch import Action
1719from launch .frontend import Entity
1820from launch .frontend import expose_action
1921from launch .frontend import Parser
2022from launch .launch_context import LaunchContext
23+ from launch .some_substitutions_type import SomeSubstitutionsType
24+ from launch .substitution import Substitution
25+ from launch .utilities .type_utils import normalize_typed_substitution
26+ from launch .utilities .type_utils import perform_typed_substitution
2127
2228from launch_ros .ros_adapters import get_ros_node
2329
@@ -30,32 +36,33 @@ class SetUseSimTime(Action):
3036
3137 def __init__ (
3238 self ,
33- value : bool ,
39+ value : Union [ bool , SomeSubstitutionsType ] ,
3440 ** kwargs
3541 ) -> None :
3642 """Create a SetUseSimTime action."""
3743 super ().__init__ (** kwargs )
38- self .__value = value
44+ self .__value = normalize_typed_substitution ( value , bool )
3945
4046 @classmethod
4147 def parse (cls , entity : Entity , parser : Parser ):
4248 """Return `SetUseSimTime` action and kwargs for constructing it."""
4349 _ , kwargs = super ().parse (entity , parser )
44- kwargs ['value' ] = parser .parse_substitution (entity .get_attr ('value' ))
50+ kwargs ['value' ] = parser .parse_if_substitutions (entity .get_attr ('value' , data_type = bool ))
4551 return cls , kwargs
4652
4753 @property
48- def value (self ) -> bool :
54+ def value (self ) -> List [ Substitution ] :
4955 """Getter for value."""
5056 return self .__value
5157
5258 def execute (self , context : LaunchContext ):
5359 """Execute the action."""
60+ value = perform_typed_substitution (context , self .value , bool )
5461 node = get_ros_node (context )
5562 param = Parameter (
5663 'use_sim_time' ,
5764 Parameter .Type .BOOL ,
58- self . value
65+ value ,
5966 )
6067 node .set_parameters ([param ])
6168 if not node .get_parameter ('use_sim_time' ).get_parameter_value ().bool_value :
0 commit comments