Hello everyone,
I'm using an Arduino Mega 2560 (with [Adafruit Motor Shield](https://www.adafruit.com/product/1438) on it) and I'm trying to transfer data from it to a Rasperry Pi 3B using rosserial. However I have an error in communication when using the "Hello World" example that appears only with the RPi3 and not with my main computer.
When using rosserial from my main computer everything is working well:
rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=57600
[INFO] [WallTime: 1535317376.974559] ROS Serial Python Node
[INFO] [WallTime: 1535317376.977290] Connecting to /dev/ttyACM0 at 57600 baud
[INFO] [WallTime: 1535317380.120512] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1535317380.120794] Setup publisher on chatter [std_msgs/String]
When running the same code from the RPi3 I got this error:
rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=56700
[INFO] [1535317489.629288]: ROS Serial Python Node
[INFO] [1535317489.650718]: Connecting to /dev/ttyACM0 at 56700 baud
[INFO] [1535317491.929815]: wrong checksum for msg length, length -2296
[INFO] [1535317491.931260]: chk is 10
[ERROR] [1535317491.934192]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client
[INFO] [1535317491.935558]: Protocol version of client is unrecognized, expected Rev 1 (rosserial 0.5+)
[INFO] [1535317492.933539]: wrong checksum for msg length, length 16
[INFO] [1535317492.934947]: chk is 175
[INFO] [1535317493.933598]: wrong checksum for msg length, length -4348
[INFO] [1535317493.936049]: chk is 125
[INFO] [1535317494.935642]: wrong checksum for msg length, length 16
[INFO] [1535317494.938213]: chk is 175
[ERROR] [1535317494.946257]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client
[INFO] [1535317494.948985]: Protocol version of client is unrecognized, expected Rev 1 (rosserial 0.5+)
[INFO] [1535317495.936054]: wrong checksum for msg length, length -4348
[INFO] [1535317495.938623]: chk is 125
[ERROR] [1535317496.935010]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client
[INFO] [1535317496.937569]: Protocol version of client is unrecognized, expected Rev 1 (rosserial 0.5+)
[INFO] [1535317497.934976]: wrong checksum for msg length, length -4348
[INFO] [1535317497.937484]: chk is 125
[INFO] [1535317498.934526]: wrong checksum for msg length, length 16
[INFO] [1535317498.936874]: chk is 175
[INFO] [1535317499.938173]: wrong checksum for msg length, length -4336
[INFO] [1535317499.940590]: chk is 125
[INFO] [1535317500.937859]: wrong checksum for msg length, length -4336
[INFO] [1535317500.940557]: chk is 125
Seems to be a version related issue but I checked and the rosserial arduino library is up to date in the arduino (0.7.9). Maybe it's from the version difference between the computer and the RPi3 but I don't know what I can do about it.
Computer characteristics:
- Ubuntu 14.04.5 LTS
- ROS distro: indigo
- ROS version: 1.11.21
- rosserial_python version: 0.6.4
Raspberry Pi 3B characteristics:
- Ubuntu 16.04.2 LTS
- ROS distro: kinetic
- ROS version: 1.12.13
- rosserial_python version: 0.7.7
FYI, the "HelloWorld" code in the arduino is the following:
/*
* rosserial Publisher Example
* Prints "hello world!"
*/
#include
#include
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);
}
Any help would be appreciated!
↧
Problems when using rosserial on Raspberry Pi (wrong checksum for msg length)
↧
STM32 communication with ROS via ethernet AND Serial
Hi! I'm trying to develop a system where I can communicate from my ROS workstation to an STM32 board via ethernet (TCP or UDP doesn't matter so much), and from there, process the same message from the UART back to the computer. I've managed to flash this [STM 32 package](https://github.com/bosch-ros-pkg/stm32) onto the board, but I have no idea how to actually send messages to it? It seems like an excellent tool but perhaps isn't beginner-friendly.
I've also looked into using [rosserial](http://wiki.ros.org/rosserial_embeddedlinux) but I wouldn't even know where to start. I feel as though it's somewhat simple, the end product is a linux computer, which can send a string via ethernet (TCP or UDP) to the board, which sends a string (via serial) back to the computer.
I've lastly looked into whether it would be as simple as just setting up [multiple machines](http://wiki.ros.org/ROS/Tutorials/MultipleMachines) but i wouldn't even be able to tell you whether it's applicable to this application.
I have the ethernet cable and the serial to USB connection back to the computer. If someone would be able to even point me in the right direction I would be incredibly grateful! :)
↧
↧
Question about lwIP stack on stm32 using bosch-ros-pkg/stm32
I have an STM discovery board I want to use for my project. I've been looking into using this [stm32 package](https://github.com/bosch-ros-pkg/stm32) it has [a lot of scripts](https://github.com/bosch-ros-pkg/stm32/tree/master/src/transport/lwip) using the lwip stack, but offers no real documentation about it.
[I've followed the instructions and successfully flashed the discovery board](https://github.com/bosch-ros-pkg/stm32/wiki) , so if i was to setup a ROS node with TCP client/server communication, would it work? I tried but haven't been successful yet.
↧
Use Arduino Libraries in ROS
Hello all.
I have made a publisher/subscriber for rosserial to communicate with Arduino. There are 6 sensors in total, 1 ultrasonic, 2 analog IRs and 3 digital IRs. I uploaded my code and it is running smoothly with rosserial. But when I made a library for the sensors and used it in the Arduino, I suddenly get an error "run loop error: serial port read error returned short". How do you use an Arduino library with ROS?
↧
Lost sync with device, restarting... when Arduino code have delay
Hello all.
I have a problem with rosserial. I have a mobot that responds to the sensors data. I use a publisher/subscriber for this. The mobot is working fine, but I want it to move backwards for about 1-2 seconds then turn right or left depending on the sensors data. The problem is I'm using delay for this and when I add the delay to my Arduino code, rosserial gives me an error of "Lost sync with device, restarting...".
I have read and implemented a lot of solutions but none are working. Do help please.
↧
↧
What is rospy.sleep for?
Really confused here. I want to delay certain publishing of messages to a topic for about 1-2 seconds. Can rospy.sleep help? My code already works fine, but I need the delay since I cannot put any delays in the Arduino/rosserial because it gives a lost sync error. Can someone please help? I've been doing this for 2 weeks and no solution so far. Here is my code.
#!/usr/bin/env python
import rospy
import time
from std_msgs.msg import Int32
from sensor_msgs.msg import Range
flags = Int32()
class warning_flag():
def __init__(self):
self.aIR_FR = None
self.aIR_FL = None
self.dIR_front = None
self.dIR_BR = None
self.dIR_BL = None
self.sonic = None
def aIR_FR_callback(self, aIR_FR_msg):
print "Analog IR Right Range: %s" % aIR_FR_msg.range
self.aIR_FR = aIR_FR_msg.range
self.warn()
def aIR_FL_callback(self, aIR_FL_msg):
print "Analog IR Left Range: %s" % aIR_FL_msg.range
self.aIR_FL = aIR_FL_msg.range
self.warn()
def dIR_BL_callback(self, dIR_BL_msg):
print "Digital IR Left Range: %s" % dIR_BL_msg.range
self.dIR_BL = dIR_BL_msg.range
self.warn()
def dIR_BR_callback(self, dIR_BR_msg):
print "Digital IR Right Range: %s" % dIR_BR_msg.range
self.dIR_BR = dIR_BR_msg.range
self.warn()
def dIR_front_callback(self, dIR_front_msg):
print "Digital IR Range: %s" % dIR_front_msg.range
self.dIR_front = dIR_front_msg.range
self.warn()
def sonic_callback(self, sonic_msg):
print "Ultrasonic Range: %s" % sonic_msg.range
self.sonic = sonic_msg.range
self.warn()
def warn(self):
sonic_zone = 0.3
aIR_FR_zone = 0.2
aIR_FL_zone = 0.2
dIR_front_zone = 0
dIR_BR_zone = 1
dIR_BL_zone = 1
if (self.aIR_FR > aIR_FR_zone and self.aIR_FL <= aIR_FL_zone):
print "Turn right"
flags.data = 2
elif (self.aIR_FR <= aIR_FR_zone and self.aIR_FL > aIR_FL_zone):
print "Turn Left"
flags.data = 3
elif (self.aIR_FR <= aIR_FR_zone and self.aIR_FL <= aIR_FL_zone):
if ((self.sonic > sonic_zone and self.dIR_front != dIR_front_zone) or
(self.sonic <= sonic_zone and self.dIR_front != dIR_front_zone)):
if (self.dIR_BR != dIR_BR_zone and self.dIR_BL != dIR_BL_zone):
print "Stop"
flags.data = 5
else:
if (self.aIR_FR > self.aIR_FL):
print "Turn Right"
flags.data = 2
else:
print "Turn Left"
flags.data = 3
elif ((self.sonic > sonic_zone and self.dIR_front == dIR_front_zone) or
(self.sonic <= sonic_zone and self.dIR_front == dIR_front_zone)):
if (self.dIR_BR == dIR_BR_zone and self.dIR_BL == dIR_BL_zone):
print "Back off"
flags.data = 4
#put delay here
if (self.aIR_FR > self.aIR_FL):
print "Turn Right"
flags.data = 2
else:
print "Turn Left"
flags.data = 3
else:
if (self.aIR_FR > self.aIR_FL):
print "Turn Right"
flags.data = 2
else:
print "Turn Left"
flags.data = 3
elif (self.aIR_FR > aIR_FR_zone and self.aIR_FL > aIR_FL_zone):
if (self.sonic > sonic_zone and self.dIR_front == dIR_front_zone):
print "Advance"
flags.data = 1
else:
if (self.dIR_BR == dIR_BR_zone and self.dIR_BL == dIR_BL_zone):
print "Back off"
flags.data = 4
#put delay here
if (self.aIR_FR > self.aIR_FL):
print "Turn Right"
flags.data = 2
else:
print "Turn Left"
flags.data = 3
else:
if (self.aIR_FR > self.aIR_FL):
print "Turn Right"
flags.data = 2
else:
print "Turn Left"
flags.data = 3
def main():
rospy.init_node('sensor_pub_sub_node')
warn_pub=rospy.Publisher('Warnings', Int32, queue_size=1000)
warning = warning_flag()
aIR_FR_sub=rospy.Subscriber('aIR_FR', Range, warning.aIR_FR_callback)
aIR_FL_sub=rospy.Subscriber('aIR_FL', Range, warning.aIR_FL_callback)
dIR_BR_sub=rospy.Subscriber('dIR_BR', Range, warning.dIR_BR_callback)
dIR_BL_sub=rospy.Subscriber('dIR_BL', Range, warning.dIR_BL_callback)
dIR_front_sub=rospy.Subscriber('dIR_front', Range, warning.dIR_front_callback)
sonic_sub=rospy.Subscriber('ultrasound', Range, warning.sonic_callback)
rate = rospy.Rate(10)
while not rospy.is_shutdown():
warn_pub.publish(flags.data)
rate.sleep()
if __name__=='__main__':
try:
main()
except rospy.ROSInterruptException:
pass
↧
Why does this rosserial arduino code only permits a single subscriber?
Hi, I have a simple arduino code that takes in inputs from my joystick where a button on my joystick would act as a switch ( pressing once will turn 'on' and pressing it again turns it 'off'). My code basically publish the output as true or false and it works. However the problem arises when I add another subscriber to the cmd_vel topic. My output doesn't change and later a lost sync error occurs.
#include
#include
#include
#include
#include
#include
ros::NodeHandle nh;
float tempx;
float tempz;
float joy_button;
boolean last_reading;
boolean currentReading;
boolean flag;
boolean published;
void overrideCallback(const sensor_msgs::Joy& joy_msg){
joy_button = joy_msg.buttons[4];
}
/*
void joyCallback(const geometry_msgs::Twist& cmd_msg){
tempx = cmd_msg.linear.x;
tempz = cmd_msg.angular.z;
}*/
//ros::Subscriber joy_sub("cmd_vel", &joyCallback );
ros::Subscriber override_sub("joy", &overrideCallback);
std_msgs::Float32 override_msg;
ros::Publisher override_pub("override_status", &override_msg);
std_msgs::Bool pushed_msg;
ros::Publisher pub_button("pushed", &pushed_msg);
void setup(){
nh.initNode();
nh.subscribe(override_sub);
//nh.subscribe(joy_sub);
nh.advertise(override_pub);
nh.advertise(pub_button);
last_reading = false;
currentReading = false;
flag=true;
}
void loop(){
override_msg.data = joy_button;
if (override_msg.data == 0.0){
currentReading = false;
}else currentReading = true;
if (currentReading && !last_reading) {
flag=!flag;
if (flag) {
published = true;
}
else {
published = false;
}
}
last_reading = currentReading;
pushed_msg.data = published;
pub_button.publish(&pushed_msg);
override_pub.publish(&override_msg);
nh.spinOnce();
delay(5);
}
The above code works without the commented lines. Any help would be appreciated. Thank you.
↧
rosserial: Permission denied
hello,
I had to re-install my Ubuntu 16.04 with kinetic for some reasons. How ever, I tried to re-install all the work I've done before on the project.
All the workspaces where saved in my onwcloud, so i thought it should be an easy thing to do. Wrong :)
As I tried just to recompile the workspace with catkin_make everything failed an i tried to build from a new and clean workspace.
There is a node that uses some serial communication,so i need to add the rosserial pkg to my system.
First try by `sudo apt-get install ros-kinetic-serial`. then I did `catkin_make`. Everything fine so far. BUT when i start the node with `rosrun` an exeption ocoured:
IO Exception (13): Permission denied, file /tmp/binarydeb/ros-kinetic-serial-1.2.1/src/impl/unix.cc, line 151.
Just to check, i manually install the serial-pkg in my workspace and build both mith catkin. Now ther ist that error:
IO Exception (13): Permission denied, file /home/eddie/owncloud/eddie_ws/src/serial/src/impl/unix.cc, line 151.
which is basicly the same.
The piece of code with this revers to ist that: (l.151 is the default case)
void
Serial::SerialImpl::open ()
{
if (port_.empty ()) {
throw invalid_argument ("Empty port is invalid.");
}
if (is_open_ == true) {
throw SerialException ("Serial port already open.");
}
fd_ = ::open (port_.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd_ == -1) {
switch (errno) {
case EINTR:
// Recurse because this is a recoverable error.
open ();
return;
case ENFILE:
case EMFILE:
THROW (IOException, "Too many file handles open.");
default:
THROW (IOException, errno);
}
}
reconfigurePort();
is_open_ = true;
}
Does anyone has any ideas?
thank you all!
p.s. the hole thing worked very good before the re installation.
↧
Rosserial via ethernet on mbed platform STM32 NUCLEO
Hi,
I'm trying to use rosserial with mbed microcontroler via ethernet/tcpip. I found that it work with arduino. Does it work with mbed platform?
↧
↧
Connect two computers with RS-232 cable.
I am using Ubuntu 16.04 and ROS Kinetic. I want to connect a computer running ROS to another (without ROS) with a USB to serial connector (RS-232 cable), in order to send data (ex. send 3 decimals from a PC using ROS, and be able to see them in another's PC terminal). My research so far led me to install rosserial package, but I couldn't find any tutorial or sample code to see how exactly is going to work. I am new to ROS. Any suggestions or possible solutions would be appreciated.
↧
Issues with ros_lib for Arduino
Please, I need help to review the code at the bottom of the post, there is something very odd happening.
Github: [https://github.com/renanmb/box_controller](https://github.com/renanmb/box_controller)
[https://github.com/renanmb/Ros_arduino](https://github.com/renanmb/Ros_arduino)
When I compile the code there is no errors, however when I upload the code on my Arduino Mega and Arduino Uno it does not connect with the :
> rosrun rosserial_python serial_node.py
gives me the following error:
> [ERROR] [1537656135.447846]: Unable to> sync with device; possible link> problem or link software version> mismatch such as hydro> rosserial_python with groovy Arduino
I tried to reinstall rosserial, the arduino IDE, the ros_lib. I changed the wires, increased the baud_rate, I don't know what else to try.
What is driving me crazy is that it does connect when I run all the examples in ros_lib or when I run similar codes such as:
> ros_pwm_test5
#include
#include
#include
#include
#include
ros::NodeHandle nh;
std_msgs::Int32 str_msg;
ros::Publisher chatter("debug", &str_msg);
const int step_pin1 = 11;
const int dir_pin1 = 22;
const int step_pin2 = 12;
const int dir_pin2 = 24;
int32_t frequency1 = 0; //frequency (in Hz)
int32_t frequency2 = 0; //frequency (in Hz)
int32_t duty1 = 0;
int32_t duty2 = 0;
bool dir1 = true;
bool dir2 = true;
void driveCallback ( const geometry_msgs::Twist& twistMsg ){
//need to pubish straigth the motor commands and do the dir calculations on the Arduino
frequency1 = abs( twistMsg.linear.x ) ;
frequency2 = abs( twistMsg.linear.y ) ;
SetPinFrequency(step_pin1, frequency1);
SetPinFrequency(step_pin2, frequency2);
str_msg.data = frequency1;
chatter.publish(&str_msg);
if(frequency1 > 0){
duty1 = 32768;
if(twistMsg.linear.x >= 0){
digitalWrite(dir_pin1, HIGH);
}
else{
digitalWrite(dir_pin1, LOW);
}
}
else{
duty1 = 0; }
if(frequency2 > 0){
duty2 = 32768;
if(twistMsg.linear.y >= 0){
digitalWrite(dir_pin2, HIGH);
}
else{
digitalWrite(dir_pin2, LOW);
}
}
else{
duty2 = 0; }
}
ros::Subscriber driveSubscriber("comm_drive_robot", &driveCallback) ;
void setup(){ //initialize all timers except for 0, to save time keeping functions
InitTimersSafe();
nh.initNode();
// Subscribe to the steering and throttle messages
nh.subscribe(driveSubscriber);
nh.advertise(chatter);
//======================================================================================= /* ================ PWM Function ======================================================= */
pinMode(step_pin1, OUTPUT);
pinMode(dir_pin1, OUTPUT);
//PWM + direction to the motors 2
pinMode(step_pin2, OUTPUT);
pinMode(dir_pin2, OUTPUT);
}
void loop(){
nh.spinOnce();
pwmWriteHR(step_pin1, duty1);
pwmWriteHR(step_pin2, duty2);
delay(1); }
**Code with the issue:**
> box_controller_test3
#include
#include
#include
#include //PWM library for controlling the steppers
ros::NodeHandle nh;
std_msgs::Float32 temp_msg;
ros::Publisher temp("temp", &temp_msg);
//use pin 11 on the Mega instead, otherwise there is a frequency cap at 31 Hz
const int cooler_pin = 9;
const int LED_left_pin = 10;
const int LED_right_pin = 11;
const int sensor1 = A0;
int32_t frequency1 = 0; //frequency (in Hz)
int32_t frequency2 = 0; //frequency (in Hz)
int32_t frequency3 = 0;
void boxCallback ( const geometry_msgs::Twist& twistMsg ){
frequency1 = twistMsg.linear.x;
frequency2 = twistMsg.linear.y;
frequency3 = twistMsg.linear.z;
}
ros::Subscriber sub1("box", &boxCallback) ;
void setup(){
//initialize all timers except for 0, to save time keeping functions
InitTimersSafe();
nh.initNode();
// Subscribe
nh.subscribe(sub1);
nh.advertise(temp);
// =======================================================================================
/* ================ PWM Function ======================================================= */
//PWM to cooler
pinMode(cooler_pin, OUTPUT);
SetPinFrequency(cooler_pin, frequency1);
//PWM to LED_left
pinMode(LED_left_pin, OUTPUT);
SetPinFrequency(LED_left_pin, frequency2);
//PWM to LED_right
pinMode(LED_right_pin, OUTPUT);
SetPinFrequency(LED_right_pin, frequency3);
while(true){
//setting the duty to 50% with the highest possible resolution that
//can be applied to the timer (up to 16 bit). 1/2 of 65536 is 32768.
pwmWriteHR(cooler_pin, 32768);
pwmWriteHR(LED_left_pin, 32768);
pwmWriteHR(LED_right_pin, 32768);
}
}
void loop(){
nh.spinOnce();
temp_msg.data = analogRead(sensor1);
temp.publish( &temp_msg);
delay(100);
}
↧
"wrong checksum for id and message" when using interrupts to read ultrasonic sensors.
I am using interrupts to read from ultrasonic sensors on a Teensy 3.5 board. When I publish data I get a stream of "wrong checksum for topic id and message" warnings. I will also occasionally get errors:
Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client
When I increase the delay in my loop the amount of the first error decreases and the second one generally does not occur but the node will eventually crash in any case, displaying:
Traceback (most recent call last):
File "/my/home/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 85, in
client.run()
File "/my/home/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 493, in run
self.callbacks[topic_id](msg)
File "/my/home/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 107, in handlePacket
m.deserialize(data)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/nav_msgs/msg/_Odometry.py", line 225, in deserialize
raise genpy.DeserializationError(e) #most likely buffer underfill
genpy.message.DeserializationError: unpack requires a string argument of length 4
When I disable the trigger pulse to the ultrasonic sensors or when I detach the interrupts that read the pulse back from the sensors the issues go away. When I comment out all ros publishes the problems (logically) don't happen as well. I have some pretty large publishes such as Odometry and if I comment just that one out the issues decrease drastically but are still present.
Here is the really weird part, if each of the ultrasonic sensors detects a distance of less than a meter there are no issues with 5 ms of delay in the loop function, if there is more than a meter of clear space it takes 50 ms of delay to make the issues go away which is too slow for how often the wheel velocity commands are updating.
I'm pretty sure it has something to do with the interrupts for reading the distance activating during publishing but I have no idea why or how to fix it. The interrupt function looks like this:
void ISR_USreadB2() {
Threads::Scope m(mylock);
if (digitalRead(PIN_ECHO_B2))
{
B2PulseStart = micros();
}
else
{
d_b2 = (micros() - B2PulseStart) / PULSE_TO_CM;
}
}
The interrupt is attached:
attachInterrupt(digitalPinToInterrupt(PIN_ECHO_B2), ISR_USreadB2, CHANGE);
I know micros() doesn't work great inside of interrupts but it seems to be working decently when I tested outside of ROS.
I am running:
ROS Kinetic
Ubuntu 16.04
The code is running on a Teensy 3.5
↧
Issue in communicating with multiple robots using rosserial_xbee
Hi,
I have 10 robots - all with an xbee end device and an xbee coordinator to which they all connect. I calculate velocity commands for each of the robots and publish the cmd_vel to 10 different topics, 1 for each robot to which they subscribe. This seems to be overloading the communication resulting in delayed command reception/ packet drop. Are there ros_messages that I can use where only one publisher can publish all the velocity commands for all the bots on one topic to which all the robots subscribe and receive the commands?
↧
↧
Connection lost for only a few devices, when connecting multiple devices in a rosserial_xbee network
I have a xbee network of about 8-9 robots with xbee devices and I notice that whenever i use`rosrun rosserial_xbee xbee_network.py /dev/ttyUSB* 1 2 3 4 5 6 7 8 9` and so on, to establish the network, last 1 or 2 robots always fail to join with the error `[ERROR] [1538767384.068548]: Lost sync with device, restarting...`. When the robots are restarted or the xbee network is reset, then all the connections eventually are successful, but it still takes a couple of trials [(on/off) of robots and xbee coordinator]. Why should this be happening? How to ensure that they dont drop out of network while I am communicating with them?
Now, I have read up that the rosserial_xbee errors are usually extremely generic, but how do I ensure a reliable network with about 15-20 xbee end devices?
↧
Slower execution speed leading to Lost Sync With Device in STM32F103
Using the rosserial_stm32(https://github.com/yoneken/rosserial_stm32) library, I am trying to publishing a message(std_msgs/UInt32) on the /chatter topic at a rate of 5Hz. The message gets published at a rate 20% lower as seen from the screenshot below. When estimating the time of execution, I found the time taken for each loop to be around 236ms which is roughly 4.2Hz.


I am also getting a Lost Sync with Device error very frequently (once every 2 minutes) as the code hangs. Any pointers to solutions? Thanks!
↧
ROS, MBED and ethernet
Hey everyone
I want to use an MBED board (NUCLEO-F767ZI) to connect to ROS via Ethernet and not serial
So far can't find anyone who has done that successfully, so if you have done it and can show a way that'd be great
Regards,
↧
ROSserial Arduino Subcriber function is not run after adding Publisher
I use an Arduino Uno for debugging purposes of the issue below.
The function that is run for one of the subscribers (cb_drive) is not ran/called.
I have removed lines of code until the function worked once more.
The code below works. As soon as I send some (empty) message to mule_005_commands_drive, the led on pin 13 turns on.
#include
#include
#include
// Read commands drive message
void cb_drive(const sensor_msgs::JointState &cmd_drive)
{
digitalWrite(13,HIGH);
}
ros::NodeHandle nh;
diagnostic_msgs::DiagnosticStatus diagnostics_emergency_brake;
// Publishers
ros::Publisher mule_005_diagnostics_emergency_brake("mule_005_diagnostics_emergency_brake", &diagnostics_emergency_brake);
// Subscribers
ros::Subscriber mule_005_commands_drive("mule_005_commands_drive", &cb_drive);
In tab e_setup
void setup()
{
nh.initNode();
// Setup sensor feedback publisher
nh.advertise(mule_005_diagnostics_emergency_brake);
//Setup subscribers
nh.subscribe(mule_005_commands_drive);
pinMode(13, OUTPUT);
}
In tab f_loop
void loop()
{
diagnostics_emergency_brake.level = byte(0);
diagnostics_emergency_brake.name = "Safety PLC status";
diagnostics_emergency_brake.message = "Ok";
diagnostics_emergency_brake.hardware_id = "Siemens Logo Safety PLC ";
mule_005_diagnostics_emergency_brake.publish(&diagnostics_emergency_brake);
nh.spinOnce();
}
If I add another publisher, the led stays off when I send a command to mule_005_commands_drive. I believe that this implies that the code within cb_drive is not run. Can someone help me out? I don't understand what causes this behaviour.
#include
#include
#include
// Read commands drive message
void cb_drive(const sensor_msgs::JointState &cmd_drive)
{
digitalWrite(13,HIGH);
}
ros::NodeHandle nh;
diagnostic_msgs::DiagnosticStatus diagnostics_emergency_brake;
diagnostic_msgs::DiagnosticStatus diagnostics_parking_brake;
// Publishers
ros::Publisher mule_005_diagnostics_emergency_brake("mule_005_diagnostics_emergency_brake", &diagnostics_emergency_brake);
ros::Publisher mule_005_diagnostics_parking_brake("mule_005_diagnostics_parking_brake", &diagnostics_parking_brake);
// Subscribers
ros::Subscriber mule_005_commands_drive("mule_005_commands_drive", &cb_drive);
In tab e_setup
void setup()
{
nh.initNode();
// Setup sensor feedback publisher
nh.advertise(mule_005_diagnostics_emergency_brake);
nh.advertise(mule_005_diagnostics_parking_brake);
//Setup subscribers
nh.subscribe(mule_005_commands_drive);
pinMode(13, OUTPUT);
}
In tab f_loop
void loop()
{
diagnostics_emergency_brake.level = byte(0);
diagnostics_emergency_brake.name = "Safety PLC status";
diagnostics_emergency_brake.message = "Ok";
diagnostics_emergency_brake.hardware_id = "Siemens Logo Safety PLC ";
mule_005_diagnostics_emergency_brake.publish(&diagnostics_emergency_brake);
diagnostics_parking_brake.level = byte(0);
diagnostics_parking_brake.name = "Motor Brake status";
diagnostics_parking_brake.message = "Brake status unknown";
diagnostics_parking_brake.hardware_id = "DC Motor brakes";
mule_005_diagnostics_parking_brake.publish(&diagnostics_parking_brake);
nh.spinOnce();
}
↧
↧
rosserial tivac tutorials rgb srv
Hello,
I am following the tutorial on http://wiki.ros.org/rosserial_tivac/Tutorials/RGB%20srv
I am sure that my tool chain works, as I am able to run the tutorial on http://wiki.ros.org/rosserial_tivac/Tutorials/Hello%20World with success.
For the rgv srv, I get no errors, and able to flash my Tiva-C board with:
~/catkin_ws$ catkin_make rosserial_tivac_tutorials_rgb_srv_flash
however, as I run rosserial node, I get the following error:
[ERROR] [1539545853.975630]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
as a result rosserial is unable to register the service.
I have googled errors on similar subjects, and most people had problems with generating the messages, I have succeeded in this part, and the program compiles and is sent to the tiva-c successfully.
I am suspecting rosserial needs the generated messages in python as well in order to operate.
Any ideas/recomendations/help are greatly apreciated.
Best Regards,
-C.
↧
Problem with rosserial arduino and python serial
I'm using ROS Kinetic on an ErleBrain3 trying to connect it with an Arduino UNO. I'm trying to follow the rosserial tutorials but after running: rosrun rosserial_python serial_node.py /dev/ttyUSB0 I get the following error:
[INFO] [WallTime: 1539967951.033639] ROS Serial Python Node
[INFO] [WallTime: 1539967951.062010] Connecting to /dev/ttyACM0 at 9600 baud
Traceback (most recent call last):
File "/home/erle/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 88, in
client = SerialClient(port_name, baud, fix_pyserial_for_test=fix_pyserial_for_test)
File "/home/erle/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 358, in __init__
self.port = Serial(port, baud, timeout=self.timeout, write_timeout=10)
TypeError: __init__() got an unexpected keyword argument 'write_timeout'
I have the 2.7 python serial package which I think is the recommended for these tutorials. I'm very new to ROS and Linux please give me easy to understand answers. Thank you!
↧
Rosserial Arduino Proper Use Of Float32MultiArray
Hi I am struggling for a week for the proper use of Float32MultiArray. I am using an Arduino mega and I have an IMU which sends the data over Serial2 for yaw, pitch and roll data.
I tested the IMU code and it is working well. Then I tried to publish the data to ROS using Float32MultiArray and that's where the problem comes in.
With the below code, I can see the IMU data is reading but the "/imu_ypr" topic is not published.
If I comment out the "imu_ypr_msg" layout code, I can see the topic "/imu_ypr" using "rostopic list" but the IMU is not reading the data. I guess it is something related to the memory allocation but I cannot figure it out. Any help is appreciated! Thanks!
#include
#include
#include
#include
float yaw = 0;
float pitch = 0;
float roll = 0;
int index = 0;
int temp;
byte data;
byte imu_buffer[20];
ros::NodeHandle nh;
std_msgs::Float32MultiArray imu_ypr_msg;
ros::Publisher pub_imu_ypr("imu_ypr", &imu_ypr_msg);
void setup() {
// put your setup code here, to run once:
nh.initNode();
imu_setup();
/*imu_ypr_msg.layout.dim_length = 1;
imu_ypr_msg.layout.dim[0].label = "imu";
imu_ypr_msg.layout.dim[0].size = 3;
imu_ypr_msg.layout.dim[0].stride = 3;
imu_ypr_msg.layout.data_offset = 0;
imu_ypr_msg.layout.dim = (std_msgs::MultiArrayDimension *)malloc(sizeof(std_msgs::MultiArrayDimension) * 2); */
imu_ypr_msg.data_length = 3;
imu_ypr_msg.data = (float *)malloc((sizeof(float))*imu_ypr_msg.data_length * 2);
nh.advertise(pub_imu_ypr);
}
void loop() {
// put your main code here, to run repeatedly:
imu_check();
imu_ypr_msg.data[0] = yaw;
imu_ypr_msg.data[1] = pitch;
imu_ypr_msg.data[2] = roll;
pub_imu_ypr.publish(&imu_ypr_msg);
nh.spinOnce();
}
void imu_setup() {
Serial2.begin(115200);
}
void imu_check() {
if(Serial2.available() > 0) {
//data = imuSerial.read();
data = Serial2.read();
if(data == 0xA5) {
index = 0;
imu_buffer[index++] = data;
} else if(index==1 && data==0x5A) {
imu_buffer[index++] = data;
} else if(index==2 && data==0x12) {
imu_buffer[index++] = data;
} else if(index==3 && data==0xA1) {
imu_buffer[index++] = data;
} else if(index >= 4) {
imu_buffer[index++] = data;
}
if(index > 9) {
nh.loginfo("IMU data found");
temp = 0;
temp = imu_buffer[4];
temp <<= 8;
temp |= imu_buffer[5];
if(temp & 0x8000) {
temp = 0 - (temp & 0x7fff);
} else {
temp = (temp & 0x7fff);
}
yaw = (float)temp / 10.0f;
temp = 0;
temp = imu_buffer[6];
temp <<= 8;
temp |= imu_buffer[7];
if(temp & 0x8000) {
temp = 0 - (temp & 0x7fff);
} else {
temp = (temp & 0x7fff);
}
pitch = (float)temp / 10.0f;
temp = 0;
temp = imu_buffer[8];
temp <<= 8;
temp |= imu_buffer[9];
if(temp & 0x8000) {
temp = 0 - (temp & 0x7fff);
} else {
temp = (temp & 0x7fff);
}
roll = (float)temp / 10.0f;
index = 0;
/*
Serial.print("yaw: ");
Serial.print(yaw);
Serial.print(" pitch: ");
Serial.print(pitch);
Serial.print(" roll: ");
Serial.println(roll);
*/
}
}
}
↧