Skip to content

Commit 30bcd49

Browse files
authored
Merge pull request #48 from schmrlng/0.7
Updates for Julia 0.7, dropping 0.6 support
2 parents 3b123e3 + a5cb6ca commit 30bcd49

File tree

11 files changed

+75
-63
lines changed

11 files changed

+75
-63
lines changed

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
language: julia
22
julia:
3-
- 0.6
3+
- 0.7
4+
- 1.0
45
- nightly
56
sudo: required
67
dist: trusty
8+
env:
9+
global:
10+
- PYTHON=python
711
before_install:
812
- sudo apt-add-repository -y "deb http://packages.ros.org/ros/ubuntu trusty main"
913
- wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
@@ -19,10 +23,18 @@ before_script:
1923
- python test/echonode.py &
2024
- sleep 5
2125
after_success:
22-
- julia -e 'cd(Pkg.dir("RobotOS")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
23-
- julia -e 'Pkg.add("Documenter");'
24-
- julia -e 'cd(Pkg.dir("RobotOS")); ENV["DOCUMENTER_DEBUG"]="true"; include(joinpath("docs", "make.jl"))'
26+
- julia --project -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
2527
after_script:
2628
- killall roscore
2729
- killall python
2830
- sleep 5
31+
jobs:
32+
include:
33+
- stage: "Documentation"
34+
julia: 1.0
35+
os: linux
36+
script:
37+
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate();
38+
Pkg.add(PackageSpec(path=pwd()))'
39+
- julia --project=docs/ docs/make.jl
40+
after_success: skip

REQUIRE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
julia 0.6
2-
PyCall 1.11.0
3-
Compat 0.34.0
1+
julia 0.7
2+
PyCall 1.17.1

docs/Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
4+
[compat]
5+
Documenter = "~0.19"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ deploydocs(
1111
branch = "gh-pages",
1212
latest = "master",
1313
osname="linux",
14-
julia="0.6",
14+
julia="1.0",
1515
deps=Deps.pip("mkdocs"),
1616
)

docs/src/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ load-time latency (useful for real-life applications!) by generating the ROS typ
7777
modules inside your package module using an approach similar to the example below:
7878

7979
# MyROSPackage.jl
80-
__precompile__()
8180
module MyROSPackage
8281

8382
using RobotOS
8483

8584
@rosimport geometry_msgs.msg: Pose
86-
rostypegen(current_module())
85+
rostypegen(@__MODULE__)
8786
import .geometry_msgs.msg: Pose
8887
# ...
8988

src/RobotOS.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
isdefined(Base, :__precompile__) && __precompile__()
2-
31
module RobotOS
42

53
using PyCall
@@ -9,14 +7,22 @@ const _py_sys = PyCall.PyNULL()
97
const _py_ros_callbacks = PyCall.PyNULL()
108
const __rospy__ = PyCall.PyNULL()
119

10+
include("debug.jl")
11+
include("time.jl")
12+
include("gentypes.jl")
13+
include("rospy.jl")
14+
include("pubsub.jl")
15+
include("services.jl")
16+
include("callbacks.jl")
17+
1218
function __init__()
1319
#Put julia's ARGS into python's so remappings will work
1420
copy!(_py_sys, pyimport("sys"))
1521
_py_sys["argv"] = ARGS
1622

1723
#Fill in empty PyObjects
1824
if ! (dirname(@__FILE__) in _py_sys["path"])
19-
unshift!(_py_sys["path"], dirname(@__FILE__))
25+
pushfirst!(_py_sys["path"], dirname(@__FILE__))
2026
end
2127
copy!(_py_ros_callbacks, pyimport("ros_callbacks"))
2228

@@ -32,15 +38,7 @@ function __init__()
3238
end
3339

3440
#Compile the callback notify function, see callbacks.jl
35-
CB_NOTIFY_PTR[] = cfunction(_callback_notify, Cint, Tuple{Ptr{Void}})
41+
CB_NOTIFY_PTR[] = @cfunction(_callback_notify, Cint, (Ptr{Cvoid},))
3642
end
3743

38-
include("debug.jl")
39-
include("time.jl")
40-
include("gentypes.jl")
41-
include("rospy.jl")
42-
include("pubsub.jl")
43-
include("services.jl")
44-
include("callbacks.jl")
45-
4644
end

