Esempio n. 1
0
    def mouseThreadFunction(self, shared_event, running):
        try:
            # open the connection
            print("Opening connection to SpaceNav driver ...")
            spacenav.open()
            print("... connection established.")
            # register the close function if no exception was raised
            atexit.register(spacenav.close)
        except spacenav.ConnectionError:
            # give some user advice if the connection failed
            print(
                "No connection to the SpaceNav driver. Is spacenavd running?")
            sys.exit(-1)

        # loop over space navigator events
        scaling_value = 1.0
        while running.value:
            # wait for next event
            event = spacenav.wait()

            if type(event) is spacenav.ButtonEvent and event.pressed == 0:
                print("button pressed {}".format(event.button))

                if event.button == 1:
                    scaling_value = scaling_value + 0.1
                    if scaling_value > 2:
                        scaling_value = 2
                    print("scaling up by .1: {}".format(scaling_value))

                elif event.button == 0:
                    scaling_value = scaling_value - 0.1
                    if scaling_value < 0.1:
                        scaling_value = 0.1
                    print("scaling down by .1: {}".format(scaling_value))

            elif type(event) is spacenav.MotionEvent:
                #Update shared memory with mouse information
                shared_event[0] = int(event.x * scaling_value)
                shared_event[1] = int(event.y * scaling_value)
                shared_event[2] = int(event.z * scaling_value)
                shared_event[3] = int(event.rx * scaling_value)
                shared_event[4] = int(event.ry * scaling_value)
                shared_event[5] = int(event.rz * scaling_value)
Esempio n. 2
0
solo = robots_loader.loadSolo()
solo.initDisplay(loadModel=True)

q = solo.q0

solo.display(q)

### Spacemouse configuration
import spacenav as sp
import atexit

try:
    # open the connection
    print("Opening connection to SpaceNav driver ...")
    sp.open()
    print("... connection established.")
    # register the close function if no exception was raised
    atexit.register(sp.close)
except sp.ConnectionError:
    # give some user advice if the connection failed
    print("No connection to the SpaceNav driver. Is spacenavd running?")
    sys.exit(-1)

# reset exit condition
stop = False

dt = 1e-3  # Integration step
t = 0  # Starting time of the simulation

# Convergence gain
Esempio n. 3
0
import spacenav, atexit

try:
    # open the connection
    print("Opening connection to SpaceNav driver ...")
    spacenav.open()
    print("... connection established.")
    # register the close function if no exception was raised
    atexit.register(spacenav.close)
except spacenav.ConnectionError:
    # give some user advice if the connection failed
    print("No connection to the SpaceNav driver. Is spacenavd running?")
    sys.exit(-1)

# reset exit condition
stop = False

# loop over space navigator events
while not stop:
    # wait for next event
    event = spacenav.wait()

    # if event signals the release of the first button
    if type(event) is spacenav.ButtonEvent \
     and event.button == 0 and event.pressed == 0:
        # set exit condition
        stop = True

    # print event
    print(str(event))
Esempio n. 4
0
import spacenav, atexit

try:
	# open the connection
	print("Opening connection to SpaceNav driver ...")
	spacenav.open()
	print("... connection established.")
	# register the close function if no exception was raised
	atexit.register(spacenav.close)
except spacenav.ConnectionError:
	# give some user advice if the connection failed 
	print("No connection to the SpaceNav driver. Is spacenavd running?")
	sys.exit(-1)

# reset exit condition
stop = False

# loop over space navigator events
while not stop:
	# wait for next event
	event = spacenav.wait()

	# if event signals the release of the first button
	if type(event) is spacenav.ButtonEvent \
		and event.button == 0 and event.pressed == 0:
		# set exit condition
		stop = True

	# print event
	print(str(event))