7
7
### Description
8
8
9
9
This package enables interfacing Julia code with a ROS ([ Robot Operating
10
- System] ( http://wiki.ros.org ) ) system. It works by generating native Julia types for
11
- ROS messages, the same as in C++ or Python, and then wrapping rospy through the
12
- PyCall package to get communication through topics and parameters.
10
+ System] ( http://wiki.ros.org ) ) system. It works by generating native Julia types
11
+ for ROS types, the same as in C++ or Python, and then wrapping rospy through
12
+ the PyCall package to get communication through topics, services, and
13
+ parameters.
13
14
14
15
### Installation
15
16
@@ -28,18 +29,18 @@ directly to version 1.0.
28
29
29
30
## Usage: Type Generation
30
31
31
- ROS message types are brought into your program with the ` @rosimport ` macro
32
- which specifies a package and one or more types. The three valid forms can be
33
- seen here :
32
+ ROS types are brought into your program with the ` @rosimport ` macro which
33
+ specifies a package and one or more types. The three valid syntax forms can be
34
+ seen in these examples :
34
35
35
36
@rosimport std_msgs.msg.Header
36
- @rosimport geometry_msgs.msg: PoseStamped
37
- @rosimport sensor_msgs .msg: Imu, Image
37
+ @rosimport nav_msgs.srv: GetPlan
38
+ @rosimport geometry_msgs .msg: PoseStamped, Vector3
38
39
39
- ` @rosimport ` will bring in the python modules for the requested type and all
40
+ ` @rosimport ` will import the python modules for the requested type and all
40
41
its dependencies but the native Julia types are not created yet since any
41
42
inter-module dependencies have to be resolved first. After the final
42
- ` @rosimport ` call, initiate the message generation with:
43
+ ` @rosimport ` call, initiate the type generation with:
43
44
44
45
rostypegen()
45
46
@@ -125,6 +126,20 @@ example:
125
126
sub2 = Subscriber{Imu}("topic", cb2, queue_size = 10)
126
127
spin()
127
128
129
+ ### Using services
130
+
131
+ ROS services are fully supported, including automatic request and response type
132
+ generation. For the ` @rosimport ` call, use the plain service type name. After
133
+ ` rostypegen() ` , the generated ` .srv ` submodule will contain 3 types: the plain
134
+ type, a request type, and a response type. For example ` GetPlan ` ,
135
+ ` GetPlanRequest ` , and ` GetPlanResponse ` . To provide the service to other nodes,
136
+ you would create a ` Service{GetPlan} ` object. To call it, a
137
+ ` ServiceProxy{GetPlan} ` object. The syntax exactly matches rospy to construct
138
+ and use these objects. The only exception is in Julia v0.3, where the ` call `
139
+ method is not overloaded for objects. In that case, you must call the
140
+ ` ServiceProxy ` via ` call(myproxy, myreq) ` instead of the rospy method of
141
+ ` myproxy(myreq) ` which works in later versions of Julia.
142
+
128
143
### Parameter Server
129
144
130
145
` get_param ` , ` set_param ` , ` has_param ` , and ` delete_param ` are all implemented
@@ -165,19 +180,29 @@ republishes them as Points.
165
180
rostypegen()
166
181
using geometry_msgs.msg
167
182
168
- callback(msg::Pose2D, pub_obj::Publisher{Point}) = begin
183
+ function callback(msg::Pose2D, pub_obj::Publisher{Point})
169
184
pt_msg = Point(msg.x, msg.y, 0.0)
170
185
publish(pub_obj, pt_msg)
171
186
end
172
- pub = Publisher{Point}("pts", queue_size=10)
173
- sub = Subscriber{Pose2D}("pose", callback, (pub,), queue_size=10)
174
-
175
- init_node("rosjl_example")
176
- loop_rate = Rate(5.0)
177
- while ! is_shutdown()
178
- npt = Point(rand(), rand(), 0.0)
179
- publish(pub, npt)
180
- sleep(loop_rate)
187
+
188
+ function loop(pub_obj)
189
+ loop_rate = Rate(5.0)
190
+ while ! is_shutdown()
191
+ npt = Point(rand(), rand(), 0.0)
192
+ publish(pub_obj, npt)
193
+ sleep(loop_rate)
194
+ end
195
+ end
196
+
197
+ function main()
198
+ init_node("rosjl_example")
199
+ pub = Publisher{Point}("pts", queue_size=10)
200
+ sub = Subscriber{Pose2D}("pose", callback, (pub,), queue_size=10)
201
+ loop(pub)
202
+ end
203
+
204
+ if ! isinteractive()
205
+ main()
181
206
end
182
207
183
208
## Versions
0 commit comments