ROS Arduino HelloWorld例程的一些问题

我使用的是Arduino Due, 板子插上后, 打开Arduino IDE, 提示需要安装Arduino Due的Library, 安装就可以了.
安装ros_lib到Arduino开发环境:

  # cd <sketchbook>/libraries
  cd '/home/dq/Arduino/libraries'
  rm -rf ros_lib
  rosrun rosserial_arduino make_libraries.py .

串口连接是需要许可的, 不然不能下载程序, 方法参考 Serial port permissions

As normal user from terminal: ls -l /dev/ttyUSB* or ls -l /dev/ttyACM*
You will get something like
crw-rw---- 1 root uucp 188, 0 5 apr 23.01 ttyUSB0 or
crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0
The “0” might be a different number, or multiple entries might be returned. In the first case the data we need is uucp, in the second dialout. (this is the group owner of the file)
Now we just need to add our user to the group:
usermod -a -G group-name username
group-name is the data found before, and username is your Linux user name. You will need to log out and in again for this change to take effect.

我的是ttyACM0, 所以 sudo usermod -a -G dialout wf 就可以了(wf是我的用户名), 注销然后重新登录.
Arduino ROS HelloWorld的代码:

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

char hello[13] = "hello world!";

void setup()
{
  nh.initNode();
  nh.advertise(chatter);
}

void loop()
{
  str_msg.data = hello;
  chatter.publish( &str_msg );
  nh.spinOnce();
  delay(1000);
}

这个不行的, 按照步骤走下去会报错:

Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

参考 rosserial arduino can’t connect 中的方法: 在 #include <ros.h> 前面加上 #define USE_USBCON 才可以.
工具中选择 开发板为Arduino Due, 端口选ttyACM0, 下载到Arduino板中. 三个终端分别输入下面3条命令:

 roscore
 rosrun rosserial_python serial_node.py /dev/ttyACM0
 rostopic echo chatter

这样就好了:
rosserial
echo

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值