How do I properly resolve the below issues? Would be nice to hear comments from professionals.I've got a stream of messages coming into an I2C slave from its master. However when I read the time before calling 'logger.publish()' the problem doesn't reproduce, so it's definitely something related to serial communication being performed. It probably has something to do with 'millis()' disabling the interrupts in order to read consistent view of the current time. I'm not sure exactly how it works internally, but apparently there is some sort of clash between ROS publisher communicating over Serial, interruptions being triggered (I mean 'motorInterruptLeft') and reading the current time with 'millis()' call. Time = millis() // !!!!!! THIS CALL CAUSES ROSSERIAL TO LOOSE CONNECTION Logger.publish( &log_msg ) // doing some publishing every 100ms Ros::Publisher logger("logger", &log_msg) LogMsgType log_msg // where LogMsgType is some/any ROS message type So the code I had was something like this: ros::NodeHandle nh The thing is that I was trying to measure the time it takes to publish a message to ROS from Arduino. Ok, so I figured out what code was triggering the issue. Anyone has ideas about how to use ROS on Arduino while still being able to handle interrupts? I still get the same "Lost sync with device" problem. logger.publish(.) // doing some publishing every 100ms I troubleshooted the problem a little bit and have minimized the code to just this:ĪttachInterrupt(1, motorInterruptLeft, CHANGE) the wheel starts turning).Īt this point it seems like Arduino program is restarted (crashes?) and rosserial loses connection to it (I get "lost sync with device") When I run the program and connect it to ROS with rosserial.py everything runs smoothly (I'm getting ROS messages from Arduino) till the interrupt is triggered for the first time (i.e. So I'm measuring the speed of the wheel using interrupts (one of the 2 outputs of a hall sensor is connected to interrupt pin). The motors have a Hall sensor-based wheel encoders with a relatively high resolution (~3000 ticks per turn of the wheel). I'm implementing a motor controller on Arduino connected to ROS stack via rosserial_arduino.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |