-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ros-2-complete' of https://github.com/purdue-arc/rocket…
…_league into ros-2-complete
- Loading branch information
Showing
4 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
"""Real-time evaluation of the agent trained for the Rocket League project. | ||
License: | ||
BSD 3-Clause License | ||
Copyright (c) 2023, Autonomous Robotics Club of Purdue (Purdue ARC) | ||
All rights reserved. | ||
""" | ||
|
||
from rktl_autonomy.rocket_league_interface import RocketLeagueInterface | ||
from stable_baselines3 import PPO | ||
from os.path import expanduser | ||
from rclpy.exceptions import ROSInterruptException | ||
|
||
|
||
def main(): | ||
# create interface (and init ROS) | ||
env = RocketLeagueInterface(eval=True) | ||
|
||
# load the model | ||
weights = expanduser(env.node.get_parameter('~weights').get_parameter_value().string_value) | ||
model = PPO.load(weights) | ||
|
||
# evaluate in real-time | ||
obs = env.reset() | ||
while True: | ||
action, __ = model.predict(obs) | ||
try: | ||
obs, __, __, __ = env.step(action) | ||
# except rospy.ROSInterruptException: | ||
except ROSInterruptException: | ||
exit() | ||
|
||
if __name__=='__main__': | ||
main() | ||
|
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