gazebosim / gazebosim/sdformat

Support for `long int` in Param::Get?

Open
#423 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
216
Forks
125
Avg merge
1d 14h
Merged PRs (30d)
14

Description

Hello!

My team has a model for an absolute rotary encoder sensor whose parameterization for certain absolute integer positions is a `long int`. In ROS Kinetic (GCC 5, gazebo9, sdformat4), we were able to fetch `long int` sized parameters using the `Param::Get` API. I am in the process of migrating our platform to ROS Noetic (GCC 9, gazebo11, sdformat9), and I discovered that calls to `Param::Get` (or the equivalent typedef `Param::Get`) no longer compile on this new platform.

Technically we are using `sdformat` through `GazeboRos::getParameter`, but since the compilation failure seems to have to do with `sdformat` directly as far as I can tell so I am reporting this here. Here is my invocation, and the subsequent compilation failure.

Usage:
```c++
...
gazebo_ros_->getParameter(wheel_encoder_max_value_, "wheelEncoderMaxValue");
...
```

Result:
```
In file included from /usr/include/sdformat-9.2/sdf/Param.hh:30,
from /usr/include/sdformat-9.2/sdf/Element.hh:28,
from /usr/include/sdformat-9.2/sdf/Actor.hh:25,
from /usr/include/sdformat-9.2/sdf/sdf.hh:2,
from /usr/include/gazebo-11/gazebo/common/Battery.hh:25,
from /usr/include/gazebo-11/gazebo/common/common.hh:8,
from /app/ros_ws/src/weedrobot_gazebo/plugins/include/weedrobot_gazebo/WheelEncoder.h:13,
from /app/ros_ws/src/weedrobot_gazebo/plugins/src/WheelEncoder.cpp:15:
/usr/include/c++/9/variant: In instantiation of ‘constexpr std::add_pointer_t<_Tp> std::get_if(std::variant<_Types ...>*) [with _Tp = long int; _Types = {bool, char, std::__cxx11::basic_string, std::allocator >, int, long unsigned int, unsigned int, double, float, sdf::v9::Time, ignition::math::v6::Angle, ignition::math::v6::Color, ignition::math::v6::Vector2, ignition::math::v6::V
ector2, ignition::math::v6::Vector3, ignition::math::v6::Quaternion, ignition::math::v6::Pose3}; std::add_pointer_t<_Tp> = long int*]’:
/usr/include/sdformat-9.2/sdf/Param.hh:318:34: required from ‘bool sdf::v9::Param::Get(T&) const [with T = long int]’
/usr/include/sdformat-9.2/sdf/Element.hh:511:7: required from ‘std::pair sdf::v9::Element::Get(const string&, const T&) const [with T = long int; std::string = std::__cxx11::basic_string]’
/usr/include/sdformat-9.2/sdf/Element.hh:486:24: required from ‘T sdf::v9::Element::Get(const string&) const [with T = long int; std::string = std::__cxx11::basic_string]’
/opt/ros/noetic/include/gazebo_plugins/gazebo_ros_utils.h:251:20: required from ‘void gazebo::GazeboRos::getParameter(T&, const char*) [with T = long int]’
/app/ros_ws/src/weedrobot_gazebo/plugins/src/WheelEncoder.cpp:44:89: required from here
/usr/include/c++/9/variant:1125:42: error: static assertion failed: T should occur for exactly once in alternatives
1125 | static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Please let me know if you think this is an upstream `gazebo_ros_pkgs` problem rather than an `sdformat` problem.

Thank you!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported Param::Get or Param::Get compilation failure through gazebo_ros getParameter, then inspect sdf/Param.hh and the related Element.hh calls shown in the trace. Done means the requested integer type is handled by the parameter API without the reported std::variant static assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.