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

Testing parameters PR (#305) with prerelease repos #349

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3d691a7
wip
ivanpauno Mar 10, 2022
493af65
wip
ivanpauno Mar 15, 2022
2573250
wip
ivanpauno Mar 21, 2022
c0b587f
Complete implementation of parameters::Registry class
ivanpauno Mar 21, 2022
c7e67ac
Use const std::string & when appropriate
ivanpauno Mar 21, 2022
d3d0a09
First ParameterClient implementation
ivanpauno Mar 23, 2022
1878dbb
Add ListParameters() to both registry and client
ivanpauno Mar 29, 2022
5b8cf84
Fix
ivanpauno Mar 30, 2022
8490314
Fix declare parameter
ivanpauno Apr 5, 2022
e47860c
Add command line API for param
ivanpauno Apr 7, 2022
c201493
Document ParameterRegistry class
ivanpauno Apr 25, 2022
a96f102
fix code style
ivanpauno Apr 25, 2022
832a8ab
Make methods const when possible. Fix logs
ivanpauno Apr 25, 2022
e45478a
Make mehtods const if possible, alphabetize includes
ivanpauno Apr 25, 2022
d0e64ce
Remove copy-pasted line in docs
ivanpauno Apr 25, 2022
8ef1fce
* Use pimpl in ParametersClient.
ivanpauno Apr 26, 2022
b004c95
rename GetParameter() to Parameter()
ivanpauno Apr 26, 2022
0518eb4
Add unit tests for ParametersRegistry and fixes
ivanpauno Jun 15, 2022
97d8e8d
Fix style issues in Registry_TEST.cc
ivanpauno Jun 22, 2022
b7508f4
Add unit tests for parameters client
ivanpauno Jun 22, 2022
22290ac
Fix bug in DeclareParameter service callback
ivanpauno Jun 22, 2022
6b721ce
Merge branch 'ign-transport11' into ivanpauno/parameters-component11
caguero Jun 28, 2022
418ec77
Add a ParamtersInterface base class, make ParametersClient a derived …
ivanpauno Jun 30, 2022
c36144a
Derive ParametersRegistry from ParametersInterface
ivanpauno Jul 1, 2022
cf11a3e
Make lints pass
ivanpauno Jul 1, 2022
32ea9a1
Adapt code to use google::protobuf::Any
ivanpauno Jul 4, 2022
f624a9d
Communicate errors in SetParameter/DeclareParameter correctly between…
ivanpauno Jul 4, 2022
8b7e18b
Merge remote-tracking branch 'origin/ivanpauno/parameters-component11…
ivanpauno Jul 4, 2022
3fb61c2
Merge branch 'ign-transport11' into ivanpauno/parameters-component11
caguero Aug 8, 2022
2973504
Merge branch 'ign-transport11' into ivanpauno/parameters-component11
scpeters Aug 18, 2022
a1586e1
Replace NO_ERROR with SUCCESS
ivanpauno Aug 23, 2022
21911ce
Add visibility macros
ivanpauno Aug 25, 2022
f93da8f
codecheck
ivanpauno Aug 25, 2022
6c1007b
Maybe fix build error on Windows
ivanpauno Aug 25, 2022
4089abf
Fix build warning on windows
ivanpauno Aug 25, 2022
1688b63
Fix comment
scpeters Aug 23, 2022
2ea957d
Remove unnecessary cmake warning
ivanpauno Aug 31, 2022
ccb520f
Add function separators
ivanpauno Aug 31, 2022
dff201b
Use camelCase for free functions
ivanpauno Aug 31, 2022
8adc376
Add unit tests for parameters utils module
ivanpauno Aug 31, 2022
b4bb900
Fix linking on Windows
ivanpauno Aug 31, 2022
d5c7c0c
Add tests for ParamCommandAPI
ivanpauno Sep 12, 2022
dc77e1d
Please cpplint
ivanpauno Sep 14, 2022
34f6190
Mark symbols in ParamCommandAPI as visible
ivanpauno Sep 14, 2022
c258ef2
Fix build error
ivanpauno Sep 14, 2022
1bcb2e4
Merge branch 'ign-transport11' into ivanpauno/parameters-component11
caguero Sep 27, 2022
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ign_find_package(SQLite3
# Configure the build
#============================================================================
ign_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS log)
COMPONENTS log parameters)

