-
 

Package Summary

Tags No category tags.
Version 3.7.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 ros2-devel
Last Updated 2024-10-23
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A package that extends rclcpp with some commonly used functionality to reduce boilerplate code.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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 ros2 service 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 generate_topic_service_files block to your project’s CMakeList.txt and use it almost the same way you would an rosidl_generate_interfaces block. This generates the individual topic service messages and returns a list of these to the variable named by the first argument. Make sure to add these to your rosidl_generate_interfaces call along with the marti_common_msgs dependency.

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

For example:

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

rosidl_generate_interfaces(${PROJECT_NAME}
   your_other_messages_here.msg
   ${generated_message_list}
  DEPENDENCIES 
   ${MSG_DEPS}
   marti_common_msgs
)

To use the generated topics simply include your_project/srv/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.7.3 (2024-09-18)

3.7.2 (2024-09-16)

3.7.1 (2024-09-06)

3.7.0 (2024-09-06)

  • Simplify Cmake by linking to the library target (#742) By linking to the library target, we can reuse the include paths and libraries from it. This will simplify the Cmake a bit. It also fixes a bug when linking to the [ros2-jazzy]{.title-ref} branch of [diagnostic_updater]{.title-ref}.
  • Sanity checking time before performing duration calculation (#735)
  • Add definitions for subscribers with unique_ptr callback arguments (#731)
  • Cleaning up package maintainer (#721)
  • Contributors: David Anthony, Ramon Wijnands, Veronica Knisley

3.6.1 (2023-09-11)

  • Fixing Buildfarm Issues (#716)
    • Cleaning up code to fix build farm errors
  • Contributors: David Anthony

3.6.0 (2023-08-22)

  • Rolling updates (#715)
    • Updating code for Rolling.
    • Removing conditional compilation code related to EOL distributions.
  • Contributors: David Anthony

3.5.4 (2023-08-14)

  • Add publisher and subscription options to constructors (#714)
  • Use System QoS Settings as Defaults (#713)
  • Adding wrapper for unique_ptr arguments (#712)
  • Contributors: David Anthony, Veronica Knisley

3.5.3 (2023-06-07)

  • Fixing build warnings (#707)
  • Contributors: David Anthony

3.5.2 (2023-05-30)

  • Fix dependencies (#704)
    • Fixing build process so dependencies are correctly exported.
  • Contributors: David Anthony

3.5.1 (2022-11-29)

3.5.0 (2022-10-11)

3.4.2 (2022-10-10)

3.3.2 (2020-11-24)

  • Fix topic services under ros2 (#604)
  • Fix bugs related to subscription age and setting timeout (#609, #611) (#612)
  • Contributors: David Anthony, mschickler

3.3.1 (2020-08-19)

3.3.0 (2020-07-15)

  • Implement topic services in ROS 2 (#2893)
  • Contributors: Matthew Bries

3.2.1 (2020-06-10)

  • ROS Foxy support (#582)
  • Contributors: P. J. Reed

3.2.0 (2020-05-13)

3.1.0 (2020-03-30)

3.0.5 (2020-03-10)

3.0.4 (2020-03-05)

  • ROS 2 Eloquent compatibility (#568)
  • Contributors: P. J. Reed

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 3.7.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 ros2-devel
Last Updated 2024-10-23
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A package that extends rclcpp with some commonly used functionality to reduce boilerplate code.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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 ros2 service 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 generate_topic_service_files block to your project’s CMakeList.txt and use it almost the same way you would an rosidl_generate_interfaces block. This generates the individual topic service messages and returns a list of these to the variable named by the first argument. Make sure to add these to your rosidl_generate_interfaces call along with the marti_common_msgs dependency.

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

For example:

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

rosidl_generate_interfaces(${PROJECT_NAME}
   your_other_messages_here.msg
   ${generated_message_list}
  DEPENDENCIES 
   ${MSG_DEPS}
   marti_common_msgs
)

To use the generated topics simply include your_project/srv/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.7.3 (2024-09-18)

3.7.2 (2024-09-16)

3.7.1 (2024-09-06)

3.7.0 (2024-09-06)

  • Simplify Cmake by linking to the library target (#742) By linking to the library target, we can reuse the include paths and libraries from it. This will simplify the Cmake a bit. It also fixes a bug when linking to the [ros2-jazzy]{.title-ref} branch of [diagnostic_updater]{.title-ref}.
  • Sanity checking time before performing duration calculation (#735)
  • Add definitions for subscribers with unique_ptr callback arguments (#731)
  • Cleaning up package maintainer (#721)
  • Contributors: David Anthony, Ramon Wijnands, Veronica Knisley

3.6.1 (2023-09-11)

  • Fixing Buildfarm Issues (#716)
    • Cleaning up code to fix build farm errors
  • Contributors: David Anthony

3.6.0 (2023-08-22)

  • Rolling updates (#715)
    • Updating code for Rolling.
    • Removing conditional compilation code related to EOL distributions.
  • Contributors: David Anthony

3.5.4 (2023-08-14)

  • Add publisher and subscription options to constructors (#714)
  • Use System QoS Settings as Defaults (#713)
  • Adding wrapper for unique_ptr arguments (#712)
  • Contributors: David Anthony, Veronica Knisley

3.5.3 (2023-06-07)

  • Fixing build warnings (#707)
  • Contributors: David Anthony

3.5.2 (2023-05-30)

  • Fix dependencies (#704)
    • Fixing build process so dependencies are correctly exported.
  • Contributors: David Anthony

3.5.1 (2022-11-29)

3.5.0 (2022-10-11)

3.4.2 (2022-10-10)

3.3.2 (2020-11-24)

  • Fix topic services under ros2 (#604)
  • Fix bugs related to subscription age and setting timeout (#609, #611) (#612)
  • Contributors: David Anthony, mschickler

3.3.1 (2020-08-19)

3.3.0 (2020-07-15)

  • Implement topic services in ROS 2 (#2893)
  • Contributors: Matthew Bries

3.2.1 (2020-06-10)

  • ROS Foxy support (#582)
  • Contributors: P. J. Reed

3.2.0 (2020-05-13)

3.1.0 (2020-03-30)

3.0.5 (2020-03-10)

3.0.4 (2020-03-05)

  • ROS 2 Eloquent compatibility (#568)
  • Contributors: P. J. Reed

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 3.7.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 ros2-devel
Last Updated 2024-10-23
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A package that extends rclcpp with some commonly used functionality to reduce boilerplate code.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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 ros2 service 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 generate_topic_service_files block to your project’s CMakeList.txt and use it almost the same way you would an rosidl_generate_interfaces block. This generates the individual topic service messages and returns a list of these to the variable named by the first argument. Make sure to add these to your rosidl_generate_interfaces call along with the marti_common_msgs dependency.

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

For example:

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

rosidl_generate_interfaces(${PROJECT_NAME}
   your_other_messages_here.msg
   ${generated_message_list}
  DEPENDENCIES 
   ${MSG_DEPS}
   marti_common_msgs
)

To use the generated topics simply include your_project/srv/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.7.3 (2024-09-18)

3.7.2 (2024-09-16)

3.7.1 (2024-09-06)

3.7.0 (2024-09-06)

  • Simplify Cmake by linking to the library target (#742) By linking to the library target, we can reuse the include paths and libraries from it. This will simplify the Cmake a bit. It also fixes a bug when linking to the [ros2-jazzy]{.title-ref} branch of [diagnostic_updater]{.title-ref}.
  • Sanity checking time before performing duration calculation (#735)
  • Add definitions for subscribers with unique_ptr callback arguments (#731)
  • Cleaning up package maintainer (#721)
  • Contributors: David Anthony, Ramon Wijnands, Veronica Knisley

3.6.1 (2023-09-11)

  • Fixing Buildfarm Issues (#716)
    • Cleaning up code to fix build farm errors
  • Contributors: David Anthony

3.6.0 (2023-08-22)

  • Rolling updates (#715)
    • Updating code for Rolling.
    • Removing conditional compilation code related to EOL distributions.
  • Contributors: David Anthony

3.5.4 (2023-08-14)

  • Add publisher and subscription options to constructors (#714)
  • Use System QoS Settings as Defaults (#713)
  • Adding wrapper for unique_ptr arguments (#712)
  • Contributors: David Anthony, Veronica Knisley

3.5.3 (2023-06-07)

  • Fixing build warnings (#707)
  • Contributors: David Anthony

3.5.2 (2023-05-30)

  • Fix dependencies (#704)
    • Fixing build process so dependencies are correctly exported.
  • Contributors: David Anthony

3.5.1 (2022-11-29)

3.5.0 (2022-10-11)

3.4.2 (2022-10-10)

3.3.2 (2020-11-24)

  • Fix topic services under ros2 (#604)
  • Fix bugs related to subscription age and setting timeout (#609, #611) (#612)
  • Contributors: David Anthony, mschickler

3.3.1 (2020-08-19)

3.3.0 (2020-07-15)

  • Implement topic services in ROS 2 (#2893)
  • Contributors: Matthew Bries

3.2.1 (2020-06-10)

  • ROS Foxy support (#582)
  • Contributors: P. J. Reed

3.2.0 (2020-05-13)

3.1.0 (2020-03-30)

3.0.5 (2020-03-10)

3.0.4 (2020-03-05)

  • ROS 2 Eloquent compatibility (#568)
  • Contributors: P. J. Reed

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 3.7.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 ros2-devel
Last Updated 2024-10-23
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A package that extends rclcpp with some commonly used functionality to reduce boilerplate code.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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 ros2 service 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 generate_topic_service_files block to your project’s CMakeList.txt and use it almost the same way you would an rosidl_generate_interfaces block. This generates the individual topic service messages and returns a list of these to the variable named by the first argument. Make sure to add these to your rosidl_generate_interfaces call along with the marti_common_msgs dependency.

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

For example:

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

rosidl_generate_interfaces(${PROJECT_NAME}
   your_other_messages_here.msg
   ${generated_message_list}
  DEPENDENCIES 
   ${MSG_DEPS}
   marti_common_msgs
)

To use the generated topics simply include your_project/srv/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.7.3 (2024-09-18)

3.7.2 (2024-09-16)

3.7.1 (2024-09-06)

3.7.0 (2024-09-06)

  • Simplify Cmake by linking to the library target (#742) By linking to the library target, we can reuse the include paths and libraries from it. This will simplify the Cmake a bit. It also fixes a bug when linking to the [ros2-jazzy]{.title-ref} branch of [diagnostic_updater]{.title-ref}.
  • Sanity checking time before performing duration calculation (#735)
  • Add definitions for subscribers with unique_ptr callback arguments (#731)
  • Cleaning up package maintainer (#721)
  • Contributors: David Anthony, Ramon Wijnands, Veronica Knisley

3.6.1 (2023-09-11)

  • Fixing Buildfarm Issues (#716)
    • Cleaning up code to fix build farm errors
  • Contributors: David Anthony

3.6.0 (2023-08-22)

  • Rolling updates (#715)
    • Updating code for Rolling.
    • Removing conditional compilation code related to EOL distributions.
  • Contributors: David Anthony

3.5.4 (2023-08-14)

  • Add publisher and subscription options to constructors (#714)
  • Use System QoS Settings as Defaults (#713)
  • Adding wrapper for unique_ptr arguments (#712)
  • Contributors: David Anthony, Veronica Knisley

3.5.3 (2023-06-07)

  • Fixing build warnings (#707)
  • Contributors: David Anthony

3.5.2 (2023-05-30)

  • Fix dependencies (#704)
    • Fixing build process so dependencies are correctly exported.
  • Contributors: David Anthony

3.5.1 (2022-11-29)

3.5.0 (2022-10-11)

3.4.2 (2022-10-10)

3.3.2 (2020-11-24)

  • Fix topic services under ros2 (#604)
  • Fix bugs related to subscription age and setting timeout (#609, #611) (#612)
  • Contributors: David Anthony, mschickler

3.3.1 (2020-08-19)

3.3.0 (2020-07-15)

  • Implement topic services in ROS 2 (#2893)
  • Contributors: Matthew Bries

3.2.1 (2020-06-10)

  • ROS Foxy support (#582)
  • Contributors: P. J. Reed

3.2.0 (2020-05-13)

3.1.0 (2020-03-30)

3.0.5 (2020-03-10)

3.0.4 (2020-03-05)

  • ROS 2 Eloquent compatibility (#568)
  • Contributors: P. J. Reed

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.15.2
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 2024-06-03
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Enhancements to roscpp functionality to reduce boilerplate code and implement common patterns.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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.15.2 (2022-09-01)

2.14.2 (2020-09-09)

2.14.1 (2020-08-18)

2.14.0 (2020-07-15)

2.13.7 (2020-06-26)

2.13.6 (2020-06-17)

2.13.5 (2020-06-17)

  • Fix more Boost::thread issues (#587)
  • Contributors: P. J. Reed

2.13.4 (2020-06-16)

2.13.3 (2020-06-12)

  • Use setuptools instead of distutils
  • Contributors: P. J. Reed

2.13.2 (2020-06-10)

  • Support ROS Noetic (#581)
  • Contributors: P. J. Reed

2.13.1 (2020-05-21)

  • Fix the directory argument and correctly call add_message_files to avoid weird extra installed files (#580)
  • Contributors: Matthew Bries

2.13.0 (2020-05-13)

2.12.0 (2020-03-25)

  • Add Enum Support to DynamicParameters (#564)
  • Use safe_execute_process to generate messages instead and prevent it from running every build (#563)
  • Contributors: Matthew Bries

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 3.7.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 ros2-devel
Last Updated 2024-10-23
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A package that extends rclcpp with some commonly used functionality to reduce boilerplate code.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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 ros2 service 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 generate_topic_service_files block to your project’s CMakeList.txt and use it almost the same way you would an rosidl_generate_interfaces block. This generates the individual topic service messages and returns a list of these to the variable named by the first argument. Make sure to add these to your rosidl_generate_interfaces call along with the marti_common_msgs dependency.

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

For example:

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

rosidl_generate_interfaces(${PROJECT_NAME}
   your_other_messages_here.msg
   ${generated_message_list}
  DEPENDENCIES 
   ${MSG_DEPS}
   marti_common_msgs
)

To use the generated topics simply include your_project/srv/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.7.3 (2024-09-18)

3.7.2 (2024-09-16)

3.7.1 (2024-09-06)

3.7.0 (2024-09-06)

  • Simplify Cmake by linking to the library target (#742) By linking to the library target, we can reuse the include paths and libraries from it. This will simplify the Cmake a bit. It also fixes a bug when linking to the [ros2-jazzy]{.title-ref} branch of [diagnostic_updater]{.title-ref}.
  • Sanity checking time before performing duration calculation (#735)
  • Add definitions for subscribers with unique_ptr callback arguments (#731)
  • Cleaning up package maintainer (#721)
  • Contributors: David Anthony, Ramon Wijnands, Veronica Knisley

3.6.1 (2023-09-11)

  • Fixing Buildfarm Issues (#716)
    • Cleaning up code to fix build farm errors
  • Contributors: David Anthony

3.6.0 (2023-08-22)

  • Rolling updates (#715)
    • Updating code for Rolling.
    • Removing conditional compilation code related to EOL distributions.
  • Contributors: David Anthony

3.5.4 (2023-08-14)

  • Add publisher and subscription options to constructors (#714)
  • Use System QoS Settings as Defaults (#713)
  • Adding wrapper for unique_ptr arguments (#712)
  • Contributors: David Anthony, Veronica Knisley

3.5.3 (2023-06-07)

  • Fixing build warnings (#707)
  • Contributors: David Anthony

3.5.2 (2023-05-30)

  • Fix dependencies (#704)
    • Fixing build process so dependencies are correctly exported.
  • Contributors: David Anthony

3.5.1 (2022-11-29)

3.5.0 (2022-10-11)

3.4.2 (2022-10-10)

3.3.2 (2020-11-24)

  • Fix topic services under ros2 (#604)
  • Fix bugs related to subscription age and setting timeout (#609, #611) (#612)
  • Contributors: David Anthony, mschickler

3.3.1 (2020-08-19)

3.3.0 (2020-07-15)

  • Implement topic services in ROS 2 (#2893)
  • Contributors: Matthew Bries

3.2.1 (2020-06-10)

  • ROS Foxy support (#582)
  • Contributors: P. J. Reed

3.2.0 (2020-05-13)

3.1.0 (2020-03-30)

3.0.5 (2020-03-10)

3.0.4 (2020-03-05)

  • ROS 2 Eloquent compatibility (#568)
  • Contributors: P. J. Reed

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.15.2
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 2024-06-03
Dev Status DEVELOPED
CI status Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Enhancements to roscpp functionality to reduce boilerplate code and implement common patterns.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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.15.2 (2022-09-01)

2.14.2 (2020-09-09)

2.14.1 (2020-08-18)

2.14.0 (2020-07-15)

2.13.7 (2020-06-26)

2.13.6 (2020-06-17)

2.13.5 (2020-06-17)

  • Fix more Boost::thread issues (#587)
  • Contributors: P. J. Reed

2.13.4 (2020-06-16)

2.13.3 (2020-06-12)

  • Use setuptools instead of distutils
  • Contributors: P. J. Reed

2.13.2 (2020-06-10)

  • Support ROS Noetic (#581)
  • Contributors: P. J. Reed

2.13.1 (2020-05-21)

  • Fix the directory argument and correctly call add_message_files to avoid weird extra installed files (#580)
  • Contributors: Matthew Bries

2.13.0 (2020-05-13)

2.12.0 (2020-03-25)

  • Add Enum Support to DynamicParameters (#564)
  • Use safe_execute_process to generate messages instead and prevent it from running every build (#563)
  • Contributors: Matthew Bries

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.15.2
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 2024-06-03
Dev Status DEVELOPED
CI status Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Enhancements to roscpp functionality to reduce boilerplate code and implement common patterns.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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.15.2 (2022-09-01)

2.14.2 (2020-09-09)

2.14.1 (2020-08-18)

2.14.0 (2020-07-15)

2.13.7 (2020-06-26)

2.13.6 (2020-06-17)

2.13.5 (2020-06-17)

  • Fix more Boost::thread issues (#587)
  • Contributors: P. J. Reed

2.13.4 (2020-06-16)

2.13.3 (2020-06-12)

  • Use setuptools instead of distutils
  • Contributors: P. J. Reed

2.13.2 (2020-06-10)

  • Support ROS Noetic (#581)
  • Contributors: P. J. Reed

2.13.1 (2020-05-21)

  • Fix the directory argument and correctly call add_message_files to avoid weird extra installed files (#580)
  • Contributors: Matthew Bries

2.13.0 (2020-05-13)

2.12.0 (2020-03-25)

  • Add Enum Support to DynamicParameters (#564)
  • Use safe_execute_process to generate messages instead and prevent it from running every build (#563)
  • Contributors: Matthew Bries

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.15.2
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 2024-06-03
Dev Status DEVELOPED
CI status Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Enhancements to roscpp functionality to reduce boilerplate code and implement common patterns.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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.15.2 (2022-09-01)

2.14.2 (2020-09-09)

2.14.1 (2020-08-18)

2.14.0 (2020-07-15)

2.13.7 (2020-06-26)

2.13.6 (2020-06-17)

2.13.5 (2020-06-17)

  • Fix more Boost::thread issues (#587)
  • Contributors: P. J. Reed

2.13.4 (2020-06-16)

2.13.3 (2020-06-12)

  • Use setuptools instead of distutils
  • Contributors: P. J. Reed

2.13.2 (2020-06-10)

  • Support ROS Noetic (#581)
  • Contributors: P. J. Reed

2.13.1 (2020-05-21)

  • Fix the directory argument and correctly call add_message_files to avoid weird extra installed files (#580)
  • Contributors: Matthew Bries

2.13.0 (2020-05-13)

2.12.0 (2020-03-25)

  • Add Enum Support to DynamicParameters (#564)
  • Use safe_execute_process to generate messages instead and prevent it from running every build (#563)
  • Contributors: Matthew Bries

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.15.2
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 2024-06-03
Dev Status DEVELOPED
CI status Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Enhancements to roscpp functionality to reduce boilerplate code and implement common patterns.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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.15.2 (2022-09-01)

2.14.2 (2020-09-09)

2.14.1 (2020-08-18)

2.14.0 (2020-07-15)

2.13.7 (2020-06-26)

2.13.6 (2020-06-17)

2.13.5 (2020-06-17)

  • Fix more Boost::thread issues (#587)
  • Contributors: P. J. Reed

2.13.4 (2020-06-16)

2.13.3 (2020-06-12)

  • Use setuptools instead of distutils
  • Contributors: P. J. Reed

2.13.2 (2020-06-10)

  • Support ROS Noetic (#581)
  • Contributors: P. J. Reed

2.13.1 (2020-05-21)

  • Fix the directory argument and correctly call add_message_files to avoid weird extra installed files (#580)
  • Contributors: Matthew Bries

2.13.0 (2020-05-13)

2.12.0 (2020-03-25)

  • Add Enum Support to DynamicParameters (#564)
  • Use safe_execute_process to generate messages instead and prevent it from running every build (#563)
  • Contributors: Matthew Bries

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.15.2
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 2024-06-03
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Enhancements to roscpp functionality to reduce boilerplate code and implement common patterns.

Additional Links

No additional links.

Maintainers

  • Southwest Research Institute

Authors

  • P. J. Reed

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.15.2 (2022-09-01)

2.14.2 (2020-09-09)

2.14.1 (2020-08-18)

2.14.0 (2020-07-15)

2.13.7 (2020-06-26)

2.13.6 (2020-06-17)

2.13.5 (2020-06-17)

  • Fix more Boost::thread issues (#587)
  • Contributors: P. J. Reed

2.13.4 (2020-06-16)

2.13.3 (2020-06-12)

  • Use setuptools instead of distutils
  • Contributors: P. J. Reed

2.13.2 (2020-06-10)

  • Support ROS Noetic (#581)
  • Contributors: P. J. Reed

2.13.1 (2020-05-21)

  • Fix the directory argument and correctly call add_message_files to avoid weird extra installed files (#580)
  • Contributors: Matthew Bries

2.13.0 (2020-05-13)

2.12.0 (2020-03-25)

  • Add Enum Support to DynamicParameters (#564)
  • Use safe_execute_process to generate messages instead and prevent it from running every build (#563)
  • Contributors: Matthew Bries

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

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged swri_roscpp at Robotics Stack Exchange