Skip to content

Commit

Permalink
External repository access now works
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestlaine committed Mar 25, 2024
1 parent 1d02fc6 commit 6a22994
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/VehicleSim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ include("measurements.jl")
include("map.jl")
include("example_project.jl")

export server, shutdown!, keyboard_client, GroundTruthMeasurement, CameraMeasurement, IMUMeasurement, GPSMeasurement, VehicleCommand, training_map, load_mechanism
export server, shutdown!, keyboard_client, GroundTruthMeasurement, CameraMeasurement, IMUMeasurement, GPSMeasurement, VehicleCommand, training_map, load_mechanism, MeasurementMessage

end
6 changes: 3 additions & 3 deletions src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function keyboard_client(host::IPAddr=IPv4(0), port=4444; v_step = 1.0, s_step =
num_gps += 1
end
end
# @info "Measurements received: $num_gt gt; $num_cam cam; $num_imu imu; $num_gps gps"
@info "Measurements received: $num_gt gt; $num_cam cam; $num_imu imu; $num_gps gps"
end

target_velocity = 0.0
Expand Down Expand Up @@ -83,7 +83,7 @@ function keyboard_client(host::IPAddr=IPv4(0), port=4444; v_step = 1.0, s_step =
steering_angle -= s_step
@info "Target steering angle: $steering_angle"
end
cmd = VehicleCommand(steering_angle, target_velocity, controlled)
cmd = (steering_angle, target_velocity, controlled)
serialize(socket, cmd)
end
end
Expand All @@ -106,7 +106,7 @@ function example_client(host::IPAddr=IPv4(0), port=4444)
shutdown = true
persist = false
end
cmd = VehicleCommand(0.0, 2.5, persist, shutdown)
cmd = (0.0, 2.5, persist, shutdown)
serialize(socket, cmd)
end

Expand Down
4 changes: 2 additions & 2 deletions src/example_project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function decision_making(localization_state_channel,
# figure out what to do ... setup motion planning problem etc
steering_angle = 0.0
target_vel = 0.0
cmd = VehicleCommand(steering_angle, target_vel, true)
cmd = (steering_angle, target_vel, true)
serialize(socket, cmd)
end
end
Expand All @@ -78,7 +78,7 @@ end

function my_client(host::IPAddr=IPv4(0), port=4444)
socket = Sockets.connect(host, port)
map_segments = VehicleSim.training_map()
map_segments = VehicleSim.city_map()

msg = deserialize(socket) # Visualization info
@info msg
Expand Down
7 changes: 5 additions & 2 deletions src/sim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,20 @@ function server(max_vehicles=1,
break
end
end
car_cmd = deserialize(sock)
raw_cmd = deserialize(sock)
received = true

!received && continue
car_cmd = VehicleCommand(raw_cmd...)
put!(cmd_channels[vehicle_id], car_cmd)
if !car_cmd.controlled
close(sock)
end
end
catch e
@warn "Error receiving command for vehicle $vehicle_id. Did client fail?"
@warn e
@warn "Error receiving command for vehicle $vehicle_id. Client may have failed. Closing socket connection to client."
close(sock)
end
end
@async begin
Expand Down

0 comments on commit 6a22994

Please sign in to comment.