-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrosnode.cpp
75 lines (67 loc) · 1.53 KB
/
rosnode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* @Author: Tfly6 2085488186@qq.com
* @Date: 2023-07-22 21:50:05
* @LastEditors: Tfly6 2085488186@qq.com
* @LastEditTime: 2023-07-23 21:26:24
* @Description: rosnode 命令
*/
#include "rosnode.h"
#include <QDebug>
Rosnode::Rosnode(QObject *parent) : MyCommand(parent)
{
modeFlag = MODENULL;
connect(process,&QProcess::readyReadStandardOutput,this,&Rosnode::onReOut);
}
void Rosnode::onReOut()
{
QString line = process->readAll(); // 读取命令输出的内容
if(line.isEmpty())
{
qDebug() <<"error: " ;
}
QStringList con = line.split("\n",QString::SkipEmptyParts);
if(modeFlag == MODELIST)
{
content = con;
emit readOut(modeFlag,content);
}
if(modeFlag == MODEINFO)
{
content = con;
emit readOut(modeFlag,content);
}
if(modeFlag == MODEPING)
{
content = con;
emit readOut(modeFlag,content);
}
if(modeFlag == MODEKILL)
{
content = con;
emit readOut(modeFlag,content);
}
}
void Rosnode::list()
{
writeCmd("rosnode list\n");
modeFlag = MODELIST;
//qDebug()<<"rosnode list";
}
void Rosnode::info(QString node)
{
writeCmd("rosnode info "+node+"\n");
modeFlag = MODEINFO;
//qDebug()<<"rosnode info";
}
void Rosnode::ping(QString node)
{
writeCmd("rosnode ping -c 5 "+node+"\n");
modeFlag = MODEPING;
//qDebug()<<"rosnode ping";
}
void Rosnode::kill(QString node)
{
writeCmd("rosnode kill "+node+"\n");
modeFlag = MODEKILL;
//qDebug()<<"rosnode kill";
}