Skip to content

Commit 97edcb3

Browse files
committed
Series of fixes to CI, documentation workflow, and small bug fixes.
- Update CI.yml to point to correct branch (main instead of master) - Run CI on julia 1.9, 1.10 AND 1.11 - Fix compat in Project.toml, add entries to improve compat for julia 1.9 - Initialize all caches vectors/matrices to zero instead of undef. - Separate out ros example from ROS.jl - Update documentation github workflow to work with GLMakie - Link to docs from readme
1 parent 298dfa9 commit 97edcb3

File tree

13 files changed

+177
-190
lines changed

13 files changed

+177
-190
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: CI
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
tags: ['*']
77
pull_request:
88
branches:
9-
- master
9+
- main
1010
concurrency:
1111
# Skip intermediate builds: always.
1212
# Cancel intermediate builds: only if it is a pull request build.
@@ -20,8 +20,9 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
version:
23-
# - '1.0'
2423
- '1.9'
24+
- '1.10'
25+
- '1.11'
2526
- 'nightly'
2627
os:
2728
- ubuntu-latest

.github/workflows/documentation.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@ on:
99

1010
jobs:
1111
build:
12+
env:
13+
MODERNGL_DEBUGGING: "true" # turn on errors when running OpenGL tests
1214
permissions:
1315
actions: write
1416
contents: write
1517
pull-requests: read
1618
statuses: write
17-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-20.04
1820
steps:
1921
- uses: actions/checkout@v4
2022
- uses: julia-actions/setup-julia@v2
2123
with:
2224
version: '1'
2325
- uses: julia-actions/cache@v2
24-
- name: Install dependencies
26+
- name: Install GLMakie dependencies for headless server # From https://github.com/MakieOrg/Makie.jl/tree/master/GLMakie#troubleshooting-opengl.
27+
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils
28+
- name: Precompile
2529
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
26-
- name: Build and deploy
30+
- name: Build and Deploy
2731
env:
2832
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
2933
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
30-
run: julia --project=docs/ docs/make.jl
34+
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ docs/make.jl
35+

Project.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,30 @@ VMRobotControlMakieExt = "Makie"
4545

4646
[compat]
4747
BenchmarkTools = "1"
48-
ColorTypes = ">= 0.11"
49-
Colors = ">= 0.12"
50-
DataStructures = ">= 0.18"
51-
DifferentialEquations = "7"
48+
ColorTypes = "0.11, 0.12"
49+
Colors = "0.12, 0.13"
50+
DataStructures = "0.18"
5251
DiffResults = "1"
53-
DigitalAssetExchangeFormatIO = ">= 1.1.2" # This is required, previous versions broken
52+
DifferentialEquations = "7"
53+
DigitalAssetExchangeFormatIO = "1.1.2"
5454
EzXML = "1"
5555
FileIO = "1"
56-
ForwardDiff = ">= 0.10"
56+
ForwardDiff = "0.10"
5757
FunctionWrappers = "1"
58-
GeometryBasics = ">= 0.4"
58+
GeometryBasics = "0.4"
5959
Graphs = "1"
60-
JSON = ">= 0.21"
61-
LoopVectorization = ">= 0.12"
62-
Makie = ">= 0.21"
63-
MeshIO = ">= 0.4"
64-
Observables = ">= 0.5"
60+
JSON = "0.21"
61+
LoopVectorization = "0.12"
62+
Makie = "0.21"
63+
MeshIO = "0.4"
64+
Observables = "0.5"
6565
OrderedCollections = "1"
66-
PreallocationTools = ">= 0.4"
67-
ResultTypes = "4"
68-
StaticArrays = ">= 1.8.1" # Manual
69-
StatsBase = ">= 0.34"
7066
Pkg = "1"
67+
PreallocationTools = "0.4"
68+
ResultTypes = "3, 4"
7169
SparseArrays = "1"
70+
StaticArrays = "1.8.1"
71+
StatsBase = "0.34"
7272

7373
[extras]
7474
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# VMRobotControl.jl
22

3-
![VMRobotControl.jl logo](docs/src/assets/Logo.svg)
3+
<div align="center">
4+
<picture>
5+
<source srcset="docs/src/assets/Logo.svg" >
6+
<img alt="VMRobotControl.jl logo" src="docs/src/assets/Logo.svg" width="350">
7+
</picture>
8+
</div>
9+
10+
[![][docs-dev-img]][docs-dev-url]
411

