Spacenav not communicating to Freecad 0.16 on Debian stretch

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
CLCreate
Posts: 5
Joined: Wed Sep 27, 2017 4:54 pm

Spacenav not communicating to Freecad 0.16 on Debian stretch

Post by CLCreate »

I am working on an inexpensive full featured CNC system based around Freecad and the raspberry pi 3.
I know it sounds like an odd combination but you'll be very surprised how well it works.
In fact, Freecad works splendidly, much better than I would have thought. With the proper OpenGL drivers and memory allocation, Freecad is a dream and very stable.
Pycam works well, and using the combination of Freecad, Pycam, and LinuxCNC gives a surprisingly robust and affordable package.

This works so well that I very much wish to get the SpaceNavigator working in Freecad, which would create a nearly perfect package.

Both Freecad and Spacenav appear to be working well but are not communicating with each other.
FreeCAD.log has the error
Log: Couldn't connect to spacenav daemon

As far as I can tell, these lines in GuiApplicationNativeEventAware.cpp is where the issue lies:
#ifdef SPNAV_FOUND
if (spnav_x11_open(QX11Info::display(), window->winId()) == -1)
Base::Console().Log("Couldn't connect to spacenav daemon\n");

Seems that "spnav_x11_open(QX11Info::display(), window->winId())" is returning a -1 even though spacenav is running and communicating.

Hardware
SpaceNavigator over USB connected to a Raspberry Pi 3.
The SpaceNavigator is tested and working properly in Blender, so hardware is not the issue.

Software
Freecad
Version and info:
Version 0.16
Revision number (blank)
Release date 2017/02/01 11:04:13
Operating system Raspian GNU/Linux 9.1 (stretch)
Word size 32 bit

Spacenav
spacenavd_0.6-1_armhf.deb (this installs successfully)

Issuing the command "sudo spacnav_ctl x11 start" returns
"signalled spacenav, it should now start sending x events."

Issuing the command "sudo xhost +" returns
"access control disabled, clients can connect from any host"

Issuing the command "sudo /etc/init.d/spacenavd restart" returns
"[ok] Restarting spacenavd (via systemctl): spacenavd.service"
Issuing this command also blinks the SpaceNavigator LED, so it's communication.

The x11 service is running and active.

Yet opening Freecad and going to Tools -> Customize -> Spaceball = No Spaceball Present

Is there anything I am missing?
Any way to get this to work?
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Spacenav not communicating to Freecad 0.16 on Debian stretch

Post by bejant »

Hi CLCreate, and welcome here! I use a SpaceBall with FreeCAD on Ubuntu, and before I start FreeCAD I have to run this in the terminal:

Code: Select all

sudo xhost +
sudo /etc/init.d/spacenavd restart
Maybe that will help you?

I just tested on:

OS: Ubuntu 16.04.3 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6712 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: da2d364457257a7a8c6fb2137cea12c45becd71a
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

and

OS: Ubuntu 16.04.3 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.17.12140 (Git)
Build type: None
Branch: master
Hash: 6ed14ed76a03d5040f3192a5f529a37d48dd0ce8
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)
CLCreate
Posts: 5
Joined: Wed Sep 27, 2017 4:54 pm

Re: Spacenav not communicating to Freecad 0.16 on Debian stretch

Post by CLCreate »

Thank you for your reply.

Yes I tried this, and here was the response.

Issuing the command "sudo xhost +" returns
"access control disabled, clients can connect from any host"

Issuing the command "sudo /etc/init.d/spacenavd restart" returns
"[ok] Restarting spacenavd (via systemctl): spacenavd.service"
The fault is, apparently, somewhere in the spnav_x11_open routine.

I'm curious why (spnav_x11_open(QX11Info::display(), window->winId()) == -1) is true when spacenav seems to be up and running.
User avatar
tanderson69
Veteran
Posts: 1624
Joined: Thu Feb 18, 2010 1:07 am

Re: Spacenav not communicating to Freecad 0.16 on Debian stretch

Post by tanderson69 »

CLCreate wrote: Thu Sep 28, 2017 2:09 amI'm curious why (spnav_x11_open(QX11Info::display(), window->winId()) == -1) is true when spacenav seems to be up and running.
The daemon is up and running but libspnav (linked into freecad) can't connect to it for some reason.

can you track the build logs for your os. Here is a spacenavd build log for debian stretch amd64 and snippet. Notice the "x11 communication method: yes". See if your os build log has that.

https://buildd.debian.org/status/fetch. ... 5737&raw=0

Code: Select all

configuring spacenavd - 0.6
  prefix: /usr
  optimize for speed: yes
  include debugging symbols: yes
  x11 communication method: yes
  use hotplug: yes
CLCreate
Posts: 5
Joined: Wed Sep 27, 2017 4:54 pm

Re: Spacenav not communicating to Freecad 0.16 on Debian stretch

Post by CLCreate »

Well, I'm getting closer.
I was able to get Spacenav to work by issuing these commands in this order from the command line.
sudo spnavd_ctl x11 start
sudo /etc/init.d/spacenavd restart
sudo cp ~/.Xauthority /root/

Now I am working on automating these commands when starting Freecad.

I modified the freecad.desktop file by adding these lines-
Exec=/etc/init.d/spnav_ctl_start
Exec=/etc/init.d/spacenavd_restart
Exec=/etc/init.d/Xauthority_root

right before the
Exec=/usr/bin/freecad %F
thereby - in theory - starting spacenav properly before freecad so the spacenavigator will be detected.

where spnav_ctl_start, spacenavd_restart, and Xauthority_root
are all executable scripts as follows:

#!/bin/bash
# Spacenavd_restart
sudo /etc/init.d/spacenavd restart

#!/bin/bash
# spnavd_ctl_start
sudo spnavd_ctl x11 start

#!/bin/bash
# Xauthority_root
sudo cp ~/.Xauthority /root/

All of these files work fine executing from the command line, but no luck from the freecad.desktop script.

What would you suggest?
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Spacenav not communicating to Freecad 0.16 on Debian stretch

Post by bejant »

You know more about Linux than me but I'm wondering about this:
CLCreate wrote: Thu Sep 28, 2017 8:02 am right before the
Exec=/usr/bin/freecad %F
thereby - in theory - starting spacenav properly before freecad so the spacenavigator will be detected.
Do you have to authenticate before FreeCAD is started because of the occurrences of sudo in your scripts?
How can you know that spacenavd is actually restarted?
Post Reply