【发布时间】:2021-06-30 19:01:52
【问题描述】:
我正在使用一个通过 localhost 连接到远程 PC 的机器人。我使用 Paramiko 库将命令从远程 pc 发送到我的机器人。我想在 /activate 主题上发布一个数字,如下所示:
rostopic pub /activate std_msgs/Int16 "data: 1"
问题不是我的连接,因为上面的命令使用 PuTTY 或 SSH 工作。
我写了以下代码:
import paramiko
host = "xxx.xxx.x.x"
port = 22
username = "robot"
password = "xxx"
command = "rostopic pub /activate std_msgs/Int16 'data: 1'"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)
stdin, stdout, stderr = ssh.exec_command(command)
但是使用此代码,我在我的机器人中看不到任何结果。有人可以帮忙吗?
【问题讨论】:
标签: python ubuntu ssh ros paramiko