BrainsOnBoard/bob_robotics

Make ``BoBRobotics::Viz::JoystickKeyboard`` more configurable

Open

#143 aberto em 8 de ago. de 2019

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)C++ (6 forks)auto 404
enhancementgood first issue

Métricas do repositório

Stars
 (2 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

It would be nice if the mapping of SFML keys to axis, currently hard-coded here, could be configurable - probably via a YAML file. You could implement this in the constructor of JoystickKeyboard something like this:

// Read config values from file
{
    cv::FileStorage configFile(configFilename, cv::FileStorage::READ);
    if(configFile.isOpened()) {
        auto &configNode = configFile["config"];
        cv::read(configNode["leftStickVertical"], m_AxisKeys[HID::JAxis::LeftStickVertical], m_AxisKeys[HID::JAxis::LeftStickVertical]);
        // **TODO** other buttons and axes, ideally saving typing with loops!
    }
}

// Re-write config file
{
    cv::FileStorage configFile(configFilename, cv::FileStorage::WRITE)
    configFile << "config" << "{";
    configFile << "leftStickVertical" << m_AxisKeys[HID::JAxis::LeftStickVertical];
    // **TODO** other buttons and axes, ideally saving typing with loops!
    configFile << "}";
}

Guia do colaborador