3 from reinforcement_learning_node
import ReinforcementLearningNode
6 from parameters_policy_gradient
import Policy, ACTIONS, LASER_SAMPLE_COUNT
8 from torch.distributions
import Categorical
12 ''' ROS node to drive the car using previously learned 13 Policy Gradient weights 23 message =
"Model parameters for the neural net not found. You need to train it first." 25 rospy.signal_shutdown(message)
28 ReinforcementLearningNode.__init__(self, ACTIONS, LASER_SAMPLE_COUNT)
37 action_probabilities = self.
policy(state)
38 action_distribution = Categorical(action_probabilities)
39 action = action_distribution.sample()
43 rospy.init_node(
'policy_gradient_driving', anonymous=
True)
def convert_laser_message_to_tensor(self, message, use_device=True)
def on_receive_laser_scan(self, message)
def perform_action(self, action_index)