Comments (4)
I'm trying to learn to make GUI with qt qreator (ros industrial) using your code.
I found some errors in the y speed widget which should have been corresponding to rotational speed.
It is not responding.
I tried to edit the callback function from qnode.cpp, but I could't make it work.
Do you have any ideas?
Thank you
To be precise, I'm not subscribing here to the rotational speed, it's just the y-axis speed. In the 143-line speedCallback() function of qnode.cpp,:
void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg) { emit speed_x(msg->twist.twist.linear.x); emit speed_y(msg->twist.twist.linear.y); }
send a custom signal to mainwindow.cpp, you can change the y-axis speed here to the raw value to send past, in mainWindow.cpp's slot_speed_x (double x) and slot_speed_y (double x) functions handle the signal sent over and update the UI display.
from ros_qt5_gui_app.
Thank you for the advice.
I did as you advised like this:
(qnode.cpp)
//Speed callback function
void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg)
{
emit speed_x(msg->twist.twist.linear.x);
emit speed_y(msg->twist.twist.linear.y);
}
(mainwindow.cpp)
void MainWindow::connections()
{
//connectSpeed signal
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_x(double)));
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_y(double)));
Now both widget are subscribing to the same speed variable in my display.
Sorry but I don't understand how to change the y-axis speed to the raw value.
I wanted the widget_speed_x to subscribe forward/backward speed and widget_speed_y to subscribe left/right speed.
Thank you so much for your help, really.
from ros_qt5_gui_app.
//connectSpeed signal
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_x(double)));
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_y(double)));
//connectSpeed signal
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_x(double)));
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_y(double)));
All of you are linking here are speed_x (double) signals, so it will cause the y-axis speed to be the same as the x-axis.
The original code is:
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_x(double))); connect(&qnode,SIGNAL(speed_y(double)),this,SLOT(slot_speed_y(double)));
Only change this:
void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg) { emit speed_x(msg->twist.twist.linear.x); emit speed_y(msg->twist.twist.linear.y); }
as:
void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg) { emit speed_x(msg->twist.twist.linear.x); emit speed_y(msg->twist.twist.angular.z); }
The z-axis angle speed was released to mainwindow.cpp ,slot_speed_y(double):
So you need to change the ui display in the slot_speed_y function:
void MainWindow::slot_speed_y(double x) { if(x>=0) ui.label_dir_y->setText("正向"); else ui.label_dir_y->setText("反向"); m_DashBoard_y->setValue(abs(x*100)); }
from ros_qt5_gui_app.
Thank you for your kind response..
so I changed as you mentioned.
in mainwindow.cpp =
...
//connectSpeed signal
connect(&qnode,SIGNAL(speed_x(double)),this,SLOT(slot_speed_x(double)));
connect(&qnode,SIGNAL(speed_y(double)),this,SLOT(slot_speed_y(double)));
...
void MainWindow::slot_speed_x(double x)
{
if(x>=0) ui.label_dir_x->setText("正向");
else ui.label_dir_x->setText("反向");
m_DashBoard_x->setValue(abs(x*100));
}
void MainWindow::slot_speed_y(double z)
{
if(z>=0) ui.label_dir_y->setText("正向");
else ui.label_dir_y->setText("反向");
m_DashBoard_y->setValue((z*100));
}
..
and qnode.cpp =
...
//Speed callback function
void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg)
{
emit speed_x(msg->twist.twist.linear.x);
emit speed_y(msg->twist.twist.angular.z);
}
...
When I run this, the y_speed_widget is responding, but it doesn't respond to the angular speed.
from ros_qt5_gui_app.
Related Issues (19)
- CCtrlDashBoard导入一直报错 HOT 3
- 如何打包linux下的QT包 HOT 1
- 显示的坐标和原始rviz的坐标不匹配 HOT 4
- 如何运行 HOT 9
- RVIZ: Display does not exist
- 关于使用QGraphicsView绘制雷达地图显示的具体过程是如何实现的,我没怎么看懂,想问问有没有其他demo HOT 2
- 关于在远程端进行连接不上机器人的问题 HOT 2
- 如何正确编译? HOT 3
- 编译错误 HOT 11
- undefined reference to `cv::Mat::Mat(int, int, int) HOT 4
- 老师好,购买了课程,出现了这个问题,没有搜索到解答的问题, HOT 1
- 你好,老师!Windows下cyrobot rviz tree通过命令行执行没有问题,但windeployqt打包发布,执行提示rivz找不到,是什么原因,有办法处理吗 HOT 1
- 点击连接按钮后界面闪退 HOT 4
- 上位机如何控制工控机? HOT 4
- 请问如何将moveit的display加入到界面中? HOT 2
- 请问如何设置一键式启动某个roslaunch程序
- RVIZ problem HOT 1
- rviz画bezier HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ros_qt5_gui_app.