예제 #1
0
    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)
예제 #2
0
                    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()),
예제 #3
0
        "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)
예제 #4
0
            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_car = SimCar(_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)

    next_start_waypoint_id = start_waypoint_id
    schedules = [
        Schedule.new_schedule([Target.new_node_target(sim_car)],
                              SimCar.CONST.TRIGGER.STOP, current_time,
                              current_time + 5,
                              Route.new_route(next_start_waypoint_id,
                                              next_start_waypoint_id,
                                              [start_arrow_code]))
    ]
    current_time += 5

    if args.route_code is not None:
        schedule = Schedule.new_schedule(
            [Target.new_node_target(sim_car)], SimCar.CONST.TRIGGER.MOVE,
            current_time, current_time + 100,
            Route.new_route(next_start_waypoint_id, goal_waypoint_id,
                            arrow_codes))
        schedules = Schedule.get_merged_schedules(schedules, [schedule])
예제 #5
0

if __name__ == "__main__":

    waypoint = Waypoint()
    waypoint.load(args.path_waypoint_json)

    arrow = Arrow(waypoint)
    arrow.load(args.path_arrow_json)

    route = Route()
    route.set_waypoint(waypoint)
    route.set_arrow(arrow)

    current_time = time()

    autoware_taxi = AutowareTaxi(
        _id=args.id,
        name=args.name,
        waypoint=waypoint,
        arrow=arrow,
        route=route,
        dt=0.5
    )
    autoware_taxi.set_schedules([Schedule.new_schedule(
        [Target.new_node_target(autoware_taxi)],
        AutowareTaxi.CONST.STATE.STANDBY, current_time, current_time+100,
        None
    )])
    autoware_taxi.start(host=args.host, port=args.port)
예제 #6
0
    waypoint.load(args.path_waypoint_json)

    arrow = Arrow(waypoint)
    arrow.load(args.path_arrow_json)

    route = Route()
    route.set_waypoint(waypoint)
    route.set_arrow(arrow)

    current_time = time()

    autoware = Autoware(_id=args.id,
                        name=args.name,
                        waypoint=waypoint,
                        arrow=arrow,
                        route=route,
                        dt=0.5)
    autoware.set_schedules([
        Schedule.new_schedule([Target.new_node_target(autoware)],
                              Autoware.CONST.TRIGGER.LAUNCH, current_time,
                              current_time + 100, None),
        Schedule.new_schedule([Target.new_node_target(autoware)],
                              Autoware.CONST.TRIGGER.ACTIVATE, current_time,
                              current_time + 100, None),
        Schedule.new_schedule([Target.new_node_target(autoware)],
                              Autoware.CONST.TRIGGER.SCHEDULE, current_time,
                              current_time + 1, None)
    ])
    # autoware.set_velocity(3.0)
    autoware.start(host=args.host, port=args.port)
예제 #7
0
        "10374",
        "9697", "9698", "9699", "9700", "9701", "9702", "9703", "9704", "9705", "9706", "9707", "9708",
        "8936", "8937", "8938", "8939", "8940", "8941", "8942", "8943", "8944", "8945", "8946", "8947", "8948", "8949",
        "8950", "8951", "8952", "8953", "8954", "8955", "8956", "8957", "8958", "8959", "8960", "8961", "8962", "8963",
        "8964", "8965", "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]
    start_time = time() - 5

    stop_waypoint_ids.remove(start_waypoint_id)

    goal_waypoint_id = random.choice(stop_waypoint_ids)
    goal_arrow_code = arrow.get_arrow_codes_from_waypoint_id(goal_waypoint_id)[0]

    taxi_user = SimTaxiUser(
        _id=args.id if args.id is not None else str(uuid()),
        name=args.name,
        dt=3.0
    )
    trip_schedule = Schedule.new_schedule(
        [Target.new_node_target(taxi_user)],
        User.CONST.EVENT.TRIP, start_time, start_time+9999,
        Route.new_route(start_waypoint_id, goal_waypoint_id, [start_arrow_code, goal_arrow_code])
    )
    taxi_user.set_trip_schedules([trip_schedule])
    taxi_user.start(host=args.host, port=args.port)
예제 #8
0
        "10362", "10363", "10364", "10365", "10366", "10367", "10368", "10369", "10370", "10371", "10372", "10373",
        "10374",
        "9697", "9698", "9699", "9700", "9701", "9702", "9703", "9704", "9705", "9706", "9707", "9708",
        "8936", "8937", "8938", "8939", "8940", "8941", "8942", "8943", "8944", "8945", "8946", "8947", "8948", "8949",
        "8950", "8951", "8952", "8953", "8954", "8955", "8956", "8957", "8958", "8959", "8960", "8961", "8962", "8963",
        "8964", "8965", "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_bus = SimBus(
        _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_bus.set_waypoint_id_and_arrow_code(start_waypoint_id, start_arrow_code)
    sim_bus.set_velocity(3.0)
    sim_bus.set_schedules([Schedule.new_schedule(
        [Target.new_node_target(sim_bus)],
        SimBus.CONST.TRIGGER.STAND_BY, current_time, current_time + 86400,
        Route.new_point_route(start_waypoint_id, start_arrow_code)
    )])
    sim_bus.start(host=args.host, port=args.port)