zhyma / vr15

VR15: a VR FPS game controller that generates haptic feedback with high-pressure air.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


License

本项目基于Creative Commons Attribution 4.0协议开源。

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.


VR15: a VR FPS game controller that generates haptic feedback with high-pressure air.

Disclaimer

This is a VR game controller, a variation of airsoft, not a firearm. It DOES NOT have the ability to shoot any projectile (not even BBs). Although it shares a similar appearance to an AR, it is derived from airsoft, and is NOT compatible with a firearm. The internal is re-designed to accommodate electronic and pneumatic components to generate reoil feedback only. Since it is driven by high-pressure air, please ensure components and their assembly are secured. Replicating and using this design is at your own risk. Please follow your local laws.

Disconnect the air source and the power before you disassemble the controller!

Implementation

There are two parts of this project:

  • The hardware design, which is provided in this repository.

  • The game that customized for this hardware (as shown in the video/gif). There is a demo made by Unity. You can find it here.

Features

  • The haptic feedback is provided by controlled high-pressure air.

  • The displacement of the charging handle is being tracked (trigger motion, semi-auto motion, and the magazine is also being tracked).

  • Simulate AR's hold open.

  • Check out the full introduction video on Youtube:

Design ideas

  • A GBB(gas blowback)airsoft uses a mechanical structure to release CO2 or propane to propel BBs and the bolt, which generates reoil feedback. An HPA(high-pressure air)uses a solenoid valve to control the high-pressure air, but usually does not have the bolt design for the sake of power efficiency. For a VR/AR game controller, being able to shoot BBs is not necessary, even harmful. Removing this function can improve safety while playing the game, and improve the generated recoil feedback.

  • For the above-mentioned reason, the whole structure can be re-designed (reversed): The gas input coming from the front, pointing directly toward the stock. The solenoid valve can occupy part of the magazine space, then be connected to the cylinder. It is possible to mount the air tank inside of the handguard, if choosing the right size of the air tank.

  • Main design purpose: trying to simulate the interaction with an AR as much as possible for a VR scenario.

    • The position tracking of the magazine is done by the VR system (e.g., Oculus Rift). Whether the magazine is well inserted is detected by a microswitch.
    • The displacement of the charging handle is detected by a ToF (time of flight) sensor. Since the handle and the bolt are not always moving together. Whether the bolt is in hold open state is detected by using a Hall sensor.
    • After emptying the magazine, the bolt catch is driven by an electromagnet to stop the bolt halfway.
    • Safe/fire is achieved by physical design. Pulling the trigger is detected by a microswitch. Semi/auto mode selection is detected by another microswitch.
    • The forward assist is left empty yet. It is possible to install a joystick for interaction.
  • Better trigger feedback?

    There are some considerations for using a microswitch to detect the trigger pull:

    1. I want to move the PCB and all electronic components into the trigger box, there is no space for an extra mechanical structure to implement better trigger feedback.
    2. A mechanical trigger weakens the purpose of making a "programmable" controller. The state of the trigger will be determined by the movement of the bolt and the trigger. The controller is not being able to change the state of the trigger, unless you add an extra actuator to move the whole structure (again, not enough space).
  • This design is a proof of concept for a general FPS game controller, the reason for being AR15-alike is because someone gives me a GBB one as the reference. The idea can be applied to (I would say) most rifles. The design can be altered to adapt other "running logic" (as well as the exterior).