512
VMRobotControl allows you to build dynamic controllers for your robot as intuitive
613
virtual mechanisms.
@@ -17,6 +24,9 @@ properties.
1724
This provides a simple way to program complex robot behaviour incrementally, from mechanical
1825
primitives.
1926

27+
[docs-dev-img]: https://img.shields.io/badge/Docs-dev-blue.svg
28+
[docs-dev-url]: https://cambridge-control-lab.github.io/VMRobotControl.jl/dev
29+
2030
# Installation
2131

2232
Julia must be installed, I recommend using [juliaup](https://github.com/JuliaLang/juliaup). `VMRobotControl.jl` is only tested on the latest julia version.
@@ -56,7 +66,9 @@ test
5666

5767
# Manually building documentation
5868

59-
Activate the docs environment, from the VMRobotControl.jl folder:
69+
We recommend [reading the docs online](docs-dev-url), but you can also build
70+
them locally. To do so, activate the docs environment, from the
71+
`VMRobotControl.jl` folder:
6072
```
6173
activate docs
6274
add DifferentialEquations, Documenter, FileIO, ForwardDiff, GLMakie, Literate, LiveServer, MeshIO, StaticArrays
@@ -67,5 +79,5 @@ include("./docs/make.jl")
6779
```
6880
and host them using `LiveServer.jl`:
6981
```julia
70-
include("./docs/make.jl")
82+
include("./docs/host.jl")
7183
```

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
55
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
66
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
7+
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
78
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
89
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
910
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"

docs/make.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
using Revise
1+
module_dir = joinpath(splitpath(Base.source_dir())[1:end-1])
2+
if pwd() != module_dir
3+
@info "Changing directory to folder $(module_dir)"
4+
cd(module_dir)
5+
end
6+
7+
# Ensure that VMRobotControl is devved.
8+
using Pkg
9+
Pkg.develop(PackageSpec(path=pwd()))
10+
Pkg.instantiate()
211

312
using
413
DifferentialEquations,

ros/ROS.jl

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Pkg; Pkg.activate("VMRobotControlEnv"; shared=true)
2-
31
using Printf
42
using Sockets
53
using StaticArrays
@@ -397,78 +395,3 @@ function ros_vm_controller(
397395
(E = stored_energy(control_cache)) > E_max && error("Initial stored energy exceeds $(E_max)J, was $(E)J")
398396
warmup_and_activate(connection, control_func!; )
399397
end
400-
401-
#=
402-
# Enable debug logging
403-
using Logging
404-
debuglogger = ConsoleLogger(stderr, Logging.Debug)
405-
global_logger(debuglogger)
406-
=#
407-
408-
#=
409-
# Test connection with python only
410-
with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT+1, 7, 14) do connection
411-
warmup_and_activate(connection, test_control_func; )
412-
end
413-
=#
414-
415-
#=
416-
# Test on franka
417-
module_path = joinpath(splitpath(splitdir(pathof(VMRobotControl))[1])[1:end-1])
418-
using FileIO, UUIDs
419-
try
420-
FileIO.add_format(format"DAE", (), ".dae", [:DigitalAssetExchangeFormatIO => UUID("43182933-f65b-495a-9e05-4d939cea427d")])
421-
catch
422-
end
423-
robot = parseRSON(joinpath(module_path, "RSONs/rsons/franka_panda/pandaSurgicalV2.rson"))
424-
add_gravity_compensation!(robot, 1.1*DEFAULT_GRAVITY)
425-
426-
vms = compile(VirtualMechanismSystem("franka", robot))
427-
qᵛ = Float64[]
428-
429-
with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT, 7, 14) do connection
430-
ros_vm_controller(connection, vms, qᵛ)
431-
end
432-
=#
433-
434-
# Test on sciurus
435-
# Test on franka
436-
module_path = joinpath(splitpath(splitdir(pathof(VMRobotControl))[1])[1:end-1])
437-
robot = parseURDF(joinpath(module_path, "URDFs/sciurus17_description/urdf/sciurus17.urdf"))
438-
add_gravity_compensation!(robot, DEFAULT_GRAVITY)
439-
440-
vms = VirtualMechanismSystem("sciurus", robot)
441-
# add_gravity_compensation!(vms, -0.2*DEFAULT_GRAVITY)
442-
add_coordinate!(vms, ReferenceCoord(Ref(SVector(.3, 0.1, 0.2))); id="l_tgt")
443-
add_coordinate!(vms, FramePoint(".robot.l_link7", SVector(0., 0., 0.)); id="l_hand")
444-
add_coordinate!(vms, CoordDifference("l_tgt", "l_hand"), id="l_err")
445-
add_component!(vms, TanhSpring("l_err"; stiffness=200.0, max_force=5.0); id="l_spring")
446-
add_component!(vms, LinearDamper(5., "l_err"); id="l_damper")
447-
448-
add_coordinate!(vms, ReferenceCoord(Ref(SVector(.3, 0.1, 0.2))); id="r_tgt")
449-
add_coordinate!(vms, FramePoint(".robot.r_link7", SVector(0., 0., 0.)); id="r_hand")
450-
add_coordinate!(vms, CoordDifference("r_tgt", "r_hand"), id="r_err")
451-
add_component!(vms, TanhSpring("r_err"; stiffness=200.0, max_force=5.0); id="r_spring")
452-
add_component!(vms, LinearDamper(5., "r_err"); id="r_damper")
453-
454-
455-
456-
function f_setup(cache)
457-
l_ref_coord_id = get_compiled_coordID(cache, "l_tgt")
458-
r_ref_coord_id = get_compiled_coordID(cache, "r_tgt")
459-
return (l_ref_coord_id, r_ref_coord_id)
460-
end
461-
462-
function f_control(cache, t, setup_ret, extra)
463-
l_ref_coord_id, r_ref_coord_id = setup_ret
464-
coord = cache[l_ref_coord_id].coord_data.val[] = SVector(0.3, .1 + 0.1*sin(t), 0.2)
465-
coord = cache[r_ref_coord_id].coord_data.val[] = SVector(0.3 + 0.1*cos(t), -.1, 0.2 + 0.1*sin(t))
466-
nothing
467-
end
468-
469-
cvms = compile(vms)
470-
471-
qᵛ = Float64[]
472-
with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT, 21, 42) do connection
473-
ros_vm_controller(connection, cvms, qᵛ; f_control, f_setup, E_max=2.0)
474-
end

