!1 The first version of the pointcloud visualization tool.

Merge pull request !1 from jzq/online_version
pull/2/MERGE
jzq 2023-10-17 11:02:36 +00:00 committed by Gitee
commit 144e6545c2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
81 changed files with 2425 additions and 1053 deletions

View File

@ -9,14 +9,18 @@
#### 安装教程
1. xxxx
2. xxxx
1. chmod +x build.sh
2. ./build.sh
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
在最外层目录 catkin_make
在工作目录下(src上一层)
记得source(可能需要)
1. source ./devel/setup.bash
2. roslaunch point_visual laser.launch
3. xxxx
#### 参与贡献

28
build.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# 创建工作目录
mkdir ~/PointVisual
cd ..
#将当前src移动到PointVisual
cp -r src ~/PointVisual
# 切换到工作目录
cd ~/PointVisual
# 在工作目录make
catkin_make
if [ $? -eq 0 ]; then
# 执行source命令
source ./devel/setup.bash
# 运行其他命令
# roslaunch point_visual laser.launch
roscore &
sleep 2
rosrun point_visual myviz
else
exit 1
fi

View File

@ -1,10 +0,0 @@
<!--
Used for visualising rplidar in action.
It requires rplidar.launch.
-->
<launch>
<include file="$(find librviz_tutorial)/launch/rplidar.launch" />
<node name="myviz" pkg="librviz_tutorial" type="myviz"/>
</launch>

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
##
## First start with some standard catkin stuff.
cmake_minimum_required(VERSION 3.0.2)
project(librviz_tutorial)
project(point_visual)
set(SDK_PATH "./sdk/")
@ -17,7 +17,15 @@ FILE(GLOB SDK_SRC
find_package(catkin REQUIRED COMPONENTS
rviz roscpp std_msgs
rosconsole sensor_msgs # node.cpp
rosbag
rosbag
pcl_ros
)
find_package(PCL REQUIRED)
include_directories(
include
${catkin_INCLUDE_DIRS}
/usr/include/pcl-1.8
)
@ -58,6 +66,7 @@ set(SRC_FILES
src/myviz.cpp
src/main.cpp
tools/color.cpp
src/loginDialog.cpp
)
## Add the "myviz" executable and specify the list of source files we
@ -67,9 +76,9 @@ set(SRC_FILES
add_executable(myviz ${SRC_FILES} )
add_executable(rplidarNode src/node.cpp ${SDK_SRC}) # laser
target_link_libraries(rplidarNode ${catkin_LIBRARIES})
# add_executable(rplidarNode src/node.cpp ${SDK_SRC}) # laser
# target_link_libraries(rplidarNode ${catkin_LIBRARIES})
target_link_libraries(myviz -lcrypto)
## Link the myviz executable with whatever Qt libraries have been defined by
@ -84,11 +93,11 @@ target_link_libraries(myviz ${QT_LIBRARIES} ${catkin_LIBRARIES})
## Install
install(TARGETS myviz DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(TARGETS rplidarNode
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
# install(TARGETS rplidarNode
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
install(DIRECTORY launch sdk
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}

View File

@ -0,0 +1,10 @@
<!--
Used for visualising rplidar in action.
It requires rplidar.launch.
-->
<launch>
<!-- <include file="$(find point_visual)/launch/rplidar.launch" /> -->
<node name="myviz" pkg="point_visual" type="myviz"/>
</launch>

View File

@ -1,5 +1,5 @@
<launch>
<node name="rplidarNode" pkg="librviz_tutorial" type="rplidarNode" output="screen">
<node name="rplidarNode" pkg="point_visual" type="rplidarNode" output="screen">
<param name="serial_port" type="string" value="/dev/ttyUSB0"/>
<param name="serial_baudrate" type="int" value="115200"/><!--A1/A2 -->
<!--param name="serial_baudrate" type="int" value="256000"--><!--A3 -->

View File

@ -1,5 +1,5 @@
<package>
<name>librviz_tutorial</name>
<name>point_visual</name>
<version>0.11.0</version>
<description>
Tutorial showing how to compile your own C++ program with RViz displays and features.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

@ -0,0 +1,5 @@
root 123!@
wbw 1234
## 待删除,保存原始用户密码
##

View File

@ -0,0 +1,2 @@
root p<><70><EFBFBD><08><><EFBFBD><EFBFBD>w<>:<3A><>R<EFBFBD>wH<77>pD<02><>#<23><><EFBFBD>6
wbw <03>gB<16><>\v<1E><><EFBFBD>U<EFBFBD>g<EFBFBD>6#ȳ<><C8B3>E<EFBFBD><13>x<EFBFBD><78>F<EFBFBD>

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,181 @@
#include "loginDialog.h"
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QMessageBox>
#include<QDebug>
LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
{
this->setFixedSize(380, 300);
userLabel = new QLabel(this);
userLabel->move(70, 80);
userLabel->setText(tr("用户名"));
userEditLine = new QLineEdit(this);
userEditLine->move(150, 80);
userEditLine->setPlaceholderText(tr("请输入用户名"));
pwdLabel = new QLabel(this);
pwdLabel->move(70, 130);
pwdLabel->setText(tr("密码"));
pwdEditLine = new QLineEdit(this);
pwdEditLine->move(150, 130);
pwdEditLine->setPlaceholderText(tr("请输入密码"));
pwdEditLine->setEchoMode(QLineEdit::Password);
loginBtn = new QPushButton(this);
loginBtn->move(60, 200);
loginBtn->setText(tr("登录"));
exitBtn = new QPushButton(this);
exitBtn->move(220, 200);
exitBtn->setText(tr("退出"));
connect(loginBtn, &QPushButton::clicked, this, &LoginDialog::login);
connect(exitBtn, &QPushButton::clicked, this, &LoginDialog::close);
// 待解锁的组件名称
setting_name = {"cloud_topic", "laser_topic", "open_file", "bag_progress", "fixd_frame_topic"};
// 账号路径
user_file_name = "../PointVisual/src/point_visual/sources/user/user.txt";
// 创建用户表存下
createUser();
// userPasswords["root"] = hashPassword("root123");
// userPasswords["wbw"] = hashPassword("123");
}
void LoginDialog::createUser(){
std::ifstream inputFile(user_file_name);
// 第一次读写user.txt将user加密后建立userPasswords
if(inputFile.is_open()){
std::string line;
while(std::getline(inputFile, line)){
std::istringstream iss(line);
std::string username, pwd;
if(iss>> username && iss>> pwd){
if(pwd.size() <= 8){
// 根据长度判断是否已经被加密
pwd = hashPassword(pwd);
}
// 创建map/用户表
userPasswords[QString::fromStdString(username)] = QString::fromStdString(pwd);
}
}
inputFile.close();
}else{
qDebug() << "Unable to open the user.txt.";
}
writeHash(userPasswords);
}
// 加密后的账户密码写入user.txt
void LoginDialog::writeHash(const std::map<QString, QString> user){
std::ofstream file(user_file_name);
if(file.is_open()){
for(auto iter = user.begin(); iter != user.end() ; iter++){
file << (iter->first).toStdString() << " ";
file << (iter->second).toStdString() << std::endl;
}
file.close();
}else{
qDebug()<<"Unable to write hashcode!!!";
}
}
// hash加密函数
QString LoginDialog::hashPassword(const QString& pwd) {
std::string password = pwd.toStdString();
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, password.c_str(), password.size());
SHA256_Final(hash, &sha256);
std::string hashedPassword;
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
hashedPassword += hash[i];
}
return QString(hashedPassword.c_str());
}
// 重载加密函数
std::string LoginDialog::hashPassword(const std::string& password) {
// std::string password = pwd.toStdString();
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, password.c_str(), password.size());
SHA256_Final(hash, &sha256);
std::string hashedPassword;
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
hashedPassword += hash[i];
}
return hashedPassword;
}
// 判断用户账号返回不同code
int LoginDialog::checkUser(const QString username, const QString pwd){
auto iter = userPasswords.find(username);
if(iter != userPasswords.end()){
if(pwd.size() > 8) { return 1; }
if(iter->second == hashPassword(pwd)){
// 用户密码都对
return 2;
}else{
// 用户对,密码不对
return 1;
}
}else {
// 用户不对
return 0;
}
}
// 槽函数
void LoginDialog::login()
{
int flag = checkUser(userEditLine->text().trimmed(), pwdEditLine->text());
switch(flag){
case 0: {
QMessageBox::warning(this, tr("登录失败"), tr("用户名错误"), QMessageBox::Ok);
break;
}
case 1: {
QMessageBox::warning(this, tr("登录失败"), tr("密码错误"), QMessageBox::Ok);
break;
}
case 2:{
for(int i=0 ; i<setting_name.size(); i++){
QWidget *foundChild = parent()->findChild<QWidget*>(setting_name[i]);
if (foundChild) {
// 找到了指定的子组件 在这里可以对子组件进行操作
foundChild->setEnabled(true);
}else{
qDebug()<<"" << i+1 <<"组件未找到" ;
}
}
QMessageBox::information(this, tr("登录成功"), tr("已解锁"), QMessageBox::Ok);
accept();
}
}
userEditLine->clear();
pwdEditLine->clear();
userEditLine->setFocus();
}
LoginDialog::~LoginDialog()
{
}

