USB Devices / 3D space mouse


#1

Hi There,

I am thinking through the options of using USB-Devices as Inputs for the Axoloti. Especially I am looking to use a Standard mouse, usb Joystick or the 3D Connection space mouse. The latter one recenters like a Joystick, but is able to provide 6 different values (6 DoF) as Input. Usually it is used for CAD applications, but I could imagine that it might be a superb Expression device.

Is there any Chance to get that working? How would you tackle an idea like that?
reverse engineer the raw usb data from the device?

There is some SDK from 3d Connection to connect to their Driver on Windows Systems, but that is probably just of Little use when you connect to a totally different System with no OS at all...

thank you for Feedback,
Reinald


#2

there is some support for standard HID devices in the axoloti firmware, depending on your needs , you might need to extend this.

yeah, if its not a standard HID device, then your going to need to extend the USB devices in the axoloti firmware.
rather than try to reverse engineer data, Id usually look to see if there are some open source drivers available... usually on linux... whilst these will not (obviously) work, its easier to read C/C++ code, to figure out how they work, and then implement that in the axoloti firmware.

as for implementing in Axoloti , you could look at one of the existing usb devices to see how they work.
(basically they are variations on the stm ones)

also before you do too much work, you will want to check its going to work due to hardware, e.g. usb 1.1 and not drawing too much power.


#3

Hi @thetechnobear Mark,

after a quick google search I found some hints that there is support under Linux available:
there is an open source driver, and blender can be build with support for the 3d mouse. Even raspian seems to recognise it and creates some structures in /dev/input for the space navigator.

I will dig into that and see if I get some level of understanding to check if there is some chance to get that migrated to the axoloti firmware.

thank you for pointing out the direction,
Reinald


#4

cool, that's good news.. makes life easier :slight_smile:

ok, you wont be able to 'migrate the software' , as the device structure on Linux is very different....

what I would do is...
largely, ignore the low level usb part of the code, what your looking for is 3 bits code of code:
i) initialisation
often usb devices have some kind of handshake, startup procedure, this can be as simple as recognising the device/model and telling it to start sending data, all the way to downloading firmware to it.
.. the point is, often without that initialisation sequence, the device wont send anything. so this has to be your first step

ii) protocol encoding/decoding
basically, the low level code (which cant be ported) will allow data to be sent to the device, and received from it... it'll then be passed to another bit of code, to handle the data... this is where you'll be able to see the protocol, and might even be able to reuse bits of the code (with some modification)
... once you have this, you should be able to 'see' the raw data

iii) driver capabilities
often, not always, the raw data then has to be massaged to be useable, this can be anything from simple (or complex) filtering... to adding various 'capabilities' (eg switching modes).
obviously this varies enormously between devices, some will do more of this in firmware/hardware, others will have pretty 'dumb' hardware, and do lots of stuff in software.
(also its where, open source drivers often vary from the OEM driver)

of course, the other bit, as mentioned before, is getting familiar with how usb data is sent/received on Axoloti, by looking at other drivers... this is pretty simple for synchronous devices like these.

btw... also what I like to do, is have the open source driver running on Linux (even if only in a VM), this makes it easier to check the code is doing what you think its doing... you can even build a modified version of the driver (with debug code) to check if your unsure.

ps. I had a quick look at the above driver, and your in luck because it appears to be cross-platform, that makes it much , since they already have had to abstract the low level layer, to make it work across platforms.. or in other words, your task is to add an additional platform.


Using the Spacenavigator 3D mouse
#5

I've got a SpaceNavigator too, but have not attempted to get it to work with Axoloti. Current firmware uses the STM32Cube USB Host Library to handle the USB host port. It's a matter of parsing the HID descriptor/report, it should not need to be specific for the SpaceNavigator, but could equally support USB joysticks, flightsticks, steering wheels etc.

But I'm also attempting to replace the STM32Cube USB Host Library with the ChibiOS USB host community driver. The benefit is that it avoids wrapping the STM32Cube host library into Chibios, and that the ChibiOS USB host community driver supports USB hubs. But this effort is currently incomplete, usb-midi works but causes a flood of USB NAK events resulting in a high cpu load.

That means if you do an effort using the STM32Cube USB Host Library it may need additional work when the switch is made to the ChibiOS USB host community driver.


#6

3 posts were split to a new topic: USB Hub support development


#7

thanks for feedback, I will start perparing my build environment for the axoloti. Since I usually spare only a few hours a month on projects like that it might take some time, maybe by that time the change of USB stuff is already changed :slight_smile:


#8

I did a little test, reading/decoding the USB/HID reports from the SpaceNavigator.
In this case I decoded the HID report manually, while the report format is also formally reported by the HID device I believe, so this code is really specific for the SpaceNavigator... (but does not verify it actually is one...).
To use this patch you currently need experimental firmware and GUI, last tested with https://github.com/axoloti/axoloti/commit/3cd4810528d7311ab19fe9a4ed26d90c09137c40
Do not try this if you're not comfortable with Git, C/C++, java, firmware flashing etc.
3dconnection.axp (4.9 KB)


#9

Hi @johannes,
that looks like a good starting point, thank you! I will check as soon as I got my toolchain up and running, unfortunately I didn't have the chance to get forward with that yet :frowning:

cheers,
Reinald


#10

