Problem to connect RPLIDAR A2

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

User avatar
esmetaman
Advanced Member
Posts: 358
Joined: Wed Sep 13, 2006 12:16 am
Location: UK, Milton Keynes
Contact:

Problem to connect RPLIDAR A2

Postby esmetaman » Mon Jul 31, 2017 9:20 pm

Hi @Andy,

I am trying to run the LIDAR sensor, RPLIDAR A2 on the EV3 Brick with LeJOS but although the electronic board is detected on the brick:

Image

https://www.slamtec.com/en/Lidar

Code: Select all

root@EV3:~/lejos/jni# lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 003: ID 0846:9030 NetGear, Inc.
Bus 001 Device 004: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x Composite Device
root@EV3:~/lejos/jni# cd /dev/


The system doesn´t detect the usb sensor:

Code: Select all

root@EV3:/dev# ls
block               lms_uart            mtd2ro              ptyp4               tty16               tty33               tty50               ttyS1
bus                 lms_ui              mtd3                ptyp5               tty17               tty34               tty51               ttyS2
char                loop0               mtd3ro              ptyp6               tty18               tty35               tty52               ttyp0
console             loop1               mtd4                ptyp7               tty19               tty36               tty53               ttyp1
cpu_dma_latency     loop2               mtd4ro              ram0                tty2                tty37               tty54               ttyp2
disk                loop3               mtdblock0           random              tty20               tty38               tty55               ttyp3
fb                  loop4               mtdblock1           root                tty21               tty39               tty56               ttyp4
fb0                 loop5               mtdblock2           rtc                 tty22               tty4                tty57               ttyp5
full                loop6               mtdblock3           rtc0                tty23               tty40               tty58               ttyp6
i2c-1               loop7               mtdblock4           shm                 tty24               tty41               tty59               ttyp7
initctl             mem                 network_latency     tty                 tty25               tty42               tty6                udev_network_queue
kmem                mmcblk0             network_throughput  tty0                tty26               tty43               tty60               urandom
kmsg                mmcblk0p1           null                tty1                tty27               tty44               tty61               vcs
lms_analog          mmcblk0p2           ptmx                tty10               tty28               tty45               tty62               vcs1
lms_dcm             mtd0                pts                 tty11               tty29               tty46               tty63               vcsa
lms_iic             mtd0ro              ptyp0               tty12               tty3                tty47               tty7                vcsa1
lms_motor           mtd1                ptyp1               tty13               tty30               tty48               tty8                watchdog
lms_pwm             mtd1ro              ptyp2               tty14               tty31               tty49               tty9                zero
lms_sound           mtd2                ptyp3               tty15               tty32               tty5                ttyS0


I think that it could be possible to run this library:
https://github.com/ev3dev-lang-java/RPLidar4J

on an EV3 Brick with LeJOS if the connection is possible. I think that RXTX is available for armel:

Code: Select all

robot@brick1:/usr/lib/jni$ scp -oKexAlgorithms=diffie-hellman-group1-sha1  *.so root@192.168.1.85:/home/root/lejos/jni
root@192.168.1.85's password:
librxtxI2C-2.2pre1.so                                                                                                                         100%   17KB  17.5KB/s   00:00   
librxtxI2C.so                                                                                                                                 100%   17KB  17.5KB/s   00:00   
librxtxParallel-2.2pre1.so                                                                                                                    100%   13KB  13.4KB/s   00:00   
librxtxParallel.so                                                                                                                            100%   13KB  13.4KB/s   00:00   
librxtxRS485-2.2pre1.so                                                                                                                       100%   17KB  17.5KB/s   00:00   
librxtxRS485.so                                                                                                                               100%   17KB  17.5KB/s   00:00   
librxtxRaw-2.2pre1.so                                                                                                                         100%   17KB  17.5KB/s   00:00   
librxtxRaw.so                                                                                                                                 100%   17KB  17.5KB/s   00:00   
librxtxSerial-2.2pre1.so                                                                                                                      100%   50KB  49.9KB/s   00:00   
librxtxSerial.so                                                                                                                              100%   50KB  49.9KB/s   00:00   


And besides with a simple modification on jrun script is possible to load new native user libraries compatible for armel:

Code: Select all

root@EV3:~/lejos/bin# cat jrun
#! /bin/sh
. /etc/default/lejos
export LD_LIBRARY_PATH=${LEJOS_HOME}/jni/:${LEJOS_HOME}/libjna/usr/lib/arm-linux-gnueabi/:${LEJOS_HOME}/libjna/usr/lib/jni/
classpath=${LEJOS_HOME}/lib/ev3classes.jar:${LEJOS_HOME}/lib/dbusjava.jar:${LEJOS_HOME}/lib/opencv-2411.jar:${LEJOS_HOME}/libjna/usr/share/java/jna.jar:.
if [ "$1" = "-cp" ]
then
        classpath="$2":$classpath
        shift 2
fi
exec ${LEJOS_HOME}/ejre*/bin/java -classpath $classpath $*


Do you think that it is possible to add some module to load the usb device in /dev like ttyUSB0?

Juan Antonio
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://ev3dev-lang-java.github.io/#/
https://github.com/jabrena/livingrobots

User avatar
gloomyandy
leJOS Team Member
Posts: 5898
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problem to connect RPLIDAR A2

Postby gloomyandy » Tue Aug 01, 2017 10:37 am

Why mess around using USB to serial conversion when the EV3 has perfectly good hardware UARTS? Just use one of those directly.

The leJOS kernel seems to have a driver for this device cp210x (but no idea if it will work with the one you have). To use it you would need to build a new kernel and configure the kernel for USB serial support and enable the cp210x support (probably as a module) then use that kernel and module instead of the standard leJOS version.

