Control I/O#

C++#

#include <iostream>

#include <jacobi/planner.hpp>
#include <jacobi/drivers/universal.hpp>
#include <jacobi/robots/universal_ur10e.hpp>


using namespace jacobi;
using namespace jacobi::drivers;
using namespace jacobi::robots;


int main() {
    auto robot = std::make_shared<UniversalUR10e>();
    auto planner = std::make_shared<Planner>(robot);

    auto driver = std::make_shared<UniversalDriver>(planner, "192.168.102.132");

    // Read the value of the digital input
    auto value = driver->get_digital_input("gripper");
    if (!value) {
        std::cout << "Could not read from address 'gripper'." << std::endl;
        std::exit(1);
    }
    std::cout << "Value of digital input 'gripper' is '" << value.value() << "'." << std::endl;

    // Set an output for a group of 8 bits
    const bool success = driver->set_group_output("gripper", 1);
    if (!success) {
        std::cout << "Could not write to address 'gripper'." << std::endl;
        std::exit(1);
    }

    // Read value again
    value = driver->get_digital_input("gripper");
    std::cout << "Value of digital input 'gripper' is now '" << value.value() << "'." << std::endl;
}

Python#

from jacobi import Planner
from jacobi.drivers import UniversalDriver
from jacobi.robots import UniversalUR10e


if __name__ == '__main__':
    robot = UniversalUR10e()
    planner = Planner(robot)

    driver = UniversalDriver(planner, '192.168.102.132')

    # Read the value of the digital input
    value = driver.get_digital_input('gripper')
    if not value:
        print("Could not read from address 'gripper'.")
        exit()

    print(f"Value at digital input 'sensor' is '{value}'.")

    # Set an output for a group of 8 bits
    success = driver.set_digital_output('gripper', 1)
    if not success:
        print("Could not write to address 'gripper'.")
        exit()

    # Read value again
    value = driver.get_digital_input('gripper')
    print(f"Value at digital input 'gripper' is now '{value}'.")