-
Notifications
You must be signed in to change notification settings - Fork 2
/
io_example.cpp
46 lines (36 loc) · 1.42 KB
/
io_example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <ur_rtde/rtde_io_interface.h>
#include <ur_rtde/rtde_receive_interface.h>
#include <iostream>
#include <thread>
using namespace ur_rtde;
int main(int argc, char* argv[])
{
RTDEIOInterface rtde_io("127.0.0.1");
RTDEReceiveInterface rtde_receive("127.0.0.1");
/** How-to set and get standard and tool digital outputs. Notice that we need the
* RTDEIOInterface for setting an output and RTDEReceiveInterface for getting the state
* of an output.
*/
if (rtde_receive.getDigitalOutState(7))
std::cout << "Standard digital out (7) is HIGH" << std::endl;
else
std::cout << "Standard digital out (7) is LOW" << std::endl;
if (rtde_receive.getDigitalOutState(16))
std::cout << "Tool digital out (16) is HIGH" << std::endl;
else
std::cout << "Tool digital out (16) is LOW" << std::endl;
rtde_io.setStandardDigitalOut(7, true);
rtde_io.setToolDigitalOut(0, true);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
if (rtde_receive.getDigitalOutState(7))
std::cout << "Standard digital out (7) is HIGH" << std::endl;
else
std::cout << "Standard digital out (7) is LOW" << std::endl;
if (rtde_receive.getDigitalOutState(16))
std::cout << "Tool digital out (16) is HIGH" << std::endl;
else
std::cout << "Tool digital out (16) is LOW" << std::endl;
// How to set a analog output with a specified current ratio
rtde_io.setAnalogOutputCurrent(1, 0.25);
return 0;
}