NavMap
Loading...
Searching...
No Matches
navmap_pose_tool.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// This file is part of the project Easy Navigation (EasyNav in short)
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16
17#ifndef NAVMAP_RVIZ_PLUGIN__NAVMAP_POSE_TOOL_HPP_
18#define NAVMAP_RVIZ_PLUGIN__NAVMAP_POSE_TOOL_HPP_
19
20#include <memory>
21#include <string>
22#include <utility>
23
24#include <OgreVector.h>
25
26#include <QCursor> // NOLINT cpplint cannot handle include order here
27
28#include "geometry_msgs/msg/point.hpp"
29#include "geometry_msgs/msg/quaternion.hpp"
30
31#include "rviz_common/tool.hpp"
32#include "rviz_rendering/viewport_projection_finder.hpp"
33#include "rviz_default_plugins/visibility_control.hpp"
34
36{
37class Arrow;
38} // namespace rviz_rendering
39
40namespace navmap_rviz_plugin
41{
42
43class RVIZ_DEFAULT_PLUGINS_PUBLIC NavMapPoseTool : public rviz_common::Tool
44{
45public:
47
48 ~NavMapPoseTool() override;
49
50 void onInitialize() override;
51
52 void activate() override;
53
54 void deactivate() override;
55
56 int processMouseEvent(rviz_common::ViewportMouseEvent & event) override;
57
58protected:
59 virtual void onPoseSet(double x, double y, double z, double theta) = 0;
60
61 geometry_msgs::msg::Quaternion orientationAroundZAxis(double angle);
62
63 void logPose(
64 std::string designation,
65 geometry_msgs::msg::Point position,
66 geometry_msgs::msg::Quaternion orientation,
67 double angle,
68 std::string frame);
69
70 std::shared_ptr<rviz_rendering::Arrow> arrow_;
71
78 double angle_;
79
80 Ogre::Vector3 arrow_position_;
81 std::shared_ptr<rviz_rendering::ViewportProjectionFinder> projection_finder_;
82
83private:
84 int processMouseLeftButtonPressed(std::pair<bool, Ogre::Vector3> xy_plane_intersection);
85 int processMouseMoved(std::pair<bool, Ogre::Vector3> xy_plane_intersection);
86 int processMouseLeftButtonReleased();
87 void makeArrowVisibleAndSetOrientation(double angle);
88 double calculateAngle(Ogre::Vector3 start_point, Ogre::Vector3 end_point);
89};
90
91} // namespace navmap_rviz_plugin
92
93#endif // NAVMAP_RVIZ_PLUGIN__NAVMAP_POSE_TOOL_HPP_
Ogre::Vector3 arrow_position_
Definition navmap_pose_tool.hpp:80
NavMapPoseTool()
Definition navmap_pose_tool.cpp:48
void onInitialize() override
Definition navmap_pose_tool.cpp:56
std::shared_ptr< rviz_rendering::Arrow > arrow_
Definition navmap_pose_tool.hpp:70
State state_
Definition navmap_pose_tool.hpp:77
void deactivate() override
Definition navmap_pose_tool.cpp:70
virtual void onPoseSet(double x, double y, double z, double theta)=0
int processMouseEvent(rviz_common::ViewportMouseEvent &event) override
Definition navmap_pose_tool.cpp:115
std::shared_ptr< rviz_rendering::ViewportProjectionFinder > projection_finder_
Definition navmap_pose_tool.hpp:81
State
Definition navmap_pose_tool.hpp:73
@ Position
Definition navmap_pose_tool.hpp:74
@ Orientation
Definition navmap_pose_tool.hpp:75
geometry_msgs::msg::Quaternion orientationAroundZAxis(double angle)
Definition navmap_pose_tool.cpp:199
void activate() override
Definition navmap_pose_tool.cpp:64
void logPose(std::string designation, geometry_msgs::msg::Point position, geometry_msgs::msg::Quaternion orientation, double angle, std::string frame)
Definition navmap_pose_tool.cpp:209
double angle_
Definition navmap_pose_tool.hpp:78
Definition navmap_goal_tool.hpp:39
Definition navmap_pose_tool.hpp:36