forked from gazebosim/gz-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Very, VERY rough attempt at creating a solution to Issue gazebosim#1673…
…; code is completely untested and no tests have been written for it.
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
examples/plugin/custom_rendering_sensor/MirroredCamera.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <gz/plugin/Register.hh> | ||
|
||
//header file | ||
#include "MirroredCamera.hh" | ||
|
||
//headers for other code used | ||
#include </gz/sensors/CameraSensor.hh> | ||
#include </gz/common/Image.hh> | ||
#include <FreeImage.h> | ||
#include </gz/sensors/RenderingSensor.hh> | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <gz/sim/System.hh> | ||
|
||
#include </gz/sensors/CameraSensor.hh> | ||
#include </gz/common/Image.hh> | ||
#include <FreeImage.h> | ||
#include </gz/sensors/RenderingSensor.hh> | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|