-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
328 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import time | ||
|
||
import rlviser_py as vis | ||
import RocketSim as rs | ||
|
||
# Create example arena | ||
arena = rs.Arena(rs.GameMode.SOCCAR) | ||
|
||
# Set boost pad locations | ||
vis.set_boost_pad_locations([pad.get_pos().as_tuple() for pad in arena.get_boost_pads()]) | ||
|
||
# Setup example arena | ||
car = arena.add_car(rs.Team.BLUE) | ||
car.set_state(rs.CarState(pos=rs.Vec(z=17), vel=rs.Vec(x=50))) | ||
arena.ball.set_state(rs.BallState(pos=rs.Vec(y=400, z=100))) | ||
car.set_controls(rs.CarControls(throttle=1, steer=1)) | ||
|
||
# Run for 3 seconds | ||
|
||
steps = 0 | ||
starttime = time.time() | ||
for i in range(round(3 * arena.tick_rate)): | ||
arena.step(1) | ||
|
||
# Render the current game state | ||
pad_states = [pad.get_state().is_active for pad in arena.get_boost_pads()] | ||
car_data = [(car.id, car.team, car.get_config(), car.get_state()) for car in arena.get_cars()] | ||
vis.render(steps, arena.tick_rate, pad_states, arena.ball.get_state(), car_data) | ||
|
||
# sleep to simulate running real time (it will run a LOT after otherwise) | ||
time.sleep(max(0, starttime + steps / arena.tick_rate - time.time())) | ||
steps += 1 | ||
|
||
# Tell RLViser to exit | ||
print("Exiting...") | ||
vis.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.