Skip to content

Support wide angle camera #744

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

Merged
merged 9 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/sdf/Sensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ namespace sdf
BOUNDINGBOX_CAMERA = 23,

/// \brief A custom sensor
CUSTOM = 24
CUSTOM = 24,

/// \brief A wide angle camera sensor
WIDE_ANGLE_CAMERA = 25
};

/// \brief Information about an SDF sensor.
Expand Down
11 changes: 10 additions & 1 deletion src/Sensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const std::vector<std::string> sensorTypeStrs =
"navsat",
"segmentation_camera",
"boundingbox_camera",
"custom"
"custom",
"wideanglecamera"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document this string here: https://github.com/ignitionrobotics/sdformat/blob/f2a286cbf89aca7daa722a70a357e0de32224372/sdf/1.9/sensor.sdf#L10-L36

Most other cameras are using camel_case (at least partially), can we do it here too? i.e. wideangle_camera or wide_angle_camera, or all of them to be safe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the existing convention with gazebo classic is wideanglecamera. I think we can choose to add alternates, but I would keep wideanglecamera for backwards compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed wideanglecamera to wide_angle_camera here. Also updated the Load function to check for both wide_angle_came and wideanglecamera when loading the sdf for backward compatibility.
8aacb98

};

class sdf::Sensor::Implementation
Expand Down Expand Up @@ -169,6 +170,7 @@ bool Sensor::operator==(const Sensor &_sensor) const
case SensorType::DEPTH_CAMERA:
case SensorType::RGBD_CAMERA:
case SensorType::THERMAL_CAMERA:
case SensorType::WIDE_ANGLE_CAMERA:
case SensorType::SEGMENTATION_CAMERA:
case SensorType::BOUNDINGBOX_CAMERA:
return *(this->dataPtr->camera) == *(_sensor.dataPtr->camera);
Expand Down Expand Up @@ -302,6 +304,13 @@ Errors Sensor::Load(ElementPtr _sdf)
Errors err = this->dataPtr->camera->Load(_sdf->GetElement("camera"));
errors.insert(errors.end(), err.begin(), err.end());
}
else if (type == "wideanglecamera")
{
this->dataPtr->type = SensorType::WIDE_ANGLE_CAMERA;
this->dataPtr->camera.emplace();
Errors err = this->dataPtr->camera->Load(_sdf->GetElement("camera"));
errors.insert(errors.end(), err.begin(), err.end());
}
else if (type == "force_torque")
{
this->dataPtr->type = SensorType::FORCE_TORQUE;
Expand Down
6 changes: 4 additions & 2 deletions src/Sensor_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ TEST(DOMSensor, Type)
sdf::SensorType::WIRELESS_RECEIVER,
sdf::SensorType::WIRELESS_TRANSMITTER,
sdf::SensorType::THERMAL_CAMERA,
sdf::SensorType::CUSTOM
sdf::SensorType::CUSTOM,
sdf::SensorType::WIDE_ANGLE_CAMERA
};
std::vector<std::string> typeStrs =
{
Expand All @@ -288,7 +289,8 @@ TEST(DOMSensor, Type)
"wireless_receiver",
"wireless_transmitter",
"thermal_camera",
"custom"
"custom",
"wideanglecamera"
};

for (size_t i = 0; i < types.size(); ++i)
Expand Down