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

RSDK-794 Sensor wrapper #174

Merged
merged 8 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ethan comments
benjirewis committed Nov 14, 2023
commit 0ca18835e20c68631fb4d8b907f12249bbc9ed10
3 changes: 3 additions & 0 deletions src/viam/sdk/components/sensor/client.hpp
Original file line number Diff line number Diff line change
@@ -24,6 +24,9 @@ class SensorClient : public Sensor {
AttributeMap do_command(const AttributeMap& command) override;
std::vector<GeometryConfig> get_geometries(const AttributeMap& extra) override;

stuqdog marked this conversation as resolved.
Show resolved Hide resolved
using Sensor::get_geometries;
using Sensor::get_readings;

typedef viam::component::sensor::v1::SensorService::StubInterface Stub;

private:
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_sensor.cpp
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ AttributeMap MockSensor::do_command(const AttributeMap& command) {
return command;
};
std::vector<sdk::GeometryConfig> MockSensor::get_geometries(const AttributeMap& extra) {
benjirewis marked this conversation as resolved.
Show resolved Hide resolved
return std::vector<sdk::GeometryConfig>();
return fake_geometries();
};

std::shared_ptr<MockSensor> MockSensor::get_mock_sensor() {
9 changes: 9 additions & 0 deletions src/viam/sdk/tests/test_sensor.cpp
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
#include <viam/api/component/sensor/v1/sensor.grpc.pb.h>
#include <viam/api/component/sensor/v1/sensor.pb.h>

#include "viam/sdk/spatialmath/geometry.hpp"
benjirewis marked this conversation as resolved.
Show resolved Hide resolved
#include <viam/sdk/common/proto_type.hpp>
#include <viam/sdk/components/sensor/client.hpp>
#include <viam/sdk/components/sensor/sensor.hpp>
@@ -94,6 +95,14 @@ BOOST_AUTO_TEST_CASE(test_do_command) {
});
}

benjirewis marked this conversation as resolved.
Show resolved Hide resolved
BOOST_AUTO_TEST_CASE(test_get_geometries) {
server_to_mock_pipeline([](Sensor& client, std::shared_ptr<MockSensor> mock) -> void {
std::vector<sdk::GeometryConfig> expected = fake_geometries();
std::vector<sdk::GeometryConfig> geometries = client.get_geometries();
BOOST_CHECK(expected == geometries);
});
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace sdktests