Possible improvements

  • Design an all-in-one PCB that fits the trigger box. So the battery can be installed inside of the pistol grip. The ESP32 being used currently is just for prototyping. Replace it with either CC254x, CSR, or some other Bluetooth microcontrollers.

  • Add a spring that keeps the bolt catch in place. Currently, if you tilt the controller, it might accidentally move to the hold-open position.

  • Add an RFID reader next to the magazine detection switch (maybe the switch can be replaced). Attach RFID tags to magazines. So the VR15 can detect different magazines being inserted (keep tracking the number of the "bullets" in each magazine).

  • The animations of ejecting a shell/round and loading a round into the chamber have not been implemented in the game.

  • Implement AR's malfunction in the game. Example: a bullet has been fired but failed to extract its shell. In this case, when the player pulls the charging handle to move the bolt, he/she should be able to see the bolt extractor carrying a shell. Or in some cases, the player needs to remove the magazine, pull the charging handle several times to empty the weapon, then do a reload (double feed, maybe?)

  • The place for the forward assist is left empty. It might be a good place for a joystick.

  • A handguard that can hold the air tank inside.

  • The bolt (outside of the cylinder) and the piston spacer should be made of metal. Several reasons:

    1. The bolt is a moving component, should be tough.
    2. They should be heavier for stronger haptic feedback.
  • Finding some better solenoid valve (smaller, better fits the upper, higher pressure if possible).

  • Tuning 1) the weight of the bolt+piston+buffer, 2) the load of the spring, 3) the input pressure to the valve, 4) the valve opening time.

    I believe those are the major factors that determine the feeling of recoil feedback

  • The bolt catch should be made of metal. Plastic is soft and not that durable.

  • A pressure gauge connects to the microcontroller. Light up a warning sign when pressure is running low.

Hardware BOM

Off-the-shelf parts

  • Electronic parts

    Item PCS Ref image Notes
    Electromagnet 1 12V,push-and-pull type. The metal frame size is 21x10x11mm, fixing by two M2 screws.
    MP1584 DC-DC step down 1
    ESP32 (WROOM) 1
    USB to TTL 1 USB to TTL
    GY6180/VL6180X sensor 1 Be aware of the dimensions (There are two sizes, get the smaller one).
    Hall sensor 1 The version that outputs an on/off signal (with an amplifier on the board).
    Microswitch KW10-Z3P 4
    NMOS SI2302 2 package: SOT-23. I think 2N7002 also works.
    Diode 1N4007 2 package: SMD (2010?)
    SMD resistors N package:0603. You will need several different values.
  • Pneumatic parts(Using Foster 22-2 and NPT 1/8 as an example. You can choose other pneumatic connectors)

    Item PCS Ref image Notes
    Solenoid valve:MAC 35A-AAA-DDBA-1BA 1 Be aware of the port (NPT or BSPP)
    You will need to modify its' shell.
    Cylinder: MAL16x75 1 You will need to cut one end off.
    Cylinder: MAL16x25 1 You only need the piston with the guiding rod. You can leave the rest of the parts as a backup.
    Foster 22-2 1/8 male NPT x 1/8 1 Depending on your air tank output connector.
    1/8 NPT female to 1/8 NPT male 1+ Being used to extend the Foster connector.
    1/8 NPT male M5x0.8 male 1 Connect the valve and the cylinder.
    Air tank (with hose) 1 I'm using an HPA air tank for airsoft. The output pressure is set to 100psi.
  • Mechanical parts

    Item 数量 参考图片 备注
    21 pieces spring and pin set 1 I think the 32 pieces one contains the magazine release and trigger guard.
    Trigger guard 1 You can either buy one or 3D print one (like this)
    Magazine release 1
    Charging handle 1 The length is roughly 17mm. Be aware of the size.
    Buffer and stock set 1 Buffer, buffer tube, buffer spring, castle nut, endplate.
    Stock (I think mk18 navy has plenty of room for batteries).
    Pistol grip 1 The one used for GBB, not AEG
    Delta ring 1 Not necessary. Or you can print it.
  • Standard parts

    Item PCS Notes
    M5-0.8x5mm headless screw 1 Seal the input/output of the cylinder.
    M2x15 screws N You may need to trim some of those shorter.
    M3x6 screw 1 Fix the GY6180.
    M3x8 screw 1 Fix the two-piece upper.
    M6x20mm screw, washer, and nut. 1 Fix the grip.
    M2.5x16mm screw. 1 Fix the bolt catch.
    4mm x 2mm disc magnet 1 Detecting the bolt catch motion.

