Skip to content

releases/v0.0.12

Compare
Choose a tag to compare
@github-actions github-actions released this 09 Oct 16:21
· 35 commits to main since this release
4a06676

Breaking change

Details and migration guide

Removes ProtoType and AttributeMap , replacing them with ProtoValue and ProtoStruct. This affects the parameter used in component doCommand calls, as well as the extra parameter included in all component methods.

For most use cases, the change will look like this:
90246f0#diff-becf92545c215777e3fe43c17c0f4196f96bb623d3aa8feee82d1357e7c1738fL11
Namely,

  • include path is now #include <viam/sdk/common/proto_value.hpp>
  • parameter is now const ProtoStruct&

The majority of code changes will be able to just do a Replace-In-Files for the two changes above

If your component or module code actually used these types directly, the changes will look something like this:
90246f0#diff-e07f0fbd2e62063a2446d7ab99d80d9a5c50e9a94649f64b9d5caf5c67b3a345
Namely, ProtoValue is now has value semantics rather than pointer semantics and std::shared_ptr , and ProtoStruct is a map of std::string to ProtoType. You can construct a ProtoValue like a normal C++ class as you would, eg, a variant or JSON type:

ProtoValue num_val{5.6};
ProtoValue str_val{"meow"};

// ProtoList is a vector of ProtoValue:
ProtoList my_list{{ProtoValue{true}, ProtoValue{"meow"}, ProtoValue{6.0}}};

// ProtoStruct is a map:
ProtoStruct my_map{
    {"cat", "meow"},
    {"dog", "woof"},
    {"number", 1.234},
    {"list", my_list}, //copies my_list
};

ProtoValue and related types now have value semantics rather than smart pointer semantics. This means, eg
map lookup operations will now use a . rather than ->, and types will behave like arithmetic types or standard library containers with respect to copying, moving, etc

Please see the proto_value.hpp header for detailed documentation and API of other methods, including

  • to_proto to convert to google::protobuf classes, and ProtoValue::from_proto to construct from google::protobuf classes
  • is_a<T> and get<T>/get_unchecked<T> for stored element inpection
  • ...or generate the doxygen documentation if you like!

To find affected code, you can grep or ag or GitHub code search for ProtoType and AttributeMap.

Additional changes

  • RSDK-8828 Remove integer type from ProtoValue by @lia-viam in #292
  • RSDK-8826: Conan builds in CI by @lia-viam in #296
  • Fix debian builds in CI by @lia-viam in #297
  • Automated Protos Update by @github-actions in #298
  • Automated Protos Update by @github-actions in #300
  • Use proto value get in example code by @lia-viam in #303
  • RSDK-6170 - add debug log support by @stuqdog in #299
  • Automated Protos Update by @github-actions in #302
  • Version bump by @lia-viam in #304

Full Changelog: releases/v0.0.11...releases/v0.0.12