#============================================================================
# ign command line support
Expand Down
4 changes: 2 additions & 2 deletions log/include/ignition/transport/log/Recorder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace ignition

/// \brief Begin recording topics
/// \param[in] _file path to log file
/// \return NO_ERROR if recording was successfully started. If the file
/// \return SUCCESS if recording was successfully started. If the file
/// already existed, this will return FAILED_TO_OPEN.
public: RecorderError Start(const std::string &_file);

Expand All @@ -86,7 +86,7 @@ namespace ignition
/// \param[in] _topic The exact topic name
/// \note This method attempts to subscribe to the topic immediately.
/// The subscription will be kept until this is destructed.
/// \return NO_ERROR if the subscription was created.
/// \return SUCCESS if the subscription was created.
public: RecorderError AddTopic(const std::string &_topic);

/// \brief Add a topic to be recorded (regex match)
Expand Down
2 changes: 2 additions & 0 deletions parameters/include/ignition/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

ign_install_all_headers(COMPONENT parameters)
120 changes: 120 additions & 0 deletions parameters/include/ignition/transport/parameters/Client.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* 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.
*
*/

#ifndef IGNITION_TRANSPORT_PARAMETERS_CLIENT_HH_
#define IGNITION_TRANSPORT_PARAMETERS_CLIENT_HH_

#include <memory>
#include <string>

#include "google/protobuf/message.h"

#include "ignition/msgs/parameter_declarations.pb.h"

#include "ignition/transport/config.hh"
#include "ignition/transport/Node.hh"
#include "ignition/transport/parameters/Export.hh"
#include "ignition/transport/parameters/Interface.hh"

namespace ignition
{
namespace transport
{
namespace parameters
{

// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {

struct ParametersClientPrivate;

/// \brief Allow to get, set, declare or list parameters
/// \brief in a remote registry.
class IGNITION_TRANSPORT_PARAMETERS_VISIBLE ParametersClient
: public ParametersInterface
{
/// \brief Constructor.
/// \param[in] _serverNamespace Namespace of the parameters registry
/// services. The client will send requests to:
/// * /${_serverNamespace}/get_parameter
/// * /${_serverNamespace}/list_parameters
/// * /${_serverNamespace}/set_parameter
/// * /${_serverNamespace}/declare_parameter
/// \param[in] _timeoutMs Time to wait for the server to respond.
public: ParametersClient(
const std::string & _serverNamespace = "",
unsigned int _timeoutMs = kDefaultTimeoutMs);

/// \brief Destructor.
public: ~ParametersClient();

/// \brief No copy constructor.
public: ParametersClient(const ParametersClient &) = delete;
/// \brief No copy assignment.
public: ParametersClient & operator=(
const ParametersClient &) = delete;
/// \brief Default move constructor.
public: ParametersClient(ParametersClient &&);
/// \brief Default move assignment.
public: ParametersClient & operator=(
ParametersClient &&);

/// \brief Declare a new parameter.
/// See ParametersInterface::DeclareParameter().
public: void DeclareParameter(
const std::string & _parameterName,
const google::protobuf::Message & _msg) final;

/// \brief Request the value of a parameter.
/// See ParametersInterface::Parameter().
public: std::unique_ptr<google::protobuf::Message> Parameter(
const std::string & _parameterName) const final;

/// \brief Request the value of a parameter.
/// See ParametersInterface::Parameter().
public: void Parameter(
const std::string & _parameterName,
google::protobuf::Message & _parameter) const final;

/// \brief Request the value of a parameter.
/// See ParametersInterface::Parameter().
using ParametersInterface::Parameter;

/// \brief Set the value of a parameter.
/// See ParametersInterface::SetParameter().
public: void SetParameter(
const std::string & _parameterName,
const google::protobuf::Message & _msg) final;

/// \brief List all parameters.
/// \return Protobuf message with a list of all declared parameter
/// names and their types.
public: ignition::msgs::ParameterDeclarations
ListParameters() const final;

private:
/// \brief Pointer to implementation.
private: std::unique_ptr<ParametersClientPrivate> dataPtr;

constexpr static inline unsigned int kDefaultTimeoutMs = 5000;
};
}
}
}
}

