Skip to content

Commit cd03d56

Browse files
authored
Merge pull request #913 from JuliaRobotics/22Q3/enh/toimage
mv toImage better placement
2 parents b2457eb + 07c80b3 commit cd03d56

3 files changed

Lines changed: 91 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- develop
88
- release**
99
jobs:
10-
test:
10+
basic-functional:
1111
name: Julia ${{ matrix.version }} - ${{ matrix.arch }} - ${{ matrix.group }} - ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
1313
env:
@@ -24,7 +24,6 @@ jobs:
2424
- x64
2525
group:
2626
- 'basic_functional_group'
27-
- 'test_cases_group'
2827
steps:
2928
- uses: actions/checkout@v2
3029
- uses: julia-actions/setup-julia@v1
@@ -54,7 +53,53 @@ jobs:
5453
with:
5554
file: lcov.info
5655

57-
test-masters:
56+
test-cases:
57+
name: Julia ${{ matrix.version }} - ${{ matrix.arch }} - ${{ matrix.group }} - ${{ matrix.os }}
58+
runs-on: ${{ matrix.os }}
59+
env:
60+
JULIA_PKG_SERVER: ""
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
version:
65+
- '1.8'
66+
os:
67+
- ubuntu-latest
68+
arch:
69+
- x64
70+
group:
71+
- 'test_cases_group'
72+
continue-on-error: true
73+
steps:
74+
- uses: actions/checkout@v2
75+
- uses: julia-actions/setup-julia@v1
76+
with:
77+
version: ${{ matrix.version }}
78+
arch: ${{ matrix.arch }}
79+
- uses: actions/cache@v1
80+
env:
81+
cache-name: cache-artifacts
82+
with:
83+
path: ~/.julia/artifacts
84+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
85+
restore-keys: |
86+
${{ runner.os }}-test-${{ env.cache-name }}-
87+
${{ runner.os }}-test-
88+
${{ runner.os }}-
89+
- uses: julia-actions/julia-buildpkg@latest
90+
- run: |
91+
git config --global user.name Tester
92+
git config --global user.email te@st.er
93+
- uses: julia-actions/julia-runtest@latest
94+
continue-on-error: ${{ matrix.version == 'nightly' }}
95+
env:
96+
IIF_TEST_GROUP: ${{ matrix.group }}
97+
# - uses: julia-actions/julia-processcoverage@v1
98+
# - uses: codecov/codecov-action@v1
99+
# with:
100+
# file: lcov.info
101+
102+
test-dev-main:
58103
#if: github.ref != 'refs/heads/release**'
59104
name: Upstream Dev
60105
runs-on: ubuntu-latest

src/images/ROSConversions.jl

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,33 @@ function unmarshal(
4040
end
4141

4242

43-
function toImage(msgd::Dict{String,Any})
44-
data = base64decode(msgd["data_b64"])
45-
h, w = msgd["height"], msgd["width"]
46-
47-
if msgd["encoding"] == "mono8"
48-
img = Matrix{Gray{N0f8}}(undef, h, w)
49-
# assuming one endian type for now, TODO both little and big endian
50-
for i in 1:h, j in 1:w
51-
img[i,j] = Gray{N0f8}(data[msgd["step"]*(i-1)+j]/255)
52-
end
53-
img
54-
else
55-
error("Conversion for ROS sensor_msgs.Image encoding not implemented yet $(msgd["encoding"])")
56-
end
57-
end
58-
5943
toImage(msg::Main.sensor_msgs.msg.Image) = unmarshal(msg) |> toImage
6044

45+
46+
"""
47+
$SIGNATURES
48+
49+
Convert `Caesar.Image::Dict` type to ROS message `sensor_msgs.msg.Image`.
50+
51+
See also: [`Caesar.unmarshal`](@ref), [`Caesar.toImage`](@ref), [`Caesar._PCL.toROSPointCloud2`](@ref)
52+
"""
53+
function toROSImage(msgd::Dict{String,Any})
54+
header = Main.std_msgs.msg.Header();
55+
header.seq = msgd["header"]["seq"]
56+
header.stamp = RobotOS.Time(msgd["header"]["stamp"]["secs"], msgd["header"]["stamp"]["nsecs"])
57+
header.frame_id = msgd["header"]["frame_id"]
58+
59+
msg = Main.sensor_msgs.msg.Image();
60+
61+
msg.header = header
62+
msg.height = UInt32(msgd["height"])
63+
msg.width = UInt32(msgd["width"])
64+
65+
msg.is_bigendian = UInt8(msgd["is_bigendian"])
66+
msg.step = UInt32(msgd["step"])
67+
msg.data = base64decode(msgd["data_b64"])
68+
msg.encoding = msgd["encoding"]
69+
70+
msg
71+
end
6172
#

src/images/images.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ export imhcatPretty, csmAnimationJoinImgs, csmAnimateSideBySide
99
export makeVideoFromData
1010

1111

12+
function toImage(msgd::Dict{String,Any})
13+
data = base64decode(msgd["data_b64"])
14+
h, w = msgd["height"], msgd["width"]
15+
16+
if msgd["encoding"] == "mono8"
17+
img = Matrix{Gray{N0f8}}(undef, h, w)
18+
# assuming one endian type for now, TODO both little and big endian
19+
for i in 1:h, j in 1:w
20+
img[i,j] = Gray{N0f8}(data[msgd["step"]*(i-1)+j]/255)
21+
end
22+
img
23+
else
24+
error("Conversion for ROS sensor_msgs.Image encoding not implemented yet $(msgd["encoding"])")
25+
end
26+
end
27+
1228
"""
1329
$SIGNATURES
1430

0 commit comments

Comments
 (0)