View File

@ -0,0 +1,54 @@
#ifndef LOGINDIALOG_H
#define LOGINDIALOG_H
#include <QDialog>
#include<iostream>
#include<vector>
#include <map>
#include <openssl/sha.h>
#include <fstream>
#include<sstream>
class QLabel;
class QLineEdit;
class QPushButton;
class LoginDialog : public QDialog
{
Q_OBJECT
public:
explicit LoginDialog(QWidget *parent = 0);
~LoginDialog();
int checkUser(const QString username, const QString pwd);
QString hashPassword(const QString& pwd);
std::string hashPassword(const std::string& password); // 重载
void createUser();
void writeHash(const std::vector<std::string> usernames, const std::vector<std::string> pwds);
void writeHash(const std::map<QString, QString>);
// 待解锁组件名
std::vector<QString> setting_name;
//槽函数
private Q_SLOTS:
void login();
private:
QLabel *userLabel;
QLabel *pwdLabel;
QLineEdit *userEditLine;
QLineEdit *pwdEditLine;
QPushButton *loginBtn;
QPushButton *exitBtn;
// 待解锁组件名
// std::vector<QString> setting_name;
// 用户表
std::map<QString, QString> userPasswords;
std::string user_file_name;
};
#endif // LOGINDIALOG_H

