-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstart.lua
115 lines (86 loc) · 2.61 KB
/
start.lua
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require "rttlib"
require "rttros"
----------------------
-- get the deployer --
tc=rtt.getTC()
if tc:getName() == "lua" then
depl=tc:getPeer("Deployer")
elseif tc:getName() == "Deployer" then
depl=tc
end
rtt.setLogLevel("Warning")
--[ get convenience objects ]--
gs = gs or rtt.provides()
--tc = tc or rtt.getTC()
--depl = depl or tc:getPeer("Deployer")
--[ required imports ]--
depl:import("rtt_ros")
ros = gs:provides("ros")
ros:import("URDriver")
--rtt.setLogLevel("Info")
depl:loadComponent("URDriverRT_receiver", "URDriverRT_receiver")
URDriverRT_receiver=depl:getPeer("URDriverRT_receiver")
depl:loadComponent("URDriver_receiver", "URDriver_receiver")
URDriver_receiver=depl:getPeer("URDriver_receiver")
depl:loadComponent("URDriver_program", "URDriver_program")
URDriver_program=depl:getPeer("URDriver_program")
--URDriverRT_receiver:setPeriod(0.008)
--URDriver_receiver:setPeriod(0.1)
URDriver_program:setPeriod(0.008)
--[[
--for real robot
URDriver_program:getProperty("robot_address"):set("192.168.1.102")
URDriver_program:getProperty("my_address"):set("192.168.1.101")
URDriverRT_receiver:getProperty("robot_address"):set("192.168.1.102")
]]--
-- for ur sim on the same robot
URDriver_program:getProperty("robot_address"):set("127.0.0.1")
URDriver_program:getProperty("my_address"):set("127.0.0.1")
URDriverRT_receiver:getProperty("robot_address"):set("127.0.0.1")
--for version 1.8
URDriverRT_receiver:getProperty("version_interface"):set("Pre-3.0")
if not URDriverRT_receiver:configure() then
print("failed to conf URDriverRT_receiver")
end
--[[
if not URDriver_receiver:configure() then
print("failed to conf URDriver_receiver")
end
]]--
if not URDriverRT_receiver:start()then
print("failed to start")
end
if not URDriver_program:configure() then
print("failed to conf URDriver_program")
end
print(">> send-program")
if not URDriver_program:send_program()then
print("failed to send-program")
end
print(">> open-server")
if not URDriver_program:open_server()then
print("failed to open-server")
end
if not URDriver_program:start()then
print("failed to start URDriver_program")
end
--[[
in ops
cd URDriver_program
var array q(6)
q[1]=-1.57
send_joint_objective (q,10)
in lua
qport = rttlib.port_clone_conn(URDriverRT_receiver:getPort("q_actual_outport"))
=qport:read()
q=rtt.Variable("array")
q:fromtab({0,-1.57,0,1.57,-1.57,0})
URDriver_program:send_joint_objective(q,10)
]]--
--[[test velocity
URDriver_program:start_send_velocity()
qdd=rtt.Variable("array")
qqdport = rttlib.port_clone_conn(URDriver_program:getPort("qdes_inport"))
qdd:fromtab({0.01,0.01,0.01,0.01,0.01,0.01})
qqdport:write(qdd)
]]