Skip to content
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

feat(camera_view_plugin): add camera view plugin package #5472

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
30 changes: 30 additions & 0 deletions common/tier4_camera_view_rviz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.14)
project(tier4_camera_view_rviz_plugin)

find_package(autoware_cmake REQUIRED)
autoware_package()

find_package(Qt5 REQUIRED Core Widgets)
set(QT_LIBRARIES Qt5::Widgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
add_compile_options(-Wno-unused-parameter)
endif()

ament_auto_add_library(${PROJECT_NAME} SHARED
src/third_person_view_controller.cpp
src/third_person_view_tool.cpp
src/bird_eye_view_tool.cpp
src/bird_eye_view_controller.cpp
)

target_link_libraries(${PROJECT_NAME}
${QT_LIBRARIES}
)

pluginlib_export_plugin_description_file(rviz_common plugins/plugin_description.xml)

ament_auto_package(INSTALL_TO_SHARE icons)
9 changes: 9 additions & 0 deletions common/tier4_camera_view_rviz_plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# tier4_camera_view_rviz_plugin

## ThirdPersonView Tool

Add the `tier4_camera_view_rviz_plugin/ThirdPersonViewTool` tool to the RViz. Push the button, the camera will focus on the vehicle and set the target frame to `base_link`. Short cut key 'o'.

## BirdEyeView Tool

Add the `tier4_camera_view_rviz_plugin/BirdEyeViewTool` tool to the RViz. Push the button, the camera will turn to the BEV view, the target frame is consistent with the latest frame. Short cut key 'r'.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions common/tier4_camera_view_rviz_plugin/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>tier4_camera_view_rviz_plugin</name>
<version>0.0.0</version>
<description>The autoware camera view rviz plugin package</description>
<maintainer email="[email protected]">Yuxuan Liu</maintainer>
<maintainer email="[email protected]">Makoto Yabuta</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_ad_api_specs</depend>
<depend>component_interface_utils</depend>
<depend>geometry_msgs</depend>
<depend>libqt5-core</depend>
<depend>libqt5-gui</depend>
<depend>libqt5-widgets</depend>
<depend>rclcpp</depend>
<depend>rviz_common</depend>
<depend>rviz_default_plugins</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
<rviz plugin="${prefix}/plugins/plugin_description.xml"/>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<library path="tier4_camera_view_rviz_plugin">

<class name="tier4_camera_view_rviz_plugin/BirdEyeView" type="tier4_camera_view_rviz_plugin::BirdEyeViewController" base_class_type="rviz_common::ViewController">
<description>
Control the camera for bird-eye view.
</description>
</class>
<class name="tier4_camera_view_rviz_plugin/BirdEyeViewTool" type="tier4_camera_view_rviz_plugin::BirdEyeViewTool" base_class_type="rviz_common::Tool">
<description>
Bird-eye-view Tool. This tool requires the corresponding BirdEyeViewController.
</description>
</class>
<class name="tier4_camera_view_rviz_plugin/ThirdPersonView" type="tier4_camera_view_rviz_plugin::ThirdPersonViewController" base_class_type="rviz_common::ViewController">
<description>
Control the camera for third-person view.
</description>
</class>
<class name="tier4_camera_view_rviz_plugin/ThirdPersonViewTool" type="tier4_camera_view_rviz_plugin::ThirdPersonViewTool" base_class_type="rviz_common::Tool">
<description>
Third-person-view Tool. This tool requires the corresponding ThirdPersonViewController.
</description>
</class>

</library>
242 changes: 242 additions & 0 deletions common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
// Copyright 2023-2024 Autoware Foundation
shmpwk marked this conversation as resolved.
Show resolved Hide resolved
//
// 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.
/*
* Copyright (c) 2009, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "bird_eye_view_controller.hpp"

#include "rviz_common/display_context.hpp"
#include "rviz_common/properties/bool_property.hpp"
#include "rviz_common/properties/float_property.hpp"
#include "rviz_common/viewport_mouse_event.hpp"
#include "rviz_rendering/objects/shape.hpp"
#include "rviz_rendering/orthographic.hpp"

#include <OgreCamera.h>
#include <OgreQuaternion.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include <OgreVector3.h>
#include <OgreViewport.h>

namespace tier4_camera_view_rviz_plugin
{
static const Ogre::Quaternion ROBOT_TO_CAMERA_ROTATION =
Ogre::Quaternion(Ogre::Radian(-Ogre::Math::HALF_PI), Ogre::Vector3::UNIT_Y) *
Ogre::Quaternion(Ogre::Radian(-Ogre::Math::HALF_PI), Ogre::Vector3::UNIT_Z);

static const float PITCH_LIMIT_LOW = -Ogre::Math::HALF_PI + 0.001;
static const float PITCH_LIMIT_HIGH = Ogre::Math::HALF_PI - 0.001;

BirdEyeViewController::BirdEyeViewController() : dragging_(false)

Check warning on line 68 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L68

Added line #L68 was not covered by tests
{
scale_property_ = new rviz_common::properties::FloatProperty(
"Scale", 10, "How much to scale up the size of things in the scene.", this);
angle_property_ = new rviz_common::properties::FloatProperty(
"Angle", 0, "Angle around the Z axis to rotate.", this);
x_property_ =
new rviz_common::properties::FloatProperty("X", 0, "X component of camera position.", this);
y_property_ =
new rviz_common::properties::FloatProperty("Y", 0, "Y component of camera position.", this);
}

Check warning on line 78 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L70-L78

Added lines #L70 - L78 were not covered by tests

BirdEyeViewController::~BirdEyeViewController()

Check warning on line 80 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L80

Added line #L80 was not covered by tests
{
}

Check warning on line 82 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L82

Added line #L82 was not covered by tests

void BirdEyeViewController::onInitialize()

Check warning on line 84 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L84

Added line #L84 was not covered by tests
{
FramePositionTrackingViewController::onInitialize();

Check warning on line 86 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L86

Added line #L86 was not covered by tests

camera_->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
auto camera_parent = getCameraParent(camera_);
camera_parent->setFixedYawAxis(false);
invert_z_->hide();
}

Check warning on line 92 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L88-L92

Added lines #L88 - L92 were not covered by tests

void BirdEyeViewController::reset()

Check warning on line 94 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L94

Added line #L94 was not covered by tests
{
scale_property_->setFloat(10);
angle_property_->setFloat(0);
x_property_->setFloat(0);
y_property_->setFloat(0);
}

Check warning on line 100 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L96-L100

Added lines #L96 - L100 were not covered by tests

void BirdEyeViewController::handleMouseEvent(rviz_common::ViewportMouseEvent & event)

Check warning on line 102 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L102

Added line #L102 was not covered by tests
{
if (event.shift()) {
setStatus("<b>Left-Click:</b> Move X/Y.");

Check warning on line 105 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L104-L105

Added lines #L104 - L105 were not covered by tests
} else {
setStatus(

Check warning on line 107 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L107

Added line #L107 was not covered by tests
"<b>Left-Click:</b> Rotate. <b>Middle-Click:</b> Move X/Y. <b>Right-Click:</b>: Zoom. "
"<b>Shift</b>: More options.");
}

bool moved = false;

int32_t diff_x = 0;
int32_t diff_y = 0;

if (event.type == QEvent::MouseButtonPress) {
dragging_ = true;
} else if (event.type == QEvent::MouseButtonRelease) {
dragging_ = false;
} else if (dragging_ && event.type == QEvent::MouseMove) {
diff_x = event.x - event.last_x;
diff_y = event.y - event.last_y;

Check warning on line 123 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L117-L123

Added lines #L117 - L123 were not covered by tests
moved = true;
}

if (event.left() && !event.shift()) {
setCursor(Rotate2D);
angle_property_->add(diff_x * 0.005);
orientCamera();
} else if (event.middle() || (event.shift() && event.left())) {

Check warning on line 131 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

BirdEyeViewController::handleMouseEvent has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
setCursor(MoveXY);
float scale = scale_property_->getFloat();
move_camera(-diff_x / scale, diff_y / scale);
} else if (event.right()) {
setCursor(Zoom);
scale_property_->multiply(1.0 - diff_y * 0.01);

Check warning on line 137 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L127-L137

Added lines #L127 - L137 were not covered by tests
} else {
setCursor(event.shift() ? MoveXY : Rotate2D);

Check warning on line 139 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L139

Added line #L139 was not covered by tests
}

if (event.wheel_delta != 0) {

Check warning on line 142 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L142

Added line #L142 was not covered by tests
int diff = event.wheel_delta;
scale_property_->multiply(1.0 - (-diff) * 0.001);

Check warning on line 144 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L144

Added line #L144 was not covered by tests

moved = true;
}

if (moved) {
context_->queueRender();
emitConfigChanged();

Check warning on line 151 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L149-L151

Added lines #L149 - L151 were not covered by tests
}
}

Check warning on line 153 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

BirdEyeViewController::handleMouseEvent has a cyclomatic complexity of 15, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 153 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L153

Added line #L153 was not covered by tests

void BirdEyeViewController::orientCamera()

Check warning on line 155 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L155

Added line #L155 was not covered by tests
{
camera_->setOrientation(
Ogre::Quaternion(Ogre::Radian(angle_property_->getFloat()), Ogre::Vector3::UNIT_Z));
}

Check warning on line 159 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L157-L159

Added lines #L157 - L159 were not covered by tests

void BirdEyeViewController::mimic(rviz_common::ViewController * source_view)

Check warning on line 161 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L161

Added line #L161 was not covered by tests
{
FramePositionTrackingViewController::mimic(source_view);

Check warning on line 163 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L163

Added line #L163 was not covered by tests

if (BirdEyeViewController * source_ortho = qobject_cast<BirdEyeViewController *>(source_view)) {
scale_property_->setFloat(source_ortho->scale_property_->getFloat());
angle_property_->setFloat(source_ortho->angle_property_->getFloat());
x_property_->setFloat(source_ortho->x_property_->getFloat());
y_property_->setFloat(source_ortho->y_property_->getFloat());

Check warning on line 169 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L165-L169

Added lines #L165 - L169 were not covered by tests
} else {
auto source_camera_parent = getCameraParent(source_view->getCamera());
setPosition(source_camera_parent->getPosition());

Check warning on line 172 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L171-L172

Added lines #L171 - L172 were not covered by tests
}
}
void BirdEyeViewController::update(float dt, float ros_dt)

Check warning on line 175 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L174-L175

Added lines #L174 - L175 were not covered by tests
{
FramePositionTrackingViewController::update(dt, ros_dt);
updateCamera();
}

Check warning on line 179 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L177-L179

Added lines #L177 - L179 were not covered by tests

void BirdEyeViewController::lookAt(const Ogre::Vector3 & point)

Check warning on line 181 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L181

Added line #L181 was not covered by tests
{
setPosition(point - target_scene_node_->getPosition());
}

Check warning on line 184 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L183-L184

Added lines #L183 - L184 were not covered by tests

void BirdEyeViewController::onTargetFrameChanged(

Check warning on line 186 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L186

Added line #L186 was not covered by tests
const Ogre::Vector3 & old_reference_position,
const Ogre::Quaternion & /*old_reference_orientation*/)
{
move_camera(
old_reference_position.x - reference_position_.x,
old_reference_position.y - reference_position_.y);
}