But as I said above why not avoid having all that extra hardware and the associated software overhead and simply talk directly from the EV3 to the device using the sensor port uart?
leJOS news https://lejosnews.wordpress.com/

User avatar
esmetaman
Advanced Member
Posts: 358
Joined: Wed Sep 13, 2006 12:16 am
Location: UK, Milton Keynes
Contact:

Re: Problem to connect RPLIDAR A2

Postby esmetaman » Tue Aug 01, 2017 6:18 pm

Hi Andy,

this kind of sensors are provided with a USB connection and the EV3 Brick has the support for USB, this is the reason.

With the previous explanation, I don´t know if is possible or not to enable a module with some terminal command or I have to wait for some change in the LeJOS image.

Juan Antonio
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://ev3dev-lang-java.github.io/#/
https://github.com/jabrena/livingrobots

User avatar
gloomyandy
leJOS Team Member
Posts: 5898
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problem to connect RPLIDAR A2

Postby gloomyandy » Tue Aug 01, 2017 8:10 pm

The actual device has a serial interface to it. The USB interface (the extra board they supply) is simply a USB to serial converter that can be used for systems (like a PC) that does not have a serial interface. Why use a USB hub and USB to serial converter when you can just talk directly to the device? Using a serial port is the same interface that they recommend when using an Arduino. Going via the EV3 serial port will have a much lower overhead than via USB. See the robo peak data sheets:
http://www.robopeak.net/data/doc/rplida ... b-enUS.pdf

As I've already said to enable support for the USB serial interface you will need to build a new kernel and module.
leJOS news https://lejosnews.wordpress.com/

User avatar
esmetaman
Advanced Member
Posts: 358
Joined: Wed Sep 13, 2006 12:16 am
Location: UK, Milton Keynes
Contact:

Re: Problem to connect RPLIDAR A2

Postby esmetaman » Tue Aug 01, 2017 9:00 pm

Hi Andy,

I think that the support for USB devices could be a good improvement for next release.

Meanwhile, if you help me with the schematic to create a custom EV3 Cable to connect with RPLIDAR, I could try to test using your approach but I think that in general, LeJOS distro should have compatibility for USB devices.

Give a pair of weeks and if you like, we could try to connect. It could be useful for ROS purposes.

Cheers
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://ev3dev-lang-java.github.io/#/
https://github.com/jabrena/livingrobots

User avatar
gloomyandy
leJOS Team Member
Posts: 5898
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problem to connect RPLIDAR A2

Postby gloomyandy » Tue Aug 01, 2017 9:58 pm

It really isn't hard to hook up a serial device. Take a look at the standard pin out for an EV3 cable the LEGO Hardware developers guide gives the details. All you need are gnd (pin 3), 5V (pin 4) UART RX (pin 5) and UART TX (pin 6). The device documentation should give you the details of how to connect these pins to the device itself (they should hook up in the same way as for an Arduino). But this is an expensive device if you are not confident about this kind of thing then don't try it. I really don't like trying to get hardware like this working unless it is my own. There is always the possibility of a problem. The same goes for the a kernel module for the USB device, without access to the hardware I'm not happy just building things and hoping it will work.

As to "compatibility for USB devices" there really is no such thing, you need to build and test the modules/drivers for each device, that is what I have done for current USB devices we support (Network and video devices along with USB hubs etc.). To do this you really need the hardware available.

To be honest I'm not really sure if it is worth trying to add support for expensive devices like this to leJOS, I suspect that there are very few people that will ever use them. I thought you had this working with ev3dev?
leJOS news https://lejosnews.wordpress.com/

User avatar
esmetaman
Advanced Member
Posts: 358
Joined: Wed Sep 13, 2006 12:16 am
Location: UK, Milton Keynes
Contact:

Re: Problem to connect RPLIDAR A2

Postby esmetaman » Wed Aug 02, 2017 6:32 am

Hi Andy,

As to "compatibility for USB devices" there really is no such thing, you need to build and test the modules/drivers for each device, that is what I have done for current USB devices we support (Network and video devices along with USB hubs etc.). To do this you really need the hardware available.


If you like, I could send my unit RPLIDAR A1, the protocol is the same than RPLIDAR A2.

Image

Both models run with the same java library so we could test remotely.
https://github.com/ev3dev-lang-java/RPLidar4J

To be honest I'm not really sure if it is worth trying to add support for expensive devices like this to leJOS, I suspect that there are very few people that will ever use them. I thought you had this working with ev3dev?


It worth, because although few people are working with this kind of devices now, this is the way for the near future. This year, more platforms started using this kind of sensors. Yes with EV3Dev and Java, I have this problem solved but I would like that more people would use this kind of devices on LeJOS ecosystem too. Besides, it is a good way to continue with your research with "Surveyor". In the article https://lejosnews.wordpress.com/2017/07/15/slam/, you commented that you used LidarLite v1, but newest versions doesn´t work nice. I think that the development of the support for:

- RPLIDAR A1
- RPLIDAR A2
- Scanse Sweep

Is good in general. We could develop the first and second model, in the future the third one. If you work in team, we could get that solution and continue with SLAM developments in parallel. In your case with the project that you are developing and in my case few ROS nodes for Java.
https://github.com/gloomyandy/surveyor
https://github.com/ev3dev-lang-java/ros/tree/develop

With this kind sensor running on LeJOS 0.9.2, we could open the way for new developments...

Cheers

Juan Antonio
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://ev3dev-lang-java.github.io/#/
https://github.com/jabrena/livingrobots


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest