2014-12-05 51 views
0

我是Gumstix和ROS的新手。 我想用rosserial將Gumstix連接到Arduino(ATMega2560)。 我有Gumstix和Arduino之間的兩條路徑。 一個(Gumstix中的/ dev/ttyO0)是電路板中的連接,另一個(Gumstix中的/ dev/ttyACM3)是使用USB A到B電纜的連接。在Gumstix Overo上使用rosserial_arduino

作爲測試,我試圖運行這個例子:http://wiki.ros.org/rosserial_arduino/Tutorials/Hello%20World

在的/ dev/ttyACM3的情況下,我可以跑以下命令成功:

[email protected]:~$ rosrun rosserial_python serial_node.py _port:=/dev/ttyACM3 
[INFO] [WallTime: 946697855.203704] ROS Serial Python Node 
[INFO] [WallTime: 946697855.330657] Connecting to /dev/ttyACM3 at 57600 baud 
[INFO] [WallTime: 946697864.251922] Note: publish buffer size is 512 bytes 
[INFO] [WallTime: 946697864.260375] Setup publisher on chatter [std_msgs/String] 

但在的電路鏈路/ dev/ttyO0,我不能:

[email protected]:~$ rosrun rosserial_python serial_node.py _port:=/dev/ttyO0 
[INFO] [WallTime: 946697911.536193] ROS Serial Python Node 
[INFO] [WallTime: 946697911.662841] Connecting to /dev/ttyO0 at 57600 baud 
[ERROR] [WallTime: 946697928.814331] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino 

什麼是ttyO設備?它是不同的ttyUSB或ttyACM? 爲什麼我不能在/ dev/ttyO0的端口上運行rosserial_python?

我還檢查了/ dev/ttyO0的端口在Gumstix和Arduino之間使用回聲測試的效果很好。

問候,


這是運行rosserial_python後兩個串行端口的配置。 他們是一樣的。

[email protected]:~$ stty -F /dev/ttyACM3 
speed 57600 baud; line = 0; 
min = 0; time = 0; 
-brkint -icrnl -imaxbel 
-opost 
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 
[email protected]:~$ stty -F /dev/ttyO0 
speed 57600 baud; line = 0; 
min = 0; time = 0; 
-brkint -icrnl -imaxbel 
-opost 
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 

回答

0

自我回答。

我的/ dev/ttyO0端口連接到Arduino上的Serial1端口。 因此,我必須在ros_lib/ArduinoHardware.h上將Serial更改爲Serial1。

class ArduinoHardware { 
    public: 
    ArduinoHardware(SERIAL_CLASS* io , long baud= 57600){ 
     iostream = io; 
     baud_ = baud; 
    } 
    ArduinoHardware() 
    { 
#if defined(USBCON) and !(defined(USE_USBCON)) 
     /* Leonardo support */ 
     iostream = &Serial1; 
#else 
     iostream = &Serial1; // <=========== HERE 
#endif 
     baud_ = 57600; 
    } 
1

除了正確的版本,你需要有#include <ros.h>在代碼的頂部,ros::NodeHandle nh;聲明爲一個全球性的,nh.initNode();和內void setup()Serial.begin(115200);,並在void loop()nh.spinOnce();