3D printed parts 1

Item PCS Ref image Notes
Lower 1 vr15_lower.STL
Upper - left 1 vr15_upper_l.STL
Upper - right 1 vr15_upper_r.STL
Trigger box 1 trigger_box.STL
Trigger 1 trigger.STL
Semi-auto selector 1 selector.STL
Magazine 1 mag.STL (only a placeholder)
accessory/oculus_mount/quest_mag_mount.stl: mount Rift/Quest 2 left controller
quest_mag_mount_l.stl and quest_mag_mount_r.stl are two-pieces version.
Piston spacer 1 piston_weight_placeholder.STL
You can redesign it (e.g. with copper) to add some weight to enhance the feedback.
Piston end 1 bolt_plug.STL
You can use nuts come with your cylinder.
Bolt 1 boltcarrier.STL
The original design is using copper to add weight.
Bolt catch 1 boltcarrier.STL
You may need to file it or trim it to make sure it moves smoothly.
Charging handle block 1 charging_handle_block.STL
You may need to redesign it to make sure the front of the charging handle is flat.
Wire cover 1 lower_wire_cover.STL
ToF sensor spacer 1 tof_spacer.STL

3D printed parts 2

Item PCS Ref image Notes
delta ring nut 1 hex_ring.stl
You can use a delta ring to fix the front of the upper.
Buffer spacer 1 buffer_spacer.STL
Make sure your piston won't move out of the cylinder (IMPORTANT!)
PCB mount 1 pcb_grip_mount.STL
Quest mount 1 You will need other files from Thingiverse
quick_release_picatinny_rail_mount_grip_short
quick_release_picatinny_rail_mount_hub
quick_release_picatinny_rail_mount_lever_right
Mount Rift/Quest 2 right controller.
1/8 NPT plug 1 1_8_npt_plug.STL
1/8 NPT plug 2 1_8_npt_side_block.STL

Modify the off-the-shelf parts

Solenoid valve:

  • Use the provided model "1/8 NPT plug" to protect input/output. Remove the protruding part near port No.3.

  • File the corner so the solenoid can be installed into the upper.

  • Modify the wire (You can use a JST-XH 2-pin connector.).

