-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ros2] Port gazebo_ros_imu_sensor #793
Conversation
397882f
to
02d4213
Compare
96d3147
to
d58b7df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a partial review so far
virtual ~GazeboRosImuSensor(); | ||
|
||
// Documentation Inherited | ||
virtual void Load(gazebo::sensors::SensorPtr _sensor, sdf::ElementPtr _sdf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add override
{ | ||
public: | ||
/// Node for ros communication | ||
gazebo_ros::Node::SharedPtr rosnode_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ros_node_
to match e.g.
gazebo_ros::Node::SharedPtr ros_node_; |
return; | ||
} | ||
|
||
impl_->pub_ = impl_->rosnode_->create_publisher<sensor_msgs::msg::Imu>("~/out"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will say it explicitly in case anyone disagrees with me: though we have a sensor_data
QoS profile I'd say that's more appropriate for subscribers. It's better for this to publish as reliable so that reliable subscribers will still be able to connect.
impl_->pub_ = impl_->rosnode_->create_publisher<sensor_msgs::msg::Imu>("~/out"); | ||
|
||
// Create message to be reused | ||
auto msg = std::make_shared<sensor_msgs::msg::Imu>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikaelarguedas can you confirm that this will initialise the other elements of the covariance matrix fields to 0?
From ros2/geometry2#64 I think the answer is yes, but http://design.ros2.org/articles/generated_interfaces_cpp.html says the default constructor causes default/value initialised, and doesn't say the default is zero initialised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR: yes all the fields of the array will be set to zero
Longer answer:
From the doc: The default constructor initializes all members with their default value; if a field doesn’t have a default value, then the member is value-initialized.
As Imu doesn't provide custom default values for its' fields (https://github.com/ros2/common_interfaces/blob/60afcc4b3256d5a0f606939a5d02e173ff15bdd9/sensor_msgs/msg/Imu.msg#L18) they will initialized with ROS' default.
These default are language independent so they are defined in the Interface Definition doc.
A field can optionally specify a default value. If no default value is specified a common default value is used:
for bool it is false
for numeric types it is a 0 value
for string it is an empty string
for static size arrays it is an array of N elements with its fields zero-initialized
for bounded size arrays and dynamic size arrays it is an empty array []
The part we're interested in here is for static size arrays it is an array of N elements with its fields zero-initialized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmmm I didn't realise from the design article that it would use a ROS default and not just a default specified in the .msg. I will try to update that design doc based on your answer, thanks!!
896d976
to
fafc2e8
Compare
<sensor name="my_imu" type="imu"> | ||
<always_on>true</always_on> | ||
<update_rate>30</update_rate> | ||
<imu> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this empty tag is needed could you add a comment why?
392aea0
to
1d618ae
Compare
@ros-pull-request-builder retest this please |
After speaking with ironmig offline I reworked the test to not need the step_for_msgs function anymore, following the ros laser test instead: it now steps forward once: https://github.com/ros-simulation/gazebo_ros_pkgs/pull/793/files#diff-d966e67ca1b4db645730d08da8e16054R57 I also made it apply the force for multiple steps, and now the test checks the magnitude of the values. I noticed that the linear acceleration flips between positive and negative, though this happens with the readings of the IMU directly from gazebo, it's not a conversion problem. Not sure if that happens with the gazebo_ros_imu plugin too, but it's not something that's been introduced in the porting of this plugin. Example of the values during the test:
|
// TODO(anyone): covariance for IMU's orientation once this is added to gazebo | ||
using SNT = gazebo::sensors::SensorNoiseType; | ||
msg->angular_velocity_covariance[0] = | ||
gazebo_ros::NoiseVariance(impl_->sensor_->Noise(SNT::IMU_ANGVEL_X_NOISE_RADIANS_PER_S)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing [Err] [Sensor.cc:454] Get noise index not valid
from these lines. looking into why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's caused by https://bitbucket.org/osrf/gazebo/issues/2513/ in general, but even if the noise is specified in the SDF, the error still shows in tests because the noise isn't applied via the ServerFixture: #799
Followup work will be to prevent the noise error mentioned in https://github.com/ros-simulation/gazebo_ros_pkgs/pull/793/files#r211036103: it's caused by https://bitbucket.org/osrf/gazebo/issues/2513/ in general, but even if the noise is specified in the SDF, the error still shows in tests because the noise isn't applied via the ServerFixture: #799. We don't have to let that block this PR because the plugin is working as expected (noise applied when specified), it just prints an unnecessary error if launched with verbose e.g.
|
@chapulina realised that the test was behaving as expected from a clean build. #799 turned out to be a non-issue, just user error. #801 added noise to the sensor used in the test so the error doesn't show in the test output, but sensors using this plugin will still have error output if the noise isn't specified: https://bitbucket.org/osrf/gazebo/issues/2513/ |
Port the gazebo_ros_imu_sensor to ROS2, following the new conventions.
A wiki page has been created to guide users in migrating.