3D Magnetometer Mouse In Processing


[etgalim] works in Solidworks extensively and wanted a more intuitive way of rotating objects onscreen. To do this, he created a mouse that responds to rotation. He put a 3D compass module inside an old mouse and wired it up to an Arduino. The Arduino then relays the I2C sensor data to the computer. So far, he has a Processing script that uses the mouse to rotate a cube, but eventually he wants to write a Solidworks plugin. It’s a bit shaky, and we think it would be a bit smoother (and cheaper) if he used gyros like the jedipad. Video after the jump.

[youtube http://www.youtube.com/watch?v=4PgvRAeuIrk%5D

22 thoughts on “3D Magnetometer Mouse In Processing

  1. >It’s a bit shaky, and we think it would be a bit
    >smoother (and cheaper) if he used gyros like the
    >jedipad. Video after the jump.

    How about an RC-Filter (in software possible, too) or some other data filters?
    Those are normally used to remove the jitter of several sensors.

  2. Can we assume the first of the redundant Sparkfun product links was meant to be the guy’s page? Google translated version:


    Arduino Duemilanove: $30
    Sparkfun compass module: $150 (wow!)
    Replicating the functionality of the $53 SpaceNavigator PE, supported by SolidWorks:


    Let’s be charitable and call it priceless.

    At least it’s a hack. I’m curious how the compass is affected by localized variation in the Earth’s magnetic field and/or nearby electromagnetic disturbance.

  3. I guess this is as good a place to ask as any. I gave SW a try a while ago as a step up from SketchUp (don’t laugh) however there was one thing that just bugged me to the point of quitting. In SketchUp when you “orbit” a model the model will stay upright so to speak. In SW when I “orbit” a model around it will spin around itself and I spent more time trying to get things into position than I did actually learning the program. No matter how many keys I held down or how many menus I went through I couldn’t make it behave like SketchUp. Was it just me being retarded or is there no way to make it behave similarly to SU?

  4. Compass? Gyros? Nice work, but thats what I would call overkill. Why not just take two optical sensors inline. So if the sensors are lined up on Y axis, then mouse is rotated and not moved A sensors X movement would be direct opposite of B sensors movement. If their signal/value sum is positive, mouse is moved to one side, negative, other side. If their values are identical, no rotation is present, only movement to one side.

  5. Yep i have to agree its a good hack but very expensive, also this sort of object navigation is really limited, compaired to the Space Navigator.

    Also it could be easily achieved with an Xbox controller, Iphone, PS3 controller, Wii remote with much better results.

    Cool though craming all that additional tech inside a standard mouse

  6. @sneakypoo

    im not sure what you mean, but i spent 6 months on solidworks at uni and hated it, but if you make assemblys and use “mates” you can normally get things to align nicely.

  7. @uldics: Exactly. It is probably doable even without hardware amendments to the mouse on your desk. Optical mice have low-res monochrome cameras inside (there was a hack some time ago to use optical mouse as crude handy scanner) and calculate the movement per x and y axes between two consecutive frames. In other words, they could as well calculate angle of rotation between the two frames, if they had it implemented and if their MCU processing power suffices. That would be a neat hack…

  8. My guess is he wanted something with an ABSOLUTE 1:1 mapping, rather than the relative mapping you’d get with a SpaceNavigator or similar. Looks like he’s using the compass along with accelerometer data in order to get an absolute orientation (with just the accelerometer, like the many wiimote projects, you have no way of accurately measuring rotation in the horizontal plane, so things get out of alignment rather quickly).

  9. @ryantheleach: My explanation was more than a little fussy so I’m not surprised. The operation I was talking about is when you hold down the middle mousebutton to rotate the view of the object. In sketchup the y-axis is kept perfectly straight while orbiting the object, think coffee cup on the rotating plate in a microwave. You can hold down the button and spin the mouse round and round and you’ll still be right side up.
    Now, with SW if you do the same there it is more like watching space-debris spinning out of control.

  10. @sneakypoo

    Ah I see what you mean, probably because it gives you too much control by mapping the y axis of the mouse to a pitch change.

    You should mail the developers, I’m sure they would at least take it into consideration to make it an option. Alternatively its been a while since I’ve used it but there might be a right click option to only rotate in 1 plane but that would get tedious having to right click all the time and use the context menu.

  11. In solidworks, to rotate about a plane (or cylinder or really anything that only varies in two dimensions, like the outline of a hole or an arc…) do the following, assuming you have a clickable scroll wheel (which you do, if you’re doing the normal pan/rotate thing)
    1) find the plane you wish to rotate about
    2) click on the plane withe the click button in the wheel and let go without moving the mouse. The plane will turn purple
    3) click again on the plane and hold. now drag. Your view will spin about the plane.

    Normally, you’d just do step 3. Steps 1 and 2 are what lock you into a plane.

    If you’re looking to do engineering for a living, knowing SW or PRO/E or inventor(ick) is pretty much a requirement. don’t bother with things like sketch-up, you’ll only waste your time.

  12. @swgeek

    I second that motion. I’ve used sketchup. It’s nicest feature is that it’s free, intuitive and makes decently pretty pictures of models. It’s not useful for much more. I’ve spent about equal time (multiple thousands of hours) on SW, Autocad, and ProE…plus less on a few others.

  13. @swgeek: Sweeet, thanks man I’ll have to give that a try. I’m not using these programs for anything but my own amusement. I find SketchUp absolutely brilliant for quickly making mockups of things I want to build, to give a quick idea if it’s going to work at all (is that circuit going to fit in that box? things of that nature).

    Most recently I designed a new desk in it and it turned out pretty nice in real life as well. I’ve also designed a CNC machine in it but I have yet to build that one. It’s for things like the latter a more capable program such as SW would come in handy but the issue I mentioned was driving me crazy.
    Oh and one last thing @will, give Kerkythea a try if you want to produce stunning looking renders of your SketchUp work.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.