ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Why would rosserial_python fail when it connect to arduino?

asked 2017-11-01 22:22:47 -0500

Liuche gravatar image

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?

edit retag flag offensive close merge delete

Comments

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?

ahendrix gravatar image ahendrix  ( 2017-11-01 22:58:25 -0500 )edit

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...

Liuche gravatar image Liuche  ( 2017-11-02 01:09:17 -0500 )edit

I solved the problem! I reinstalled the entire ROS system!

Liuche gravatar image Liuche  ( 2017-11-03 01:14:31 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-11-03 01:15:34 -0500

Liuche gravatar image

I solved the problem! I reinstalled the entire ROS system

Maybe I delete some file in ros? I don't know,but Finally I solved it

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-11-01 22:22:47 -0500

Seen: 388 times

Last updated: Nov 03 '17