Cloning this folder will create a folder named TrafficSim on your system. If this happens, you must type the following to correct the name of the folder to match the package name:
cd path/to/TrafficSim/..orcd parent/path/of/TrafficSimmv TrafficSim/ trafficsim/mv trafficsim/ path/to/ros2_ws/src
- This project is build for Ubuntu Linux - Noble Numbat (24.04)
- ROS 2 Jazzy - Build according to docs
- Pyrobosim - Build according to docs
- Type
source ./setup/source_pyrobosim.bashto source and enter the python virtual environment before any steps below
pip install -r path/to/ros2_ws/src/trafficsim/core/requirements.txt
cd path/to/ros2_ws/src/trafficsimbash build_and_launch.bash
pip install xxxx- ONLY if failed
sudo apt install python3-xxxx
There are three folders within this repository - each contain a separate package:
corecontains thetrafficsimpackage.trafficsim_interfacescontains the custom interfaces used to communicate with TrafficSim package.station_datasetcontains the station coordinates and CRS codes (incsvformat), as well as a Python script,dataset_to_json.pyto generate rail lines and stations based on an internal dictionary,lines.
ros2 action send_goal <RobotName>/route_train trafficsim_interfaces/action/RouteTrain "{destination: 'Station_Name'}"ros2 action send_goal <RobotName>/follow_service_timetable trafficsim_interfaces/action/ServiceRouteros2 service call /RailTrafficScheduler/request_next_departure trafficsim_interfaces/srv/CRSDepartureLookup "{origin: 'Station_Name', lookup_only: True}"returns a response using the CRSDepartureLookup interface, similar to:
trafficsim_interfaces.srv.CRSDepartureLookup_Response(api_status_code='200', service_uid='P78998', destination='Glasgow Queen Street', origin_start_time='0530', destination_arrival_time='0831', headcode='1T10', atoc_name='ScotRail')ros2 service call /RailTrafficScheduler/request_all_departures trafficsim_interfaces/srv/CRSAllDepartures "{origin: 'Station_Name', year: 'yyyy', month: 'mm', date: 'dd'}"returns a response using the CRSAllDepartures interface, similar to:
trafficsim_interfaces.srv.CRSAllDepartures_Response(api_status_code='200', service_uid_list=['P78998', 'P78058', 'P78281', 'P79383', 'P79001', 'P79005', 'C46737', 'C48579', 'P78287', ..., 'P79411'])ros2 service call /RailTrafficScheduler/request_service_details trafficsim_interfaces/APIRailServiceLookup "{service_uid: 'P78077', year: '2024', month: '12', date: '06'}"returns a response using the APIRailServiceLookup interface, similar to:
trafficsim_interfaces.srv.APIRailServiceLookup_Response(api_status_code='200', origin='Aberdeen', destination='Edinburgh', stops=['Stonehaven', 'Laurencekirk', 'Montrose', 'Arbroath', 'Carnoustie', 'Dundee', 'Leuchars', 'Haymarket', 'Edinburgh'])To begin spawning freight:
ros2 topic pub /toggle_freight_spawning trafficsim_interfaces/msg/ToggleFreightSpawning '{enabled: true}'To stop spawning freight:
ros2 topic pub /toggle_freight_spawning trafficsim_interfaces/msg/ToggleFreightSpawning '{enabled: false}'