Skip to content

Commit

Permalink
refactor: proto merge
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat committed Aug 30, 2023
1 parent a3b4e7c commit 4d5e476
Show file tree
Hide file tree
Showing 56 changed files with 630 additions and 791 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ jobs:
- uses: hendrikmuhs/ccache-action@v1

- name: Install system dependencies (Ubuntu)
run: ./cmake/scripts/install_deps_ubuntu.sh
run: ./scripts/install_deps_ubuntu.sh
if: matrix.os == 'ubuntu-20.04'

- name: Install venv dependencies
run: ./scripts/build_venv/build_venv.sh

- name: Create Archive For Release
run: |
tar -czvf venv-${{ matrix.os }}.tar.gz cmake/venv/prefix
ls
tar -czvf venv-${{ matrix.os }}.tar.gz scripts/build_venv/venv/prefix
- name: Upload release assets
uses: actions/upload-release-asset@v1
Expand Down
1 change: 1 addition & 0 deletions cpp/farm_ng/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ add_subdirectory(enum)
add_subdirectory(misc)
if(BUILD_FARM_NG_PROTOS)
add_subdirectory(prototools)
add_subdirectory(proto_conv)
add_subdirectory(pipeline)
endif()
9 changes: 9 additions & 0 deletions cpp/farm_ng/core/proto_conv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[[
core
]]

add_subdirectory(linalg)
add_subdirectory(lie)
add_subdirectory(image)
add_subdirectory(sensor)
add_subdirectory(geometry)
22 changes: 22 additions & 0 deletions cpp/farm_ng/core/proto_conv/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
farm_ng_add_library(farm_ng_core_proto_conv_geometry
NAMESPACE farm_ng_core
INCLUDE_DIR ../../..
HEADERS
conv.h
SOURCES
conv.cpp
)

target_link_libraries(farm_ng_core_proto_conv_geometry PUBLIC
sophus_lie
protobuf::libprotobuf
farm_ng_core::farm_ng_core_prototools
farm_ng_core_proto_defs
farm_ng_core::farm_ng_core_proto_conv_linalg)

if(${BUILD_SOPHUS_TESTS})
farm_ng_add_test(conv
PARENT_LIBRARY farm_ng_core_proto_conv_geometry
LINK_LIBRARIES farm_ng_core_proto_conv_geometry
LABELS small)
endif()
45 changes: 45 additions & 0 deletions cpp/farm_ng/core/proto_conv/geometry/conv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2022, farm-ng inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "farm_ng/core/proto_conv/geometry/conv.h"

#include "farm_ng/core/proto_conv/linalg/conv.h"

namespace farm_ng::core {

Expected<sophus::UnitVector3F64> fromProto(proto::UnitVec3F64 const& proto) {
return sophus::UnitVector3F64::tryFromUnitVector(fromProto(proto.vec3()));
}

proto::UnitVec3F64 toProto(sophus::UnitVector3F64 const& uvec) {
proto::UnitVec3F64 proto;
*proto.mutable_vec3() = toProto(uvec.params());
return proto;
}

Expected<Eigen::Hyperplane<double, 3>> fromProto(
proto::Hyperplane3F64 const& proto) {
SOPHUS_TRY(sophus::UnitVector3F64, normal, fromProto(proto.normal()));
return Eigen::Hyperplane<double, 3>{normal.params(), proto.offset()};
}

proto::Hyperplane3F64 toProto(Eigen::Hyperplane<double, 3> const& plane) {
proto::Hyperplane3F64 proto;
*proto.mutable_normal() =
toProto(sophus::UnitVector3F64::fromVectorAndNormalize(plane.normal()));
proto.set_offset(plane.offset());
return proto;
}

} // namespace farm_ng::core
29 changes: 29 additions & 0 deletions cpp/farm_ng/core/proto_conv/geometry/conv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2022, farm-ng inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "farm_ng/core/geometry.pb.h"
#include "sophus/geometry/ray.h"

namespace farm_ng::core {

Expected<sophus::UnitVector3F64> fromProto(proto::UnitVec3F64 const& proto);
proto::UnitVec3F64 toProto(sophus::UnitVector3F64 const& uvec);

Expected<Eigen::Hyperplane<double, 3>> fromProto(
proto::Hyperplane3F64 const& proto);
proto::Hyperplane3F64 toProto(Eigen::Hyperplane<double, 3> const& plane);

} // namespace farm_ng::core
19 changes: 19 additions & 0 deletions cpp/farm_ng/core/proto_conv/geometry/conv_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2022, farm-ng inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "farm_ng/core/proto_conv/lie/conv.h"

