Driving the Cosmos with Gaia Sky

Written by max on 2019-01-15
Demo of using an iRacing rig to navigate the stars

I stumbled on the amazing Universe Simulator Gaia Sky by Toni Sagristà Sellés through a twitter post a couple evenings ago. Gaia Sky is a real-time universe simulator to provide a way to explore the data from the ESA’s Gaia spacecraft.

Immediately, I wondered how I could rig it up to my race driving setup on my PC. With a minor tweak the source code, and a few helper programs, I was off and driving the stars in a few hours. This is setup for my wheel and pedals, but is generic enough for any.

Hardware

Software

Gaia Sky

Image Copyright: ESA/ATG medialab

Gaia Sky (https://zah.uni-heidelberg.de/institutes/ari/gaia/outreach/gaiasky/) is a real-time universe simulator that provides a way to explore the data from the ESA’s Gaia spacecraft.

Controller Mapping – UCR

Here is my .controller file for my setup. Add this file to %HOME%\.gaiasky\mappings. Then select the mapping in the GUI Control Panel in Gaia Sky.

# Thrustmaster T300RS - PS3 Mode - Windows
# UCR Remap Using vJoy device
# ( https://www.autohotkey.com/boards/viewtopic.php?t=12249 )
#
# UCR Assignment:
#  S1A1 - Steering
#  S1A2 - Brake
#  S1A3 - Clutch
#  S1A4 - Accelerator
#
#  S1B1  - Left Shift
#  S1B2  - Right Shift
#  S1B3  - Triangle (Up Right DPAD)
#  S1B4  - Square (Left Right DPAD)
#  S1B5  - Circle (Right Right DPAD)
#  S1B6  - X (Down Right DPAD)
#  S1B10 - L2
#  S1B9  - R2
#  S1B7  - SE
#  S1B8  - ST
#  S1B13 - R3
#  S1B11 - L3
#  S1B13 - PS
#  S1HatUp    - DPAD Up
#  S1HatLeft  - DPAD Left
#  S1HatDown  - DPAD Down
#  S1HatRight - DPAD Right
#
# VJoy remapping in UCR
# Steering to Yaw (L/R)
#   Remapper (Axis to Axis)
#     In A1 = Stick 1, Axis 1
#     Deadzone : 3%
#     Sensitivity : 400% (half-turn)
#     Out    - vJoy Stick 1, Axis 1 (gaiasky 0)
#
# Clutch + Throttle to Pitch (rudders)
#   Remapper (Axis Merger)
#     In A1 = Stick 1, Axis 3
#     In A2 - Stick 1, Axis 4, Invert
#     Out    - vJoy Stick 1, Axis 2 (gaiasky 1)
# 
#  Brakes to Positive Roll
#   Remapper (Axis Merger)
#     In A1 = <clear>
#     In A2 - Stick 1, Axis 2, Invert
#     Out    - vJoy Stick 1, Axis 3 (gaiasky 2)
#
#  "Hat" L/R to Axis 4
#    Remapper (Buttons to Axis)
#
#  "Hat" U/D to Axis 5
#    Remapper (Buttons to Axis)
#
#  S1B1  -> vS1B1 (gaiasky 0)
#  S1B2  -> vS1B2 (gaiasky 1)
#  S1B3  -> "1"
#  S1B4  -> "2"
#  S1B5  -> "0"
#  S1B6  -> "3"
#  S1B10 -> vS1B3 (gaiasky 2)
#  S1B9  -> vS1B4 (gaiasky 3)
#  S1B7  -> ","
#  S1B8  -> "."
#  S1B13 -> "/"
#  S1B11 -> "Escape"
#  S1B13 -> "Home"
#  S1HatUp    -> vS1A5 High
#  S1HatDown  -> vS1A5 Low
#  S1HatLeft  -> vS1A4 Low
#  S1HatRight -> vS1A4 High
#
# AXES
# axis.roll             Focus / Spacecraft: Roll right and left
#                       Camera: Move sideways
axis.roll=2
# axis.pitch            Focus: Vertical rotation around focus
#                       Camera / Spacecraft : Pitch up and down
axis.pitch=1
# axis.yaw              Focus: Horizontal rotation around focus
#                       Camera / Spacecraft: Yaw right and left
axis.yaw=0
# axis.move             Focus: Move towards or away from focus
#                       Camera: Move forward and backward
#                       Spacecraft: None
axis.move=3
# axis.velocityup       Focus / Camera:  Move towards focus
#                       Spacecraft: Apply forward thrust
axis.velocityup=4
# axis.velocitydown     Focus / Camera: Move away from focus
#                       Spacecraft: Apply backward thrust
axis.velocitydown=5

# BUTTONS
# button.velocityup     Focus / Camera: Move towards focus
#                       Spacecraft: Increase engine power
button.velocityup=0
# button.velocitydown   Focus / Camera: Move away from focus
#                       Spacecraft: Decrease engine power
button.velocitydown=1
# button.velocitytenth  Focus / Camera: Hold to apply 0.1 factor to speed
#                       Spacecraft: Stop spacecraft
button.velocitytenth=2
# button.velocityhalf   Focus / Camera: Hold to apply 0.5 factor to speed
#                       Spacecraft: Stabilise spacecraft rotations
button.velocityhalf=3

Controller Mapping (Native)

This doesn’t work, but here is my attempt at a controller mapping w/out using UCR and blacklisting the native device. Without UCR the pedals only behave if you can push them half-way to the “zero” point, which is tricky. This is because they go from -1 (off) to 0 (half-on) to +1 (full-on) for racing games. Another limitation is that Gaiasky can’t map most commands to random buttons, only the 4 shown.

# Thrustmaster T300RS - PS3 Mode - Windows
#
# B0 - Left Shift
# B1 - Right Shift
# B2 - Triangle (Up Right DPAD)
# B3 - Square (Left Right DPAD)
# B4 - Circle (Right Right DPAD)
# B5 - X (Down Right DPAD)
# B6 - SE
# B7 - ST
# B8 - R2
# B9 - L2
# B10 - L3
# B11 - R3
# A0 - Steering Wheel
#   Dead on center, takes 3 turns to get to full, needs to be scaled
#   Left -A0, Right +A0
# A1 - Brake Pedal
#    +1 -> 0 -> -1
# A2 - Accelerator Pedal
#    +1 -> 0 -> -1
#
# TODO: These are not responding in Gaia Sky  2.1.7
# B?  - DPAD Up
# B?  - DPAD Left
# B?  - DPAD Down
# B?  - DPAD Right
# A?  - Clutch
#
# AXES
# axis.roll             Focus / Spacecraft: Roll right and left
#                       Camera: Move sideways
axis.roll=0
# axis.pitch            Focus: Vertical rotation around focus
#                       Camera / Spacecraft : Pitch up and down
axis.pitch=2
# axis.yaw              Focus: Horizontal rotation around focus
#                       Camera / Spacecraft: Yaw right and left
axis.yaw=1
# axis.move             Focus: Move towards or away from focus
#                       Camera: Move forward and backward
#                       Spacecraft: None
axis.move=8
# axis.velocityup       Focus / Camera:  Move towards focus
#                       Spacecraft: Apply forward thrust
axis.velocityup=9
# axis.velocitydown     Focus / Camera: Move away from focus
#                       Spacecraft: Apply backward thrust
axis.velocitydown=9

# BUTTONS
# button.velocityup     Focus / Camera: Move towards focus
#                       Spacecraft: Increase engine power
button.velocityup=0
# button.velocitydown   Focus / Camera: Move away from focus
#                       Spacecraft: Decrease engine power
button.velocitydown=1
# button.velocitytenth  Focus / Camera: Hold to apply 0.1 factor to speed
#                       Spacecraft: Stop spacecraft
button.velocitytenth=9
# button.velocityhalf   Focus / Camera: Hold to apply 0.5 factor to speed
#                       Spacecraft: Stabilise spacecraft rotations
button.velocityhalf=8

Blacklisting the actual Joystick(s)

When using UCR, you will get double / conflicting input from your real controllers and the virtual vJoy one. The new “controls.blacklist” global property (thanks @jumpinglangur!) allows you to ignore all but the vJoy controller. Change the line in your %HOME\.gaiasky\global.properties file.

This requires version 2.1.8 or newer.

# Ignore the real joystick, use the vJoy one
controls.blacklist="Thrustmaster T300RS Racing Wheel"

Patch for UCR / vJoy

The following patch was required as of Gaia Sky 2.1.7 (20190113) in order to ignore the actual joystick and only use the vJoy virtual one. As of 20190115 you can use the controls.blacklist=”Thrustmaster T300RS Racing Wheel” directive in global.properties to have Gaiasky ignore the actual controller(s) and use the virtual vJoy controller instead.

Development Platform

In order to hack the current version of Gaia Sky to ignore the actual joystick and only look at the virtual one, the development environment was bootstrapped. I am not a Java programmer, so this was pretty quick and dirty. First install the following :

Then checkout and bootstrap the code. Do this on an SSD drive if you have one.

c:\> git clone https://gitlab.com/langurmonkey/gaiasky.git
c:\> cd gaiasky
c:\gaiasky> gradlew.bat core:run
c:\gaiasky> gradlew.bat eclipse

Next launch Eclipse and choose File -> Import -> Gradle -> Existing Gradle Project and point it to c:\gaiasky\core. With “Gradle Tasks -> gaiasky” highlighted, Choose Run -> Run. You should be up and running with the IDE now. I couldn’t figure out how to make a debug session run.

Spaceship Mode

Right now Spaceship mode is not behaving right with this mapping. I’m seeing axis 2 get stuck after I release the brake pedal and the vJoy device returns to zero. Also, the accelerator keys don’t work the same as camera mode. I haven’t dug into this much yet.

Universal Control Remapper (UCR)

Universal Control Remapper (UCR) is a Windows program that can change mouse, keyboard, and joystick actions so that the appear as a new mouse / keyboard / joystick. Underneath the hood this application is a front-end for the amazing AutoHotKey featured in my very first blog post https://warped.org/blog/2008/10/06/the-free-one-handed-keyboard/ way back in 2008. It also depends heavily on the virtual joystick device driver vJoy.

  1. Download and install vJoy. Configure your new device driver with the desired number of axes and buttons.
  2. Download and install UCR and launch

UCR Configuration

Screenshot of my partial configuration

Each axis and button from your existing controller(s) will need to be mapped to the new vJoy controller, even if there is no re-mapping and it’s a straight pass-through. The trick with the UCR interface is that you have to click on the same drop-down twice in order to assign first the “stick” and then the “axis” or “button” to vJoy.

After a little tinkering, here is my current mappings :

# VJoy remapping in UCR
# Steering to Yaw (L/R)
#   Remapper (Axis to Axis)
#     In A1 = Stick 1, Axis 1
#     Deadzone : 3%
#     Sensitivity : 400% (half-turn)
#     Out    - vJoy Stick 1, Axis 1 (gaiasky 0)
#
# Clutch + Throttle to Pitch (rudders)
#   Remapper (Axis Merger)
#     In A1 = Stick 1, Axis 3
#     In A2 - Stick 1, Axis 4, Invert
#     Out    - vJoy Stick 1, Axis 2 (gaiasky 1)
# 
#  Brakes to Positive Roll
#   Remapper (Axis Merger)
#     In A1 = <clear>
#     In A2 - Stick 1, Axis 2, Invert
#     Out    - vJoy Stick 1, Axis 3 (gaiasky 2)
#
#  "Hat" L/R to Axis 4
#    Remapper (Buttons to Axis)
#
#  "Hat" U/D to Axis 5
#    Remapper (Buttons to Axis)
#
#  S1B1  -> vS1B1 (gaiasky 0)
#  S1B2  -> vS1B2 (gaiasky 1)
#  S1B3  -> "1"
#  S1B4  -> "2"
#  S1B5  -> "0"
#  S1B6  -> "3"
#  S1B10 -> vS1B3 (gaiasky 2)
#  S1B9  -> vS1B4 (gaiasky 3)
#  S1B7  -> ","
#  S1B8  -> "."
#  S1B13 -> "/"
#  S1B11 -> "Escape"
#  S1B13 -> "Home"
#  S1HatUp    -> vS1A5 High
#  S1HatDown  -> vS1A5 Low
#  S1HatLeft  -> vS1A4 Low
#  S1HatRight -> vS1A4 High