Package Summary

Tags No category tags.
Version 3.0.3
License BSD
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version dashing-devel
Last Updated 2019-11-19
Dev Status DEVELOPED
Released RELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • P. J. Reed

Authors

No additional authors.

swri_roscpp

This packages contains a set of wrappers classes and functions for common ROS operations.

Topic Services

Note: Not yet implemented in ROS2

Topic services are a wrappers over ROS topics that provide a service like functionality but in a much more introspectable way. Eg: There is no rosservice echo and no way to view service clients in a running system.

The usage is very similar to that of standard ROS services and can even make use of the same service definitions. For most usages simply just substitute ros::ServiceServer or ros::ServiceClient for swri::TopicServiceServer or swri::TopicServiceClient in the declaration and use it in the same way.

Generating Topics from a Service

In order to generate the backing topics for a Topic Service from a service message add a add_topic_service_files block to your project's CMakeList.txt and use it the same way you would an add_message_files or add_service_files block.

Make sure to add this swri_roscpp as a dependency to your message project.

For example:

add_topic_service_files(DIRECTORY topic_srv FILES
  ClearActiveRoute.srv
  DeleteRoute.srv
  GetRoute.srv
  GetRouteNames.srv
  SaveRoute.srv
  SetActiveRoute.srv
  SetRoute.srv
  SetNextCheckpoint.srv
)

To use the generated topics simply include your_project/your_service.h. They have response and request fields just like normal services.

Dynamic Parameters

Note: This package's dynamic parameter implementation has been deprecated and removed; it is unnecessary in ROS 2 Dashing and rclcpp::Node::declare_parameter provides an equivalent alternative.

CHANGELOG

Changelog for package swri_roscpp

3.0.3 (2019-11-11)

  • Replace deprecated functions in swri_roscpp
  • Contributors: P. J. Reed

3.0.2 (2019-11-11)

3.0.1 (2019-11-11)

