Пример #1
0
def begin():
    """NEED TO PAIR DEVICES FIRST
	will read temp from paired devices for given time
	then write data to an array
	uses thread for each sensor"""
    device_list = ts_api.getComPorts(filter=ts_api.TSS_FIND_DNG)
    print device_list

    com_port = device_list[0]
    dng_device = ts_api.TSDongle(com_port=com_port)

    for i in xrange(numDevices):
        wl_devices.append(dng_device[i])

    for device in wl_devices:
        newThread = threadFunction(device)
        threads.append(newThread)
        newThread.start()

    for thread in threads:
        thread.join()

    return concatData
## Now go through our list of devices and create the appropriate instance by
## using the devices' type and COM port. Unknown devices could be 3-Space Sensor
## devices that were connected via a serial connection. We can find out if there
## is any 3-Space Sensor devices by using the getSensorInfo function. However,
## we must send commands over the port which could make devices other than
## 3-Space Sensor devices act strangely. So, be sure to know what port your
## 3-Space Sensor device(s) are on when calling this function.
## getSensorInfo returns a list of information that it found from the COM port
## (Friendly name, 3-Space Type, 3-Space ID, 3-Space Firmware Version String,
##  3-Space Hardware Version String, is in bootloader mode)
for device_port in device_list:
    com_port, friendly_name, device_type = device_port
    if device_type == "USB":
        device = ts_api.TSUSBSensor(com_port=com_port)
    elif device_type == "DNG":
        device = ts_api.TSDongle(com_port=com_port)
    elif device_type == "WL":
        device = ts_api.TSWLSensor(com_port=com_port)
    elif device_type == "EM":
        device = ts_api.TSEMSensor(com_port=com_port)
    elif device_type == "DL":
        device = ts_api.TSDLSensor(com_port=com_port)
    elif device_type == "BT":
        device = ts_api.TSBTSensor(com_port=com_port)
    elif device_type == "BTL":
        device = "Device on " + com_port + " is in bootloader mode."
    elif device_type == "???":
        port_info = ts_api.getDeviceInfoFromComPort(com_port, poll_device=True)
        device_type = port_info[1]
        is_bootloader = port_info[5]
        if is_bootloader:
Пример #3
0
def returnDev(arg):
    # rospy.init_node("detect")
    result = find_ports.findPorts()
    dng_list = []
    dev_list = []
    rospy.logwarn(result)
    if arg == "dng":
        for a_port in result:
            try:
                rospy.loginfo("Checking for dongle in port %s", a_port)
                dongle = tsa.TSDongle(com_port=a_port, baudrate=115200)
                rospy.logwarn(dongle)
                hwid = convertString(dongle.f7WriteRead('getSerialNumber'))
                panid = None
                channel = None
                wa = None
                att = 0
                while panid is None or channel is None or wa is None:
                    try:
                        att += 1
                        if att > 10:
                            break
                        rospy.loginfo(
                            "Attempting to get Dongle data from port %s, attempt #%d",
                            a_port, att)
                        channel = tsa.TSDongle.getWirelessChannel(dongle)
                        panid = tsa.TSDongle.getWirelessPanID(dongle)
                        wa = tsa.TSDongle.getWirelessAddress(dongle)
                        rospy.logwarn("HW ID : %s", hwid)
                        rospy.logwarn("PanID : %s", panid)
                        rospy.logwarn("Channel : %s", channel)
                        rospy.logwarn("Wireless Address %s", wa)
                        rospy.logwarn(dongle.wireless_table)
                        dng_list.append(dongle)
                    except:
                        pass
            except:
                pass
        print dng_list
        return dng_list
    else:
        for a_port in result:
            try:
                rospy.loginfo("Checking for wireless sensor in port %s",
                              a_port)
                sensor = tsa.TSWLSensor(com_port=a_port, baudrate=115200)
                rospy.logwarn(sensor)
                hwid = convertString(sensor.f7WriteRead('getSerialNumber'))
                # dev_list.append(sensor)
                panid = None
                channel = None
                wa = None
                att = 0
                while panid is None or channel is None or wa is None:
                    try:
                        att += 1
                        if att > 10:
                            break
                        rospy.loginfo(
                            "Attempting to get Wireless Sensor data from port %s, attempt #%d",
                            a_port, att)
                        channel = tsa.TSWLSensor.getWirelessChannel(sensor)
                        # tsa.TSWLSensor.setWirelessPanID(sensor, channel)
                        panid = tsa.TSWLSensor.getWirelessPanID(sensor)
                        wa = tsa.TSWLSensor.getWirelessAddress(sensor)
                        rospy.logwarn("HW ID : %s", hwid)
                        rospy.logwarn("PanID : %s", panid)
                        rospy.logwarn("Channel : %s", channel)
                        rospy.logwarn("Wireless Address %s", wa)
                        dev_list.append(sensor)
                    except:
                        pass
            except:
                pass
        return dev_list
