USB Missile Launcher controlled with libusb

I always wanted a weapon of mass destruction in my power. How to imagine who would be my co-workers (Pere, Sergi) who facilitate me the access to one of them.

The weapon in question:

Joking aside and having already fired a few missiles at someone’s head manually with the software that came in the same box of missiles, I had and excellent idea for an application.

Why not make an auto-launch system that lock targets acquired by a webcam?. Sounds good. Wait, those targets will be human? Obviously.

To start we need to have control of the usb. For this task, I used the libusb library. With this library you can make calls to any USB device that has been previously identified with productID and VendorID.

The system is quite simple, first instance the usb device with the correct ProductID and VendorID:

for(bus = usb_get_busses(); bus; bus = bus->next)
{
        // for each bus device
        for(device = bus->devices; device; device = device->next)
        {
                // check the productID and vendorID
                if(device->descriptor.idVendor == 6465 &&
                        device->descriptor.idProduct == 32801)
                {
                        USBMissileLauncher *newLauncher = new USBMissileLauncher(device);
                        mMissileLaunchers.push_back(newLauncher);
                }
        }
}

Once the device is instantiated, you can call the libusb initialization functions:

usb_init();
usb_find_busses();
usb_find_devices();

With this we have our missile launcher ready to listen orders.

Searching in Google, I found the mapping of each order in hexadecimal using usb_control_msg function ().

  • 0x1 / 0x2 : up / down
  • 0x4 / 0x8: left / right
  • 0x10: fire!
  • 0x0: stop

However, although the movement is direct, to shoot something alive I had to send before, two commands used to “init” the missile launcher. They are usb_control_msg parameters.

{‘U’, ‘S’, ‘B’, ‘C’, 0, 0, 4, 0}

{‘U’, ‘S’, ‘B’, ‘C’, 0, 64, 2, 0}

Once they were sent, the shot is interpreted correctly.

Now you can control the usb, I will adapt it to a computer vision algorithm to shoot automatically. Not today but soon. Stay tunned!

This entry was tagged as , ,

Leave a Reply

Your email address will not be published.