Skip to content

Commit 6492792

Browse files
committed
Change call syntax and drop v0.3 support
1 parent fd63325 commit 6492792

File tree

5 files changed

+16
-21
lines changed

5 files changed

+16
-21
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,23 @@ example:
139139
ROS services are fully supported, including automatic request and response type
140140
generation. For the `@rosimport` call, use the plain service type name. After
141141
`rostypegen()`, the generated `.srv` submodule will contain 3 types: the plain
142-
type, a request type, and a response type. For example `GetPlan`,
143-
`GetPlanRequest`, and `GetPlanResponse`. To provide the service to other nodes,
144-
you would create a `Service{GetPlan}` object. To call it, a
145-
`ServiceProxy{GetPlan}` object. The syntax exactly matches rospy to construct
146-
and use these objects. The only exception is in Julia v0.3, where the `call`
147-
method is not overloaded for objects. In that case, you must call the
148-
`ServiceProxy` via `call(myproxy, myreq)` instead of the rospy method of
149-
`myproxy(myreq)` which works in later versions of Julia.
142+
type, a request type, and a response type. For example `@rosimport
143+
nav_msgs.srv.GetPlan` will create `GetPlan`, `GetPlanRequest`, and
144+
`GetPlanResponse`. To provide the service to other nodes, you would create a
145+
`Service{GetPlan}` object. To call it, a `ServiceProxy{GetPlan}` object. The
146+
syntax exactly matches rospy to construct and use these objects. For example,
147+
if `myproxy` is a `ServiceProxy` object, it can be called with
148+
`myproxy(my_request)`.
150149

151150
### Parameter Server
152151

153152
`get_param`, `set_param`, `has_param`, and `delete_param` are all implemented
154153
in the `RobotOS` module with the same syntax as in rospy.
155154

156155
### Message Constants
157-
Message constants may be accessed using `getindex` syntax. For example for [visualization_msgs/Marker.msg](http://docs.ros.org/api/visualization_msgs/html/msg/Marker.html) we have:
156+
Message constants may be accessed using `getindex` syntax. For example for
157+
[visualization_msgs/Marker.msg](http://docs.ros.org/api/visualization_msgs/html/msg/Marker.html)
158+
we have:
158159

159160
import visualization_msgs.msg: Marker
160161
Marker[:SPHERE] == getindex(Marker, :SPHERE) == 2 # true

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
julia 0.3
1+
julia 0.4
22
PyCall
33
Compat

src/gentypes.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#Generate Julia composite types for ROS messages
2-
using Compat
32

43
export @rosimport, rostypegen, rostypereset, gentypes, cleartypes
54

@@ -38,7 +37,7 @@ const _rospy_imports = Dict{ASCIIString,ROSPackage}()
3837
const _rospy_objects = Dict{ASCIIString,PyObject}()
3938
const _rospy_modules = Dict{ASCIIString,PyObject}()
4039

41-
const _ros_builtin_types = @compat Dict{ASCIIString, Symbol}(
40+
const _ros_builtin_types = Dict{ASCIIString, Symbol}(
4241
"bool" => :Bool,
4342
"int8" => :Int8,
4443
"int16" => :Int16,

src/services.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#API for calling/creating services. Syntax is practically identical to rospy.
22
export Service, ServiceProxy, wait_for_service
33

4-
if VERSION < v"0.4-"
5-
export call
6-
else
7-
import Base.call
8-
end
4+
using Compat
95

106
type ServiceProxy{SrvType <: ServiceDefinition}
117
o::PyObject
@@ -24,8 +20,7 @@ function ServiceProxy{SrvType<:ServiceDefinition}(
2420
ServiceProxy{SrvType}(ascii(name); kwargs...)
2521
end
2622

27-
function call{SrvType <: ServiceDefinition}(
28-
srv::ServiceProxy{SrvType},
23+
@compat function (srv::ServiceProxy{SrvType}){SrvType <: ServiceDefinition}(
2924
req::SrvT
3025
)
3126
if ! isa(req, _srv_reqtype(SrvType))

test/services.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const srvlisten = Service("getplan", GetPlan, srv_cb)
3131
println("Waiting for 'callme' service...")
3232
wait_for_service("callme")
3333
println("Calling service now")
34-
call(srvcall, EmptyRequest())
34+
srvcall(EmptyRequest())
3535

3636
#Wait for call from echo
3737
println("Waiting for service call from echo..")
@@ -52,4 +52,4 @@ end
5252

5353
#Test error handling
5454
@test_throws ErrorException wait_for_service("fake_srv", timeout=1.0)
55-
@test_throws ArgumentError call(srvcall, EmptyResponse())
55+
@test_throws ArgumentError srvcall(EmptyResponse())

0 commit comments

Comments
 (0)