Пример #4
0
        if control_signal[1] < 0:
            control_signal[1] = 0
        elif control_signal[1] > pw_max:
            control_signal[1] = pw_max
        pw = control_signal
        # print(pw, current)
        if stimulation:
            stim.update(3, pw, current)
        # time.sleep(0.2)
    if stimulation:
        stim.stop()
        serialPortStimulator.close()


# IMU setup
dng_device = ts_api.TSDongle(com_port=IMU_port)
IMU_controller_1 = dng_device[IMU_controller_address_1]
IMU_controller_2 = dng_device[IMU_controller_address_2]
IMU_subject_1 = dng_device[IMU_subject_address_1]
IMU_subject_2 = dng_device[IMU_subject_address_2]
IMU_controller_1.setEulerAngleDecompositionOrder(0)
IMU_controller_1.setCompassEnabled(0)
IMU_controller_1.setFilterMode(1)
IMU_controller_1.setStreamingTiming(interval=0,
                                    delay=0,
                                    duration=0,
                                    timestamp=False)
IMU_controller_1.setStreamingSlots(slot0='getTaredOrientationAsEulerAngles',
                                   slot1='getNormalizedGyroRate')
IMU_controller_1.tareWithCurrentOrientation()
IMU_controller_1.startStreaming()
Пример #5
0
import threespace_api as ts_api
import time

################################################################################
################# Second using a broadcaster to get streaming ##################
################# data for every 3-Space Sensor device known ###################
################################################################################
print("=============================")
print("Broadcaster calls")
print("=============================")

all_list = []
sensor_list = []

device = ts_api.TSDongle(com_port='/dev/ttyACM0')

if device is not None:
    all_list.append(device)
    
    for i in range(6): # Only checking the first six logical indexes
            sens = device[i]
            if sens is not None:
                sensor_list.append(sens)
                    
## The YEI 3-Space Python API has a global broadcaster called global_broadcaster
## which is an instance of Broadcaster
ts_api.global_broadcaster.setStreamingTiming(   interval=0,
                                                duration=110000000,
                                                delay=1000000,
                                                delay_offset=12000,
Пример #6
0
import math
import string
import sensor_table
import threespace_api as tsa
import find_ports
from threespace_api import *
from socket import *

rospy.init_node("poll_dongles")

result = find_ports.findPorts()
dongle_list = []
for a_port in result:
    try:
        rospy.loginfo("Checking for dongle in port %s", a_port)
        dongle = tsa.TSDongle(com_port=a_port, baudrate=115200)
        rospy.logwarn(dongle)
        hwid = convertString(dongle.f7WriteRead('getSerialNumber'))
        panid = None
        channel = None
        wa = None
        att = 0
        while panid is None or channel is None or wa is None:
            try:
                att += 1
                rospy.loginfo("Attempting to get Dongle Data attempt #%d", att)
                panid = tsa.TSDongle.getWirelessPanID(dongle)
                channel = tsa.TSDongle.getWirelessChannel(dongle)
                wa = tsa.TSDongle.getWirelessAddress(dongle)
                rospy.logwarn("HW ID : %s", hwid)
                rospy.logwarn("PanID : %s", panid)