Working with OpenDS3.0

Abstract:

In this project, we will connect a hardware dashboard (VW Polo R8 speedometer) to the driver simulator OpenDS 3.0. This will increase the “real driving” felling and the immersion for the driving person. The interface between the simulator and the speedometer will be realized by an Arduino uno board. Therefore, we use the serial conversion module of the Arduino to connect the Arduino via USB to the host (desktop computer). This data will also be send to the HC-05 Bluetooth module. This module will be connected via software serial interface implemented in JAVA. The simulator provides the data via TCP (client). We will implement the TCP server enabling the client to connect and to send the data. The Arduino uno board will send the data to the speedometer. The interface between the Arduino uno and the speedometer will be a CAN-Bus.

The app will retrieve the data via Bluetooth and analyze the data to display statistics over the last driving session. Additionally, we will display the life data, so the driving session can be monitored in progress. The displayed data will be the velocity, the rounds per minute of the engine, the turn signal status and the status of the high beams (on/off). The analyzed data will be the maximum speed, the average speed and the average rounds per minute to ensure a good driving habit. Otherwise, the driver could severely damage an engine in real life.

1. Retrieve data from OpenDS 3.0

OpenDS has an integrated CAN interface to retrieve the driving data. The interface is a simple TCP client connecting to the server to send the data. This feature requires some modifications in the source code of the simulator. Additionally, we need to implement a TCP server waiting for the data from the client.

 

Modifications OpenDS – Step 1 (DrivingTask):

The CAN interface must be activated for each “DrivingTask“. In this example we take Paris as simulation environment. The folder “assets/DrivingTasks/Projects/Paris/“ contains a “settings.xml“ file. This can be opened and edited in Eclipse.

The Node “CANInterface“ contains several parameters.

At first, the “enableConnection“ must be set to “true“. To test the connection, we set the loopback address 127.0.0.1. The other parameters can be left as they are.

 

Modifications OpenDS – Step 2 (Source):

In the next step the “sendCarData()“ function in the file “eu.opends.canbus.CANClient.java“ needs to be activated. This method send the driving data periodically via TCP to the server. Additionally, the methods “timeDiff(…)“ and “forwardEvent(…)“ need to be reactivated (uncomment methods)

The field “framerate“ as well as “timeOfLasFire“ need to be uncommented in the declaration and the initialization within the constructor.

The “sendCarData“ will be adapted as shown:

publicsynchronizedvoid sendCarData()

{

  // break, if no connection established

  if(socket == null || errorOccurred)

     return;

  // generate time stamp

   Calendar currentTime = new GregorianCalendar();

  if(forwardEvent(currentTime))

   {

     floatspeed = ((float) car.getCurrentSpeedKmhRounded()); // in kph

     floatheading = car.getHeadingDegree(); // 0..360 degree

     try {

          String positionString = "$SimCarState#" + speed + "#" + heading + "%";

          printWriter = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));

          printWriter.print(positionString);

          printWriter.flush();

         } catch (IOException e) {

          System.err.println("CANClient_sendCarData(): " + e.toString());

         }

    }

}

 

After these modifications, the simulator can be tested. However, the program will crash, because it doesn’t have a server to connect to yet. Parts oft he error message are shown below.

DrivingTast with Paris/paris.xml.

 

2. TCP Server for OpenDS3.0

Simple TCP-Server for OpenDS3.0, listen on Port 4711

OpenDS TCP-Server Sample

Rate this blog entry:
0
Social Gardening
Fortune Cookie: putting data collection into spotl...

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
Thursday, 19 October 2017

Captcha Image