3.0.0 (2019-11-08)

  • ROS2 Dashing conversion (#549)
  • Contributors: P. J. Reed

2.10.0 (2019-09-04)

  • Prevent swri:Subscriber latency calculations if current time is zero (#548)
  • Change way name is created for topic services (#541)
  • Contributors: jgassaway, nick-alton

2.9.0 (2019-05-23)

  • Add callback for on change for dynamic parameters (#540)
  • Add topic service unit tests (#538)
  • Contributors: Matthew, P. J. Reed

2.8.0 (2019-02-06)

  • Add dynamic parameters (#532)
  • Contributors: Matthew

2.7.3 (2019-01-03)

2.7.2 (2018-12-20)

  • Fix cmake macro for service_splitter.py (#535)
  • Contributors: P. J. Reed

2.7.1 (2018-12-14)

  • Fix conditional causing exists to not work properly. (#533)
  • Remove non ascii character to please python (#530)
  • Contributors: Matthew

2.7.0 (2018-12-04)

  • Add topic based services and associated cmake utils (#523) Provide utilities for implementing service type requests using messages in an almost transparent way.
  • Contributors: Matthew

2.6.0 (2018-11-03)

2.5.0 (2018-10-12)

2.4.0 (2018-10-09)

  • Update package maintainers (#520)
  • Contributors: P. J. Reed

2.3.0 (2018-05-25)

  • Only calculate statistics when messages arrive in order (#516)
  • Contributors: David Anthony

2.2.1 (2018-05-11)

2.2.0 (2018-02-12)

  • Fix crash from messages with null timestamps (#511)
  • Contributors: Matthew

2.1.0 (2018-01-26)

2.0.0 (2017-12-18)

  • Ensure all swri::Subscriber members are initialized (#505)
  • Contributors: P. J. Reed

1.2.0 (2017-10-13)

1.1.0 (2017-08-31)

  • Add OptionalDiagnosedPublisher class (#483)
  • Contributors: Edward Venator, P. J. Reed

1.0.0 (2017-08-02)

  • Add support for boost::function callbacks to swri::Subscriber.
  • Contributors: Elliot Johnson

0.3.0 (2017-06-20)

  • Merge together the indigo, jade, and kinetic branches (#443)
  • Contributors: P. J. Reed

0.2.4 (2017-04-11)

  • Port #385 and #419 to kinetic. (#420) A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This feature allows the node author to output a WARNING for any unused parameters. Ported forward from indigo-devel
  • Contributors: Edward Venator

0.2.3 (2016-12-09)

0.2.2 (2016-12-07)

  • Deprecate LatchedSubscriber. (#391) LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Contributors: P. J. Reed

0.2.1 (2016-10-23)

0.2.0 (2016-06-21)

0.1.5 (2016-05-13)

0.1.4 (2016-05-12)

  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.1.3 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.14 (2017-04-11)

  • Increase queue_size in swri_roscpp/Subscriber. This commit increases the queue size for subscribers that use the store mechanism instead of a callback. The queue size was set to 1, which we have seen problems with, so this will increase it to 2.
  • Add missing qualifiers for swri_roscpp unused parameter functions.
  • Merge pull request #385 from evenator/unused-parameter-warnings Adds the ability to warn when unused parameters are set in a namespace.
  • Add test for getUnusedParamKeys Adds an automated test for getUnusedParamKeys based on the example code.
  • Remove default value of node handle for warnUnusedParams This default value may cause unexpected behvavior, especially with nodelets.
  • Rename param_test to param_example. param_test isn\'t an automated test, just an example of how to use the param utilities.
  • Document unused parameter functions. The set difference algorithms used to determine which parameters are used are non-obvious. This adds documentation.
  • Mark _used_params static.
  • Adds the ability to warn when unused parameters are set in a namespace. A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This features allows the node author to output a WARNING for any unused parameters. See the param_test node for an example.
  • Contributors: Ed Venator, Edward Venator, Elliot Johnson, elliotjo

0.0.13 (2016-10-23)

  • Add swri_roscpp functions for reading float values. These add support for reading float values directly instead of doubles.
  • Contributors: Elliot Johnson

0.0.12 (2016-08-14)

0.0.11 (2016-05-13)

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.

0.0.9 (2016-03-04)

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.1.2 (2016-01-06)

0.1.1 (2015-11-17)

  • First jade release of swri_roscpp
  • Contributors: Edward Venator

0.1.0 (2015-09-29)

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org

Package Summary

Tags No category tags.
Version 2.11.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version master
Last Updated 2019-11-13
Dev Status DEVELOPED
Released RELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • P. J. Reed

Authors

No additional authors.

swri_roscpp

This packages contains a set of wrappers classes and functions for common ROS operations.

Topic Services

Topic services are a wrappers over ROS topics that provide a service like functionality but in a much more introspectable way. Eg: There is no rosservice echo and no way to view service clients in a running system.

The usage is very similar to that of standard ROS services and can even make use of the same service definitions. For most usages simply just substitute ros::ServiceServer or ros::ServiceClient for swri::TopicServiceServer or swri::TopicServiceClient in the declaration and use it in the same way.

Generating Topics from a Service

In order to generate the backing topics for a Topic Service from a service message add a add_topic_service_files block to your project's CMakeList.txt and use it the same way you would an add_message_files or add_service_files block.

Make sure to add this swri_roscpp as a dependency to your message project.

For example:

add_topic_service_files(DIRECTORY topic_srv FILES
  ClearActiveRoute.srv
  DeleteRoute.srv
  GetRoute.srv
  GetRouteNames.srv
  SaveRoute.srv
  SetActiveRoute.srv
  SetRoute.srv
  SetNextCheckpoint.srv
)

To use the generated topics simply include your_project/your_service.h. They have response and request fields just like normal services.

Dynamic Parameters

A class that implements the same functionality as Dynamic Reconfigure, but in a more dynamic and easier to use way. Instead of declaring configurable parameters at compile time in a config file they are specified in your C++ code.

To use, add the class to your node and call the initalize function with a NodeHandle in your private namespace.

#include <swri_roscpp/dynamic_parameters.h>

void main()
{
  // your node stuff here

  ros::NodeHandle pnh("~");
  swri::DynamicParameters params;
  params.initialize(pnh);
...

You can then start declaring and reading in configuration values, giving a long living pointer to a variable for each. This variable is changed on a dynamic reconfigure of that parameter. Be sure to lock the parameter mutex before reading any of these parameters. You can do this by calling the params.mutex() function and manually locking/unlocking it, or by using the .get() function on each *Param to do it automatically.

  FloatParam flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  DoubleParam dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  BoolParam bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  StringParam str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

You can also load the parameters directly in to normal variables (doubles, ints, strings), but you will have to get the new values in the on change callback function discussed below.

  float flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  double dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  bool bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  std::string str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

These functions read in the current parameter value to the provided variable, if they haven't been set they are set to the default value. After you have read in all the variables you want to be dynamically reconfigurable, call the finalize() function.

  params.finalize();

This publishes the configuration options to a latched topic so that the dynamic reconfigure tools can read them in.

After you call finalize, you should be able to access and dynamically configure your node with any dynamic reconfigure compatible tools.

Then to use/read in the parameter values in your code:

  float val = flt.get();// or *flt to get it without locking the mutex if you know what you are doing

You can also lock the mutex manually for getting the parameters in a block as follows:

  params.mutex().lock();

  float a = *flt;
  double b = *dbl;
  bool c = *bl;
  std::string d = *str; 

  params.mutex().unlock();

Alternatively you can use the on change callback to be notified when variables change and load the updated values then.


void callback(swri::DynamicParameters& params)
{
  double param1 = params.getDouble("double_value");
  float  param2 = params.getFloat("float_value");
  int    param3 = params.getInt("int_value");
  bool   param4 = params.getBool("bool_value");
  std::string param5 = params.getString("string_value");
}

// somewhere in your initialization....
params.setCallback(callback);


CHANGELOG

Changelog for package swri_roscpp

2.11.0 (2019-11-13)

  • Fix incorrect type for strings in dynamic params (#553)
  • Contributors: jgassaway

2.10.0 (2019-09-04)

  • Prevent swri:Subscriber latency calculations if current time is zero (#548)
  • Change way name is created for topic services (#541)
  • Contributors: jgassaway, nick-alton

2.9.0 (2019-05-23)

  • Add callback for on change for dynamic parameters (#540)
  • Add topic service unit tests (#538)
  • Contributors: Matthew, P. J. Reed

2.8.0 (2019-02-06)

  • Add dynamic parameters (#532)
  • Contributors: Matthew

2.7.3 (2019-01-03)

2.7.2 (2018-12-20)

  • Fix cmake macro for service_splitter.py (#535)
  • Contributors: P. J. Reed

2.7.1 (2018-12-14)

  • Fix conditional causing exists to not work properly. (#533)
  • Remove non ascii character to please python (#530)
  • Contributors: Matthew

2.7.0 (2018-12-04)

  • Add topic based services and associated cmake utils (#523) Provide utilities for implementing service type requests using messages in an almost transparent way.
  • Contributors: Matthew

2.6.0 (2018-11-03)

2.5.0 (2018-10-12)

2.4.0 (2018-10-09)

  • Update package maintainers (#520)
  • Contributors: P. J. Reed

2.3.0 (2018-05-25)

  • Only calculate statistics when messages arrive in order (#516)
  • Contributors: David Anthony

2.2.1 (2018-05-11)

2.2.0 (2018-02-12)

  • Fix crash from messages with null timestamps (#511)
  • Contributors: Matthew

2.1.0 (2018-01-26)

2.0.0 (2017-12-18)

  • Ensure all swri::Subscriber members are initialized (#505)
  • Contributors: P. J. Reed

1.2.0 (2017-10-13)

1.1.0 (2017-08-31)

  • Add OptionalDiagnosedPublisher class (#483)
  • Contributors: Edward Venator, P. J. Reed

1.0.0 (2017-08-02)

  • Add support for boost::function callbacks to swri::Subscriber.
  • Contributors: Elliot Johnson

0.3.0 (2017-06-20)

  • Merge together the indigo, jade, and kinetic branches (#443)
  • Contributors: P. J. Reed

0.2.4 (2017-04-11)

  • Port #385 and #419 to kinetic. (#420) A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This feature allows the node author to output a WARNING for any unused parameters. Ported forward from indigo-devel
  • Contributors: Edward Venator

0.2.3 (2016-12-09)

0.2.2 (2016-12-07)

  • Deprecate LatchedSubscriber. (#391) LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Contributors: P. J. Reed

0.2.1 (2016-10-23)

0.2.0 (2016-06-21)

0.1.5 (2016-05-13)

0.1.4 (2016-05-12)

  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.1.3 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.14 (2017-04-11)

  • Increase queue_size in swri_roscpp/Subscriber. This commit increases the queue size for subscribers that use the store mechanism instead of a callback. The queue size was set to 1, which we have seen problems with, so this will increase it to 2.
  • Add missing qualifiers for swri_roscpp unused parameter functions.
  • Merge pull request #385 from evenator/unused-parameter-warnings Adds the ability to warn when unused parameters are set in a namespace.
  • Add test for getUnusedParamKeys Adds an automated test for getUnusedParamKeys based on the example code.
  • Remove default value of node handle for warnUnusedParams This default value may cause unexpected behvavior, especially with nodelets.
  • Rename param_test to param_example. param_test isn\'t an automated test, just an example of how to use the param utilities.
  • Document unused parameter functions. The set difference algorithms used to determine which parameters are used are non-obvious. This adds documentation.
  • Mark _used_params static.
  • Adds the ability to warn when unused parameters are set in a namespace. A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This features allows the node author to output a WARNING for any unused parameters. See the param_test node for an example.
  • Contributors: Ed Venator, Edward Venator, Elliot Johnson, elliotjo

0.0.13 (2016-10-23)

  • Add swri_roscpp functions for reading float values. These add support for reading float values directly instead of doubles.
  • Contributors: Elliot Johnson

0.0.12 (2016-08-14)

0.0.11 (2016-05-13)

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.

0.0.9 (2016-03-04)

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.1.2 (2016-01-06)

0.1.1 (2015-11-17)

  • First jade release of swri_roscpp
  • Contributors: Edward Venator

0.1.0 (2015-09-29)

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org

Package Summary

Tags No category tags.
Version 2.11.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version master
Last Updated 2019-11-13
Dev Status DEVELOPED
Released RELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • P. J. Reed

Authors

No additional authors.

swri_roscpp

This packages contains a set of wrappers classes and functions for common ROS operations.

Topic Services

Topic services are a wrappers over ROS topics that provide a service like functionality but in a much more introspectable way. Eg: There is no rosservice echo and no way to view service clients in a running system.

The usage is very similar to that of standard ROS services and can even make use of the same service definitions. For most usages simply just substitute ros::ServiceServer or ros::ServiceClient for swri::TopicServiceServer or swri::TopicServiceClient in the declaration and use it in the same way.

Generating Topics from a Service

In order to generate the backing topics for a Topic Service from a service message add a add_topic_service_files block to your project's CMakeList.txt and use it the same way you would an add_message_files or add_service_files block.

Make sure to add this swri_roscpp as a dependency to your message project.

For example:

add_topic_service_files(DIRECTORY topic_srv FILES
  ClearActiveRoute.srv
  DeleteRoute.srv
  GetRoute.srv
  GetRouteNames.srv
  SaveRoute.srv
  SetActiveRoute.srv
  SetRoute.srv
  SetNextCheckpoint.srv
)

To use the generated topics simply include your_project/your_service.h. They have response and request fields just like normal services.

Dynamic Parameters

A class that implements the same functionality as Dynamic Reconfigure, but in a more dynamic and easier to use way. Instead of declaring configurable parameters at compile time in a config file they are specified in your C++ code.

To use, add the class to your node and call the initalize function with a NodeHandle in your private namespace.

#include <swri_roscpp/dynamic_parameters.h>

void main()
{
  // your node stuff here

  ros::NodeHandle pnh("~");
  swri::DynamicParameters params;
  params.initialize(pnh);
...

You can then start declaring and reading in configuration values, giving a long living pointer to a variable for each. This variable is changed on a dynamic reconfigure of that parameter. Be sure to lock the parameter mutex before reading any of these parameters. You can do this by calling the params.mutex() function and manually locking/unlocking it, or by using the .get() function on each *Param to do it automatically.

  FloatParam flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  DoubleParam dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  BoolParam bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  StringParam str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

You can also load the parameters directly in to normal variables (doubles, ints, strings), but you will have to get the new values in the on change callback function discussed below.

  float flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  double dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  bool bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  std::string str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

These functions read in the current parameter value to the provided variable, if they haven't been set they are set to the default value. After you have read in all the variables you want to be dynamically reconfigurable, call the finalize() function.

  params.finalize();

This publishes the configuration options to a latched topic so that the dynamic reconfigure tools can read them in.

After you call finalize, you should be able to access and dynamically configure your node with any dynamic reconfigure compatible tools.

Then to use/read in the parameter values in your code:

  float val = flt.get();// or *flt to get it without locking the mutex if you know what you are doing

You can also lock the mutex manually for getting the parameters in a block as follows:

  params.mutex().lock();

  float a = *flt;
  double b = *dbl;
  bool c = *bl;
  std::string d = *str; 

  params.mutex().unlock();

Alternatively you can use the on change callback to be notified when variables change and load the updated values then.


void callback(swri::DynamicParameters& params)
{
  double param1 = params.getDouble("double_value");
  float  param2 = params.getFloat("float_value");
  int    param3 = params.getInt("int_value");
  bool   param4 = params.getBool("bool_value");
  std::string param5 = params.getString("string_value");
}

// somewhere in your initialization....
params.setCallback(callback);


CHANGELOG

Changelog for package swri_roscpp

2.11.0 (2019-11-13)

  • Fix incorrect type for strings in dynamic params (#553)
  • Contributors: jgassaway

2.10.0 (2019-09-04)

  • Prevent swri:Subscriber latency calculations if current time is zero (#548)
  • Change way name is created for topic services (#541)
  • Contributors: jgassaway, nick-alton

2.9.0 (2019-05-23)

  • Add callback for on change for dynamic parameters (#540)
  • Add topic service unit tests (#538)
  • Contributors: Matthew, P. J. Reed

2.8.0 (2019-02-06)

  • Add dynamic parameters (#532)
  • Contributors: Matthew

2.7.3 (2019-01-03)

2.7.2 (2018-12-20)

  • Fix cmake macro for service_splitter.py (#535)
  • Contributors: P. J. Reed

2.7.1 (2018-12-14)

  • Fix conditional causing exists to not work properly. (#533)
  • Remove non ascii character to please python (#530)
  • Contributors: Matthew

2.7.0 (2018-12-04)

  • Add topic based services and associated cmake utils (#523) Provide utilities for implementing service type requests using messages in an almost transparent way.
  • Contributors: Matthew

2.6.0 (2018-11-03)

2.5.0 (2018-10-12)

2.4.0 (2018-10-09)

  • Update package maintainers (#520)
  • Contributors: P. J. Reed

2.3.0 (2018-05-25)

  • Only calculate statistics when messages arrive in order (#516)
  • Contributors: David Anthony

2.2.1 (2018-05-11)

2.2.0 (2018-02-12)

  • Fix crash from messages with null timestamps (#511)
  • Contributors: Matthew

2.1.0 (2018-01-26)

2.0.0 (2017-12-18)

  • Ensure all swri::Subscriber members are initialized (#505)
  • Contributors: P. J. Reed

1.2.0 (2017-10-13)

1.1.0 (2017-08-31)

  • Add OptionalDiagnosedPublisher class (#483)
  • Contributors: Edward Venator, P. J. Reed

1.0.0 (2017-08-02)

  • Add support for boost::function callbacks to swri::Subscriber.
  • Contributors: Elliot Johnson

0.3.0 (2017-06-20)

  • Merge together the indigo, jade, and kinetic branches (#443)
  • Contributors: P. J. Reed

0.2.4 (2017-04-11)

  • Port #385 and #419 to kinetic. (#420) A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This feature allows the node author to output a WARNING for any unused parameters. Ported forward from indigo-devel
  • Contributors: Edward Venator

0.2.3 (2016-12-09)

0.2.2 (2016-12-07)

  • Deprecate LatchedSubscriber. (#391) LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Contributors: P. J. Reed

0.2.1 (2016-10-23)

0.2.0 (2016-06-21)

0.1.5 (2016-05-13)

0.1.4 (2016-05-12)

  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.1.3 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.14 (2017-04-11)

  • Increase queue_size in swri_roscpp/Subscriber. This commit increases the queue size for subscribers that use the store mechanism instead of a callback. The queue size was set to 1, which we have seen problems with, so this will increase it to 2.
  • Add missing qualifiers for swri_roscpp unused parameter functions.
  • Merge pull request #385 from evenator/unused-parameter-warnings Adds the ability to warn when unused parameters are set in a namespace.
  • Add test for getUnusedParamKeys Adds an automated test for getUnusedParamKeys based on the example code.
  • Remove default value of node handle for warnUnusedParams This default value may cause unexpected behvavior, especially with nodelets.
  • Rename param_test to param_example. param_test isn\'t an automated test, just an example of how to use the param utilities.
  • Document unused parameter functions. The set difference algorithms used to determine which parameters are used are non-obvious. This adds documentation.
  • Mark _used_params static.
  • Adds the ability to warn when unused parameters are set in a namespace. A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This features allows the node author to output a WARNING for any unused parameters. See the param_test node for an example.
  • Contributors: Ed Venator, Edward Venator, Elliot Johnson, elliotjo

0.0.13 (2016-10-23)

  • Add swri_roscpp functions for reading float values. These add support for reading float values directly instead of doubles.
  • Contributors: Elliot Johnson

0.0.12 (2016-08-14)

0.0.11 (2016-05-13)

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.

0.0.9 (2016-03-04)

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.1.2 (2016-01-06)

0.1.1 (2015-11-17)

  • First jade release of swri_roscpp
  • Contributors: Edward Venator

0.1.0 (2015-09-29)

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org

Package Summary

Tags No category tags.
Version 2.11.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version master
Last Updated 2019-11-13
Dev Status DEVELOPED
Released RELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • P. J. Reed

Authors

No additional authors.

swri_roscpp

This packages contains a set of wrappers classes and functions for common ROS operations.

Topic Services

Topic services are a wrappers over ROS topics that provide a service like functionality but in a much more introspectable way. Eg: There is no rosservice echo and no way to view service clients in a running system.

The usage is very similar to that of standard ROS services and can even make use of the same service definitions. For most usages simply just substitute ros::ServiceServer or ros::ServiceClient for swri::TopicServiceServer or swri::TopicServiceClient in the declaration and use it in the same way.

Generating Topics from a Service

In order to generate the backing topics for a Topic Service from a service message add a add_topic_service_files block to your project's CMakeList.txt and use it the same way you would an add_message_files or add_service_files block.

Make sure to add this swri_roscpp as a dependency to your message project.

For example:

add_topic_service_files(DIRECTORY topic_srv FILES
  ClearActiveRoute.srv
  DeleteRoute.srv
  GetRoute.srv
  GetRouteNames.srv
  SaveRoute.srv
  SetActiveRoute.srv
  SetRoute.srv
  SetNextCheckpoint.srv
)

To use the generated topics simply include your_project/your_service.h. They have response and request fields just like normal services.

Dynamic Parameters

A class that implements the same functionality as Dynamic Reconfigure, but in a more dynamic and easier to use way. Instead of declaring configurable parameters at compile time in a config file they are specified in your C++ code.

To use, add the class to your node and call the initalize function with a NodeHandle in your private namespace.

#include <swri_roscpp/dynamic_parameters.h>

void main()
{
  // your node stuff here

  ros::NodeHandle pnh("~");
  swri::DynamicParameters params;
  params.initialize(pnh);
...

You can then start declaring and reading in configuration values, giving a long living pointer to a variable for each. This variable is changed on a dynamic reconfigure of that parameter. Be sure to lock the parameter mutex before reading any of these parameters. You can do this by calling the params.mutex() function and manually locking/unlocking it, or by using the .get() function on each *Param to do it automatically.

  FloatParam flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  DoubleParam dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  BoolParam bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  StringParam str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

You can also load the parameters directly in to normal variables (doubles, ints, strings), but you will have to get the new values in the on change callback function discussed below.

  float flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  double dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  bool bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  std::string str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

These functions read in the current parameter value to the provided variable, if they haven't been set they are set to the default value. After you have read in all the variables you want to be dynamically reconfigurable, call the finalize() function.

  params.finalize();

This publishes the configuration options to a latched topic so that the dynamic reconfigure tools can read them in.

After you call finalize, you should be able to access and dynamically configure your node with any dynamic reconfigure compatible tools.

Then to use/read in the parameter values in your code:

  float val = flt.get();// or *flt to get it without locking the mutex if you know what you are doing

You can also lock the mutex manually for getting the parameters in a block as follows:

  params.mutex().lock();

  float a = *flt;
  double b = *dbl;
  bool c = *bl;
  std::string d = *str; 

  params.mutex().unlock();

Alternatively you can use the on change callback to be notified when variables change and load the updated values then.


void callback(swri::DynamicParameters& params)
{
  double param1 = params.getDouble("double_value");
  float  param2 = params.getFloat("float_value");
  int    param3 = params.getInt("int_value");
  bool   param4 = params.getBool("bool_value");
  std::string param5 = params.getString("string_value");
}

// somewhere in your initialization....
params.setCallback(callback);


CHANGELOG

Changelog for package swri_roscpp

2.11.0 (2019-11-13)

  • Fix incorrect type for strings in dynamic params (#553)
  • Contributors: jgassaway

2.10.0 (2019-09-04)

  • Prevent swri:Subscriber latency calculations if current time is zero (#548)
  • Change way name is created for topic services (#541)
  • Contributors: jgassaway, nick-alton

2.9.0 (2019-05-23)

  • Add callback for on change for dynamic parameters (#540)
  • Add topic service unit tests (#538)
  • Contributors: Matthew, P. J. Reed

2.8.0 (2019-02-06)

  • Add dynamic parameters (#532)
  • Contributors: Matthew

2.7.3 (2019-01-03)

2.7.2 (2018-12-20)

  • Fix cmake macro for service_splitter.py (#535)
  • Contributors: P. J. Reed

2.7.1 (2018-12-14)

  • Fix conditional causing exists to not work properly. (#533)
  • Remove non ascii character to please python (#530)
  • Contributors: Matthew

2.7.0 (2018-12-04)

  • Add topic based services and associated cmake utils (#523) Provide utilities for implementing service type requests using messages in an almost transparent way.
  • Contributors: Matthew

2.6.0 (2018-11-03)

2.5.0 (2018-10-12)

2.4.0 (2018-10-09)

  • Update package maintainers (#520)
  • Contributors: P. J. Reed

2.3.0 (2018-05-25)

  • Only calculate statistics when messages arrive in order (#516)
  • Contributors: David Anthony

2.2.1 (2018-05-11)

2.2.0 (2018-02-12)

  • Fix crash from messages with null timestamps (#511)
  • Contributors: Matthew

2.1.0 (2018-01-26)

2.0.0 (2017-12-18)

  • Ensure all swri::Subscriber members are initialized (#505)
  • Contributors: P. J. Reed

1.2.0 (2017-10-13)

1.1.0 (2017-08-31)

  • Add OptionalDiagnosedPublisher class (#483)
  • Contributors: Edward Venator, P. J. Reed

1.0.0 (2017-08-02)

  • Add support for boost::function callbacks to swri::Subscriber.
  • Contributors: Elliot Johnson

0.3.0 (2017-06-20)

  • Merge together the indigo, jade, and kinetic branches (#443)
  • Contributors: P. J. Reed

0.2.4 (2017-04-11)

  • Port #385 and #419 to kinetic. (#420) A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This feature allows the node author to output a WARNING for any unused parameters. Ported forward from indigo-devel
  • Contributors: Edward Venator

0.2.3 (2016-12-09)

0.2.2 (2016-12-07)

  • Deprecate LatchedSubscriber. (#391) LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Contributors: P. J. Reed

0.2.1 (2016-10-23)

0.2.0 (2016-06-21)

0.1.5 (2016-05-13)

0.1.4 (2016-05-12)

  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.1.3 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.14 (2017-04-11)

  • Increase queue_size in swri_roscpp/Subscriber. This commit increases the queue size for subscribers that use the store mechanism instead of a callback. The queue size was set to 1, which we have seen problems with, so this will increase it to 2.
  • Add missing qualifiers for swri_roscpp unused parameter functions.
  • Merge pull request #385 from evenator/unused-parameter-warnings Adds the ability to warn when unused parameters are set in a namespace.
  • Add test for getUnusedParamKeys Adds an automated test for getUnusedParamKeys based on the example code.
  • Remove default value of node handle for warnUnusedParams This default value may cause unexpected behvavior, especially with nodelets.
  • Rename param_test to param_example. param_test isn\'t an automated test, just an example of how to use the param utilities.
  • Document unused parameter functions. The set difference algorithms used to determine which parameters are used are non-obvious. This adds documentation.
  • Mark _used_params static.
  • Adds the ability to warn when unused parameters are set in a namespace. A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This features allows the node author to output a WARNING for any unused parameters. See the param_test node for an example.
  • Contributors: Ed Venator, Edward Venator, Elliot Johnson, elliotjo

0.0.13 (2016-10-23)

  • Add swri_roscpp functions for reading float values. These add support for reading float values directly instead of doubles.
  • Contributors: Elliot Johnson

0.0.12 (2016-08-14)

0.0.11 (2016-05-13)

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.

0.0.9 (2016-03-04)

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.1.2 (2016-01-06)

0.1.1 (2015-11-17)

  • First jade release of swri_roscpp
  • Contributors: Edward Venator

0.1.0 (2015-09-29)

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org

Package Summary

Tags No category tags.
Version 2.11.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version master
Last Updated 2019-11-13
Dev Status DEVELOPED
Released RELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • P. J. Reed

Authors

No additional authors.

swri_roscpp

This packages contains a set of wrappers classes and functions for common ROS operations.

Topic Services

Topic services are a wrappers over ROS topics that provide a service like functionality but in a much more introspectable way. Eg: There is no rosservice echo and no way to view service clients in a running system.

The usage is very similar to that of standard ROS services and can even make use of the same service definitions. For most usages simply just substitute ros::ServiceServer or ros::ServiceClient for swri::TopicServiceServer or swri::TopicServiceClient in the declaration and use it in the same way.

Generating Topics from a Service

In order to generate the backing topics for a Topic Service from a service message add a add_topic_service_files block to your project's CMakeList.txt and use it the same way you would an add_message_files or add_service_files block.

Make sure to add this swri_roscpp as a dependency to your message project.

For example:

add_topic_service_files(DIRECTORY topic_srv FILES
  ClearActiveRoute.srv
  DeleteRoute.srv
  GetRoute.srv
  GetRouteNames.srv
  SaveRoute.srv
  SetActiveRoute.srv
  SetRoute.srv
  SetNextCheckpoint.srv
)

To use the generated topics simply include your_project/your_service.h. They have response and request fields just like normal services.

Dynamic Parameters

A class that implements the same functionality as Dynamic Reconfigure, but in a more dynamic and easier to use way. Instead of declaring configurable parameters at compile time in a config file they are specified in your C++ code.

To use, add the class to your node and call the initalize function with a NodeHandle in your private namespace.

#include <swri_roscpp/dynamic_parameters.h>

void main()
{
  // your node stuff here

  ros::NodeHandle pnh("~");
  swri::DynamicParameters params;
  params.initialize(pnh);
...

You can then start declaring and reading in configuration values, giving a long living pointer to a variable for each. This variable is changed on a dynamic reconfigure of that parameter. Be sure to lock the parameter mutex before reading any of these parameters. You can do this by calling the params.mutex() function and manually locking/unlocking it, or by using the .get() function on each *Param to do it automatically.

  FloatParam flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  DoubleParam dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  BoolParam bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  StringParam str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

You can also load the parameters directly in to normal variables (doubles, ints, strings), but you will have to get the new values in the on change callback function discussed below.

  float flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  double dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  bool bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  std::string str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

These functions read in the current parameter value to the provided variable, if they haven't been set they are set to the default value. After you have read in all the variables you want to be dynamically reconfigurable, call the finalize() function.

  params.finalize();

This publishes the configuration options to a latched topic so that the dynamic reconfigure tools can read them in.

After you call finalize, you should be able to access and dynamically configure your node with any dynamic reconfigure compatible tools.

Then to use/read in the parameter values in your code:

  float val = flt.get();// or *flt to get it without locking the mutex if you know what you are doing

You can also lock the mutex manually for getting the parameters in a block as follows:

  params.mutex().lock();

  float a = *flt;
  double b = *dbl;
  bool c = *bl;
  std::string d = *str; 

  params.mutex().unlock();

Alternatively you can use the on change callback to be notified when variables change and load the updated values then.


void callback(swri::DynamicParameters& params)
{
  double param1 = params.getDouble("double_value");
  float  param2 = params.getFloat("float_value");
  int    param3 = params.getInt("int_value");
  bool   param4 = params.getBool("bool_value");
  std::string param5 = params.getString("string_value");
}

// somewhere in your initialization....
params.setCallback(callback);


CHANGELOG

Changelog for package swri_roscpp

2.11.0 (2019-11-13)

  • Fix incorrect type for strings in dynamic params (#553)
  • Contributors: jgassaway

2.10.0 (2019-09-04)

  • Prevent swri:Subscriber latency calculations if current time is zero (#548)
  • Change way name is created for topic services (#541)
  • Contributors: jgassaway, nick-alton

2.9.0 (2019-05-23)

  • Add callback for on change for dynamic parameters (#540)
  • Add topic service unit tests (#538)
  • Contributors: Matthew, P. J. Reed

2.8.0 (2019-02-06)

  • Add dynamic parameters (#532)
  • Contributors: Matthew

2.7.3 (2019-01-03)

2.7.2 (2018-12-20)

  • Fix cmake macro for service_splitter.py (#535)
  • Contributors: P. J. Reed

2.7.1 (2018-12-14)

  • Fix conditional causing exists to not work properly. (#533)
  • Remove non ascii character to please python (#530)
  • Contributors: Matthew

2.7.0 (2018-12-04)

  • Add topic based services and associated cmake utils (#523) Provide utilities for implementing service type requests using messages in an almost transparent way.
  • Contributors: Matthew

2.6.0 (2018-11-03)

2.5.0 (2018-10-12)

2.4.0 (2018-10-09)

  • Update package maintainers (#520)
  • Contributors: P. J. Reed

2.3.0 (2018-05-25)

  • Only calculate statistics when messages arrive in order (#516)
  • Contributors: David Anthony

2.2.1 (2018-05-11)

2.2.0 (2018-02-12)

  • Fix crash from messages with null timestamps (#511)
  • Contributors: Matthew

2.1.0 (2018-01-26)

2.0.0 (2017-12-18)

  • Ensure all swri::Subscriber members are initialized (#505)
  • Contributors: P. J. Reed

1.2.0 (2017-10-13)

1.1.0 (2017-08-31)

  • Add OptionalDiagnosedPublisher class (#483)
  • Contributors: Edward Venator, P. J. Reed

1.0.0 (2017-08-02)

  • Add support for boost::function callbacks to swri::Subscriber.
  • Contributors: Elliot Johnson

0.3.0 (2017-06-20)

  • Merge together the indigo, jade, and kinetic branches (#443)
  • Contributors: P. J. Reed

0.2.4 (2017-04-11)

  • Port #385 and #419 to kinetic. (#420) A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This feature allows the node author to output a WARNING for any unused parameters. Ported forward from indigo-devel
  • Contributors: Edward Venator

0.2.3 (2016-12-09)

0.2.2 (2016-12-07)

  • Deprecate LatchedSubscriber. (#391) LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Contributors: P. J. Reed

0.2.1 (2016-10-23)

0.2.0 (2016-06-21)

0.1.5 (2016-05-13)

0.1.4 (2016-05-12)

  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.1.3 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.14 (2017-04-11)

  • Increase queue_size in swri_roscpp/Subscriber. This commit increases the queue size for subscribers that use the store mechanism instead of a callback. The queue size was set to 1, which we have seen problems with, so this will increase it to 2.
  • Add missing qualifiers for swri_roscpp unused parameter functions.
  • Merge pull request #385 from evenator/unused-parameter-warnings Adds the ability to warn when unused parameters are set in a namespace.
  • Add test for getUnusedParamKeys Adds an automated test for getUnusedParamKeys based on the example code.
  • Remove default value of node handle for warnUnusedParams This default value may cause unexpected behvavior, especially with nodelets.
  • Rename param_test to param_example. param_test isn\'t an automated test, just an example of how to use the param utilities.
  • Document unused parameter functions. The set difference algorithms used to determine which parameters are used are non-obvious. This adds documentation.
  • Mark _used_params static.
  • Adds the ability to warn when unused parameters are set in a namespace. A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This features allows the node author to output a WARNING for any unused parameters. See the param_test node for an example.
  • Contributors: Ed Venator, Edward Venator, Elliot Johnson, elliotjo

0.0.13 (2016-10-23)

  • Add swri_roscpp functions for reading float values. These add support for reading float values directly instead of doubles.
  • Contributors: Elliot Johnson

0.0.12 (2016-08-14)

0.0.11 (2016-05-13)

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.

0.0.9 (2016-03-04)

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.1.2 (2016-01-06)

0.1.1 (2015-11-17)

  • First jade release of swri_roscpp
  • Contributors: Edward Venator

0.1.0 (2015-09-29)

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org

Package Summary

Tags No category tags.
Version 2.11.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version master
Last Updated 2019-11-13
Dev Status DEVELOPED
Released RELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • P. J. Reed

Authors

No additional authors.

swri_roscpp

This packages contains a set of wrappers classes and functions for common ROS operations.

Topic Services

Topic services are a wrappers over ROS topics that provide a service like functionality but in a much more introspectable way. Eg: There is no rosservice echo and no way to view service clients in a running system.

The usage is very similar to that of standard ROS services and can even make use of the same service definitions. For most usages simply just substitute ros::ServiceServer or ros::ServiceClient for swri::TopicServiceServer or swri::TopicServiceClient in the declaration and use it in the same way.

Generating Topics from a Service

In order to generate the backing topics for a Topic Service from a service message add a add_topic_service_files block to your project's CMakeList.txt and use it the same way you would an add_message_files or add_service_files block.

Make sure to add this swri_roscpp as a dependency to your message project.

For example:

add_topic_service_files(DIRECTORY topic_srv FILES
  ClearActiveRoute.srv
  DeleteRoute.srv
  GetRoute.srv
  GetRouteNames.srv
  SaveRoute.srv
  SetActiveRoute.srv
  SetRoute.srv
  SetNextCheckpoint.srv
)

To use the generated topics simply include your_project/your_service.h. They have response and request fields just like normal services.

Dynamic Parameters

A class that implements the same functionality as Dynamic Reconfigure, but in a more dynamic and easier to use way. Instead of declaring configurable parameters at compile time in a config file they are specified in your C++ code.

To use, add the class to your node and call the initalize function with a NodeHandle in your private namespace.

#include <swri_roscpp/dynamic_parameters.h>

void main()
{
  // your node stuff here

  ros::NodeHandle pnh("~");
  swri::DynamicParameters params;
  params.initialize(pnh);
...

You can then start declaring and reading in configuration values, giving a long living pointer to a variable for each. This variable is changed on a dynamic reconfigure of that parameter. Be sure to lock the parameter mutex before reading any of these parameters. You can do this by calling the params.mutex() function and manually locking/unlocking it, or by using the .get() function on each *Param to do it automatically.

  FloatParam flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  DoubleParam dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  BoolParam bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  StringParam str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

You can also load the parameters directly in to normal variables (doubles, ints, strings), but you will have to get the new values in the on change callback function discussed below.

  float flt;
  params.get("float_value", flt, 
              10.0f /*default*/, "Description...", 
             -10.0f /* min */, 10.0f /* max */);
  double dbl;
  params.get("double_value", dbl, 
              10.0 /*default*/, "Description...", 
             -10.0 /* min */, 10.0 /* max */);
  bool bl;
  params.get("bool_value", bl, 
              10.0f /*default*/, "Description...");
  std::string str;
  params.get("string_value", str, 
              "default" /*default*/, "Description...");

These functions read in the current parameter value to the provided variable, if they haven't been set they are set to the default value. After you have read in all the variables you want to be dynamically reconfigurable, call the finalize() function.

  params.finalize();

This publishes the configuration options to a latched topic so that the dynamic reconfigure tools can read them in.

After you call finalize, you should be able to access and dynamically configure your node with any dynamic reconfigure compatible tools.

Then to use/read in the parameter values in your code:

  float val = flt.get();// or *flt to get it without locking the mutex if you know what you are doing

You can also lock the mutex manually for getting the parameters in a block as follows:

  params.mutex().lock();

  float a = *flt;
  double b = *dbl;
  bool c = *bl;
  std::string d = *str; 

  params.mutex().unlock();

Alternatively you can use the on change callback to be notified when variables change and load the updated values then.


void callback(swri::DynamicParameters& params)
{
  double param1 = params.getDouble("double_value");
  float  param2 = params.getFloat("float_value");
  int    param3 = params.getInt("int_value");
  bool   param4 = params.getBool("bool_value");
  std::string param5 = params.getString("string_value");
}

// somewhere in your initialization....
params.setCallback(callback);


CHANGELOG

Changelog for package swri_roscpp

2.11.0 (2019-11-13)

  • Fix incorrect type for strings in dynamic params (#553)
  • Contributors: jgassaway

2.10.0 (2019-09-04)

  • Prevent swri:Subscriber latency calculations if current time is zero (#548)
  • Change way name is created for topic services (#541)
  • Contributors: jgassaway, nick-alton

2.9.0 (2019-05-23)

  • Add callback for on change for dynamic parameters (#540)
  • Add topic service unit tests (#538)
  • Contributors: Matthew, P. J. Reed

2.8.0 (2019-02-06)

  • Add dynamic parameters (#532)
  • Contributors: Matthew

2.7.3 (2019-01-03)

2.7.2 (2018-12-20)

  • Fix cmake macro for service_splitter.py (#535)
  • Contributors: P. J. Reed

2.7.1 (2018-12-14)

  • Fix conditional causing exists to not work properly. (#533)
  • Remove non ascii character to please python (#530)
  • Contributors: Matthew

2.7.0 (2018-12-04)

  • Add topic based services and associated cmake utils (#523) Provide utilities for implementing service type requests using messages in an almost transparent way.
  • Contributors: Matthew

2.6.0 (2018-11-03)

2.5.0 (2018-10-12)

2.4.0 (2018-10-09)

  • Update package maintainers (#520)
  • Contributors: P. J. Reed

2.3.0 (2018-05-25)

  • Only calculate statistics when messages arrive in order (#516)
  • Contributors: David Anthony

2.2.1 (2018-05-11)

2.2.0 (2018-02-12)

  • Fix crash from messages with null timestamps (#511)
  • Contributors: Matthew

2.1.0 (2018-01-26)

2.0.0 (2017-12-18)

  • Ensure all swri::Subscriber members are initialized (#505)
  • Contributors: P. J. Reed

1.2.0 (2017-10-13)

1.1.0 (2017-08-31)

  • Add OptionalDiagnosedPublisher class (#483)
  • Contributors: Edward Venator, P. J. Reed

1.0.0 (2017-08-02)

  • Add support for boost::function callbacks to swri::Subscriber.
  • Contributors: Elliot Johnson

0.3.0 (2017-06-20)

  • Merge together the indigo, jade, and kinetic branches (#443)
  • Contributors: P. J. Reed

0.2.4 (2017-04-11)

  • Port #385 and #419 to kinetic. (#420) A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This feature allows the node author to output a WARNING for any unused parameters. Ported forward from indigo-devel
  • Contributors: Edward Venator

0.2.3 (2016-12-09)

0.2.2 (2016-12-07)

  • Deprecate LatchedSubscriber. (#391) LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Contributors: P. J. Reed

0.2.1 (2016-10-23)

0.2.0 (2016-06-21)

0.1.5 (2016-05-13)

0.1.4 (2016-05-12)

  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.1.3 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.14 (2017-04-11)

  • Increase queue_size in swri_roscpp/Subscriber. This commit increases the queue size for subscribers that use the store mechanism instead of a callback. The queue size was set to 1, which we have seen problems with, so this will increase it to 2.
  • Add missing qualifiers for swri_roscpp unused parameter functions.
  • Merge pull request #385 from evenator/unused-parameter-warnings Adds the ability to warn when unused parameters are set in a namespace.
  • Add test for getUnusedParamKeys Adds an automated test for getUnusedParamKeys based on the example code.
  • Remove default value of node handle for warnUnusedParams This default value may cause unexpected behvavior, especially with nodelets.
  • Rename param_test to param_example. param_test isn\'t an automated test, just an example of how to use the param utilities.
  • Document unused parameter functions. The set difference algorithms used to determine which parameters are used are non-obvious. This adds documentation.
  • Mark _used_params static.
  • Adds the ability to warn when unused parameters are set in a namespace. A common error when using unfamiliar ROS nodes is to accidentally set parameters by the wrong name. This features allows the node author to output a WARNING for any unused parameters. See the param_test node for an example.
  • Contributors: Ed Venator, Edward Venator, Elliot Johnson, elliotjo

0.0.13 (2016-10-23)

  • Add swri_roscpp functions for reading float values. These add support for reading float values directly instead of doubles.
  • Contributors: Elliot Johnson

0.0.12 (2016-08-14)

0.0.11 (2016-05-13)

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.

0.0.9 (2016-03-04)

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.1.2 (2016-01-06)

0.1.1 (2015-11-17)

  • First jade release of swri_roscpp
  • Contributors: Edward Venator

0.1.0 (2015-09-29)

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org

Package Summary

Tags No category tags.
Version 0.0.10
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/swri-robotics/marti_common.git
VCS Type git
VCS Version hydro-devel
Last Updated 2016-10-14
Dev Status DEVELOPED
Released UNRELEASED

Package Description

swri_roscpp

Additional Links

No additional links.

Maintainers

  • Elliot Johnson

Authors

No additional authors.
README
No README found. See repository README.
CHANGELOG

Changelog for package swri_roscpp

0.0.10 (2016-05-12)

  • Deprecate LatchedSubscriber. This commit adds an alternative to LatchedSubscriber and deprecates the LatchedSubscriber interface. LatchedSubscriber should be replaced with a swri::Subscriber that is initialized with the address of a location to store messages. For example, instead of: swri::LatchedSubscriber<my_package::MyMessage> msg_; ... msg_.initialize(nh_, \"topic_name\"); ... ROS_INFO(\"msg->field = %f\", msg->field); this becomes: swri::Subscriber sub_; my_package::MyMessageConstPtr msg_; ... sub_ = swri::SubscribeR(nh_, \"topic_name\", &msg_); ... ROS_INFO(\"msg->field = %f\", msg->field). This change makes for a simpler and more consistent interface, and avoids the confusion that comes from overloading the -> operator.
  • Add timeoutParam() method to swri::Subscriber. This commit adds a new convenience method, timeoutParam, to swri::Subscriber that reads a specified parameter directly from the parameter server and sets it as the subscriber\'s timeout value. This is to simplify setup code that currently has to define a temporary variable, read the parameter in the temp, and then set the timeout.
  • Contributors: Elliot Johnson

0.0.9 (2016-03-04)

  • Adds getParam() functions to swri_roscpp. These functions wrap NodeHandle::getParam(). If the parameter does not exist, they emit an error message and return false.
  • Fixes some compiler warnings.
  • The swri::Subscriber::blockTimeouts function now returns a value. Previously, it did not explicitly returning a value, which has undefined behavior. It now returns the result of the blockTimeouts function that it wraps.
  • Contributors: Edward Venator, Elliot Johnson, P. J. Reed

0.0.8 (2016-01-06)

  • Makes swri::Subscriber\'s assignment operator return a value. According to the C++ spec, assignment operators must return a reference to the current object (*this). swri::Subscriber\'s assignment operator was not returning a value, which works in GCC, but not Clang. GCC would do the right thing for you, but Clang will compile the code but generate a SIGILL exception at runtime. This is easily fixed by manually returning *this.
  • Contributors: P. J. Reed

0.0.7 (2015-11-18)

  • Fixes broken changelog #279.

0.0.6 (2015-11-17)

  • First release of swri_roscpp
  • Contributors: Edward Venator

0.0.5 (2015-09-27 15:27)

0.0.4 (2015-09-27 11:35)

0.0.3 (2015-09-26)

0.0.2 (2015-09-25 15:00)

0.0.1 (2015-09-25 09:06)

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Package Dependencies

System Dependencies

No direct system dependencies.

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at answers.ros.org