ParallelIMU::ParallelIMU() {

    //  Using RTIMULib here allows it to use the .ini file generated by RTIMULibDemo.
    //  Or, you can create the .ini in some other directory by using:
    //      RTIMUSettings *settings = new RTIMUSettings("<directory path>", "RTIMULib");
    //  where <directory path> is the path to where the .ini file is to be loaded/saved
    RTIMUSettings *settings = new RTIMUSettings("config", "RTIMULib");

    imu = RTIMU::createIMU(settings);

    if ((imu == NULL) || (imu->IMUType() == RTIMU_TYPE_NULL)) {
    printf("No IMU found\n");
    exit(1);
    }

    //  This is an opportunity to manually override any settings before the call IMUInit

    //  set up IMU
    imu->IMUInit();

    //  this is a convenient place to change fusion parameters
    imu->setSlerpPower(0.02);
    imu->setGyroEnable(true);
    imu->setAccelEnable(true);
    imu->setCompassEnable(true);

    std::thread tempThread(&ParallelIMU::startCapture, this);
    std::swap(tempThread, imuThread);

}
Beispiel #2
0
Lepton::Lepton() {
    SpiOpenPort(0);

    int ret = 0;
    int fd;

    fd = open(device, O_RDWR);
    if (fd < 0)
    {
        pabort("can't open device");
    }

    ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
    if (ret == -1)
    {
        pabort("can't set spi mode");
    }

    ret = ioctl(fd, SPI_IOC_RD_MODE, &mode);
    if (ret == -1)
    {
        pabort("can't get spi mode");
    }

    ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
    if (ret == -1)
    {
        pabort("can't set bits per word");
    }

    ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
    if (ret == -1)
    {
        pabort("can't get bits per word");
    }

    ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
    if (ret == -1)
    {
        pabort("can't set max speed hz");
    }

    ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
    if (ret == -1)
    {
        pabort("can't get max speed hz");
    }

    _latestFrame = (uint16_t*) malloc(VIEWPORT_WIDTH_PIX * VIEWPORT_HEIGHT_PIX * sizeof(uint16_t));
    _newFrameAvailable = false;
    _canOverwriteLatestFrame = true;

    std::thread tempThread(&Lepton::startCapture, this);
    std::swap(tempThread, _leptonThread);
}
Beispiel #3
0
MockIMU::MockIMU() {

    // initialize dummies
    mockPitch = 0;
    mockRoll = 0;
    mockYaw = 0;

    std::thread tempThread(&MockIMU::startCapture, this);
    std::swap(tempThread, imuThread);

}
    void Server::startListening()
    {
        // Bind the listener to a port
        if (listener.listen(53000) == sf::Socket::Done)
        {
            std::cout << "Server listening!" << "\n";
        }

        // Create temporary thread and swap it with this instance's thread.
        std::thread tempThread(listenerThreadFunc, this);
        std::swap(tempThread, listenerThread);
    }
    void Server::listenerThreadFunc()
    {
        while (running && listening)
        {
            if (listener.accept(clients.back().socket) == sf::Socket::Done)
            {
                // Connection accepted.
                std::cout << "Connection successful to " << clients.back().socket.getRemoteAddress() << "!\n";

                // Set client's id.
                clients.back().id = clients.size();

                // Create temporary thread and swap it with the current client's thread.
                std::thread tempThread(clientThreadFunc, this, &clients.back());
                std::swap(tempThread, clients.back().thread);

                // Create the empty position to be filled by the next client.
                clients.emplace_back();
            }
        }
    }
Beispiel #6
0
bool encodeAssembly(CAssemblerCommand* content)
{
	bool Revalidate;
	
	Arm.Pass2();
	Mips.Pass2();

	int validationPasses = 0;
	do	// loop until everything is constant
	{
		Global.validationPasses = validationPasses;
		Logger::clearQueue();
		Revalidate = false;

		if (validationPasses >= 100)
		{
			Logger::queueError(Logger::Error,L"Stuck in infinite validation loop");
			break;
		}

		g_fileManager->reset();

#ifdef _DEBUG
		if (!Logger::isSilent())
			printf("Validate %d...\n",validationPasses);
#endif

		if (Global.memoryMode)
			g_fileManager->openFile(Global.memoryFile,true);

		Revalidate = content->Validate();

		Arm.Revalidate();
		Mips.Revalidate();

		if (Global.memoryMode)
			g_fileManager->closeFile();

		validationPasses++;
	} while (Revalidate == true);

	Logger::printQueue();
	if (Logger::hasError() == true)
	{
		return false;
	}

#ifdef _DEBUG
	if (!Logger::isSilent())
		printf("Encode...\n");
#endif

	// and finally encode
	if (Global.memoryMode)
		g_fileManager->openFile(Global.memoryFile,false);

	// writeTempData, writeSymData and encode all access the same
	// memory but never change, so they can run in parallel
	assemblyContent = content;
	if (Global.multiThreading)
	{
		std::thread tempThread(writeTempData);
		std::thread symThread(writeSymData);

		content->Encode();

		tempThread.join();
		symThread.join();
	} else {
		writeTempData();
		writeSymData();
		content->Encode();
	}

	if (g_fileManager->hasOpenFile())
	{
		if (!Global.memoryMode)
			Logger::printError(Logger::Warning,L"File not closed");
		g_fileManager->closeFile();
	}

	return true;
}