python - ROS CPP 相当于 Python subprocess.call() with shell=True

标签 python c++ ros

以下代码片段在 ROS Indigo (Python 2.7) 中运行良好-

import subprocess
subprocess.call(["rosnode", "kill", "my_node"], shell=True)

但是,我正在寻找与上述功能等效的 ROS CPP。 system 命令不起作用,因为指定的命令应该通过 shell 执行。

最佳答案

.system() 方法就是这样。

我之前在ROS包中使用这种方法,如下手动发布主题:

system("rostopic pub -1 /tilt_scan_controller/command std_msgs/Float64 -- 0.0"); 

在你的情况下会是:

system("rosnode kill <your-node-name>"); 

关于python - ROS CPP 相当于 Python subprocess.call() with shell=True,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50839633/

相关文章:

c++ - 无法在虚幻引擎中使用 std::vector

c++ - ROS订阅者一直阻塞回调

c++ - 按照初学者 cv_bridge 教程,不起作用

python - 如何检查数组是否在 Python 中的数组列表中?

python - 如何在不重新采样的情况下将这个月度 xarray 数据集转换为年度平均值?

python - 在 OS X 10.8(64 位)上运行 wxPython 2.9

python - 延迟加载 Python 模块的最佳实践

c++ - 如何从 char 数组中读取 "%"字符并使用 fprintf_s 将其写入文件?

c++ - 如何减少 UWP 应用程序中的全屏交换链显示延迟?

catkin_make 中的 cmake 版本与全局 cmake 版本不同?