WOW! This thread is a goldmine!
I have been searching for a fitting way to create synthesizer hardware that can work with my spacenavigator in order to create a highly expressive instrument. I had taken so many changes in direction, because turning usb into control parameters seems so difficult without having a full linux system...
And then there comes axoloti!
Guys this is awesome!
So if anyone wants to collaborate in order to create something for spacenavigator (maybe some special fine-tuning of the translation of spacenavigarot-coordinates into control parameters i would like to contribute something.


#11

There is a lot of info available if you search "spacenavigator midi". I use a navigator at work but so far have not brought it home for testing/research. I do however have a number of the old model 2003 3003 'relics' and had planned to make a cool midi controller. I have the original serial protocol if interested and got so far as using an arduino to translate the serial data packets into something usable and had control of the 9 buttons with combinations and force and translation xyz data. I since got busy with other projects and put that one on hold. Realizing my project was serial based is probably not applicable to yours, but for interest sake thought I would chime in. :wink:


#12

Actually that might still be very helpful! I am right now convent waiting on getting the axoloti and finally use it to control sound. (I actually did this a few years back with some strange workarounds and connecting midi out to midi in with some great effect - it was quite cool but had a lot of lag because of the weird setup).
A few weeks back I contacted a German industrial-parts company who sells spacenavigators that are mountable (for putting in a plate - I can try and find the link. The site is magetron or something) they also sell a serial based version. Unfortunately they only sell to companies - so I will wait and build my proof of concept first.
But yeah - reading out the serial data might actually be more useful.
Edit: https://www.megatron.de/produkte/fingerjoysticks/fingerjoystick-serie-spacemouseR-module.html


#13

Thanks for the link. FYI, here is the original serial protocol used: http://spacemice.org/pdf/SpaceBall_2003-3003_Protocol.pdf


#14

If anyone is interested, if you create an account at 3DConnexion, you can download the 3DxWare SDK. There is also a developers forum with a lot of resources.


#15

I'm actually not that interested in using the sdk. I found some python code that can extract all data from the SpaceNavigator as is. It is just about knowing which values do what. I already tried it it worked. It printed the output in the console. The only thing I was wonderin was the datarate. Maybe that is something that can be adjusted by the driver (i felt it was a little slow.) In theory the rate can be 100 times per second, but it feld slower. So maybe on its own the davice just gives less. I don't know.
You can try out the python code yourself - https://github.com/jwick1234/3d-mouse-rpi-python/blob/develop/HelloSpaceNavigator.py
apparently it is written for a Raspberry Pi, but it worked as well on my laptop.
I didn't do much else though since i wanted to avoid a raspberry pi as it is a whole linux. I don't want that overhead so to speak.
The axoloti seems to be able to read it out without the whole stuff around the protocol - that's actually the main reason i just ordered one before :smiley:


#16

yeah just threw the sdk thing out there... I've heard of the Rpi being used but like you would want a more direct approach. It's also been done for the arduino with a usb shield - https://github.com/jwick1234
To be honest I'm not a programmer and usually just hack my way through my projects using examples I find, tweaking, and experimenting... An Axoloti object to parse the incoming data would be cool... but in my project I was unsure what to do with the data once received? ie. parameter control... how best to incorporate the translation and rotation data (each with 3 changing values). Anyhow, this stuff still has my interest and with my 'old' spaceballs being old school serial out I now realize I could likely connect direct to the Axo Rx pin. That will have to wait until I figure out how programming 'anything' in the Axo is done (still a newbie) :sweat_smile:


#17

I am still waiting for my axoloti to arrive, so this is still theoretical...
When I used the Spacenavigator the first time as an expressive device in ableton (used VVVV to turn the USB-Intput into a virtual Midi-Out, connected a midi cable from midi-out to midi-in on my audio-interface and usd the midi-in in ableton) I build my own synth out of the basic blocks plus effects.

here's some ideas of what you can try:

  • z-axis can control volume - that way you create your own tremolo with whatever rhythm you want. If the z-mid-point is normal volume, than of course one direction would be "louder than normal" which might result in clipping along the way. That's why i would add some kind of saturation (mathematically an Arctan-function) around it. So actually this parameter would be some kind of gain i guess.
  • have a band-pass filter that increases volume in that band. like a wahwah. One parameter controls the center-frequency and another the amount. In ableton live (if you know it) there is one great distortion effect that has a bandpass. Only the content in the bandpass is distorted and added to the normal signal. It is a greatly expressive effect that can be used in an instrument (it has both center frequency and amount).
  • one or two reverbs. Put them where you like - before or after the distortion/saturation. I learned that changing the reverb-time and mix of a reverb at the same time can be a great effect. When you have all the lower frequencies in the reverb as well (no or little decay in the low end) you get all kinds of rumbling effects Those are not so cool on its own, but since they have very high amplitudes, they have great effect in the saturation (effectively squishing the waveform of higher frequencies). And with some decay time, when you play two different notes the transition phase between them results in some very unusual sound. So effectively use a reverb not in the final stage of the effect chain, but maybe before and change it's parameters as if it was an expressive thing. This can also result in a cool stereo-to-mono morphing.

  • something i only recently thought of: A modulation between polyphony and arpeggiator. think about a parameter that goes from 0 to 1. It it's at 0 and you play to notes, they play together. at 1 they are played after each other. but at 0.5 they are modulated in a way that one is only half as loud as the other. (of course this effect would actually be polyphonic all the time, so no glide between pitches).

that's about it. if processing power is enough on the axoloti, a chorus in order to make the stereo of the reverb more interesting (before its is distorted :D) can be added and changed over time.