Hi Michael,
If you’re getting the message:
Requirement already satisfied: pyserial in /usr/lib/python2.7/dist-packages
Everything seems to be ok. If you’re talking about [this] (http://wiki.ros.org/roslib) ros_lib for CORE2, we do not use it at all. If you meant some other library please let me know which one.
The default name of CORE2 device connected by rpi connector is /dev/ttyCORE2
so you can try this code to launch it on your CORE2-ROS:
<launch>
<node pkg="rosserial_python" type="serial_node.py" name="robby_node">
<param name="port" value="/dev/ttyCORE2" />
<param name="baud" value="500000" />
</node>
</launch>
Regards,
Hubert.
Hi Hubert
thanks for your suggestion, but unfortunately it does not work;
PARAMETERS
- /robby_node/baud: 500000
- /robby_node/motorLeftFactor: 300
- /robby_node/motorRightFactor: 300
- /robby_node/port: /dev/ttyCORE2
- /rosdistro: kinetic
- /rosversion: 1.12.13
NODES
/
robby_node (rosserial_python/serial_node.py)
ROS_MASTER_URI=http://localhost:11311
process[robby_node-1]: started with pid [5461]
[ERROR] [1523906098.613524]: Error opening serial: [Errno 2] could not open port /dev/ttyCORE2: [Errno 2] >No such file or directory: ‘/dev/ttyCORE2’
[robby_node-1] process has finished cleanly
log file: /home/husarion/.ros/log/5d22e58e-3f4c-11e8-8b36-b827eb5b9192/robby_node-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor…
… shutting down processing monitor complete
done
My SBC is a RPi.
Michael
Hi Michael.
It looks like you don’t have installed pkg for communication with CORE2. You can check it by typing:
apt-cache policy husarion-sdk
Normally the result should look like this
husarion-sdk:
Installed: 2017.11.24.1
Candidate: 2017.11.24.1
Version table:
*** 2017.11.24.1 500
500 https://files.husarion.com/repo xenial/main armhf Packages
100 /var/lib/dpkg/status
1.4.3 500
500 https://files.husarion.com/repo xenial/main armhf Packages
If I’m right you will get:
husarion-sdk:
Installed: (none)
Candidate: 2017.11.24.1
Version table:
2017.11.24.1 500
500 https://files.husarion.com/repo xenial/main armhf Packages
1.4.3 500
500 https://files.husarion.com/repo xenial/main armhf Packages
Install it typing:
sudo apt-get install husarion-sdk
Now try to run the same launch file as earlier. Let me know if this has fixed your problem
Regards,
Hubert.
Hi Hubert
unfortunately I get the first output. So it seems that the Husarion SDK is installed.
The install results in “nothing to install”.
Do you have any other ideas ?
Michael
Hi Michael.
Show me please results of:
ls /dev/tty* -l
Maybe you don’t have ttyCORE2 in your device list.
Yes, I have another way but it’s quite brutal way. You can download new image from our website and try one more time install rosserial_python and pyserial. For now I don’t have any others idea. I will have to investigate it a little bit more.
Regards,
Hubert.
Hi Hubert
there are tty, than tty0 to tty63, ttyAMA0, ttyS0, ttyprintk, but no ttyCORE2.
Is there a way to get ttyCORE2 in my device list?
Downloading and flashing is also an option, but than I have to think about saving my changes and configurations.
But: As I wrote before, the communication in general works. It just dies after a few seconds …
Michael
Hi Michael.
So now we know what the problem is.
As you mentioned, it might have been some changes in configuration that could have caused RPi not seeing CORE2 properly. As we don’t know what exactly caused the issue, please try to complete the confirguration with a fresh image from here. If you don’t want to lose your data, you can use another SD card to check if this works.
Regards,
Hubert.
Hi Hubert
I flashed a new SD card with this image. After that the ttyCORE2 device was available.
Did connect an ethernet cable and than a sudo apt-get update and sudo apt-get dist-upgrade which did a lot of updates.
After that ttyCORE2 was available.
Did “systemctl disable husarion-shield” like mentioned here because I want to work without cloud. But when I try to start “roscore” I get a message something like “Could not connect to master” (I am not in front of my Core2-ROS, so the message is not exact).
What is going wrong now? The Core2 is waiting for connection (bland and yellow leds are blinking).
Michael
Hi Michael.
Now we are sure that lack of the port was caused by some software changes that you implemented.
Message you mentioned probably say:
WARNING: ROS_MASTER_URI [http://master:11311] host is not set to this machine
Normaly it means that your CORE2-ROS is in Husarnet network and you have chosen another device as ROS master, but in this case it’s probably because CORE2-ROS is in the configuration mode. You have to connect it to Husarion Cloud just once with the new SD card. After that you can disable husarion-shield and remove device from Husarion Cloud.
Regards,
Hubert.
Hi Hubert
I made some additional findings.
It seems that /dev/ttyCORE2 is only available in the cloud mode. If I disable the husarion-shield (systemctl disable husarion-shield
) ttyCORE2 disappears after a reboot. After enabling it again (systemctl enable husarion-shield
)(and a reboot) it appears again.
So it seems ttyCORE2 is only available when I am connected to the cloud. But this is not what I want. If I am working offline (without cloud) I have to obviously use /dev/serial0.
Unfortunately this leads again to my original question:
Why is the communication between Core2 and RPi very instable and what can I do against it?
In the current state the Core2-ROS is not usable!
Michael
Hi Michael
It seems that you have everything configured correctly.
Could you post here your code for CORE2?
Do you have any other nodes or applications running on RPi while the problem occurs?
I could set up the same configuration as yours and try to figure out what causes problem.
Regards,
Łukasz
Hi Łukasz
I tried several progams on Core2. Among others the example from ROS tutorial 3. The effect is always the same. The program on Core2 runs but the ros_serial stops working after a while.
On RPi the desktop is running (remote connection via RDP). Also a Teleop node, of course roscore. I think the problem occurs when I start a "rostopic echo " command. So maybe the problem is in the communication between Core2 and RPi. As mentioned before I am working without cloud.
Michael
Hi Michael,
Code for CORE2 needs a little modifications to work without cloud.
Beginning with code from tutorial 3, I commented out line 2:
//#include "hCloudClient.h"
and lines 88, 89 (begginig of hMain() function):
//platform.begin(&RPi);
//nh.getHardware()->initWithDevice(&platform.LocalSerial);
Then after line 89, I added:
nh.getHardware()->initWithDevice(&RPi);
Without these modifications errors with connection setup will occur.
Then I started serial bridge with command:
/opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyS1
You may need to use:
/opt/husarion/tools/rpi-linux/ros-core2-client /dev/serial0
The difference is because you are working on Raspberry and I was testing on TinkerBoard.
During my tests I had husarion-shield disabled and uploaded program on CORE2 by VSCode and USB cable.
I was working on fresh image with all updates installed (sudo apt update; sudo apt upgrade
). The only modifications are mentioned above.
Regards,
Łukasz
Hi Łukasz
thanks for your answer. I did these changes regarding to a further answer from your collegue in the forum.
The remaining difference is that I started roslaunch with the following node:
<node pkg="rosserial_python" type="serial_node.py" name="robby_node">
<param name="port" value="/dev/serial0" />
<param name="baud" value="500000" />
</node>
instead of ros-core2-client
. I will try this later.
Can I use ros-core2-client
also with roslaunch? If yes, how?
Michael
Hi Michael,
You can use ros-core2-client
with roslaunch, but it requires a bit of workaround.
Create a bash script containing:
#!/bin/bash
/opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyS1
Save it as bridge.sh
in a new package (eg. serial_bridge
) in folder scripts
.
Add execution permissions to script:
chmod a+x bridge.sh
Your launch file should be like:
<launch>
<node pkg="serial_bridge" type="bridge.sh" name="bridge" output="screen"/>
</launch>
Łukasz
This works in general, thanks. But unfortunatly it does not solve my problem. I get the following error messages (after a lot of “wrong checksum for topic id and msg”, “wrong checksum for msg length, length 56” messages.
[INFO] [1525967645.162604]: Protocol version of client is unrecognized, expected Rev 1 (rosserial 0.5+)
[INFO] [1525967645.525580]: wrong checksum for topic id and msg
[ERROR] [1525967645.529966]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client
[INFO] [1525967645.534823]: Protocol version of client is unrecognized, expected Rev 1 (rosserial 0.5+)
Traceback (most recent call last):
File "/opt/husarion/tools/rpi-linux/ros-core2-client", line 89, in <module>
client.run()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosserial_python/SerialClient.py", line 504, in run
self.callbacks[topic_id](msg)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosserial_python/SerialClient.py", line 107, in handlePacket
m.deserialize(data)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/geometry_msgs/msg/_PoseStamped.py", line 142, in deserialize
raise genpy.DeserializationError(e) #most likely buffer underfill
genpy.message.DeserializationError: unpack requires a string argument of length 56
I show the pose message with rostopic echo pose in another terminal window.
After increasing the delay to 50 milliseconds it seems to work better which means it does not stop after ~1000 msgs but after ~10000.
Michael
Hi Michael,
I made some additional tests to reproduce your error. It turns out, that problem is not caused by your software - serial connection errors are caused by the way RPi is handling communication with its subsystems.
If CPU, GPU and WiFi are stressed to their maximum performance - serial connection will break within few seconds.
On the other hand, when CPU or GPU are almost unused, serial communication will work for hours without single warning.
RDP connection bring enough load to occasionally break serial, especially when moving windows or opening new apps.
Tests were also conducted on RPi with Ubuntu Mate and clean ROS installation, errors also exists.
The same tests on TinkerBoard resulted with no warnings regardless of device load.
The best solution would be to switch your SBC to TinkeBoard.
You can also connect to RPi remotely through SSH or use HDMI cable if you want graphical interface. Just keep in mind, that if you encounter serial errors, some computations should be moved to other device, e.g desktop computer.
Regards,
Łukasz
Hi Łukasz
That sounds not so good.
I searched a little bit in Web around Raspi serial communication problems and found some hints (e.g. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=165897 and http://www.ryanmartinphd.com/enable-serial-port-on-raspbian-jessie/ but they did not help.
Is there a way to reduce the baudrate or to enable serial handshake?
In theory every Raspi used together with Rosserial should have such problems.
Michael
Hi Łukasz
Again the question whether it is possible to reduce the baudrate or enable some handshaking to make the serial communication more robust.
Also I wonder if others have the same problems with the Raspberry.
Nevertheless I found the rosmon package, which was similar to roslaunch but is able to restart a node automatically in case of error. Maybe this helps others.
Michael
1 Like
Hi Michael
It s possible to reduce baudrate,
On Core2 add line:
RPi.setBaudrate(57600);
before:
nh.getHardware()->initWithDevice(&RPi);
Then launch rosserial with:
/opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyS1 _baud:=57600
Regards
Łukasz