Using SpaceNavigator with Arduino?

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

gast0n
Posts: 3
Joined: Sat Sep 29, 2012 8:58 am

Using SpaceNavigator with Arduino?

Post by gast0n » Sat Sep 29, 2012 10:03 am

Hello,

Is it possible to connect the SpaceNavigator directly to a Arduino board without using a computer and the 3Dconnexion SDK as interface?

Thanks!

/Andreas

ngomes
Moderator
Moderator
Posts: 2005
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Using SpaceNavigator with Arduino?

Post by ngomes » Mon Oct 01, 2012 2:42 am

Hi Andreas,

This would be a very cool project but we're not very familiar with the Arduino.

As far as I understand, the USB port on the Arduino is used to set up a serial connection to the programming host. You would need to be able to have a "USB host" capability in the Arduino board to get data directly from the 3D mouse.

One possible alternative, is to use the Raspberry Pi board as it has USB host capabilities (and it should be fairly doable to interface with other Arduino hardware).

mlkoch
Posts: 4
Joined: Mon Jun 24, 2013 1:06 am

Re: Using SpaceNavigator with Arduino?

Post by mlkoch » Mon Jun 24, 2013 1:27 am

Hello,

it is possible to connect a HID device to an arduino board (e.g. Arduino Mega 2560) using a "usb shield" (e. g. the USB Shield 2.0 by circuitsathome http://www.circuitsathome.com/products- ... r-arduino/).
In combination with a joystick (e.g. Logitech Extreme 3D Pro) this works very well.

The problem I have is to define a DataEvent for the SpaceNavigator.

The working DataEvent for the joystick:
struct GamePadEventData
{
union { //axes and hut switch
uint32_t axes;
struct {
uint32_t x : 10;
uint32_t y : 10;
uint32_t hat : 4;
uint32_t twist : 8;
};
};
uint8_t buttons_a;
uint8_t slider;
uint8_t buttons_b;
};

How to define the DataEvent für the SpaceNavigator?

Thanks for any advice!
Michael

jwick
Moderator
Moderator
Posts: 2665
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Mon Jun 24, 2013 7:33 am

Most 3Dx devices send motion data in two packets. The first byte of the packet is a muxing byte that determines which packet it is. 1 for translations; 2 for rotations; 3 for buttons, etc. Some newer devices send all motion the data in one translation packet--your code should be prepared to handle both.

The muxing byte is followed by 3 double byte values (or 6 double bytes) of axis data. The axis data is in X, Y, Z order, little endian.
For the long packets, you get Tx, Ty, Tz, Rx, Ry, Rz. You know which packet it is by the length (7 or 13).

mlkoch
Posts: 4
Joined: Mon Jun 24, 2013 1:06 am

Re: Using SpaceNavigator with Arduino?

Post by mlkoch » Mon Jun 24, 2013 11:21 pm

Thanks a lot for this hint! I'll try my very best :D

Best regards!
Michael

gast0n
Posts: 3
Joined: Sat Sep 29, 2012 8:58 am

Re: Using SpaceNavigator with Arduino?

Post by gast0n » Fri Jul 05, 2013 12:28 pm

Hello Michael!
Did you get the USB Shield 2.0 to work with SpaceNavigator?

Thanks!

/Andreas

mlkoch
Posts: 4
Joined: Mon Jun 24, 2013 1:06 am

Re: Using SpaceNavigator with Arduino?

Post by mlkoch » Tue Jul 16, 2013 3:41 am

Yes, it's working! :D
I 'm going to purge my code and post it here!
Best regards!
Michael

mlkoch
Posts: 4
Joined: Mon Jun 24, 2013 1:06 am

Re: Using SpaceNavigator with Arduino?

Post by mlkoch » Wed Jul 17, 2013 4:40 am

Here is the code ...
Arduino files for usb host shield 2.0 and SpaceNavigator

Have fun!
Michael
Attachments
USB_SpaceNavigator.rar
Arduino files for usb host shield 2.0 and SpaceNavigator
(2.2 KiB) Downloaded 1628 times

jorgef
Posts: 1
Joined: Thu Oct 23, 2014 5:07 pm

Re: Using SpaceNavigator with Arduino?

Post by jorgef » Thu Oct 23, 2014 5:09 pm

The line that reads "JoystickEvents JoyEvents;" is troubling my Arduino. What does this line call for to run?

jwick
Moderator
Moderator
Posts: 2665
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Fri Apr 21, 2017 3:33 am


DRogers96
Posts: 2
Joined: Sun Feb 09, 2020 9:47 pm

Re: Using SpaceNavigator with Arduino?

Post by DRogers96 » Sun Feb 09, 2020 9:50 pm

mlkoch wrote:
Wed Jul 17, 2013 4:40 am
Here is the code ...
Arduino files for usb host shield 2.0 and SpaceNavigator

Have fun!
Michael
I was able to get this code to work, however there is no rotation data.
Any idea why that might be?
I'm using the SpaceMouse Wireless with Arduino UNO and a USB shield.

jwick
Moderator
Moderator
Posts: 2665
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Mon Feb 10, 2020 1:18 am

I didn't look at that code, but there is a difference between the Spacenavigator and SpaceMouse Wireless data packet.
In recent devices, such as the SMW, the rotations are included in the same packet as the translations. The packet is longer.

DRogers96
Posts: 2
Joined: Sun Feb 09, 2020 9:47 pm

Re: Using SpaceNavigator with Arduino?

Post by DRogers96 » Mon Feb 10, 2020 6:16 pm

Yep, that's what it was. I used a USB analyzer on my laptop to see all the data it was sending and saw there were a bunch of data packets that weren't being used by the Arduino code. I added six more variables to hold the six extra data packets that represent the rotation and was able to read the rotation data. The rotation packets are still in x-y-z order. Attached is the updated code (credits to mlkoch for the original code).
Attachments
USBHIDSpaceNavigator.zip
(1.91 KiB) Downloaded 66 times

jwick
Moderator
Moderator
Posts: 2665
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Tue Feb 11, 2020 1:34 am

I probably need to update my code on GitHub too.
I was using a SN to control a car with an Arduino and Raspberry Pi.
I wanted to do it wirelessly but we didn't have a wireless device at the time.

DennisBc
Posts: 1
Joined: Thu Feb 20, 2020 4:51 am

Re: Using SpaceNavigator with Arduino?

Post by DennisBc » Thu Feb 20, 2020 4:58 am

Hey there,
I am trying to connect the SpaceMouse Wireless to an USB Shield on my UNO to control 3 Stepperdrivers on a CNC-Shield.
In the first step I just want to output the values from the mouse (Axis).
I found the provided code and it started but now I struggle to get the USB Input to the Serial Monitor. I am unsure how to get back the values from the dongle.
Is it possible to steer a CNC-Shield with the spacemouse?

Thank you

Post Reply