Skip to content

Commit

Permalink
Merge pull request #64 from UoA-CARES/Experiment3-merged-12
Browse files Browse the repository at this point in the history
Update f1tenth and lidar
  • Loading branch information
Bac0nEater authored Jul 10, 2023
2 parents f132707 + 47472b4 commit bdba878
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/environments/environments/CarTrackParentEnvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(self, car_name, reward_range=1, max_steps=50, collision_range=0.2,

# Environment Details ----------------------------------------
self.MAX_STEPS_PER_GOAL = max_steps
self.MIN_ACTIONS = np.asarray([0, -3.14])
self.OBSERVATION_SIZE = 8 + 10 # Car position + Lidar rays

self.check_goal = False
Expand Down Expand Up @@ -151,8 +150,11 @@ def compute_reward(self, state, next_state):

goal_position = self.goal_position

prev_distance = math.dist(goal_position, state[:2])
current_distance = math.dist(goal_position, next_state[:2])


reward += prev_distance - current_distance

if current_distance < self.REWARD_RANGE:
reward += 50
self.goal_number += 1
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environments/ParentCarEnvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, env_name, car_name, reward_range, max_steps, collision_range,
self.lidar_sub = Subscriber(
self,
LaserScan,
f'/lidar',
f'/{self.NAME}/scan',
)

self.message_filter = ApproximateTimeSynchronizer(
Expand Down
8 changes: 4 additions & 4 deletions src/reinforcement_learning/config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ test:
ros__parameters:
environment: 'CarTrack1'
max_steps_evaluation: 1000000
actor_path: models/cartrack_1_training-26-06-2023-06:50:49_150000_actor.pht
critic_path: models/cartrack_1_training-26-06-2023-06:50:49_150000_critic.pht
max_steps: 100
actor_path: models/23_07_05_03:52:58/models/actor_checkpoint.pht
critic_path: models/23_07_05_03:52:58/models/critic_checkpoint.pht
max_steps: 300
step_length: 0.25
reward_range: 0.2
reward_range: 2.0
collision_range: 0.2
2 changes: 1 addition & 1 deletion src/reinforcement_learning/reinforcement_learning/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def main():
'reward_range': REWARD_RANGE,
'collision_range': COLLISION_RANGE
}
record = Record(networks=networks, checkpoint_freq=MAX_STEPS_TRAINING / 10, config=config)
record = Record(networks=networks, checkpoint_freq=100, config=config)

train(env=env, agent=agent, record=record)

Expand Down

0 comments on commit bdba878

Please sign in to comment.