pull/1/head
wubw1656 2023-10-16 21:07:33 +08:00
parent fa32bc4ad4
commit 6271c3ec67
81 changed files with 2194 additions and 1198 deletions

View File

@ -9,16 +9,23 @@
#### 安装教程 #### 安装教程
1. xxxx 1. chmod +x build.sh
2. xxxx 2. ./build.sh
3. xxxx 3. xxxx
#### 使用说明 #### 使用说明
<<<<<<< Updated upstream
在最外层目录 catkin_make 在最外层目录 catkin_make
可能需要 source ./devel/setup.bash 可能需要 source ./devel/setup.bash
1. roslaunch librviz_tutorial laser.launch 1. roslaunch librviz_tutorial laser.launch
2. xxxx 2. xxxx
=======
在工作目录下(src上一层)
记得source(可能需要)
1. source ./devel/setup.bash
2. roslaunch point_visual laser.launch
>>>>>>> Stashed changes
3. xxxx 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. ## First start with some standard catkin stuff.
cmake_minimum_required(VERSION 3.0.2) cmake_minimum_required(VERSION 3.0.2)
project(librviz_tutorial) project(point_visual)
set(SDK_PATH "./sdk/") set(SDK_PATH "./sdk/")
@ -17,7 +17,15 @@ FILE(GLOB SDK_SRC
find_package(catkin REQUIRED COMPONENTS find_package(catkin REQUIRED COMPONENTS
rviz roscpp std_msgs rviz roscpp std_msgs
rosconsole sensor_msgs # node.cpp rosconsole sensor_msgs # node.cpp
rosbag rosbag
pcl_ros
)
find_package(PCL REQUIRED)
include_directories(
include
${catkin_INCLUDE_DIRS}
/usr/include/pcl-1.8
) )
@ -68,8 +76,8 @@ set(SRC_FILES
add_executable(myviz ${SRC_FILES} ) add_executable(myviz ${SRC_FILES} )
add_executable(rplidarNode src/node.cpp ${SDK_SRC}) # laser # add_executable(rplidarNode src/node.cpp ${SDK_SRC}) # laser
target_link_libraries(rplidarNode ${catkin_LIBRARIES}) # target_link_libraries(rplidarNode ${catkin_LIBRARIES})
target_link_libraries(myviz -lcrypto) target_link_libraries(myviz -lcrypto)
@ -85,11 +93,11 @@ target_link_libraries(myviz ${QT_LIBRARIES} ${catkin_LIBRARIES})
## Install ## Install
install(TARGETS myviz DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) install(TARGETS myviz DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(TARGETS rplidarNode # install(TARGETS rplidarNode
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
) # )
install(DIRECTORY launch sdk install(DIRECTORY launch sdk
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 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> <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_port" type="string" value="/dev/ttyUSB0"/>
<param name="serial_baudrate" type="int" value="115200"/><!--A1/A2 --> <param name="serial_baudrate" type="int" value="115200"/><!--A1/A2 -->
<!--param name="serial_baudrate" type="int" value="256000"--><!--A3 --> <!--param name="serial_baudrate" type="int" value="256000"--><!--A3 -->

View File

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

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -9,8 +9,10 @@
LoginDialog::LoginDialog(QWidget *parent):QDialog(parent) LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
{ {
this->setFixedSize(380, 300);
userLabel = new QLabel(this); userLabel = new QLabel(this);
userLabel->move(80, 80); userLabel->move(70, 80);
userLabel->setText(tr("用户名")); userLabel->setText(tr("用户名"));
userEditLine = new QLineEdit(this); userEditLine = new QLineEdit(this);
@ -18,7 +20,7 @@ LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
userEditLine->setPlaceholderText(tr("请输入用户名")); userEditLine->setPlaceholderText(tr("请输入用户名"));
pwdLabel = new QLabel(this); pwdLabel = new QLabel(this);
pwdLabel->move(80, 130); pwdLabel->move(70, 130);
pwdLabel->setText(tr("密码")); pwdLabel->setText(tr("密码"));
pwdEditLine = new QLineEdit(this); pwdEditLine = new QLineEdit(this);
@ -33,23 +35,24 @@ LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
exitBtn = new QPushButton(this); exitBtn = new QPushButton(this);
exitBtn->move(220, 200); exitBtn->move(220, 200);
exitBtn->setText(tr("退出")); exitBtn->setText(tr("退出"));
connect(loginBtn, &QPushButton::clicked, this, &LoginDialog::login); connect(loginBtn, &QPushButton::clicked, this, &LoginDialog::login);
connect(exitBtn, &QPushButton::clicked, this, &LoginDialog::close); connect(exitBtn, &QPushButton::clicked, this, &LoginDialog::close);
// 待解锁的组件名称 // 待解锁的组件名称
setting_name = {"laser_topic", "open_file", "bag_progress"}; setting_name = {"cloud_topic", "laser_topic", "open_file", "bag_progress", "fixd_frame_topic"};
// 账号路径
user_file_name = "../PointVisual/src/point_visual/sources/user/user.txt";
// to do read from file // 创建用户表存下
createUser(); createUser();
// userPasswords["root"] = hashPassword("root123"); // userPasswords["root"] = hashPassword("root123");
// userPasswords["wbw"] = hashPassword("123"); // userPasswords["wbw"] = hashPassword("123");
} }
void LoginDialog::createUser(){ void LoginDialog::createUser(){
std::ifstream inputFile("../Rviz/librviz_ws/src/librviz_tutorial/sources/user/user.txt"); std::ifstream inputFile(user_file_name);
// 第一次读写user.txt将user加密后建立userPasswords // 第一次读写user.txt将user加密后建立userPasswords
if(inputFile.is_open()){ if(inputFile.is_open()){
std::string line; std::string line;
@ -57,7 +60,7 @@ void LoginDialog::createUser(){
std::istringstream iss(line); std::istringstream iss(line);
std::string username, pwd; std::string username, pwd;
if(iss>> username && iss>> pwd){ if(iss>> username && iss>> pwd){
if(pwd.size() < 8){ if(pwd.size() <= 8){
// 根据长度判断是否已经被加密 // 根据长度判断是否已经被加密
pwd = hashPassword(pwd); pwd = hashPassword(pwd);
} }
@ -74,7 +77,7 @@ void LoginDialog::createUser(){
// 加密后的账户密码写入user.txt // 加密后的账户密码写入user.txt
void LoginDialog::writeHash(const std::map<QString, QString> user){ void LoginDialog::writeHash(const std::map<QString, QString> user){
std::ofstream file("../Rviz/librviz_ws/src/librviz_tutorial/sources/user/user.txt"); std::ofstream file(user_file_name);
if(file.is_open()){ if(file.is_open()){
for(auto iter = user.begin(); iter != user.end() ; iter++){ for(auto iter = user.begin(); iter != user.end() ; iter++){
@ -124,15 +127,16 @@ std::string LoginDialog::hashPassword(const std::string& password) {
// 判断用户账号返回不同code // 判断用户账号返回不同code
int LoginDialog::checkUser(const QString username, const QString pwd){ int LoginDialog::checkUser(const QString username, const QString pwd){
auto iter = userPasswords.find(username); auto iter = userPasswords.find(username);
if (iter != userPasswords.end()) { if(iter != userPasswords.end()){
if(iter->second == hashPassword(pwd)){ if(pwd.size() > 8) { return 1; }
// 用户密码都对 if(iter->second == hashPassword(pwd)){
return 2; // 用户密码都对
}else{ return 2;
// 用户对,密码不对 }else{
return 1; // 用户对,密码不对
} return 1;
} else { }
}else {
// 用户不对 // 用户不对
return 0; return 0;
} }
@ -168,35 +172,6 @@ void LoginDialog::login()
userEditLine->clear(); userEditLine->clear();
pwdEditLine->clear(); pwdEditLine->clear();
userEditLine->setFocus(); userEditLine->setFocus();
// //判断用户名和密码是否正确 todo 函数判断
// if (userEditLine->text().trimmed() == tr("tom") &&
// pwdEditLine->text() == tr("123456"))
// {
// for(int i=0 ; i<setting_name.size(); i++){
// QWidget *foundChild = parent()->findChild<QWidget*>(setting_name[i]);
// if (foundChild) {
// qDebug()<<"111" ;
// // 找到了指定的子组件 在这里可以对子组件进行操作
// foundChild->setEnabled(true);
// }else{
// qDebug()<<"第" << i+1 <<"组件未找到" ;
// }
// }
// QMessageBox::information(this, tr("登录成功"), tr("已解锁"), QMessageBox::Yes);
// // landed = 1;
// accept();
// }
// else
// {
// QMessageBox::warning(this, tr("登录失败"), tr("用户名或者密码错误"), QMessageBox::Yes);
// }
// userEditLine->clear();
// pwdEditLine->clear();
// userEditLine->setFocus();
// QMessageBox::information(this, tr("提示"), tr("已经登陆,请勿重新登录"), QMessageBox::Yes);
} }

View File

@ -46,6 +46,7 @@ private:
// std::vector<QString> setting_name; // std::vector<QString> setting_name;
// 用户表 // 用户表
std::map<QString, QString> userPasswords; std::map<QString, QString> userPasswords;
std::string user_file_name;
}; };

2038
point_visual/src/myviz.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

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