Modify the cylinder:

  • Remove the cap of both ends.

  • The cap with the rod going through will not be used. For the other one, cut to remove the through-hole. Drill, then tap with M5x0.8. After this modification, the input/output will be located at the top of the cap. Tight the cap back to the cylinder (don't forget your O-ring).

  • Now there is one end of the cylinder is left open. Cut near that end to remove the thread, file it to make sure the cut is round and smooth.

  • install the piston spacer (it serves as a linear bearing). Using a nut to tighten it up. Then install the rod end.

  • Grease the piston and the spacer.

  • Install the Foster connector, solenoid valve, and cylinder. (The 1/8 NPT male to the female connector is used to make sure that you can easily connect/disconnect your air source.)

  • Use thread seal tape and a headless screw to seal the original input/output in the cylinder.

  • Mount the bolt to the rod end. You can use some glue.

Microswitches:

  • You need to modify one of them (for semi-auto selector) a little bit (maybe add a piece of plastic underneath the handle)

  • The switch for magazine detection will be installed this way.

Modify the charging handle

  • Glue the charging handle block to the front to make sure the surface toward the TOF sensor is flat.

  • You will need to file the L shape end to make sure it can slide into the upper.

Assembly

Upper

  • Install the TOF sensor. Make sure its' direction is parallel to the handle's movement (you can use the TOF spacer and cut some rubber plate)

  • Install the charging handle and pneumatic parts.

  • Make sure your wiring is secured.

  • The two pieces can be fixed by using screws (3xM2 to the top and )

Trigger box

  • Install the microswitch for mag detection (with two M2 screws).

  • Install the microswitches for firing and semi-auto (with two M2 screws).

  • Install the electromagnet (with two M2 screws).

  • Install the Hall sensor (you can use some hot glue). You adjust the position of the Hall sensor for later steps.

  • Install the trigger and its' spring.

  • Connect the wires.

下机匣

  • Install the trigger guards, take-down pins, selector pin, buffer pin, buffer tube to the lower.

  • Install the trigger box. fix it with the pin and the magazine release.

  • Secure your wires. install the pistol grip (do not tight the screw yet).

  • Install the selector (be careful of the little metal handles of the microswitches! ) Now you can tighten the screw.

  • Use epoxy to glue the disc magnet to the bolt catch. Be aware of the polarity. The hall sensor is only sensitive toward one direction.

  • Install the bolt catch (with an M2.5 screw). You may need to file or trim it to make sure:

    • There is no friction between it and the lower (the electromagnet can move it easily).
    • It moves freely when the upper is installed.
    • It can hold the bolt (the corner that makes contact with the bolt is not so round).
    • It can release the bolt once you press it (the corner that makes contact with the bolt is smooth).

  • This is how the bolt catch works:

PCB

  • You can find the schematic, PCB design, and Gerber files in the source file.

  • Some soldering. (Move the components from the DC-DC module to the PCB.) The PCB was updated after I made this prototype, but has not been tested yet. I made the mistake of using the pins that are connected to the internal flash as GPIO.

  • The pinout is shown below.

  • There is a model to mount your PCB inside the pistol grip. Wires are TTL (TXD, RXD, GND) and power (11.1V Li-Po)

Assemble the upper and the lower

  • Connect the connectors (ToF sensor and the solenoid valve)

  • Place the upper and the lower in place and fix them with the front and rear take-down pins.

Firmware

  • Flash the firmware:

    • Turn the switch to "flash" (IO 0 is connected to the GND).
    • Connect TXD to RXD of the USB-TTL board, RXD to TXD, and GND to GND (can't remember whether you should connect the USB first or power up first).
  • Use I2C to read VL6180Xdata (Arduino's default setting for ESP32)

    • White/IO 22: SCL
    • Green/IO 21: SDA

Arduino Configuration

Communication protocol

ESP32 to Unity

  • 5 bytes, example:

    1 2 3 4 5
    0xFA ToF H ToF L Switches' states 0xAF
  • Start: 0xFA; end: 0xAF

  • The 2nd, 3rd byte: ToF data

  • The 4th byte: the 5th bit is used to report the solenoid operation is done (from turning on to turning off). The last four bits are used to represent the states of microswitches.

    7 6 5 4 3 2 1 0
    x x x Operating is done
    "1" is "done".
    Hold open
    "1" is closed.
    "0" is open.
    Magazine inserted
    "1" is no mag.
    "0" is mag inserted.
    Trigger
    "1" is trigger pulled
    "0" is not being pulled.
    Semi-auto
    "1" is auto.
    "0" is semi.

Unity to ESP32

  • 1 byte. The first 4 bits are used to control the time of turning on the solenoid. The latter 4 bits are used to decide how long it takes to turn off the electromagnet after turning the solenoid off.
    • Solenoid being turned on for 0 ~ 150ms. Step size: 10ms. The command is 0x0 ~ 0xF.
    • Electromagnet delay is 10 ~ 150ms. Step size: 10ms. The command is 0x1 ~ 0xF. The command 0x0 will not turn on the electromagnet at all.
    • Example:
      • 0x20 will turn on the solenoid for 20ms, the electromagnet will not be turned on.
      • 0x2A will turn on the solenoid for 20ms, electromagnet for 120ms (20ms plus 100ms delay).

Acknowledgment

Big thanks to Tomi, 老吴, Eric, and 检察长!

Early prototype (with circuit inside of the lower)

About

VR15: a VR FPS game controller that generates haptic feedback with high-pressure air.


Languages

Language:C++ 100.0%