#endif
120 changes: 120 additions & 0 deletions parameters/include/ignition/transport/parameters/Interface.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* 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.
*
*/

#ifndef IGNITION_TRANSPORT_PARAMETERS_INTERFACE_HH_
#define IGNITION_TRANSPORT_PARAMETERS_INTERFACE_HH_

#include <functional>
#include <memory>
#include <string>

#include <google/protobuf/message.h>

#include <ignition/msgs/parameter_declarations.pb.h>

#include "ignition/transport/config.hh"
#include "ignition/transport/parameters/exceptions.hh"
#include "ignition/transport/parameters/Export.hh"

namespace ignition
{
namespace transport
{
namespace parameters
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {

/// \brief Common interface, implemented by ParametersRegistry
/// (local updates) and by ParametersClients (remote requests).
class IGNITION_TRANSPORT_PARAMETERS_VISIBLE ParametersInterface
{
/// Default virtual destructor.
public: virtual ~ParametersInterface() = default;

/// \brief Declare a new parameter.
/// \param[in] _parameterName Name of the parameter to be declared.
/// \param[in] _msg Protobuf message to be used as the initial
/// parameter value.
/// \throw ParameterAlreadyDeclaredException if a parameter with the
/// same name was declared before.
/// \throw ParameterInvalidTypeException (can only happen in client)
/// if the parameter server does not recognize the parameter type.
public: virtual void DeclareParameter(
const std::string & _parameterName,
const google::protobuf::Message & _msg) = 0;

/// \brief Request the value of a parameter.
/// \param[in] _parameterName Name of the parameter to be requested.
/// \return The value of the parameter (a protobuf msg).
/// \throw ParameterNotDeclaredException if a parameter of that name
/// was not declared before.
/// \throw std::runtime_error if an unexpected error happens.
public: virtual std::unique_ptr<google::protobuf::Message> Parameter(
const std::string & _parameterName) const = 0;

/// \brief Request the value of a parameter.
/// \param[in] _parameterName Name of the parameter to be requested.
/// \param[out] _parameter Output were the parameter value will be set.
/// \throw ParameterNotDeclaredException if a parameter of that name
/// was not declared before.
/// \throw ParameterInvalidTypeException if the type of `_parameter`
/// does not match the type of the parameter when it was declared.
/// \throw std::runtime_error if an unexpected error happens.
public: virtual void Parameter(
const std::string & _parameterName,
google::protobuf::Message & _parameter) const = 0;

/// \brief Set the value of a parameter.
/// \param[in] _parameterName Name of the parameter to be set.
/// \param[in] _msg Protobuf message to be used as the parameter value.
/// \throw ParameterNotDeclaredException if a parameter of that name
/// was not declared before.
/// \throw ParameterInvalidTypeException if the type does not match
/// the type of the parameter when it was declared.
public: virtual void SetParameter(
const std::string & _parameterName,
const google::protobuf::Message & _msg) = 0;

/// \brief List all existing parameters.
/// \return The name and types of existing parameters.
public: virtual ignition::msgs::ParameterDeclarations
ListParameters() const = 0;

/// \brief Get the value of a parameter.
/// \tparam ProtoMsgT A protobuf message type, e.g.: ign::msgs::Boolean.
/// \param[in] _parameterName Name of the parameter to get.
/// \return The parameter value, as a protobuf message.
/// \throw ParameterNotDeclaredException if a parameter of that name
/// was not declared before.
/// \throw ParameterInvalidTypeException if ProtoMsgT does not match
/// the type of the parameter when it was declared.
/// \throw std::runtime_error if an unexpected error happens.
public: template<typename ProtoMsgT>
ProtoMsgT Parameter(const std::string & _parameterName) const
{
ProtoMsgT ret;
this->Parameter(_parameterName, ret);
return ret;
}
};
}
}
}
}

#endif
Loading