#include <gtest/gtest.h>

using namespace sophus;
24 changes: 24 additions & 0 deletions cpp/farm_ng/core/proto_conv/image/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
farm_ng_add_library(farm_ng_core_proto_conv_image
NAMESPACE farm_ng_core
INCLUDE_DIR ../../..
HEADERS
conv.h
SOURCES
conv.cpp
)

target_link_libraries(farm_ng_core_proto_conv_image PUBLIC
Sophus::sophus_linalg
protobuf::libprotobuf
farm_ng_core::farm_ng_core_proto_defs
farm_ng_core::farm_ng_core_prototools
farm_ng_core::farm_ng_core_proto_conv_linalg
sophus_image
)

if(${BUILD_SOPHUS_TESTS})
farm_ng_add_test(conv
PARENT_LIBRARY farm_ng_core_proto_conv_image
LINK_LIBRARIES farm_ng_core_proto_conv_image
LABELS small)
endif()
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// Copyright (c) 2011, Hauke Strasdat
// Copyright (c) 2012, Steven Lovegrove
// Copyright (c) 2021, farm-ng, inc.
// Copyright 2022, farm-ng inc.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "sophus/image/proto/conv.h"
#include "farm_ng/core/proto_conv/image/conv.h"

namespace sophus {
namespace farm_ng::core {

sophus::ImageSize fromProto(proto::ImageSize const& proto) {
sophus::ImageSize image_size;
Expand Down Expand Up @@ -53,7 +59,7 @@ proto::PixelFormat toProto(sophus::PixelFormat const& layout) {
}

Expected<sophus::AnyImage<>> fromProto(proto::DynImage const& proto) {
SOPHUS_TRY(PixelFormat, format, fromProto(proto.pixel_format()));
SOPHUS_TRY(sophus::PixelFormat, format, fromProto(proto.pixel_format()));
auto layout = fromProto(proto.layout());

SOPHUS_ASSERT_EQ(size_t(layout.sizeBytes()), proto.data().size());
Expand All @@ -69,4 +75,4 @@ Expected<sophus::IntensityImage<>> intensityImageFromProto(
return sophus::IntensityImage<>::tryFrom(any_image);
}

} // namespace sophus
} // namespace farm_ng::core
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
// Copyright (c) 2011, Hauke Strasdat
// Copyright (c) 2012, Steven Lovegrove
// Copyright (c) 2021, farm-ng, inc.
// Copyright 2022, farm-ng inc.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "sophus/image.pb.h"
#include "farm_ng/core/image.pb.h"
#include "sophus/image/dyn_image_types.h"

namespace sophus {
namespace farm_ng::core {

sophus::ImageSize fromProto(proto::ImageSize const& proto);
proto::ImageSize toProto(sophus::ImageSize const& image_size);
Expand All @@ -38,4 +44,4 @@ proto::DynImage toProto(sophus::DynImage<TPredicate> const& image) {

return proto;
}
} // namespace sophus
} // namespace farm_ng::core
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// Copyright (c) 2011, Hauke Strasdat
// Copyright (c) 2012, Steven Lovegrove
// Copyright (c) 2021, farm-ng, inc.
// Copyright 2022, farm-ng inc.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "sophus/image/proto/conv.h"
#include "farm_ng/core/proto_conv/image/conv.h"

#include <gtest/gtest.h>

Expand Down
23 changes: 23 additions & 0 deletions cpp/farm_ng/core/proto_conv/lie/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
farm_ng_add_library(farm_ng_core_proto_conv_lie
NAMESPACE farm_ng_core
INCLUDE_DIR ../../..
HEADERS
conv.h
SOURCES
conv.cpp
)

target_link_libraries(farm_ng_core_proto_conv_lie PUBLIC
Sophus::sophus_lie
protobuf::libprotobuf
farm_ng_core::farm_ng_core_proto_conv_linalg
farm_ng_core::farm_ng_core_prototools
)


if(${BUILD_SOPHUS_TESTS})
farm_ng_add_test(conv
PARENT_LIBRARY farm_ng_core_proto_conv_lie
LINK_LIBRARIES farm_ng_core_proto_conv_lie
LABELS small)
endif()
Loading

0 comments on commit 4d5e476

Please sign in to comment.