ros/ros_example.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Load ROS communication code
2+
include("ROS.jl")
3+
4+
# Load robot model
5+
module_path = joinpath(splitpath(splitdir(pathof(VMRobotControl))[1])[1:end-1])
6+
robot = parseURDF(joinpath(module_path, "URDFs/sciurus17_description/urdf/sciurus17.urdf"))
7+
# Include gravity compensation done by robot software (not done by our controller)
8+
add_gravity_compensation!(robot, DEFAULT_GRAVITY)
9+
10+
# Build our virtual mechanism controller
11+
vms = VirtualMechanismSystem("sciurus", robot)
12+
add_coordinate!(vms, ReferenceCoord(Ref(SVector(.3, 0.1, 0.2))); id="l_tgt")
13+
add_coordinate!(vms, FramePoint(".robot.l_link7", SVector(0., 0., 0.)); id="l_hand")
14+
add_coordinate!(vms, CoordDifference("l_tgt", "l_hand"), id="l_err")
15+
add_component!(vms, TanhSpring("l_err"; stiffness=200.0, max_force=5.0); id="l_spring")
16+
add_component!(vms, LinearDamper(5., "l_err"); id="l_damper")
17+
18+
add_coordinate!(vms, ReferenceCoord(Ref(SVector(.3, 0.1, 0.2))); id="r_tgt")
19+
add_coordinate!(vms, FramePoint(".robot.r_link7", SVector(0., 0., 0.)); id="r_hand")
20+
add_coordinate!(vms, CoordDifference("r_tgt", "r_hand"), id="r_err")
21+
add_component!(vms, TanhSpring("r_err"; stiffness=200.0, max_force=5.0); id="r_spring")
22+
add_component!(vms, LinearDamper(5., "r_err"); id="r_damper")
23+
24+
function f_setup(cache)
25+
l_ref_coord_id = get_compiled_coordID(cache, "l_tgt")
26+
r_ref_coord_id = get_compiled_coordID(cache, "r_tgt")
27+
return (l_ref_coord_id, r_ref_coord_id)
28+
end
29+
30+
function f_control(cache, t, setup_ret, extra)
31+
l_ref_coord_id, r_ref_coord_id = setup_ret
32+
coord = cache[l_ref_coord_id].coord_data.val[] = SVector(0.3, .1 + 0.1*sin(t), 0.2)
33+
coord = cache[r_ref_coord_id].coord_data.val[] = SVector(0.3 + 0.1*cos(t), -.1, 0.2 + 0.1*sin(t))
34+
nothing
35+
end
36+
37+
# Compile the virtual mechanism system, and run the controller via ROS
38+
# Make sure rospy_client.py is running first.
39+
cvms = compile(vms)
40+
qᵛ = Float64[]
41+
with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT, 21, 42) do connection
42+
ros_vm_controller(connection, cvms, qᵛ; f_control, f_setup, E_max=2.0)
43+
end

