Wi-Fi Communication¶
The CRS platform running on the host computer ("host") connects to the the vehicles through Wi-Fi.
How it works¶
The connection between the host and the vehicles is established through a local network to which both parts connect. In practice, this means setting up a Wi-Fi network through a router, and connecting the host computer to it (Ethernet is recommended for lowest latency, but Wi-Fi also works). Then, the pairing works as follows:
- On startup, the vehicle will attempt to connect to the Wi-Fi network using the stored credentials.
- If this fails (network is not responsive, credentials are wrong), the vehicle will itself create a local network,
crs-car. On this network, a settings page is available at http://192.168.4.1/config, allowing to supply new credentials.
- If this fails (network is not responsive, credentials are wrong), the vehicle will itself create a local network,
- On success, the car now waits for UDP messages sent to it, and will process the contained Protobuf messages.
- Every five seconds, the vehicle will send a "discovery packet" to a pre-configured IP address/port number pair. The purpose of this is to allow the host computer to detect the IP of the vehicle in the local network, since it may change between tests.
- This pre-configured IP must match the IP address of the host in the local network. In addition, the pre-configured port number of the vehicle must match the port number of the
ros_wifi_comnode's opened port – only if they match will the host computer receive data from the vehicle. The port number can be provided to theros_wifi_comnode as a launch parameter. - The
ros_wifi_comnode receives incoming messages from the cars and saves the IP/port of the associated vehicle. Any data it receives from its subscribed topics it will send to the vehicle. Any data sent by the vehicle, it will publish in the vehicle's namespace in ROS.
Debugging Guide¶
In case the communication between the host and the vehicles doesn't work, check the following:
- Make sure the vehicles managed to connect to the Wi-Fi network. Check on your phone or laptop if any
crs-carWi-Fi networks are visible – this indicates that a vehicle timed out in trying to connect to the Wi-Fi network.- If the connection failed, join the
crs-carnetwork, visit http://192.168.4.1/config and give the correct credentials.
- If the connection failed, join the
- Make sure the IP of the host computer matches the IP the car sends its discovery packets to, again, check http://192.168.4.1/config.
- Make sure the Docker container is forwarding its ports to the host. Run
docker psin a terminal and verify that the following appears:0/udp, 0.0.0.0:20210-20230->20210-20230/udp. If the->arrows are missing, port forwarding is not set up. Make sure the container was launched withdocker compose run --service-ports crs. - Make sure the port number from the configuration interface matches the port number in
wifi_com.yaml. Also, multiple vehicles may not share the same port and it may only be in the range 20210 - 20230.