Skip to content

Commit

Permalink
First public release
Browse files Browse the repository at this point in the history
  • Loading branch information
gstavrinos committed Dec 15, 2020
1 parent 3bea704 commit a14553c
Show file tree
Hide file tree
Showing 36 changed files with 2,478 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
deps/deps.jl
*_srv.jl
*_msg.jl
*_action.jl
*.swp
*.swo
src/gen/*
docs/build/*
40 changes: 40 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file is machine-generated - editing it directly is not advised

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BinaryProvider]]
deps = ["Libdl", "Logging", "SHA"]
git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.10"

[[Cxx]]
deps = ["BinaryProvider", "Libdl", "REPL"]
git-tree-sha1 = "71728149f62225470a4ae4260536a98a5009997c"
uuid = "a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2"
version = "0.4.0"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
8 changes: 8 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name = "ROS"
uuid = "a492bfac-16cc-4d50-a8b6-f03352b6b563"
authors = ["George Stavrinos <gstavrinos@protonmail.com>"]
version = "0.1.0"

[deps]
Cxx = "a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
206 changes: 206 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
![ROS.jl](docs/src/assets/logo.png)

ROS.jl is a Julia wrapper of the ROS C++ client.

### Requirements
* Julia 1.3 (due to current Cxx limitations)

### Installation
```julia
pkg> add ROS
```
or
```julia
using Pkg
Pkg.add("ROS")
```
### Importing the ROS client wrapper
```julia
using ROS
```

### Features
* Automatic/Dynamic Julia msg and srv type generation
* NodeHandles
* Publishers and Subscribers
* Service Servers and Clients
* Action Servers and Clients
* ROS Package
* ROS Time
* TF2

### Naming conventions
* All message and service names replace the C++ namespace symbol `::` with an underscore `_`. Thus for example, `geometry_msgs::PoseStamped` would be translated in Julia to `geometry_msgs_PoseStamped`.
* All generated ROS types have the same name as their contructor without the parentheses `()`. Thus for example, in Julia `geometry_msgs_PoseStamped()` will create a `PoseStamped` object but `geometry_msgs_PoseStamped` holds the C++ type of the `PoseStamped` object. This is useful for templated C++ ROS functions (callbacks etc).

### Examples

All the following examples assume that the `@genNew` or the `@updateAll` macro was called.

```julia
using ROS
ROS.@genNew
```

## Minimum Publisher & Subscriber combination example
```julia
using ROS
ROS.@include std_msgs: Float64MultiArray

pub = nothing

function init()
ROS.init("julia_pub_sub")
nh = ROS.NodeHandle()

global pub = ROS.advertise(nh, "test_pub", ROS.std_msgs_Float64MultiArray, 1)
sub = ROS.subscribe(nh, "test_sub", 1, ROS.std_msgs_Float64MultiArray, callback)

while ROS.ok()
ROS.spinOnce()
end
end

function callback(t)
t.data = [1,2,3,4]
ROS.publish(pub,t)
end

init()
```
Note how both the `advertise` and `subscribe` functions include the type of the message as the third parameter.

## Minimum Service Client & Server combination example
```julia
using ROS
ROS.@include std_srvs: SetBool
ROS.@include roscpp_tutorials: TwoInts

srvc = nothing

function init()
ROS.init("test_services")
nh = ROS.NodeHandle()

global srvc = ROS.serviceClient(nh, "add_two_ints", ROS.roscpp_tutorials_TwoInts);
srv = ROS.advertiseService(nh, "test_srv", ROS.std_srvs_SetBool_Request, ROS.std_srvs_SetBool_Response, srv_callback)
while ROS.ok()
ROS.spinOnce()
end
end

function srv_callback(req,res)
res.success = true
res.message = ":D"
st = ROS.roscpp_tutorials_TwoInts()
st.request.a = 1
st.request.b = 3
ROS.call(srvc, st)
return true
end

init()
```
Note how both the `serviceClient` and `advertiseService` functions include the type of the service as the third parameter (and the fourth parameter in the case of `advertiseService`.

## Minimum Action Client & Server combination example
```julia
using ROS
ROS.@include actionlib_tutorials: FibonacciAction, FibonacciFeedback, FibonacciResult, FibonacciGoal

action_server = nothing

function init()
ROS.init("test_actions")
nh = ROS.NodeHandle()

global action_server = ROS.actionlib.SimpleActionServer("test_action_server", ROS.actionlib_tutorials_FibonacciAction)
ROS.actionlib.start(action_server)
ROS.actionlib.registerGoalCallback(action_server, execute_cb)

action_client = ROS.actionlib.SimpleActionClient("test_action_server", ROS.actionlib_tutorials_FibonacciAction)
ROS.actionlib.sendGoal(action_client, ROS.actionlib_tutorials_FibonacciGoal())
ROS.actionlib.waitForResult(action_client, ROS.Duration(3))

action_result_called = ROS.actionlib.getResult(action_client)

while ROS.ok()
state = ROS.actionlib.getState(action_client)
println(state)
ROS.spinOnce()
end

function execute_cb()
goal = ROS.actionlib.acceptNewGoal(action_server)
action_feedback = ROS.actionlib_tutorials_FibonacciFeedback()
f::Vector{Number} = []
for i in 1:100
push!(f,i)
action_feedback.sequence = f
ROS.actionlib.publishFeedback(action_server, action_feedback)
end
action_result = ROS.actionlib_tutorials_FibonacciResult()
action_result.sequence = f
ROS.actionlib.setSucceeded(action_server, action_result, ":)")
end

init()
```

## TF example
```julia
using ROS
ROS.@include geometry_msgs: TransformStamped, PoseStamped

function init()
ROS.init("testTF")
nh = ROS.NodeHandle()

b = ROS.tf.TransformBroadcaster()
sb = ROS.tf.StaticTransformBroadcaster()
bf = ROS.tf.Buffer()
tl = ROS.tf.TransformListener(bf)
ts = ROS.geometry_msgs_TransformStamped()
ts.header.stamp = ROS.now()
ts.header.frame_id = "base_link"
ts.child_frame_id = "gps_link"
ts.transform.translation.x = 2.3
ts.transform.translation.y = 1.6
ts.transform.rotation.w = 1
ts2 = ROS.geometry_msgs_TransformStamped()
ts2.header.stamp = ROS.now()
ts2.header.frame_id = "base_link"
ts2.child_frame_id = "camera_link"
ts2.transform.translation.x = 0.3
ts2.transform.translation.y = 1
ts2.transform.rotation.w = 1

ROS.tf.sendTransform(b, ts)

# Send multiple TFs at once
tss = [ts,ts2]
ROS.tf.sendTransform(sb, tss)

if ROS.tf.canTransform(bf, "base_link", "camera_link", ROS.Time(0), ROS.Duration(1))
stamped = ROS.tf.lookupTransform(bf, "base_link", "camera_link", ROS.Time(0), ROS.Duration(1))
println(stamped.transform.translation.x)
println(stamped.header.frame_id)

p = ROS.geometry_msgs_PoseStamped()
p.header.frame_id = "camera_link"
p.pose.position.x = 1
p.pose.position.y = 0.6
p.pose.orientation.w = 1
try
transformed = ROS.tf.transform(bf, p, "base_link", ROS.Time(0), "gps_link", ROS.Duration(1))
println(transformed.pose.position.x)
catch
println("TF Exception :(")
end
end
end

init()
```
Note the multiple included types using the `@include` macro.

30 changes: 30 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ENV["JULIA_CXX_RTTI"]=1
using Cxx
push!(LOAD_PATH,"../src/")
using Documenter, ROS

makedocs(
modules = [ROS],
authors = "George Stavrinos",
sitename = "ROS.jl",
format = Documenter.HTML(prettyurls = false, footer = nothing),
pages = [
"Home" => "index.md",
"Features" => "features.md",
"Examples" => "examples.md",
"API" => [
"roscpp.md",
"nodehandle.md",
"subscriber.md",
"publisher.md",
"serviceServer.md",
"serviceClient.md",
"time.md",
"package.md",
"actionlib.md",
"tf.md",
"typegen.md"
],
]
)

9 changes: 9 additions & 0 deletions docs/src/actionlib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Actionlib functions
```@index
Pages = ["actionlib.md"]
```

```@autodocs
Modules = [ROS, ROS.actionlib]
Pages = ["actionlib.jl"]
```
Binary file added docs/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a14553c

Please sign in to comment.