src/coordinates/coordinate_cache.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ abstract type AbstractCoordinateCache{T} end
33
struct CoordKinematicsCache{T} <: AbstractCoordinateCache{T}
44
z::Vector{T}
55
function CoordKinematicsCache{T}(Nc) where T
6-
new{T}(Vector{T}(undef, Nc))
6+
new{T}(zeros(T, Nc))
77
end
88
end
99

@@ -12,8 +12,8 @@ struct CoordJacobiansCache{T} <: AbstractCoordinateCache{T}
1212
J::Matrix{T}
1313
function CoordJacobiansCache{T}(Nc, NDOF) where T
1414
new{T}(
15-
Vector{T}(undef, Nc),
16-
Matrix{T}(undef, Nc, NDOF)
15+
zeros(T, Nc),
16+
zeros(T, Nc, NDOF)
1717
)
1818
end
1919
end
@@ -24,9 +24,9 @@ struct CoordRBStatesCache{T} <: AbstractCoordinateCache{T}
2424
::Vector{T}
2525
function CoordRBStatesCache{T}(Nc) where T
2626
new{T}(
27-
Vector{T}(undef, Nc),
28-
Vector{T}(undef, Nc),
29-
Vector{T}(undef, Nc)
27+
zeros(T, Nc),
28+
zeros(T, Nc),
29+
zeros(T, Nc)
3030
)
3131
end
3232
end
@@ -38,10 +38,10 @@ struct CoordRBStatesJacobianCache{T} <: AbstractCoordinateCache{T}
3838
J::Matrix{T}
3939
function CoordRBStatesJacobianCache{T}(Nc, NDOF) where T
4040
new{T}(
41-
Vector{T}(undef, Nc),
42-
Vector{T}(undef, Nc),
43-
Vector{T}(undef, Nc),
44-
Matrix{T}(undef, Nc, NDOF)
41+
zeros(T, Nc),
42+
zeros(T, Nc),
43+
zeros(T, Nc),
44+
zeros(T, Nc, NDOF)
4545
)
4646
end
4747
end
@@ -53,10 +53,10 @@ struct CoordRBStatesWrenchesCache{T} <: AbstractCoordinateCache{T}
5353
f::Vector{T}
5454
function CoordRBStatesWrenchesCache{T}(Nc) where T
5555
new{T}(
56-
Vector{T}(undef, Nc),
57-
Vector{T}(undef, Nc),
58-
Vector{T}(undef, Nc),
59-
Vector{T}(undef, Nc)
56+
zeros(T, Nc),
57+
zeros(T, Nc),
58+
zeros(T, Nc),
59+
zeros(T, Nc)
6060
)
6161
end
6262
end

src/coordinates/coordinate_implementations.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,15 @@ end
283283

284284
function __jacobian!(cache::CacheBundle, mc::CMC{<:FramePoint})
285285
c = mc.coord_data
286-
Jz = _vms_jacobian_result_view(cache, J_cache_view(cache, mc), c.frameID)
286+
J_view = J_cache_view(cache, mc)
287+
288+
fill!(J_view, zero(eltype(J_view))) # TODO do this once rather than every time
289+
Jz = _vms_jacobian_result_view(cache, J_view, c.frameID)
287290
Jᵥ⁰ᵃ = get_linear_jacobian(cache, c.frameID)
288291
Jω⁰ᵃ = get_angular_jacobian(cache, c.frameID)
289292
T⁰ᵃ = get_transform(cache, c.frameID)
290293

294+
291295
pᵃ = c.point
292296
R⁰ᵃ = rotor(T⁰ᵃ)
293297
δᵒ = rotate(R⁰ᵃ, pᵃ)
@@ -305,6 +309,7 @@ function __jacobian!(cache::CacheBundle, mc::CMC{<:FramePoint})
305309
for i in axes(Jz, 1), j in axes(Jz, 2)
306310
Jz[i, j] = Jᵥ⁰ᵃ[i, j] - skew_p[i, :]' * Jω⁰ᵃ[SVector(1, 2, 3), j]
307311
end
312+
308313
nothing
309314
end
310315

0 commit comments

Comments
 (0)