To get GSClient connected to, and communicating with, GSServer
By the end of this PR, the server and client will probably not be running as intended (that is, on the same map, seeing the same simulation)
But, the logs should indicate that there is communication of the right information (the state of the vehicles) between the server and client
Changes
Added and used SHM_SIZE "constant" for the shared memory size
Since there are different types of ActorState (like VehicleState) and Actor uses ActorState (when setting self.state in __init__()), there was no way for Vehicle, for example, to use VehicleState without having to (re)set self.state
Now, Actor's constructor takes an optional state argument; if present, then it will use that as its self.state; otherwise it creates and uses an instance of ActorState
One issue occured in Vehicle.get_full_state_for_client():
Here, type was interpreted as the class (because there was no variable declared named type), and so <class 'type'> was returned
However, when a variable is declared named type it "shadows" (source) the built-in class -- something we should watch out for, but not currently an issue
Replaced remote with type in the GSClient class: it looks like a vehicle used to be either "remote" (simulated in unreal) or "not remote" (simulated in gss); now it looks like there are different types of vehicles
Fixed issue where vehicles in the server all had a yaw of 0 degrees; now the server uses the correct yaw
Ignoring collisions (active) for now; vehicles seem to collide because they are lagging; we will have to address this lag and collisions in a different PR
Test 1
In SimConfig.py set WRITE_TRAJECTORIES = False and CLIENT_SHM = True
Run bash ~/anm_unreal_sim/submodules/base_unreal_project/package.sh
Run bash ~/anm_unreal_test_suite/scripts/anm_sim_switch.bash dev
Run the following script, which will launch both the simulator (ring_road_ccw) and GSServer.py (gs_ringroad_stress_loop):
- The ego should turn left at the stop sign, onto ringroad; after going around the first bend you should see all of the vehicles (from gss) driving in the other lane; their movement will probably look very laggy
### Test 2
- We can test that `GSServer.py` can still run all of the test scenarios with this script (make sure you're in `geoscenarioserver`):
```sh
#!/bin/bash
scenarios=$(ls scenarios/test_scenarios)
source "catkin_ws/devel/setup.bash"
kill_python38()
{
killall python3.8
}
for scenario in $scenarios; do
read -p "Press ENTER to run next scenario:"
trap kill_python38 SIGINT
python3.8 GSServer.py -s "scenarios/test_scenarios/${scenario}"
trap - SIGINT
done
Goal
GSClient
connected to, and communicating with,GSServer
Changes
SHM_SIZE
"constant" for the shared memory sizeActorState
(likeVehicleState
) andActor
usesActorState
(when settingself.state
in__init__()
), there was no way forVehicle
, for example, to useVehicleState
without having to (re)setself.state
Actor
's constructor takes an optionalstate
argument; if present, then it will use that as itsself.state
; otherwise it creates and uses an instance ofActorState
Vehicle.get_full_state_for_client()
:type
was interpreted as the class (because there was no variable declared namedtype
), and so<class 'type'>
was returnedtype
it "shadows" (source) the built-in class -- something we should watch out for, but not currently an issueremote
withtype
in theGSClient
class: it looks like a vehicle used to be either "remote" (simulated in unreal) or "not remote" (simulated in gss); now it looks like there are different types of vehiclesactive
) for now; vehicles seem to collide because they are lagging; we will have to address this lag and collisions in a different PRTest 1
SimConfig.py
setWRITE_TRAJECTORIES = False
andCLIENT_SHM = True
bash ~/anm_unreal_sim/submodules/base_unreal_project/package.sh
bash ~/anm_unreal_test_suite/scripts/anm_sim_switch.bash dev
ring_road_ccw
) andGSServer.py
(gs_ringroad_stress_loop
):GSS="${HOME}/anm_unreal_sim/submodules/geoscenarioserver" SIM="${HOME}/anm_unreal_sim/src/anm_sim_platform/"
cleanup_and_exit() { killall python3.8 killall roslaunch
}
keyboard_int() { echo "" echo "Press ENTER to exit." }
trap keyboard_int SIGINT
source "${GSS}/catkin_ws/install/devel/setup.bash" python3.8 "${GSS}/GSServer.py" -s 'scenarios/test_scenarios/gs_ringroad_stress_loop.osm' > gsslog.log & bash "${SIM}/scripts/launch.bash" 'ring_road_ccw' > simlog.log &
read -p "Press ENTER to exit." cleanup_and_exit
README.md
, of course