Skip to content

Commit d4dfd61

Browse files
authored
Merge pull request #514 from gazebosim/scpeters/merge_9_main
Merge gz-sensors9 ➡️ main
2 parents 67f362d + 9d31a83 commit d4dfd61

File tree

9 files changed

+98
-21
lines changed

9 files changed

+98
-21
lines changed

Changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
## Gazebo Sensors 9
66

7+
### Gazebo Sensors 9.1.0 (2025-02-12)
8+
9+
1. Enable packing w/o padding for pointclouds
10+
* [Pull request #493](https://github.com/gazebosim/gz-sensors/pull/493)
11+
12+
1. Add support for L8 and L16 image formats in WideAngleCameraSensor
13+
* [Pull request #494](https://github.com/gazebosim/gz-sensors/pull/494)
14+
15+
1. Check camera resolution
16+
* [Pull request #480](https://github.com/gazebosim/gz-sensors/pull/480)
17+
718
### Gazebo Sensors 9.0.0 (2024-09-25)
819

920
1. **Baseline:** this includes all changes from 8.2.0 and earlier.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ configured at run time to mimic specific real-world sensors. A noise model
4343
is also provided that can be used to introduce Gaussian or custom noise
4444
models into sensor streams.
4545

46+
## Supported Sensors
47+
48+
| **Sensor Name** | **API Link** | **SDF Element** | **Notes** |
49+
|---------------------------|-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|----------------------------------------------------|
50+
| **Air Pressure Sensor** | [AirPressureSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1AirPressureSensor.html) | [`<air_pressure>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_air_pressure) | Measures atmospheric pressure |
51+
| **Air Speed Sensor** | [AirSpeedSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1AirSpeedSensor.html) | N/A | Measures the speed of air relative to the sensor |
52+
| **Altimeter** | [AltimeterSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1AltimeterSensor.html) | [`<altimeter>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_altimeter) | Measures altitude above a reference point |
53+
| **Bounding Box Camera** | [BoundingBoxCameraSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1BoundingBoxCameraSensor.html) | [`<camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_camera) | Captures images with bounding box annotations |
54+
| **Camera** | [CameraSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1CameraSensor.html) | [`<camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_camera) | Captures standard RGB images |
55+
| **Depth Camera** | [DepthCameraSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1DepthCameraSensor.html) | [`<depth_camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#camera_depth_camera) | Captures depth information |
56+
| **Doppler Velocity Log** | [DopplerVelocityLog](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1DopplerVelocityLog.html) | N/A | Measures relative velocity of an underwater vehicle |
57+
| **Force-Torque** | [ForceTorqueSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1ForceTorqueSensor.html) | [`<force_torque>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_force_torque) | Measures forces and torques on a joint |
58+
| **GPU Lidar** | [GpuLidarSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1GpuLidarSensor.html) | [`<lidar>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_lidar) | Simulates a 3D laser scanner using GPU acceleration|
59+
| **IMU** | [ImuSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1ImuSensor.html) | [`<imu>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_imu) | Measures linear acceleration and angular velocity |
60+
| **Logical Camera** | [LogicalCameraSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1LogicalCameraSensor.html) | [`<logical_camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_logical_camera) | Detects models within a specified volume |
61+
| **Magnetometer** | [MagnetometerSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1MagnetometerSensor.html) | [`<magnetometer>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_magnetometer) | Measures magnetic field strength and direction |
62+
| **NavSat (GPS)** | [NavSatSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1NavSatSensor.html) | [`<navsat>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_navsat) | Simulates GPS-like positioning sensor |
63+
| **RGBD Camera** | [RGBDCameraSensor](https://gazebosim.org/api/sensors/7/classgz_1_1sensors_1_1RgbdCameraSensor.html) | [`<camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_camera) | Captures RGB + Depth streams |
64+
| **Segmentation Camera** | [SegmentationCameraSensor](https://gazebosim.org/api/sensors/9/classgz_1_1sensors_1_1SegmentationCameraSensor.html) | [`<camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_camera) | Captures labeled segmentation images |
65+
| **Thermal Camera** | [ThermalCameraSensor](https://gazebosim.org/api/sensors/7/classgz_1_1sensors_1_1ThermalCameraSensor.html) | [`<camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_camera) | Detects heat signature |
66+
| **Wide Angle Camera** | [WideAngleCameraSensor](https://gazebosim.org/api/sensors/8/classgz_1_1sensors_1_1WideAngleCameraSensor.html)| [`<camera>`](http://sdformat.org/spec?ver=1.12&elem=sensor#sensor_camera) | Captures wide field of view |
67+
4668
# Install
4769

4870
See the [installation tutorial](https://gazebosim.org/api/sensors/9/installation.html).
@@ -51,6 +73,8 @@ See the [installation tutorial](https://gazebosim.org/api/sensors/9/installation
5173

5274
Please refer to the [examples directory](https://github.com/gazebosim/gz-sensors/tree/main/examples).
5375

76+
A list of sensors and SDF examples can be found in the [SDF specification](http://sdformat.org/spec?ver=1.12&elem=sensor)
77+
5478
# Folder Structure
5579

5680
Refer to the following table for information about important directories and files in this repository.

include/gz/sensors/LogicalCameraSensor.hh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ namespace gz
104104
/// \return True if there are subscribers, false otherwise
105105
public: virtual bool HasConnections() const override;
106106

107+
/// \brief Check if there are any image subscribers
108+
/// \return True if there are image subscribers, false otherwise
109+
public: virtual bool HasImageConnections() const;
110+
111+
/// \brief Check if there are any frustum subscribers
112+
/// \return True if there are info subscribers, false otherwise
113+
public: virtual bool HasFrustumConnections() const;
114+
107115
/// \brief Get the latest image. An image is an instance of
108116
/// msgs::LogicalCameraImage, which contains a list of detected models.
109117
/// \return List of detected models.

src/DepthCameraSensor.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,10 @@ bool DepthCameraSensor::CreateCamera()
439439
std::placeholders::_4, std::placeholders::_5));
440440

441441
// Initialize the point message.
442-
// \todo(anyone) The true value in the following function call forces
443-
// the xyz and rgb fields to be aligned to memory boundaries. This is need
444-
// by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
445-
// alignment should be configured.
446442
msgs::InitPointCloudPacked(
447443
this->dataPtr->pointMsg,
448444
this->OpticalFrameId(),
449-
true,
445+
false,
450446
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
451447
{"rgb", msgs::PointCloudPacked::Field::FLOAT32}});
452448

src/GpuLidarSensor.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,7 @@ bool GpuLidarSensor::Load(const sdf::Sensor &_sdf)
129129
}
130130

131131
// Initialize the point message.
132-
// \todo(anyone) The true value in the following function call forces
133-
// the xyz and rgb fields to be aligned to memory boundaries. This is need
134-
// by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
135-
// alignment should be configured. This same problem is in the
136-
// RgbdCameraSensor.
137-
msgs::InitPointCloudPacked(this->dataPtr->pointMsg, this->FrameId(), true,
132+
msgs::InitPointCloudPacked(this->dataPtr->pointMsg, this->FrameId(), false,
138133
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
139134
{"intensity", msgs::PointCloudPacked::Field::FLOAT32},
140135
{"ring", msgs::PointCloudPacked::Field::UINT16}});

src/LogicalCameraSensor.cc

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ class gz::sensors::LogicalCameraSensorPrivate
3636
/// \brief node to create publisher
3737
public: transport::Node node;
3838

39+
/// \brief node to create publisher for frustum
40+
public: transport::Node nodeLogic;
41+
3942
/// \brief publisher to publish logical camera messages.
4043
public: transport::Node::Publisher pub;
4144

45+
/// \brief Publisher to publish logical camera frustum information
46+
public: transport::Node::Publisher pubLogic;
47+
4248
/// \brief true if Load() has been called and was successful
4349
public: bool initialized = false;
4450

@@ -55,7 +61,10 @@ class gz::sensors::LogicalCameraSensorPrivate
5561
public: std::map<std::string, math::Pose3d> models;
5662

5763
/// \brief Msg containg info on models detected by logical camera
58-
msgs::LogicalCameraImage msg;
64+
public: msgs::LogicalCameraImage msg;
65+
66+
/// \brief Msg containing logical camera frustum info
67+
public: msgs::LogicalCameraSensor msgLogic;
5968
};
6069

6170
//////////////////////////////////////////////////
@@ -110,12 +119,23 @@ bool LogicalCameraSensor::Load(sdf::ElementPtr _sdf)
110119
this->dataPtr->node.Advertise<msgs::LogicalCameraImage>(
111120
this->Topic());
112121

122+
this->dataPtr->pubLogic =
123+
this->dataPtr->nodeLogic.Advertise<msgs::LogicalCameraSensor>(
124+
this->Topic() + "/frustum");
125+
113126
if (!this->dataPtr->pub)
114127
{
115128
gzerr << "Unable to create publisher on topic[" << this->Topic() << "].\n";
116129
return false;
117130
}
118131

132+
if (!this->dataPtr->pubLogic)
133+
{
134+
gzerr << "Unable to create publisher on topic[" << this->Topic()
135+
<< "/frustum].\n";
136+
return false;
137+
}
138+
119139
gzdbg << "Logical images for [" << this->Name() << "] advertised on ["
120140
<< this->Topic() << "]" << std::endl;
121141

@@ -166,9 +186,25 @@ bool LogicalCameraSensor::Update(
166186
frame->set_key("frame_id");
167187
frame->add_value(this->FrameId());
168188

189+
*this->dataPtr->msgLogic.mutable_header()->mutable_stamp() =
190+
msgs::Convert(_now);
191+
this->dataPtr->msgLogic.mutable_header()->clear_data();
192+
auto frame_log = this->dataPtr->msgLogic.mutable_header()->add_data();
193+
194+
frame_log->set_key("frame_id");
195+
frame_log->add_value(this->FrameId());
196+
169197
// publish
198+
this->dataPtr->msgLogic.set_near_clip(this->dataPtr->frustum.Near());
199+
this->dataPtr->msgLogic.set_far_clip(this->dataPtr->frustum.Far());
200+
this->dataPtr->msgLogic.set_horizontal_fov(
201+
this->dataPtr->frustum.FOV().Radian());
202+
this->dataPtr->msgLogic.set_aspect_ratio(
203+
this->dataPtr->frustum.AspectRatio());
170204
this->AddSequence(this->dataPtr->msg.mutable_header());
205+
171206
this->dataPtr->pub.Publish(this->dataPtr->msg);
207+
this->dataPtr->pubLogic.Publish(this->dataPtr->msgLogic);
172208

173209
return true;
174210
}
@@ -206,7 +242,18 @@ msgs::LogicalCameraImage LogicalCameraSensor::Image() const
206242

207243
//////////////////////////////////////////////////
208244
bool LogicalCameraSensor::HasConnections() const
245+
{
246+
return this->HasImageConnections() || this->HasFrustumConnections();
247+
}
248+
249+
//////////////////////////////////////////////////
250+
bool LogicalCameraSensor::HasImageConnections() const
209251
{
210252
return this->dataPtr->pub && this->dataPtr->pub.HasConnections();
211253
}
212254

255+
//////////////////////////////////////////////////
256+
bool LogicalCameraSensor::HasFrustumConnections() const
257+
{
258+
return this->dataPtr->pubLogic && this->dataPtr->pubLogic.HasConnections();
259+
}

src/RgbdCameraSensor.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,8 @@ bool RgbdCameraSensor::CreateCameras()
395395
std::placeholders::_4, std::placeholders::_5));
396396

397397
// Initialize the point message.
398-
// \todo(anyone) The true value in the following function call forces
399-
// the xyz and rgb fields to be aligned to memory boundaries. This is need
400-
// by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
401-
// alignment should be configured.
402398
msgs::InitPointCloudPacked(this->dataPtr->pointMsg, this->OpticalFrameId(),
403-
true,
399+
false,
404400
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
405401
{"rgb", msgs::PointCloudPacked::Field::FLOAT32}});
406402

test/integration/gpu_lidar_sensor.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ void GpuLidarSensorTest::DetectBox(const std::string &_renderEngine)
431431
EXPECT_EQ(static_cast<uint32_t>(vertSamples), pointMsgs.back().height());
432432
EXPECT_EQ(static_cast<uint32_t>(horzSamples), pointMsgs.back().width());
433433
EXPECT_FALSE(pointMsgs.back().is_bigendian());
434-
EXPECT_EQ(32u, pointMsgs.back().point_step());
435-
EXPECT_EQ(32u * horzSamples, pointMsgs.back().row_step());
434+
EXPECT_EQ(18u, pointMsgs.back().point_step());
435+
EXPECT_EQ(18u * horzSamples, pointMsgs.back().row_step());
436436
EXPECT_FALSE(pointMsgs.back().is_dense());
437-
EXPECT_EQ(32u * horzSamples * vertSamples, pointMsgs.back().data().size());
437+
EXPECT_EQ(18u * horzSamples * vertSamples, pointMsgs.back().data().size());
438438

439439
EXPECT_TRUE(pointMsgs.back().has_header());
440440
EXPECT_LT(1, pointMsgs.back().header().data().size());

test/integration/rgbd_camera.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void RgbdCameraSensorTest::ImagesWithBuiltinSDF(
475475
{
476476
// init the point cloud msg to be filled
477477
msgs::PointCloudPacked pointsMsg;
478-
msgs::InitPointCloudPacked(pointsMsg, "depth2Image", true,
478+
msgs::InitPointCloudPacked(pointsMsg, "depth2Image", false,
479479
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
480480
{"rgb", msgs::PointCloudPacked::Field::FLOAT32}});
481481
pointsMsg.set_width(rgbdSensor->ImageWidth());

0 commit comments

Comments
 (0)