def get_pickup_schedules(vehicle_id, user_id, pickup_route, current_time): targets = [ Target.new_target(vehicle_id, SIM_TAXI.NODE_NAME), Target.new_target(user_id, SIM_TAXI_USER.NODE_NAME) ] move_for_picking_up_schedule = Schedule.new_schedule( targets, SIM_TAXI.TRIGGER.MOVE, current_time, current_time + 1000, pickup_route) stop_for_picking_up_schedule = Schedule.new_schedule( targets, SIM_TAXI.TRIGGER.STOP, current_time + 1000, current_time + 1010, Route.new_point_route(pickup_route.goal_waypoint_id, pickup_route.arrow_codes[-1])) waiting_schedule = Schedule.new_schedule( targets, SIM_TAXI_USER.TRIGGER.WAIT, current_time, current_time + 1000, Route.new_point_route(pickup_route.goal_waypoint_id, pickup_route.arrow_codes[-1])) getting_on_schedule = Schedule.new_schedule( targets, SIM_TAXI_USER.TRIGGER.GET_ON, current_time + 1000, current_time + 1010, Route.new_point_route(pickup_route.goal_waypoint_id, pickup_route.arrow_codes[-1])) got_on_schedule = Schedule.new_schedule( targets, SIM_TAXI_USER.TRIGGER.GOT_ON, current_time + 1010, current_time + 1011, Route.new_point_route(pickup_route.goal_waypoint_id, pickup_route.arrow_codes[-1])) return [move_for_picking_up_schedule, stop_for_picking_up_schedule],\ [waiting_schedule, getting_on_schedule, got_on_schedule]
def get_carry_schedules(vehicle_id, user_id, carry_route, current_time): targets = [ Target.new_target(vehicle_id, SIM_TAXI.NODE_NAME), Target.new_target(user_id, SIM_TAXI_USER.NODE_NAME) ] move_for_discharging_schedules = Schedule.new_schedule( targets, SIM_TAXI.TRIGGER.MOVE, current_time, current_time + 1010, carry_route) stop_for_discharging_schedules = Schedule.new_schedule( targets, SIM_TAXI.TRIGGER.STOP, current_time + 1010, current_time + 1020, Route.new_point_route(carry_route.goal_waypoint_id, carry_route.arrow_codes[-1])) move_schedule = Schedule.new_schedule( targets, SIM_TAXI_USER.TRIGGER.MOVE_VEHICLE, current_time, current_time + 1010, carry_route) getting_out_schedule = Schedule.new_schedule( targets, SIM_TAXI_USER.TRIGGER.GET_OUT, current_time + 1010, current_time + 1020, Route.new_point_route(carry_route.goal_waypoint_id, carry_route.arrow_codes[-1])) got_out_schedule = Schedule.new_schedule( [Target.new_target(user_id, SIM_TAXI_USER.NODE_NAME)], SIM_TAXI_USER.TRIGGER.GOT_OUT, current_time + 1020, current_time + 1021, Route.new_point_route(carry_route.goal_waypoint_id, carry_route.arrow_codes[-1])) log_out_schedule = Schedule.new_schedule( [Target.new_target(user_id, SIM_TAXI_USER.NODE_NAME)], USER.TRIGGER.LOG_OUT, current_time + 1021, current_time + 1022, Route.new_point_route(carry_route.goal_waypoint_id, carry_route.arrow_codes[-1])) return [move_for_discharging_schedules, stop_for_discharging_schedules],\ [move_schedule, getting_out_schedule, got_out_schedule, log_out_schedule]
def set_bus_schedules(self, bus_schedules): self.__bus_schedules = bus_schedules for bus_schedules_id in self.__bus_schedules: self.relation.add_relation( Target.new_target(bus_schedules_id, SIM_BUS_FLEET.TARGET_GROUP.BUS_SCHEDULES), Target.new_target(None, SIM_BUS.NODE_NAME))
def get_unassigned_bus_schedule_target(self): targets = Target.new_targets( self.relation.get_related( Target.new_target(None, SIM_BUS.NODE_NAME))) if len(targets) == 0: return None return targets[0]
def __init__(self, _id): self.manager = Manager() self.event_loop_id = _id self.target = Target.new_target(self.event_loop_id, self.__class__.__name__) self.__subscribers = {} self.__subscribers_lock = self.manager.Lock() self.__publishers = {} self.__client = None self.__main_loop = None self.__pid = os.getpid() self.__topicPub = Topic() self.__topicPub.set_targets( Target.new_target(self.event_loop_id, EventLoop.__name__)) self.__topicPub.set_categories(EVENT_LOOP.TOPIC.CATEGORIES.RESPONSE) self.__topicSub = Topic() self.__topicSub.set_targets( None, Target.new_target(self.event_loop_id, EventLoop.__name__)) self.__topicSub.set_categories(EVENT_LOOP.TOPIC.CATEGORIES.REQUEST) self.__topicSub.set_message(EventLoopMessage) self.set_subscriber(self.__topicSub, self.on_event_loop_message) self.__user_data = None self.__user_will = None
def __init__(self, _id, name, waypoint, arrow, route, spot): super().__init__(_id, name, waypoint, arrow, route) self.waypoint = waypoint self.arrow = arrow self.route = route self.spot = spot self.relation = Relation() self.__bus_routes = {} self.__bus_schedules = {} self.bus_parkable_spots = self.spot.get_spots_of_target_group( Target.new_node_target(SimBus)) self.vehicle_statuses = self.manager.dict() self.vehicle_statuses_lock = self.manager.Lock() self.vehicle_schedules = {} self.vehicle_last_indices = {} self.bus_schedules = {} self.bus_stop_spots = {} self.state_machines = {} self.__topicPubVehicleSchedules = Topic() self.__topicPubVehicleSchedules.set_categories( FleetManager.CONST.TOPIC.CATEGORIES.SCHEDULES) self.__topicSubVehicleStatus = Topic() self.__topicSubVehicleStatus.set_targets( Target.new_target(None, SIM_BUS.NODE_NAME), None) self.__topicSubVehicleStatus.set_categories( Vehicle.CONST.TOPIC.CATEGORIES.STATUS) self.__topicSubVehicleStatus.set_message(VehicleStatus) self.set_subscriber(self.__topicSubVehicleStatus, self.update_vehicle_status)
def after_change_state_publish_new_bus_schedules(self, current_time, vehicle_id): target_vehicle = Target.new_target(vehicle_id, SIM_BUS.NODE_NAME) target_bus_schedule = self.get_unassigned_bus_schedule_target() vehicle_schedules = [] start_time = current_time move_to_circular_route_schedule, branch_index, part_type, part_index = \ self.get_move_to_circular_route_schedule( target_vehicle, target_bus_schedule, start_time) vehicle_schedules = \ Schedule.get_merged_schedules(vehicle_schedules, [move_to_circular_route_schedule]) start_time = vehicle_schedules[-1].period.end move_to_branch_point_schedules, branch_index, part_type, part_index = \ self.get_move_to_branch_point_schedules( target_vehicle, target_bus_schedule, start_time, branch_index, part_type, part_index) vehicle_schedules = \ Schedule.get_merged_schedules(vehicle_schedules, move_to_branch_point_schedules) self.vehicle_schedules[vehicle_id][0].period.end = current_time self.vehicle_schedules[vehicle_id] = \ Schedule.get_merged_schedules(self.vehicle_schedules[vehicle_id], vehicle_schedules) self.update_relation(target_bus_schedule, vehicle_id) self.after_change_state_update_last_indices(vehicle_id, branch_index, part_type, part_index) self.after_change_state_publish_schedules(vehicle_id) return True
def __init__(self, _id, name, waypoint, arrow, route, intersection, dt=1.0): super().__init__(_id, name, waypoint, arrow, route, intersection, dt=dt) self.state_machine = self.get_state_machine() self.user_statuses = self.manager.dict() self.user_statuses_lock = self.manager.Lock() self.__topicSubUserStatus = Topic() self.__topicSubUserStatus.set_targets( Target.new_target(None, SIM_BUS_USER.NODE_NAME), None) self.__topicSubUserStatus.set_categories(USER.TOPIC.CATEGORIES.STATUS) self.__topicSubUserStatus.set_message(UserStatus) self.set_subscriber(self.__topicSubUserStatus, self.update_user_status)
def __init__(self, _id, name, waypoint, arrow, route, dt=3.0): super().__init__(_id) self.status = FleetStatus.new_data(name=name, time=time(), state=FLEET_MANAGER.STATE.LOG_IN, relations={}) self.waypoint = waypoint self.arrow = arrow self.route = route self.relation = Relation() self.traffic_signals = self.manager.dict() self.state_machine = None self.dt = dt self.__pubTopicStatus = Topic() self.__pubTopicStatus.set_targets(self.target) self.__pubTopicStatus.set_categories( FLEET_MANAGER.TOPIC.CATEGORIES.STATUS) self.__topicSubTrafficSignalStatus = Topic() self.__topicSubTrafficSignalStatus.set_targets( Target.new_target(None, TRAFFIC_SIGNAL.NODE_NAME), None) self.__topicSubTrafficSignalStatus.set_categories( TRAFFIC_SIGNAL.TOPIC.CATEGORIES.STATUS) self.__topicSubTrafficSignalStatus.set_message(TrafficSignalStatus) self.set_subscriber(self.__topicSubTrafficSignalStatus, self.update_traffic_signal_status) self.set_main_loop(self.__main_loop)
def get_deploy_schedules(vehicle_id, carry_route, current_time): stand_by_schedules = Schedule.new_schedule( [ Target.new_target(vehicle_id, SIM_TAXI.NODE_NAME), ], SIM_TAXI.TRIGGER.STAND_BY, current_time, current_time + 86400, Route.new_point_route(carry_route.goal_waypoint_id, carry_route.arrow_codes[-1])) return [stand_by_schedules]
def condition_bus_arrived_at_target_bus_stop(target_bus_stop, vehicle_status): targets_vehicle_statuses = list( filter(lambda x: Target.is_same_id(x, target_bus_stop), vehicle_status.schedule.targets)) if 0 < len(targets_vehicle_statuses): if vehicle_status.schedule.event == SIM_BUS.TRIGGER.STOP: return True return False
def publish_status(self): self.status.relations = dict( map( lambda key: (Target.get_code(key), list(map(Target.get_code, self.relation.get_related(key)))), self.relation.get_keys())) payload = self.__pubTopicStatus.serialize(self.status) self.publish(self.__pubTopicStatus, payload)
def cleanup_status(self, user_statuses): user_ids = [] for user_id, user_status in user_statuses.items(): if SIM_TAXI_FLEET.TIMEOUT < time() - user_status.time: user_ids.append(user_id) for user_id in user_ids: self.relation.remove_relations_of( Target.new_target(user_id, SIM_TAXI_USER.NODE_NAME)) user_statuses.pop(user_id) self.user_schedules.pop(user_id)
def set_spots(self, spots): self.__spots = dict( map( lambda x: (x["ID"], Spot.new_spot( Target.new_targets(x["targets"]), Location.new_location(x["contact"]["waypointID"], x[ "contact"]["arrowCode"], x["contact"]["geohash"]), None, None)), spots))
def get_response_path(self, request_path): path = "/" + self.domain path += Topic.get_target_path_part(self.from_target) path += Topic.get_target_path_part( Target.new_target(*list(reversed(request_path.split("/")[2:4])))) path += "/" + "/".join( self.categories if self.categories is not None else "#") return path
def get_user_request_schedules(self, user_id, current_time): user_request_schedule = Schedule.new_schedule( [Target.new_target(user_id, SIM_TAXI_USER.NODE_NAME)], SIM_TAXI_USER.TRIGGER.REQUEST, current_time, current_time + 1, ) user_schedules = Schedule.get_merged_schedules( self.user_schedules[user_id], [user_request_schedule]) return user_schedules
def __init__(self, _id, name, waypoint, arrow, route, intersection, dt=1.0): super().__init__(_id, name, waypoint, arrow, route, dt=dt) self.state_machine = self.get_state_machine() self.velocity = None self.traffic_signals = self.manager.dict() self.traffic_signals_lock = self.manager.Lock() self.other_vehicle_locations = self.manager.dict() self.other_vehicle_locations_lock = self.manager.Lock() self.intersection = intersection self.__topicPubLocation = Topic() self.__topicPubLocation.set_targets( Target.new_target(self.target.id, SIM_CAR.NODE_NAME)) self.__topicPubLocation.set_categories( SIM_CAR.TOPIC.CATEGORIES.LOCATION) self.__topicSubStatus = Topic() self.__topicSubStatus.set_targets( Target.new_target(None, SIM_CAR.NODE_NAME), None) self.__topicSubStatus.set_categories(SIM_CAR.TOPIC.CATEGORIES.LOCATION) self.__topicSubStatus.set_message(Location) self.set_subscriber(self.__topicSubStatus, self.update_other_vehicle_locations) self.__topicSubTrafficSignalStatus = Topic() self.__topicSubTrafficSignalStatus.set_targets( Target.new_target(None, TRAFFIC_SIGNAL.NODE_NAME), None) self.__topicSubTrafficSignalStatus.set_categories( TRAFFIC_SIGNAL.TOPIC.CATEGORIES.STATUS) self.__topicSubTrafficSignalStatus.set_message(TrafficSignalStatus) self.set_subscriber(self.__topicSubTrafficSignalStatus, self.update_traffic_signals)
def after_state_change_update_schedule_target(vehicle_id, schedules): for i, schedule in enumerate(schedules): if schedule.event in [ SIM_BUS_USER.TRIGGER.GOT_ON, SIM_BUS_USER.TRIGGER.MOVE_VEHICLE, SIM_BUS_USER.TRIGGER.REQUEST_STOP, SIM_BUS_USER.TRIGGER.GET_OUT, SIM_BUS_USER.TRIGGER.GOT_OUT, ]: schedules[i].targets.append( Target.new_target(vehicle_id, SIM_BUS.NODE_NAME)) return True
def __init__(self, _id, name, waypoint, arrow, route): super().__init__(_id, name, waypoint, arrow, route) self.waypoint = waypoint self.arrow = arrow self.route = route self.user_statuses = self.manager.dict() self.user_statuses_lock = self.manager.Lock() self.vehicle_statuses = self.manager.dict() self.vehicle_statuses_lock = self.manager.Lock() self.user_schedules = {} self.vehicle_schedules = {} self.state_machines = {} self.__topicPubUserSchedules = Topic() self.__topicPubUserSchedules.set_categories( FLEET_MANAGER.TOPIC.CATEGORIES.SCHEDULES) self.__topicPubVehicleSchedules = Topic() self.__topicPubVehicleSchedules.set_categories( FLEET_MANAGER.TOPIC.CATEGORIES.SCHEDULES) self.__topicSubUserStatus = Topic() self.__topicSubUserStatus.set_targets( Target.new_target(None, SIM_TAXI_USER.NODE_NAME), None) self.__topicSubUserStatus.set_categories(USER.TOPIC.CATEGORIES.STATUS) self.__topicSubUserStatus.set_message(UserStatus) self.set_subscriber(self.__topicSubUserStatus, self.update_user_status) self.__topicSubVehicleStatus = Topic() self.__topicSubVehicleStatus.set_targets( Target.new_target(None, SIM_TAXI.NODE_NAME), None) self.__topicSubVehicleStatus.set_categories( VEHICLE.TOPIC.CATEGORIES.STATUS) self.__topicSubVehicleStatus.set_message(VehicleStatus) self.set_subscriber(self.__topicSubVehicleStatus, self.update_vehicle_status)
def load_bus_schedule_json(path_bus_schedule_json): with open(path_bus_schedule_json, "r") as f: bus_schedules_json = json.load(f)["busSchedules"] bus_schedules = {} for target_bus_schedules in bus_schedules_json: schedule_branches = [] for schedule_branch in target_bus_schedules["scheduleBranches"]: common_schedules = [] for common in schedule_branch["common"]: common_schedules = Schedule.get_merged_schedules(common_schedules, [Schedule.new_schedule( Target.new_targets(common["targets"]) if "targets" in common else None, common["event"], None, None, Route.decode_route_code(common["routeCode"]) )]) main_schedules = [] for main in schedule_branch["main"]: main_schedules = Schedule.get_merged_schedules( main_schedules, [Schedule.new_schedule( Target.new_targets(main["targets"]) if "targets" in main else None, main["event"], None, None, Route.decode_route_code(main["routeCode"]) )] ) sub_schedules = [] for sub in schedule_branch["sub"]: sub_schedules = Schedule.get_merged_schedules( sub_schedules, [Schedule.new_schedule( Target.new_targets(sub["targets"]) if "targets" in sub else None, sub["event"], None, None, Route.decode_route_code(sub["routeCode"]) )] ) schedule_branches.append( ScheduleBranch.new_schedule_branch(common_schedules, main_schedules, sub_schedules)) bus_schedules[target_bus_schedules["ID"]] = schedule_branches return bus_schedules
def condition_need_to_via(schedules, user_statuses): target_bus_stops = Target.get_same_group_targets_in_targets( "spot", schedules[0].targets) for target_bus_stop in target_bus_stops: waiting_user_statuses = list( filter(lambda x: x.state == SIM_BUS_USER.STATE.WAITING, user_statuses.values())) for user_status in waiting_user_statuses: target_waiting_bus_stop = Target.get_same_group_targets_in_targets( SIM_BUS_USER.TARGET_GROUP.START_BUS_STOP, user_status.trip_schedules[0].targets)[0] if target_bus_stop.id == target_waiting_bus_stop.id: return True stop_requested_user_statuses = list( filter( lambda x: x.schedule.event == SIM_BUS_USER.TRIGGER. REQUEST_STOP, user_statuses.values())) for user_status in stop_requested_user_statuses: target_waiting_bus_stop = Target.get_same_group_targets_in_targets( SIM_BUS_USER.TARGET_GROUP.GOAL_BUS_STOP, user_status.trip_schedules[0].targets)[0] if target_bus_stop.id == target_waiting_bus_stop.id: return True return False
def after_change_state_publish_through_schedules(self, vehicle_id): target_vehicle = Target.new_target(vehicle_id, SIM_BUS.NODE_NAME) target_bus_schedule = self.get_assigned_bus_schedule_target( target_vehicle) move_to_branch_point_schedules, branch_index, part_type, part_index = \ self.get_move_to_branch_point_schedules( target_vehicle, target_bus_schedule, self.vehicle_schedules[vehicle_id][-1].period.end, self.vehicle_last_indices[vehicle_id]["branch_index"], "main", 0) self.vehicle_schedules[vehicle_id] = Schedule.get_merged_schedules( self.vehicle_schedules[vehicle_id], move_to_branch_point_schedules) self.after_change_state_update_last_indices(vehicle_id, branch_index, part_type, part_index) self.after_change_state_publish_schedules(vehicle_id) return True
def __init__(self, _id, name, dt=1.0): super().__init__(_id, name, dt) self.state_machine = self.get_state_machine() self.target_start_bus_stop = None self.target_goal_bus_stop = None self.vehicle_id = None self.vehicle_statuses = self.manager.dict() self.vehicle_statuses_lock = self.manager.Lock() self.__topicSubVehicleStatus = Topic() self.__topicSubVehicleStatus.set_targets( Target.new_target(None, SIM_BUS.NODE_NAME), None) self.__topicSubVehicleStatus.set_categories( VEHICLE.TOPIC.CATEGORIES.STATUS) self.__topicSubVehicleStatus.set_message(VehicleStatus) self.set_subscriber(self.__topicSubVehicleStatus, self.update_vehicle_status)
default="../../res/spot.json", help="spot.json path") args = parser.parse_args() if __name__ == '__main__': waypoint = Waypoint() waypoint.load(args.path_waypoint_json) arrow = Arrow(waypoint) arrow.load(args.path_arrow_json) spot = Spot() spot.load(args.path_spot_json) bus_parkable_spots = spot.get_spots_of_target_group( Target.new_node_target(SimBus)) bus_stop_ids = list(bus_parkable_spots.keys()) start_bus_stop_id = random.choice(bus_stop_ids) start_waypoint_id = bus_parkable_spots[ start_bus_stop_id].contact.waypoint_id start_arrow_code = bus_parkable_spots[start_bus_stop_id].contact.arrow_code start_time = time() - 5 bus_stop_ids.remove(start_bus_stop_id) goal_bus_stop_id = random.choice(bus_stop_ids) goal_waypoint_id = bus_parkable_spots[goal_bus_stop_id].contact.waypoint_id goal_arrow_code = bus_parkable_spots[goal_bus_stop_id].contact.arrow_code bus_user = SimBusUser(_id=args.id if args.id is not None else str(uuid()),
eventlet.monkey_patch() app = Flask(__name__) with app.app_context(): app.waypoint = Waypoint() app.waypoint.load(args.path_waypoint_json) app.arrow = Arrow() app.arrow.load(args.path_arrow_json) app.intersection = Intersection() app.intersection.load(args.path_intersection_json) app.topics = {} topic = Topic() topic.set_targets(Target.new_target(None, SimTaxiUser.__name__), None) topic.set_categories(User.CONST.TOPIC.CATEGORIES.STATUS) app.topics["user"] = topic.get_path(use_wild_card=True) topic = Topic() topic.set_targets(Target.new_target(None, SimTaxi.__name__), None) topic.set_categories(Vehicle.CONST.TOPIC.CATEGORIES.STATUS) app.topics["vehicle"] = topic.get_path(use_wild_card=True) topic = Topic() topic.set_targets(Target.new_target(None, SimTaxiFleet.__name__), None) topic.set_categories(FleetManager.CONST.TOPIC.CATEGORIES.STATUS) app.topics["fleet_manager"] = topic.get_path(use_wild_card=True) topic = Topic() topic.set_targets(Target.new_target(None, TrafficSignal.__name__), None)
"8966", "8967", "8968", ] start_waypoint_id = args.start_waypoint_id if start_waypoint_id is None: start_waypoint_id = random.choice(stop_waypoint_ids) start_arrow_code = arrow.get_arrow_codes_from_waypoint_id( start_waypoint_id)[0] current_time = time() sim_taxi = SimTaxi(_id=args.id if args.id is not None else str(uuid()), name=args.name, waypoint=waypoint, arrow=arrow, route=route, intersection=intersection, dt=0.5) sim_taxi.set_waypoint_id_and_arrow_code(start_waypoint_id, start_arrow_code) sim_taxi.set_velocity(3.0) sim_taxi.set_schedules([ Schedule.new_schedule([Target.new_node_target(sim_taxi)], SimTaxi.CONST.TRIGGER.STAND_BY, current_time, current_time + 100, Route.new_route(start_waypoint_id, start_waypoint_id, [start_arrow_code])) ]) sim_taxi.start(host=args.host, port=args.port)
def __init__(self, _id, name, waypoint, arrow, route, dt=0.5): super().__init__(_id, name, waypoint, arrow, route, dt=dt) self.upper_distance_from_stopline = AUTOWARE.DEFAULT_UPPER_DISTANCE_FROM_STOPLINE self.state_machine = self.get_state_machine() self.__map_match = MapMatch() self.__map_match.set_waypoint(self.waypoint) self.__map_match.set_arrow(self.arrow) self.ros_closest_waypoint = None self.ros_closest_waypoint_lock = self.manager.Lock() self.ros_current_pose = None self.ros_current_pose_lock = self.manager.Lock() self.ros_decisionmaker_states = None self.ros_decisionmaker_states_lock = self.manager.Lock() self.current_locations = [] self.traffic_signals = self.manager.dict() self.traffic_signals_lock = self.manager.Lock() self.__previous_state_command = None self.__topicPubBasedLaneWaypointsArray = Topic() self.__topicPubBasedLaneWaypointsArray.set_targets( self.target, Target.new_target(self.target.id, AUTOWARE.TOPIC.ROS_NODE_NAME)) self.__topicPubBasedLaneWaypointsArray.set_categories(AUTOWARE.TOPIC.CATEGORIES.BASED_LANE_WAYPOINTS_ARRAY) self.__topicPubStateCmd = Topic() self.__topicPubStateCmd.set_targets( self.target, Target.new_target(self.target.id, AUTOWARE.TOPIC.ROS_NODE_NAME)) self.__topicPubStateCmd.set_categories(AUTOWARE.TOPIC.CATEGORIES.STATE_CMD) self.__topicPubLightColor = Topic() self.__topicPubLightColor.set_targets( self.target, Target.new_target(self.target.id, AUTOWARE.TOPIC.ROS_NODE_NAME)) self.__topicPubLightColor.set_categories(AUTOWARE.TOPIC.CATEGORIES.LIGHT_COLOR) self.__topicSubCurrentPose = Topic() self.__topicSubCurrentPose.set_targets( Target.new_target(self.target.id, AUTOWARE.TOPIC.ROS_NODE_NAME), self.target) self.__topicSubCurrentPose.set_categories(AUTOWARE.TOPIC.CATEGORIES.CURRENT_POSE) self.__topicSubCurrentPose.set_message(ROSMessage.CurrentPose) self.set_subscriber(self.__topicSubCurrentPose, self.update_current_pose) self.__topicSubClosestWaypoint = Topic() self.__topicSubClosestWaypoint.set_targets( Target.new_target(self.target.id, AUTOWARE.TOPIC.ROS_NODE_NAME), self.target) self.__topicSubClosestWaypoint.set_categories(AUTOWARE.TOPIC.CATEGORIES.CLOSEST_WAYPOINT) self.__topicSubClosestWaypoint.set_message(ROSMessage.ClosestWaypoint) self.set_subscriber(self.__topicSubClosestWaypoint, self.update_closest_waypoint) self.__topicSubDecisionMakerStates = Topic() self.__topicSubDecisionMakerStates.set_targets( Target.new_target(self.target.id, AUTOWARE.TOPIC.ROS_NODE_NAME), self.target) self.__topicSubDecisionMakerStates.set_categories(AUTOWARE.TOPIC.CATEGORIES.DECISION_MAKER_STATES) self.__topicSubDecisionMakerStates.set_message(ROSMessage.DecisionMakerStates) self.set_subscriber(self.__topicSubDecisionMakerStates, self.update_decisionmaker_states) self.__topicSubTrafficSignalStatus = Topic() self.__topicSubTrafficSignalStatus.set_targets(Target.new_target(None, TRAFFIC_SIGNAL.NODE_NAME)) self.__topicSubTrafficSignalStatus.set_categories(TRAFFIC_SIGNAL.TOPIC.CATEGORIES.STATUS) self.__topicSubTrafficSignalStatus.set_message(TrafficSignalStatus) self.set_subscriber(self.__topicSubTrafficSignalStatus, self.update_traffic_signals)
def __publish_vehicle_schedules(self, vehicle_id, payload): self.__topicPubVehicleSchedules.set_targets( self.target, Target.new_target(vehicle_id, SIM_BUS.NODE_NAME)) self.publish(self.__topicPubVehicleSchedules, payload)
def get_from_target(path): return Target.new_target(Topic.get_from_id(path), Topic.get_from_node(path))
def update_relation(self, target_bus_schedule, vehicle_id): self.relation.remove_relation( target_bus_schedule, Target.new_target(None, SIM_BUS.NODE_NAME)) self.relation.add_relation( target_bus_schedule, Target.new_target(vehicle_id, SIM_BUS.NODE_NAME))