Skip to content

Commit 58a178e

Browse files
committed
Added docstrings to pubsub and service functions
1 parent c95543c commit 58a178e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/pubsub.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ export Publisher, Subscriber, publish
33

44
using Compat
55

6+
"""
7+
Publisher{T}(topic; kwargs...)
8+
Publisher(topic, T; kwargs...)
9+
10+
Create an object to publish messages of type `T` on a topic. Keyword arguments are directly passed
11+
to rospy.
12+
"""
613
type Publisher{MsgType<:AbstractMsg}
714
o::PyObject
815

@@ -16,10 +23,22 @@ end
1623
Publisher{MT<:AbstractMsg}(topic::AbstractString, ::Type{MT}; kwargs...) =
1724
Publisher{MT}(ascii(topic); kwargs...)
1825

26+
"""
27+
publish(p::Publisher{T}, msg::T)
28+
29+
Publish `msg` on `p`, a `Publisher` with matching message type.
30+
"""
1931
function publish{MT<:AbstractMsg}(p::Publisher{MT}, msg::MT)
2032
pycall(p.o["publish"], PyAny, convert(PyObject, msg))
2133
end
2234

35+
"""
36+
Subscriber{T}(topic, callback, cb_args=(); kwargs...)
37+
Subscriber(topic, T, callback, cb_args=(); kwargs...)
38+
39+
Create a subscription to a topic with a callback to use when a message is received, which can be any
40+
callable type. Keyword arguments are directly passed to rospy.
41+
"""
2342
type Subscriber{MsgType<:AbstractMsg}
2443
callback
2544
callback_args::Tuple

src/services.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ export Service, ServiceProxy, wait_for_service
33

44
using Compat
55

6+
"""
7+
ServiceProxy{T}(name; kwargs...)
8+
ServiceProxy(name, T; kwargs...)
9+
10+
Create a proxy object used to invoke a remote service. Use `srv_proxy(msg_request)` with the object
11+
to invoke the service call. Keyword arguments are directly passed to rospy.
12+
"""
613
type ServiceProxy{SrvType <: AbstractService}
714
o::PyObject
815

@@ -32,6 +39,13 @@ end
3239
resp
3340
end
3441

42+
"""
43+
Service{T}(name, callback; kwargs...)
44+
Service(name, T, callback; kwargs...)
45+
46+
Create a service object that can receive requests and provide responses. The callback can be of
47+
any callable type. Keyword arguments are directly passed to rospy.
48+
"""
3549
type Service{SrvType <: AbstractService}
3650
handler
3751
srv_obj::PyObject
@@ -71,6 +85,12 @@ function Service{ST<:AbstractService}(name::AbstractString, srv::Type{ST}, handl
7185
Service{ST}(ascii(name), handler; kwargs...)
7286
end
7387

88+
"""
89+
wait_for_service(srv_name; kwargs...)
90+
91+
Block until the specified service is available. Keyword arguments are directly passed to rospy.
92+
Throws an exception if the waiting timeout period is exceeded.
93+
"""
7494
function wait_for_service(service::AbstractString; kwargs...)
7595
try
7696
__rospy__[:wait_for_service](ascii(service); kwargs...)

0 commit comments

Comments
 (0)