MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / main

Function main

PythonAPI/examples/dynamic_weather.py:107–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105
106
107def main():
108 argparser = argparse.ArgumentParser(
109 description=__doc__)
110 argparser.add_argument(
111 '--host',
112 metavar='H',
113 default='127.0.0.1',
114 help='IP of the host server (default: 127.0.0.1)')
115 argparser.add_argument(
116 '-p', '--port',
117 metavar='P',
118 default=2000,
119 type=int,
120 help='TCP port to listen to (default: 2000)')
121 argparser.add_argument(
122 '-s', '--speed',
123 metavar='FACTOR',
124 default=1.0,
125 type=float,
126 help='rate at which the weather changes (default: 1.0)')
127 args = argparser.parse_args()
128
129 speed_factor = args.speed
130 update_freq = 0.1 / speed_factor
131
132 client = carla.Client(args.host, args.port)
133 client.set_timeout(2.0)
134 world = client.get_world()
135
136 weather = Weather(world.get_weather())
137
138 elapsed_time = 0.0
139
140 while True:
141 timestamp = world.wait_for_tick(seconds=30.0).timestamp
142 elapsed_time += timestamp.delta_seconds
143 if elapsed_time > update_freq:
144 weather.tick(speed_factor * elapsed_time)
145 world.set_weather(weather.weather)
146 sys.stdout.write('\r' + str(weather) + 12 * ' ')
147 sys.stdout.flush()
148 elapsed_time = 0.0
149
150
151if __name__ == '__main__':

Callers 1

dynamic_weather.pyFile · 0.70

Calls 6

set_timeoutMethod · 0.95
tickMethod · 0.95
WeatherClass · 0.85
ClientMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected