-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(driving_environment_analyzer): add rviz plugin (#23)
* feat(driving_environment_analyzer): add rviz plugin Signed-off-by: satoshi-ota <[email protected]> * feat(driving_environment_analyzer): output csv file Signed-off-by: satoshi-ota <[email protected]> --------- Signed-off-by: satoshi-ota <[email protected]>
- Loading branch information
1 parent
eb7cf14
commit 2c80e30
Showing
23 changed files
with
1,600 additions
and
472 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 103 additions & 0 deletions
103
driving_environment_analyzer/include/driving_environment_analyzer/analyzer_core.hpp
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,103 @@ | ||
// Copyright 2024 TIER IV, Inc. | ||
// | ||
// 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 DRIVING_ENVIRONMENT_ANALYZER__ANALYZER_CORE_HPP_ | ||
#define DRIVING_ENVIRONMENT_ANALYZER__ANALYZER_CORE_HPP_ | ||
|
||
#include "driving_environment_analyzer/type_alias.hpp" | ||
#include "rosbag2_cpp/reader.hpp" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
#include <route_handler/route_handler.hpp> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace driving_environment_analyzer::analyzer_core | ||
{ | ||
|
||
struct ODDRawData | ||
{ | ||
rcutils_time_point_value_t timestamp; | ||
Odometry odometry; | ||
PredictedObjects objects; | ||
TFMessage tf; | ||
TFMessage tf_static; | ||
CooperateStatusArray rtc_status; | ||
}; | ||
|
||
class AnalyzerCore | ||
{ | ||
public: | ||
explicit AnalyzerCore(rclcpp::Node & node); | ||
~AnalyzerCore(); | ||
|
||
bool isDataReadyForStaticODDAnalysis() const; | ||
bool isDataReadyForDynamicODDAnalysis() const { return odd_raw_data_.has_value(); } | ||
|
||
void analyzeStaticODDFactor() const; | ||
void analyzeDynamicODDFactor(std::ofstream & ofs_csv_file) const; | ||
|
||
void addHeader(std::ofstream & ofs_csv_file) const; | ||
|
||
void setBagFile(const std::string & file_name); | ||
|
||
void setTimeStamp(const rcutils_time_point_value_t & timestamp) | ||
{ | ||
odd_raw_data_ = getRawData(timestamp); | ||
} | ||
|
||
void setMap(const HADMapBin & msg) { route_handler_.setMap(msg); } | ||
|
||
void clearData() { odd_raw_data_ = std::nullopt; } | ||
|
||
std::pair<rcutils_time_point_value_t, rcutils_time_point_value_t> getBagStartEndTime() | ||
{ | ||
const auto metadata = reader_.get_metadata(); | ||
const auto start_time = | ||
duration_cast<seconds>(metadata.starting_time.time_since_epoch()).count(); | ||
const auto duration_time = duration_cast<seconds>(metadata.duration).count(); | ||
return {start_time, start_time + duration_time}; | ||
} | ||
|
||
Odometry getOdometry() const { return odd_raw_data_.value().odometry; } | ||
PredictedObjects getObjects() const { return odd_raw_data_.value().objects; } | ||
TFMessage getTF() const { return odd_raw_data_.value().tf; } | ||
TFMessage getTFStatic() const { return odd_raw_data_.value().tf_static; } | ||
|
||
private: | ||
Pose getEgoPose() const { return odd_raw_data_.value().odometry.pose.pose; } | ||
|
||
double getEgoSpeed() const { return odd_raw_data_.value().odometry.twist.twist.linear.x; } | ||
|
||
template <class T> | ||
std::optional<T> getLastTopic(const std::string & topic_name); | ||
template <class T> | ||
std::optional<T> seekTopic( | ||
const std::string & topic_name, const rcutils_time_point_value_t & timestamp); | ||
std::optional<ODDRawData> getRawData(const rcutils_time_point_value_t & timestamp); | ||
|
||
std::optional<ODDRawData> odd_raw_data_{std::nullopt}; | ||
|
||
route_handler::RouteHandler route_handler_; | ||
|
||
rosbag2_cpp::Reader reader_; | ||
|
||
rclcpp::Logger logger_; | ||
}; | ||
} // namespace driving_environment_analyzer::analyzer_core | ||
|
||
#endif // DRIVING_ENVIRONMENT_ANALYZER__ANALYZER_CORE_HPP_ |
45 changes: 45 additions & 0 deletions
45
...nment_analyzer/include/driving_environment_analyzer/driving_environment_analyzer_node.hpp
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,45 @@ | ||
// Copyright 2024 TIER IV, Inc. | ||
// | ||
// 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 DRIVING_ENVIRONMENT_ANALYZER__DRIVING_ENVIRONMENT_ANALYZER_NODE_HPP_ | ||
#define DRIVING_ENVIRONMENT_ANALYZER__DRIVING_ENVIRONMENT_ANALYZER_NODE_HPP_ | ||
|
||
#include "driving_environment_analyzer/analyzer_core.hpp" | ||
#include "driving_environment_analyzer/type_alias.hpp" | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace driving_environment_analyzer | ||
{ | ||
|
||
class DrivingEnvironmentAnalyzerNode : public rclcpp::Node | ||
{ | ||
public: | ||
explicit DrivingEnvironmentAnalyzerNode(const rclcpp::NodeOptions & node_options); | ||
|
||
private: | ||
void onMap(const HADMapBin::ConstSharedPtr map_msg); | ||
void analyze(); | ||
|
||
std::shared_ptr<analyzer_core::AnalyzerCore> analyzer_; | ||
|
||
rclcpp::Subscription<HADMapBin>::SharedPtr sub_map_; | ||
rclcpp::TimerBase::SharedPtr timer_; | ||
rosbag2_cpp::Reader reader_; | ||
}; | ||
} // namespace driving_environment_analyzer | ||
|
||
#endif // DRIVING_ENVIRONMENT_ANALYZER__DRIVING_ENVIRONMENT_ANALYZER_NODE_HPP_ |
86 changes: 86 additions & 0 deletions
86
...nalyzer/include/driving_environment_analyzer/driving_environment_analyzer_rviz_plugin.hpp
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,86 @@ | ||
// Copyright 2024 TIER IV, Inc. | ||
// | ||
// 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 DRIVING_ENVIRONMENT_ANALYZER__DRIVING_ENVIRONMENT_ANALYZER_RVIZ_PLUGIN_HPP_ | ||
#define DRIVING_ENVIRONMENT_ANALYZER__DRIVING_ENVIRONMENT_ANALYZER_RVIZ_PLUGIN_HPP_ | ||
|
||
#include "driving_environment_analyzer/analyzer_core.hpp" | ||
#include "driving_environment_analyzer/type_alias.hpp" | ||
|
||
#include <QDir> | ||
#include <QFileDialog> | ||
#include <QHBoxLayout> | ||
#include <QLabel> | ||
#include <QPushButton> | ||
#include <QSlider> | ||
#include <QSpinBox> | ||
#include <rviz_common/display_context.hpp> | ||
#include <rviz_common/panel.hpp> | ||
#include <rviz_common/render_panel.hpp> | ||
#include <rviz_common/ros_integration/ros_node_abstraction_iface.hpp> | ||
#include <rviz_common/view_manager.hpp> | ||
#include <rviz_rendering/render_window.hpp> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace driving_environment_analyzer | ||
{ | ||
|
||
class DrivingEnvironmentAnalyzerPanel : public rviz_common::Panel | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DrivingEnvironmentAnalyzerPanel(QWidget * parent = nullptr); | ||
~DrivingEnvironmentAnalyzerPanel() override; | ||
void onInitialize() override; | ||
|
||
public Q_SLOTS: | ||
void onBoxUpdate(); | ||
void onSliderUpdate(); | ||
void onClickSetTimeStamp(); | ||
void onSelectBagFile(); | ||
void onSelectDirectory(); | ||
void onClickAnalyzeStaticODDFactor(); | ||
void onClickAnalyzeDynamicODDFactor(); | ||
|
||
private: | ||
void onMap(const HADMapBin::ConstSharedPtr map_msg); | ||
|
||
std::shared_ptr<analyzer_core::AnalyzerCore> analyzer_; | ||
|
||
std::ofstream ofs_csv_file_; | ||
|
||
QSpinBox * bag_time_selector_; | ||
QSlider * bag_time_slider_; | ||
QLabel * bag_name_label_; | ||
QLabel * bag_time_line_; | ||
QPushButton * dir_button_ptr_; | ||
QPushButton * file_button_ptr_; | ||
QPushButton * analyze_static_odd_button_; | ||
QPushButton * analyze_dynamic_odd_button_; | ||
QPushButton * set_timestamp_btn_; | ||
|
||
rclcpp::Node::SharedPtr raw_node_; | ||
rclcpp::Subscription<HADMapBin>::SharedPtr sub_map_; | ||
rclcpp::Publisher<Odometry>::SharedPtr pub_odometry_; | ||
rclcpp::Publisher<PredictedObjects>::SharedPtr pub_objects_; | ||
rclcpp::Publisher<TFMessage>::SharedPtr pub_tf_; | ||
rclcpp::Publisher<TFMessage>::SharedPtr pub_tf_static_; | ||
}; | ||
} // namespace driving_environment_analyzer | ||
|
||
#endif // DRIVING_ENVIRONMENT_ANALYZER__DRIVING_ENVIRONMENT_ANALYZER_RVIZ_PLUGIN_HPP_ |
Oops, something went wrong.