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

MovementSensor #143

Closed

Conversation

zaporter-work
Copy link
Member

@zaporter-work zaporter-work commented Aug 28, 2023

Howdy!

I needed MovementSensor bindings for a personal project so I created them.

I don't have time to polish this up and bring it through a PR, but I thought I would share the code in case someone wanted to take it from here. If everyone is busy, that is fine too! Just thought I should share.

There are a few things to figure out (and the linter is complaining about a few missing consts), but the general structure is there and the tests pass on my machine...

Weirdest part of this PR is that the file is named movementsensor/movementsensor.hpp.

Pros of movementsensor.hpp:

  • rdk has movementsensor.go
  • api has movementsensor.proto
  • protos are generated as movementsensor, not movement_sensor

Cons of movementsensor.hpp:

  • movement_sensor.hpp would be easier to read and would make more sense
  • Python calls the file movement_sensor.py
  • Ts calls the file movement-sensor.ts

@zaporter-work zaporter-work requested a review from stuqdog August 28, 2023 14:50
// uses).
struct orientation {
double o_x, o_y, o_z, theta;
// TODO(pre-merge) move the to/from protos in here. Nicer that way
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? I saw you do this for some other methods? I kept the current way with everything in the component..

Not sure what the plan is

std::unordered_map<std::string, float> result = movementsensor->get_accuracy(extra);
response->mutable_accuracy()->empty();
for (const auto& i : result) {
response->mutable_accuracy()->emplace(i.first, i.second);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strangely this like works on my laptop but does not in CI. Different proto versions maybe?

/tmp/src/viam/sdk/components/movementsensor/server.cpp:216:39: error: no member named 'emplace' in 'google::protobuf::Map<std::basic_string<char>, float>' [clang-diagnostic-error]
        response->mutable_accuracy()->emplace(i.first, i.second);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, almost certainly different proto version. I remember encountering this same issue when working on the MLModel stuff and had to stop using emplace.

@zaporter-work
Copy link
Member Author

Implemented in #171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants