From 071271f52bf7903a5cccbcdc4285b49efed6352e Mon Sep 17 00:00:00 2001 From: jEllerGRC Date: Tue, 14 May 2024 03:08:49 -0700 Subject: [PATCH 1/3] Very, VERY rough attempt at creating a solution to Issue #1673; code is completely untested and no tests have been written for it. --- .../MirroredCamera.cpp | 44 ++++++++++++++++++ .../custom_rendering_sensor/MirroredCamera.hh | 46 +++++++++++++++++++ .../plugin/custom_rendering_sensor/README.md | 20 ++++++++ 3 files changed, 110 insertions(+) create mode 100644 examples/plugin/custom_rendering_sensor/MirroredCamera.cpp create mode 100644 examples/plugin/custom_rendering_sensor/MirroredCamera.hh create mode 100644 examples/plugin/custom_rendering_sensor/README.md diff --git a/examples/plugin/custom_rendering_sensor/MirroredCamera.cpp b/examples/plugin/custom_rendering_sensor/MirroredCamera.cpp new file mode 100644 index 0000000000..f8a700c107 --- /dev/null +++ b/examples/plugin/custom_rendering_sensor/MirroredCamera.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//needed in order to register plugins +#include + +//header file +#include "MirroredCamera.hh" + +//headers for other code used +#include +#include +#include +#include + +using namespace custom; + +////////////////////////////////////////////////// +void MirroredCamera::PostUpdate(const gz::sim::UpdateInfo &_info, + const gz::sim::EntityComponentManager &_ecm) +{ + //create a camera + gz:sensors:CameraSensor camera; + camera->CreateCamera(); + + //flip image horizontally by accessing the bitmap pointer? + FreeImage_FlipHorizontal(camera->image->*bitmap); +} + +GZ_ADD_PLUGIN(custom_rendering_sensor::MirroredCamera, gz::sim::System, + custom_rendering_sensor::MirroredCamera::ISystemPostUpdate) \ No newline at end of file diff --git a/examples/plugin/custom_rendering_sensor/MirroredCamera.hh b/examples/plugin/custom_rendering_sensor/MirroredCamera.hh new file mode 100644 index 0000000000..6e303ae381 --- /dev/null +++ b/examples/plugin/custom_rendering_sensor/MirroredCamera.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GAZEBO_MIRROREDCAMERA_HH +#define GAZEBO_MIRROREDCAMERA_HH + +#include + +#include +#include +#include +#include + +namespace custom +{ + /// \brief Attempt at creating a custom rendering sensor (in this case, + /// a camera sensor with its image flipped horizontally) as an example + /// for future developers) + class MirroredCamera: + public gz::sim::System, + public gz::sim::ISystemPostUpdate + + /// \brief Creates a camera sensor, then calls the FlipHorizontal method + /// from the FreeImage library on the the pointer to the bitmap data + /// from the camera sensor's image field + { + void PostUpdate(const gz::sim::UpdateInfo &_info, + const gz::sim::EntityComponentManager &_ecm) + }; +} + +#endif //GAZEBO_MIRROREDCAMERA_HH diff --git a/examples/plugin/custom_rendering_sensor/README.md b/examples/plugin/custom_rendering_sensor/README.md new file mode 100644 index 0000000000..1b4f8d9857 --- /dev/null +++ b/examples/plugin/custom_rendering_sensor/README.md @@ -0,0 +1,20 @@ +# Custom Rendering Sensor + +This is a very basic, incomplete class that's meant to demonstrate custom rendering sensors in Gazebo. + +It attempts to implement the suggestions offered on Issue #1673: +[https://github.com/gazebosim/gz-sim/issues/1673] + +All the code is untested due to my inability to provide a proper testing environment at this time. +No CMakeLists.txt file is included with this directory due to my lack of knowledge of CMake. +Apologies in advance for the likely non-functional code. +I am not very experienced with the tools used in this development stack. + +## Build + +Not currently functional. + +## Run + +Not currently functional. + From 81aa6689b7045298719601e75cf11b99e9df7b1d Mon Sep 17 00:00:00 2001 From: jEllerGRC Date: Tue, 14 May 2024 03:11:40 -0700 Subject: [PATCH 2/3] Very, VERY rough attempt at creating a solution to Issue #1673; code is completely untested and no tests have been written for it. --- examples/plugin/custom_rendering_sensor/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/plugin/custom_rendering_sensor/README.md b/examples/plugin/custom_rendering_sensor/README.md index 1b4f8d9857..6173738ca4 100644 --- a/examples/plugin/custom_rendering_sensor/README.md +++ b/examples/plugin/custom_rendering_sensor/README.md @@ -8,7 +8,7 @@ It attempts to implement the suggestions offered on Issue #1673: All the code is untested due to my inability to provide a proper testing environment at this time. No CMakeLists.txt file is included with this directory due to my lack of knowledge of CMake. Apologies in advance for the likely non-functional code. -I am not very experienced with the tools used in this development stack. +I am not very experienced with the tools used in this development stack. ## Build From 4f5719c9f1aee9f1b568ac78f0ab2377899c4f1e Mon Sep 17 00:00:00 2001 From: jEllerGRC Date: Tue, 14 May 2024 11:01:12 -0700 Subject: [PATCH 3/3] Slight spacing update. Signed-off-by: Jared Eller --- examples/plugin/custom_rendering_sensor/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/plugin/custom_rendering_sensor/README.md b/examples/plugin/custom_rendering_sensor/README.md index 6173738ca4..1b4f8d9857 100644 --- a/examples/plugin/custom_rendering_sensor/README.md +++ b/examples/plugin/custom_rendering_sensor/README.md @@ -8,7 +8,7 @@ It attempts to implement the suggestions offered on Issue #1673: All the code is untested due to my inability to provide a proper testing environment at this time. No CMakeLists.txt file is included with this directory due to my lack of knowledge of CMake. Apologies in advance for the likely non-functional code. -I am not very experienced with the tools used in this development stack. +I am not very experienced with the tools used in this development stack. ## Build