src/callbacks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#This function will run in a new python thread created by rospy.
22
#No julia allocation allowed.
3-
function _callback_notify(handle::Ptr{Void})
4-
ccall(:uv_async_send, Cint, (Ptr{Void},), handle)
3+
function _callback_notify(handle::Ptr{Cvoid})
4+
ccall(:uv_async_send, Cint, (Ptr{Cvoid},), handle)
55
end
66

77
#The pointer to the compiled notify function. This can't be precompiled so it gets initialized in
88
#the module __init__ function.
9-
const CB_NOTIFY_PTR = Ref{Ptr{Void}}()
9+
const CB_NOTIFY_PTR = Ref{Ptr{Cvoid}}()
1010

1111
function _callback_async_loop(rosobj, cond)
1212
@debug("Spinning up callback loop...")

src/gentypes.jl

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ abstract type AbstractMsg end
6464
abstract type AbstractSrv end
6565
abstract type AbstractService end
6666

67+
_is_tuple_expr(input) = input isa Expr && input.head == :tuple
68+
_is_colon_expr(input) = input isa Expr && input.head == :call && input.args[1] == :(:)
69+
_is_dot_expr(input) = input isa Expr && input.head == :(.)
70+
6771
"""
6872
@rosimport
6973
@@ -81,13 +85,11 @@ macro rosimport(input)
8185
#Rearranges the expression into a RobotOS._rosimport call. Input comes in as a single package
8286
#qualified expression, or as a tuple expression where the first element is the same as the
8387
#single expression case. Most of the code is just error checking that the input takes that form.
84-
@assert input.head in [:tuple, :(.), :(:)] "Improper @rosimport input"
85-
if input.head == :tuple
86-
@assert isa(input.args[1], Expr) "Improper @rosimport input"
87-
@assert input.args[1].head == :(:) "First argument needs ':' following"
88-
types = String[]
88+
@assert _is_tuple_expr(input) || _is_colon_expr(input) || _is_dot_expr(input) "Improper @rosimport input"
89+
if _is_tuple_expr(input)
90+
@assert _is_colon_expr(input.args[1]) "Improper @rosimport input, first argument needs ':' following"
8991
pkg, ismsg, typ = _pkgtype_import(input.args[1])
90-
push!(types, typ)
92+
types = String[typ]
9193
for t in input.args[2:end]
9294
@assert isa(t, Symbol) "Type name ($(string(t))) not a symbol"
9395
push!(types, string(t))
@@ -98,32 +100,29 @@ macro rosimport(input)
98100
return :(_rosimport($pkg, $ismsg, $typ))
99101
end
100102
end
101-
102-
_get_quote_value(input::QuoteNode) = input.value
103-
_get_quote_value(input::Expr) = (@assert input.head == :quote; input.args[1])
104-
105103
#Return the pkg and types strings for a single expression of form:
106104
# pkg.[msg|srv].type or pkg.[msg|srv]:type
107105
function _pkgtype_import(input::Expr)
108-
@assert input.head in (:(.), :(:)) "Improper @rosimport input"
109-
@assert isa(input.args[1], Expr) "Improper @rosimport input"
110-
@assert input.args[1].head == :(.) "Improper @rosimport input"
111-
p = input.args[1].args[1]
106+
@assert _is_colon_expr(input) || _is_dot_expr(input) "Improper @rosimport input"
107+
p_ms, t = _is_colon_expr(input) ? (input.args[2], input.args[3]) : (input.args[1], input.args[2])
108+
@assert _is_dot_expr(p_ms) "Improper @rosimport input"
109+
p = p_ms.args[1]
112110
@assert isa(p, Symbol) "Package name ($(string(p))) not a symbol"
113-
m_or_s = _get_quote_value(input.args[1].args[2])
111+
@assert isa(p_ms.args[2], QuoteNode) "Improper @rosimport input"
112+
m_or_s = p_ms.args[2].value
114113
@assert m_or_s in (:msg,:srv) "Improper @rosimport input"
115114
ps = string(p)
116115
msb = m_or_s == :msg
117116
ts = ""
118-
if isa(input.args[2], Symbol)
119-
ts = string(input.args[2])
120-
elseif isa(input.args[2], Expr)
121-
@assert length(input.args[2].args) == 1 "Type name not a symbol"
122-
tsym = input.args[2].args[1]
117+
if isa(t, Symbol)
118+
ts = string(t)
119+
elseif isa(t, Expr)
120+
@assert length(t.args) == 1 "Type name ($(t)) not a symbol"
121+
tsym = t.args[1]
123122
@assert isa(tsym, Symbol) "Type name ($(string(tsym))) not a symbol"
124123
ts = string(tsym)
125-
elseif isa(input.args[2], QuoteNode)
126-
tsym = input.args[2].value
124+
elseif isa(t, QuoteNode)
125+
tsym = t.value
127126
@assert isa(tsym, Symbol) "Type name ($(string(tsym))) not a symbol"
128127
ts = string(tsym)
129128
end
@@ -179,8 +178,8 @@ function addtype!(mod::ROSMsgModule, typ::String)
179178
if !(typ in mod.members)
180179
@debug("Message type import: ", _fullname(mod), ".", typ)
181180
if _nameconflicts(typ)
182-
warn("Message type '$typ' conflicts with Julia builtin, ",
183-
"will be imported as '$(_jl_safe_name(typ,"Msg"))'")
181+
@warn("Message type '$typ' conflicts with Julia builtin, " *
182+
"will be imported as '$(_jl_safe_name(typ,"Msg"))'")
184183
end
185184
pymod, pyobj = _pyvars(_fullname(mod), typ)
186185

@@ -350,19 +349,19 @@ end
350349

351350
#The imports specific to each module, including dependant packages
352351
function _importexprs(mod::ROSMsgModule, rosrootmod::Module)
353-
imports = Expr[Expr(:import, :RobotOS, :AbstractMsg)]
352+
imports = Expr[:(import RobotOS.AbstractMsg)]
354353
othermods = filter(d -> d != _name(mod), mod.deps)
355-
append!(imports, [Expr(:using,fullname(rosrootmod)...,Symbol(m),:msg) for m in othermods])
354+
append!(imports, [Expr(:using, Expr(:., fullname(rosrootmod)..., Symbol(m), :msg)) for m in othermods])
356355
imports
357356
end
358357
function _importexprs(mod::ROSSrvModule, rosrootmod::Module)
359358
imports = Expr[
360-
Expr(:import, :RobotOS, :AbstractSrv),
361-
Expr(:import, :RobotOS, :AbstractService),
362-
Expr(:import, :RobotOS, :_srv_reqtype),
363-
Expr(:import, :RobotOS, :_srv_resptype),
359+
:(import RobotOS.AbstractSrv),
360+
:(import RobotOS.AbstractService),
361+
:(import RobotOS._srv_reqtype),
362+
:(import RobotOS._srv_resptype)
364363
]
365-
append!(imports, [Expr(:using,fullname(rosrootmod)...,Symbol(m),:msg) for m in mod.deps])
364+
append!(imports, [Expr(:using, Expr(:., fullname(rosrootmod)..., Symbol(m), :msg)) for m in mod.deps])
366365
imports
367366
end
368367

@@ -513,8 +512,8 @@ function _addtypemember!(exprs, namestr, typestr)
513512
jlconargs = exprs[4].args[2].args
514513

515514
if typestr == "char" || typestr == "byte"
516-
warn("Use of type '$typestr' is deprecated in message definitions, ",
517-
"use '$(lowercase(string(_ros_builtin_types[typestr])))' instead.")
515+
@warn("Use of type '$typestr' is deprecated in message definitions, " *
516+
"use '$(lowercase(string(_ros_builtin_types[typestr])))' instead.")
518517
end
519518

520519
typestr, arraylen = _check_array_type(typestr)
@@ -609,7 +608,7 @@ function _splittypestr(typestr::String)
609608
end
610609
#Valid ROS type string is all word chars split by a single forward slash, with
611610
#optional square brackets for array types
612-
_isrostype(s::String) = ismatch(r"^\w+/\w+(?:\[\d*\])?$", s)
611+
_isrostype(s::String) = occursin(r"^\w+/\w+(?:\[\d*\])?$", s)
613612

614613
#Sanitize a string by checking for and removing brackets if they are present
615614
#Return the sanitized type and the number inside the brackets if it is a fixed

test/pubsub.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using .geometry_msgs.msg
77
const Nmsgs = 10
88
const rate = 20. #Hz
99
const msgs = PoseStamped[]
10-
const refs = Array{Vector3}(Nmsgs)
10+
const refs = Array{Vector3}(undef, Nmsgs)
1111
const t0 = to_nsec(get_rostime())
1212

1313
for i=1:Nmsgs

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Compat.Test
1+
using Test
22
using PyCall
33
using RobotOS
44
RobotOS.debug(true)

0 commit comments

Comments
 (0)