Check warning on line 193 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L190-L193

Added lines #L190 - L193 were not covered by tests

void BirdEyeViewController::updateCamera()

Check warning on line 195 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L195

Added line #L195 was not covered by tests
{
orientCamera();

Check warning on line 197 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L197

Added line #L197 was not covered by tests

float width = camera_->getViewport()->getActualWidth();
float height = camera_->getViewport()->getActualHeight();

Check warning on line 200 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L199-L200

Added lines #L199 - L200 were not covered by tests

float scale = scale_property_->getFloat();
Ogre::Matrix4 proj = rviz_rendering::buildScaledOrthoMatrix(
-width / scale / 2, width / scale / 2, -height / scale / 2, height / scale / 2,
camera_->getNearClipDistance(), camera_->getFarClipDistance());
camera_->setCustomProjectionMatrix(true, proj);

Check warning on line 206 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L202-L206

Added lines #L202 - L206 were not covered by tests

// For Z, we use half of the far-clip distance set in
// selection_context.cpp, so that the shader program which computes
// depth can see equal distances above and below the Z=0 plane.
auto camera_parent = getCameraParent(camera_);
camera_parent->setPosition(x_property_->getFloat(), y_property_->getFloat(), 500);
}

Check warning on line 213 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L211-L213

Added lines #L211 - L213 were not covered by tests

