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
2. xxxx
1. chmod +x build.sh
2. ./build.sh
3. xxxx
#### 使用说明
<<<<<<< Updated upstream
在最外层目录 catkin_make
可能需要 source ./devel/setup.bash
1. roslaunch librviz_tutorial laser.launch
2. xxxx
=======
在工作目录下(src上一层)
记得source(可能需要)
1. source ./devel/setup.bash
2. roslaunch point_visual laser.launch
>>>>>>> Stashed changes
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/")
@ -18,6 +18,14 @@ find_package(catkin REQUIRED COMPONENTS
rviz roscpp std_msgs
rosconsole sensor_msgs # node.cpp
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(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)
@ -85,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

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -9,8 +9,10 @@
LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
{
this->setFixedSize(380, 300);
userLabel = new QLabel(this);
userLabel->move(80, 80);
userLabel->move(70, 80);
userLabel->setText(tr("用户名"));
userEditLine = new QLineEdit(this);
@ -18,7 +20,7 @@ LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
userEditLine->setPlaceholderText(tr("请输入用户名"));
pwdLabel = new QLabel(this);
pwdLabel->move(80, 130);
pwdLabel->move(70, 130);
pwdLabel->setText(tr("密码"));
pwdEditLine = new QLineEdit(this);
@ -38,18 +40,19 @@ LoginDialog::LoginDialog(QWidget *parent):QDialog(parent)
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();
// userPasswords["root"] = hashPassword("root123");
// userPasswords["wbw"] = hashPassword("123");
}
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
if(inputFile.is_open()){
std::string line;
@ -57,7 +60,7 @@ void LoginDialog::createUser(){
std::istringstream iss(line);
std::string username, pwd;
if(iss>> username && iss>> pwd){
if(pwd.size() < 8){
if(pwd.size() <= 8){
// 根据长度判断是否已经被加密
pwd = hashPassword(pwd);
}
@ -74,7 +77,7 @@ void LoginDialog::createUser(){
// 加密后的账户密码写入user.txt
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()){
for(auto iter = user.begin(); iter != user.end() ; iter++){
@ -124,15 +127,16 @@ std::string LoginDialog::hashPassword(const std::string& password) {
// 判断用户账号返回不同code
int LoginDialog::checkUser(const QString username, const QString pwd){
auto iter = userPasswords.find(username);
if (iter != userPasswords.end()) {
if(iter->second == hashPassword(pwd)){
// 用户密码都对
return 2;
}else{
// 用户对,密码不对
return 1;
}
} else {
if(iter != userPasswords.end()){
if(pwd.size() > 8) { return 1; }
if(iter->second == hashPassword(pwd)){
// 用户密码都对
return 2;
}else{
// 用户对,密码不对
return 1;
}
}else {
// 用户不对
return 0;
}
@ -168,35 +172,6 @@ void LoginDialog::login()
userEditLine->clear();
pwdEditLine->clear();
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::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<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"
@ -56,8 +58,8 @@ class RenderPanel;
class VisualizationManager;
class ToolManager;
class PropertyTreeWidget;
class ToolManager;
class PropertyTreeWidget;
class ViewManager;
class ViewController;
}
// BEGIN_TUTORIAL
@ -70,64 +72,93 @@ public:
virtual ~MyViz();
void subCallback(const std_msgs::String& msg);
void pubThread();
void PlayCircle(double 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(const QString& text); // 圆圈变化
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;
@ -142,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;