View File

@ -37,6 +37,7 @@
#include <ros/ros.h>
#include "myviz.h"
#include<iostream>
#include<QDebug>
int main(int argc, char **argv)
{

2038
point_visual/src/myviz.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -30,22 +30,26 @@
#define MYVIZ_H
#include <QWidget>
#include<QString>
#include <QString>
#include <QGridLayout>
#include<ros/ros.h>
#include"std_msgs/String.h"
#include<thread>
#include <ros/ros.h>
#include "std_msgs/String.h"
#include <thread>
#include <visualization_msgs/Marker.h>
#include<QTimer>
#include <QTimer>
#include <QMutex>
#include <QProcess>
#include <QThread>
#include<QSlider>
#include <QSlider>
#include <rosbag/bag.h>
#include <sensor_msgs/LaserScan.h>
#include <sensor_msgs/PointCloud2.h>
#include <rosbag/view.h>
#include"loginDialog.h"
namespace rviz
{
@ -54,6 +58,8 @@ class RenderPanel;
class VisualizationManager;
class ToolManager;
class PropertyTreeWidget;
class ViewManager;
class ViewController;
}
// BEGIN_TUTORIAL
@ -66,57 +72,93 @@ public:
virtual ~MyViz();
void subCallback(const std_msgs::String& msg);
void pubThread();
void PlayCircle(int index); // 圆圈线程执行函数
void PlayCircles(); // 圆圈线程执行函数
rosbag::View *view;
rosbag::View *view_;
private Q_SLOTS: // QT信号和槽
void setThickness( int thickness_percent );
void setCellSize( int cell_size_percent );
void setCloudTopic(const QString &newTopic);
void setLaserTopic(const QString &newTopic);
void setCloudSize(int cloudsize);
void setLaserSize(int lasersize);
void setCloudSize(const QString& size);
void setCloudAlpha(const QString& text);
void setLaserAlpha(const QString& laserAlpha);
void setLaserTopic(const QString &newTopic);
void setLaserSize(const QString & laserSize);
void LaserColorChanged(int index); // 雷达颜色
void GridColorChanged(int index); // 格栅颜色
void CloudColorChanged(int index);
void setFixedFrame(const QString &FixedFrame);
void setBackgroundColor(const QString& bg_color); // 背景颜色
void AxesDisplayChanged(int index); // axe
void CircleDisplayChanged(int index); // circle
void Tree_Display(QGridLayout* layout, int index);
void login_button_clicked();
void quit_login_button_clicked();
void slot_select(); // 切换至select模式
void slot_move_camera();
void CircleDisplayAdded(); // 增加圆圈按钮
void CircleDisplayDeleted(); // 删除圆圈按钮
void ViewZero(); // 视角回正
void ViewLeft(); // 视角左转
void ViewRight(); // 视角右转
void ViewTop(); // 视角俯视
// off
double extractDuration(const QByteArray& output);
void selectFile();
void SpeedChanged(int index);
void openFile();
void pcdFile();
void plyFile();
void bin();
std::string find(const std::string Path);
void pcd2ply (std::string &in_file, std::string& out_file);
void pcd2bin (std::string &in_file, std::string& out_file);
void ply2pcd (std::string &in_file, std::string& out_file);
void ply2bin (std::string &in_file, std::string& out_file);
void bin2pcd (std::string &in_file, std::string& out_file);
void bin2ply (std::string &in_file, std::string& out_file);
void TransformeType();
private:
rviz::VisualizationManager* manager_; //
rviz::RenderPanel* render_panel_;
rviz::ToolManager* tool_manager_;
rviz::ViewManager* view_man_; // 视角总类
rviz::ViewController* viewController; // 视角控制类
rviz::Display* grid_;
rviz::Display* cloud;
rviz::Display* laser_;
rviz::Display* axes_display;
rviz::Display* marker_;
rviz::PropertyTreeWidget* tree_widget_ ;
rviz::PropertyTreeWidget* select_tree_widget_ ; // select框
// rviz::PropertyTreeWidget* view_tree_widget_ ;
ros::NodeHandle nh;
ros::Subscriber sub;
ros::Publisher pub;
std::thread pub_thread;
std::vector<QString> color_name; // 颜色的名称集合
// std::vector<QString> button_name; // 带图标按钮的名称集合
QString color_icon_filename;
QString button_icon_filename;
LoginDialog* dlg;
bool landed;
QString cur_fixed_frame;
int circle_index;
std::map<double, int> circle_radius;
// off
bool isclicked;// 用于判断play第几次按下play键
bool ispauseclick;// 用于判断暂停键第几次按下
int count;// 用于记录timeout的次数
bool sliderreleased;// 用于判断是否拖动了进度条
bool playagain;// 用于检测是否多次按下play按钮
bool isthreadplaying;// 用于标识线程是否在运行
bool abs;// 用于单独开线程?
bool stored;// 用于存储一次容器,只在第一次play的时候存储容器
bool stored = false;// 用于存储一次容器,只在第一次play的时候存储容器
bool is_pause = false;
bool is_reset = false;
bool is_end = false;
@ -131,17 +173,30 @@ private:
bool threadout = false;
bool ischanged = false;
bool ismoved = false;
double speed_rate;
bool sliderpause = false;
bool is_next = false;
bool is_previous = false;
bool flag = false;
bool pointcloud2 = false;
double speed_rate = 10;
QPushButton* play;
QSlider* progress;
QString filePath;
double duration;
int remain;
QString Topic;
QString SavefileName;
QString SaveMulfileName;
double sliderPosition = 0;
int prog_num = 0;
std::vector<QString> speed_name;
ros::Publisher scan_pub;
std::vector<sensor_msgs::LaserScan::ConstPtr> indx;// 存储节点信息
int countbag;// 存储播放的具体位置
double indxsize;
ros::Publisher scan_pubpcd;
std::vector<sensor_msgs::LaserScan::ConstPtr> indx;// 存储laser节点信息
std::vector<sensor_msgs::PointCloud2::ConstPtr> indxpcd;// 存储cloud节点信息
int countbag = 0;// 存储播放的具体位置
double indxsize = 0;
double indxpcdsize = 0;
int test = 0;