Why would rosserial_python fail when it connect to arduino?
Hi! I running in 14.04 indigo, I need a hand to fix this problem :
I followed the tutorial of arduino in ros , try to create a publisher but it failed
$rosrun rosserial_python serial_node.py /dev/ttyACM0
[ERROR] [WallTime: 1509590980.692109] Creation of publisher failed: line: yaml https://raw.githubusercontent.com/ros... osx unsupported pickle protocol: 4
I tried to use $rosdep update
to fix but nothing happend
Arduino code is here:
#include <SPI.h>
#include <MFRC522.h>
/////setup/////
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Byte.h>
#include <std_msgs/Char.h>
#include <std_msgs/Int32.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("RFID", &str_msg);
char hello[13] = "hello world!";
char RFID[32];
////////////////
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class
MFRC522::MIFARE_Key key;
// Init array that will store new NUID
byte nuidPICC[4];
void setup()
{
//////node setup///////
nh.initNode();
nh.advertise(chatter);
/////////////
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}
void loop()
{
/////////ROS setup/////////
//str_msg.data = RFID;
//chatter.publish( &str_msg );
nh.spinOnce();
//delay(1000);
///////////////////////////
// Look for new cards
if ( ! rfid.PICC_IsNewCardPresent())
return;
// Verify if the NUID has been readed
if ( ! rfid.PICC_ReadCardSerial())
return;
if (rfid.uid.uidByte[0] != nuidPICC[0] ||
rfid.uid.uidByte[1] != nuidPICC[1] ||
rfid.uid.uidByte[2] != nuidPICC[2] ||
rfid.uid.uidByte[3] != nuidPICC[3] ) {
nh.loginfo("A new card has been detected.");
nh.loginfo("The NUID tag is:");
sprintf(RFID,"%d %d %d %d",rfid.uid.uidByte[0],rfid.uid.uidByte[1],rfid.uid.uidByte[2],rfid.uid.uidByte[3]);
str_msg.data = RFID;
//show data
nh.loginfo(RFID);
chatter.publish( &str_msg );
// Store NUID into nuidPICC array
for (byte i = 0; i < 4; i++) {
nuidPICC[i] = rfid.uid.uidByte[i];
}
}
else
nh.loginfo("Card read previously.");
// Halt PICC
rfid.PICC_HaltA();
// Stop encryption on PCD
rfid.PCD_StopCrypto1();
}
And my launch file is here
<launch>
<node pkg="rosserial_python" type="serial_node.py" name="serial_node" output="screen">
<param name="port" value="/dev/ttyACM0"/>
<param name="baud" value="57600"/>
</node>
</launch>
But I run these script on the other computer it's doesn't happened...
Can somebody help me?
That's a very strange error message. Is there anything different between the computer where it works and where it doesn't work? Are they using different operating systems?
They are the same . Both 14.04 and also install rosserial package and arduino is 1.8.4
It's very strange. I can't find similar question on website.
But there is a important thing. It can be used before...
I solved the problem! I reinstalled the entire ROS system!