srunner/scenariomanager/scenarioatomics/atomic_behaviors.py
def update(self):
        """
        keeps track of gap and update the controller accordingly
        """
        try:
            check_actors = operator.attrgetter("ActorsWithController")
            actor_dict = check_actors(py_trees.blackboard.Blackboard())
        except AttributeError:
            pass

        if not actor_dict or self._actor.id not in actor_dict:
            return py_trees.common.Status.FAILURE

        if actor_dict[self._actor.id].get_last_longitudinal_command() != self._start_time:
            return py_trees.common.Status.SUCCESS

        new_status = py_trees.common.Status.RUNNING

        actor_velocity = CarlaDataProvider.get_velocity(self._actor)
        reference_velocity = CarlaDataProvider.get_velocity(self._reference_actor)

        gap = sr_tools.scenario_helper.get_distance_between_actors(self._actor, self._reference_actor,
                                                                   distance_type="longitudinal",
                                                                   freespace=self._freespace,
                                                                   global_planner=self._global_rp)
        actor_transform = CarlaDataProvider.get_transform(self._actor)
        ref_actor_transform = CarlaDataProvider.get_transform(self._reference_actor)
        if is_within_distance(ref_actor_transform, actor_transform, float('inf'), [0, 90]) and \
                operator.le(gap, self._gap):
            try:
                factor = abs(actor_velocity - reference_velocity)/actor_velocity
                if actor_velocity > reference_velocity:
                    actor_velocity = actor_velocity - (factor*actor_velocity)
                elif actor_velocity < reference_velocity and operator.gt(gap, self._gap):
                    actor_velocity = actor_velocity + (factor*actor_velocity)
            except ZeroDivisionError:
                pass
            actor_dict[self._actor.id].update_target_speed(actor_velocity)

            if not self._continues:
                if operator.le(gap, self._gap):
                    new_status = py_trees.common.Status.SUCCESS
        else:
            actor_dict[self._actor.id].update_target_speed(self.max_speed)

        self.logger.debug("%s.update()[%s->%s]" % (self.__class__.__name__, self.status, new_status))
        return new_status

        keeps track of gap and update the controller accordingly
        
keeps track of gap and update the controller accordingly
keeps track of gap and update the controller accordingly
def update(self):
        try:
            check_actors = operator.attrgetter("ActorsWithController")
            actor_dict = check_actors(py_trees.blackboard.Blackboard())
        except AttributeError:
            pass
        if not actor_dict or self._actor.id not in actor_dict:
            return py_trees.common.Status.FAILURE
        if actor_dict[self._actor.id].get_last_longitudinal_command() != self._start_time:
            return py_trees.common.Status.SUCCESS
        new_status = py_trees.common.Status.RUNNING
        actor_velocity = CarlaDataProvider.get_velocity(self._actor)
        reference_velocity = CarlaDataProvider.get_velocity(self._reference_actor)
        gap = sr_tools.scenario_helper.get_distance_between_actors(self._actor, self._reference_actor,
                                                                   distance_type="longitudinal",
                                                                   freespace=self._freespace,
                                                                   global_planner=self._global_rp)
        actor_transform = CarlaDataProvider.get_transform(self._actor)
        ref_actor_transform = CarlaDataProvider.get_transform(self._reference_actor)
        if is_within_distance(ref_actor_transform, actor_transform, float('inf'), [0, 90]) and \
                operator.le(gap, self._gap):
            try:
                factor = abs(actor_velocity - reference_velocity)/actor_velocity
                if actor_velocity > reference_velocity:
                    actor_velocity = actor_velocity - (factor*actor_velocity)
                elif actor_velocity < reference_velocity and operator.gt(gap, self._gap):
                    actor_velocity = actor_velocity + (factor*actor_velocity)
            except ZeroDivisionError:
                pass
            actor_dict[self._actor.id].update_target_speed(actor_velocity)
            if not self._continues:
                if operator.le(gap, self._gap):
                    new_status = py_trees.common.Status.SUCCESS
        else:
            actor_dict[self._actor.id].update_target_speed(self.max_speed)
        self.logger.debug("%s.update()[%s->%s]" % (self.__class__.__name__, self.status, new_status))
        return new_status
def update ( self ) : try : check_actors = operator . attrgetter ( "ActorsWithController" ) actor_dict = check_actors ( py_trees . blackboard . Blackboard ( ) ) except AttributeError : pass if not actor_dict or self . _actor . id not in actor_dict : return py_trees . common . Status . FAILURE if actor_dict [ self . _actor . id ] . get_last_longitudinal_command ( ) != self . _start_time : return py_trees . common . Status . SUCCESS new_status = py_trees . common . Status . RUNNING actor_velocity = CarlaDataProvider . get_velocity ( self . _actor ) reference_velocity = CarlaDataProvider . get_velocity ( self . _reference_actor ) gap = sr_tools . scenario_helper . get_distance_between_actors ( self . _actor , self . _reference_actor , distance_type = "longitudinal" , freespace = self . _freespace , global_planner = self . _global_rp ) actor_transform = CarlaDataProvider . get_transform ( self . _actor ) ref_actor_transform = CarlaDataProvider . get_transform ( self . _reference_actor ) if is_within_distance ( ref_actor_transform , actor_transform , float ( 'inf' ) , [ 0 , 90 ] ) and operator . le ( gap , self . _gap ) : try : factor = abs ( actor_velocity - reference_velocity ) / actor_velocity if actor_velocity > reference_velocity : actor_velocity = actor_velocity - ( factor * actor_velocity ) elif actor_velocity < reference_velocity and operator . gt ( gap , self . _gap ) : actor_velocity = actor_velocity + ( factor * actor_velocity ) except ZeroDivisionError : pass actor_dict [ self . _actor . id ] . update_target_speed ( actor_velocity ) if not self . _continues : if operator . le ( gap , self . _gap ) : new_status = py_trees . common . Status . SUCCESS else : actor_dict [ self . _actor . id ] . update_target_speed ( self . max_speed ) self . logger . debug ( "%s.update()[%s->%s]" % ( self . __class__ . __name__ , self . status , new_status ) ) return new_status
keeps track of gap and update the controller accordingly
keeps track of gap and update the controller accordingly
"""
        keeps track of gap and update the controller accordingly
        """
self