Ogre::SceneNode * BirdEyeViewController::getCameraParent(Ogre::Camera * camera)

Check warning on line 215 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L215

Added line #L215 was not covered by tests
{
auto camera_parent = camera->getParentSceneNode();

Check warning on line 217 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L217

Added line #L217 was not covered by tests

if (!camera_parent) {
throw std::runtime_error("camera's parent scene node pointer unexpectedly nullptr");

Check warning on line 220 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L219-L220

Added lines #L219 - L220 were not covered by tests
}
return camera_parent;

Check warning on line 222 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L222

Added line #L222 was not covered by tests
}

void BirdEyeViewController::setPosition(const Ogre::Vector3 & pos_rel_target)

Check warning on line 225 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L225

Added line #L225 was not covered by tests
{
x_property_->setFloat(pos_rel_target.x);
y_property_->setFloat(pos_rel_target.y);
}

Check warning on line 229 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L227-L229

Added lines #L227 - L229 were not covered by tests

void BirdEyeViewController::move_camera(float dx, float dy)

Check warning on line 231 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L231

Added line #L231 was not covered by tests
{
float angle = angle_property_->getFloat();
x_property_->add(dx * cos(angle) - dy * sin(angle));
y_property_->add(dx * sin(angle) + dy * cos(angle));
}

Check warning on line 236 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L233-L236

Added lines #L233 - L236 were not covered by tests

} // namespace tier4_camera_view_rviz_plugin

#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(

Check warning on line 241 in common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_camera_view_rviz_plugin/src/bird_eye_view_controller.cpp#L241

Added line #L241 was not covered by tests
tier4_camera_view_rviz_plugin::BirdEyeViewController, rviz_common::ViewController)
Loading
Loading