Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK6734 - Remove viam/api imports from public headers #325

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 0 additions & 5 deletions src/viam/examples/dial/example_dial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@
#include <grpcpp/grpcpp.h>
#include <grpcpp/support/status.h>

#include <viam/api/common/v1/common.pb.h>
#include <viam/api/robot/v1/robot.grpc.pb.h>
#include <viam/api/robot/v1/robot.pb.h>

#include <viam/sdk/components/generic.hpp>
#include <viam/sdk/robot/client.hpp>
#include <viam/sdk/robot/service.hpp>
#include <viam/sdk/rpc/dial.hpp>

using viam::robot::v1::Status;
using namespace viam::sdk;

int main() {
Expand Down
4 changes: 0 additions & 4 deletions src/viam/examples/dial_api_key/example_dial_api_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
#include <grpcpp/grpcpp.h>
#include <grpcpp/support/status.h>

#include <viam/api/common/v1/common.pb.h>
#include <viam/api/robot/v1/robot.grpc.pb.h>
#include <viam/api/robot/v1/robot.pb.h>

#include <viam/sdk/robot/client.hpp>
#include <viam/sdk/robot/service.hpp>
#include <viam/sdk/rpc/dial.hpp>
Expand Down
5 changes: 0 additions & 5 deletions src/viam/examples/modules/complex/client.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <cstddef>
#include <functional>
#include <iostream>
#include <memory>
#include <ostream>
Expand All @@ -12,10 +11,6 @@
#include <grpcpp/grpcpp.h>
#include <grpcpp/support/status.h>

#include <viam/api/common/v1/common.pb.h>
#include <viam/api/robot/v1/robot.grpc.pb.h>
#include <viam/api/robot/v1/robot.pb.h>

#include <viam/sdk/components/motor.hpp>
#include <viam/sdk/robot/client.hpp>
#include <viam/sdk/robot/service.hpp>
Expand Down
4 changes: 0 additions & 4 deletions src/viam/examples/modules/complex/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#include <grpcpp/grpcpp.h>
#include <grpcpp/server_context.h>

#include <viam/api/common/v1/common.grpc.pb.h>
#include <viam/api/component/generic/v1/generic.grpc.pb.h>
#include <viam/api/robot/v1/robot.pb.h>

#include <viam/sdk/components/base.hpp>
#include <viam/sdk/components/component.hpp>
#include <viam/sdk/config/resource.hpp>
Expand Down
4 changes: 2 additions & 2 deletions src/viam/examples/modules/complex/proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: e7f8d366f5264595bcc4cd4139af9973
digest: shake256:e5e5f1c12f82e028ea696faa43b4f9dc6258a6d1226282962a8c8b282e10946281d815884f574bd279ebd9cd7588629beb3db17b892af6c33b56f92f8f67f509
commit: 553fd4b4b3a640be9b69a3fa0c17b383
digest: shake256:e30e3247f84b7ff9d09941ce391eb4b6f04734e1e5fae796bfc471f167e6f90813630cc39397ee46b8bc0ea7d6935c416d15c219cc5732d9778cbfdf73a1ed6e
2 changes: 0 additions & 2 deletions src/viam/examples/modules/complex/test_complex_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include <boost/test/included/unit_test.hpp>

#include <viam/api/common/v1/common.pb.h>

#include <viam/sdk/common/proto_value.hpp>
#include <viam/sdk/tests/test_utils.hpp>

Expand Down
4 changes: 0 additions & 4 deletions src/viam/examples/modules/simple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#include <grpcpp/grpcpp.h>
#include <grpcpp/server_context.h>

#include <viam/api/common/v1/common.grpc.pb.h>
#include <viam/api/robot/v1/robot.pb.h>
#include <viam/api/service/generic/v1/generic.grpc.pb.h>

#include <viam/sdk/common/exception.hpp>
#include <viam/sdk/common/proto_value.hpp>
#include <viam/sdk/config/resource.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/viam/sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ target_sources(viamsdk
common/exception.cpp
common/linear_algebra.cpp
common/pose.cpp
common/private/proto_conversions.cpp
common/proto_value.cpp
common/service_helper.cpp
common/utils.cpp
Expand All @@ -76,6 +77,7 @@ target_sources(viamsdk
components/private/board_server.cpp
components/private/camera_client.cpp
components/private/camera_server.cpp
components/private/encoder.cpp
components/private/encoder_client.cpp
components/private/encoder_server.cpp
components/private/gantry_client.cpp
Expand Down
1 change: 1 addition & 0 deletions src/viam/sdk/common/client_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <grpcpp/support/sync_stream.h>

#include <viam/sdk/common/exception.hpp>
#include <viam/sdk/common/private/client_helper.hpp>
#include <viam/sdk/common/private/utils.hpp>
#include <viam/sdk/common/proto_value.hpp>
#include <viam/sdk/common/utils.hpp>
Expand Down
14 changes: 0 additions & 14 deletions src/viam/sdk/common/linear_algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <array>

#include <viam/api/common/v1/common.pb.h>

namespace viam {
namespace sdk {

Expand Down Expand Up @@ -45,17 +43,5 @@ std::array<double, 3>& Vector3::data() {
return this->data_;
}

viam::common::v1::Vector3 Vector3::to_proto() const {
viam::common::v1::Vector3 result;
result.set_x(x());
result.set_y(y());
result.set_z(z());
return result;
};

Vector3 Vector3::from_proto(const viam::common::v1::Vector3& vec) {
return {vec.x(), vec.y(), vec.z()};
}

} // namespace sdk
} // namespace viam
3 changes: 0 additions & 3 deletions src/viam/sdk/common/linear_algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <boost/qvm/vec.hpp>
#include <boost/qvm/vec_traits.hpp>

#include <viam/api/common/v1/common.pb.h>
namespace viam {
namespace sdk {

Expand All @@ -30,8 +29,6 @@ class Vector3 {

const std::array<scalar_type, 3>& data() const;
std::array<scalar_type, 3>& data();
viam::common::v1::Vector3 to_proto() const;
static Vector3 from_proto(const viam::common::v1::Vector3& vec);

private:
std::array<scalar_type, 3> data_;
Expand Down
32 changes: 0 additions & 32 deletions src/viam/sdk/common/pose.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
#include <viam/sdk/common/pose.hpp>

#include <common/v1/common.pb.h>

namespace viam {
namespace sdk {

common::v1::PoseInFrame pose_in_frame::to_proto() const {
common::v1::PoseInFrame pif;
*pif.mutable_reference_frame() = reference_frame;
common::v1::Pose proto_pose;
proto_pose.set_x(pose.coordinates.x);
proto_pose.set_y(pose.coordinates.y);
proto_pose.set_z(pose.coordinates.z);
proto_pose.set_o_x(pose.orientation.o_x);
proto_pose.set_o_y(pose.orientation.o_y);
proto_pose.set_o_z(pose.orientation.o_z);
proto_pose.set_theta(pose.theta);
*pif.mutable_pose() = std::move(proto_pose);
return pif;
};

pose_in_frame pose_in_frame::from_proto(const common::v1::PoseInFrame& proto) {
pose_in_frame pif;
pif.reference_frame = proto.reference_frame();
const auto& proto_pose = proto.pose();
pif.pose.orientation.o_x = proto_pose.o_x();
pif.pose.orientation.o_y = proto_pose.o_y();
pif.pose.orientation.o_z = proto_pose.o_z();
pif.pose.coordinates.x = proto_pose.x();
pif.pose.coordinates.y = proto_pose.y();
pif.pose.coordinates.z = proto_pose.z();
pif.pose.theta = proto_pose.theta();

return pif;
}

bool operator==(const pose_in_frame& lhs, const pose_in_frame& rhs) {
return lhs.pose == rhs.pose && lhs.reference_frame == rhs.reference_frame;
}
Expand Down
7 changes: 1 addition & 6 deletions src/viam/sdk/common/pose.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <common/v1/common.pb.h>
#include <ostream>

namespace viam {
namespace sdk {
Expand All @@ -20,16 +20,11 @@ struct pose {
pose_orientation orientation;
double theta;

static pose from_proto(const viam::common::v1::Pose& proto);
viam::common::v1::Pose to_proto() const;

friend bool operator==(const pose& lhs, const pose& rhs);
friend std::ostream& operator<<(std::ostream& os, const pose& v);
};

struct pose_in_frame {
viam::common::v1::PoseInFrame to_proto() const;
static pose_in_frame from_proto(const viam::common::v1::PoseInFrame& proto);
pose_in_frame(std::string reference_frame_, struct pose pose_)
: reference_frame(std::move(reference_frame_)), pose(std::move(pose_)) {}
pose_in_frame() {}
Expand Down
1 change: 1 addition & 0 deletions src/viam/sdk/common/private/client_helper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <google/protobuf/struct.pb.h>
Loading
Loading