RAZOR IMU interface for Pypot

I finally wrote a class to manage the RAZOR IMU. I inherited the Razor from a Thread.
@Pierre I wanted to inherit from a Sensor class but in fact, I should instanciate a razor class inside a razorSensor class inherited from a Sensor class ? (to make it as clean as possible)
The functions are:

  • The COM port is automatically detected (I use pypot)
  • The module can get the Euler angles (in aeronautical convention)
  • but it can also return the acceleration seen by accelero, the gyro and the compass component

An example is

import razor
r = razor.Razor()
r.start()

print r.eul
print r.acc
print r.gyr
print r.mag

r.stop()

If any issueā€¦ knock me.

Here is the code :

2 Likes

Hi @Thot,

Nice! This will be a good extra feature!

  1. So first as a general comment, you should directly open a pull request this make commenting, improving and collaborating on code soon much easier :smile: Plus it also keeps track of the history of modification! You can open pull request as soon as you propose a new idea and not only when all the code is clean.

  2. Then, I think you should not always use auto-detection but rather make it possible for users. Iā€™m saying that because you have to open all port and send message. Depending on whatā€™s on the other bus this could go wrong :wink:

  3. Finally for this sensor architecture, Iā€™ll make it clearer while Iā€™m adding a camera sensor, qrcode detectionā€¦ Iā€™ll try to see how your Razor class can fit into that and propose you a solution. (Yours is pretty good, but defining it as a sensor will automatically make it available through the REST API and this kind of thingsā€¦)

Cheers!

Ok, thanks, I am not yet friendly with git but I progress as I use it :wink:

Hello @Pierre ,

I would like to know if the Razor class created by @Thot is already available as a sensor class to be used through REST API. Thanks

Not yet. @Thot, any progress on this?

I am not yet ready.
The big issue is that the connection is not possible every 4 timesā€¦ It would be useful to have the name of the ports taken by the pypot robot instanciation.
The serial port are not easy to manage with reliabilityā€¦

Yep thatā€™s a good idea! So I just add it:

You can used it like this:


from pypot.dynamixel import DxlIO

io1 = DxlIO('/dev/ttyUSB0')
io2 = DxlIO('/dev/ttyACM0')

print DxlIO.get_used_ports()
>>> ['/dev/ttyACM0', '/dev/ttyUSB0']

I also add an extra argument to the get_available_ports so you can now get only the ā€œfreeā€ ones:


from pypot.dynamixel import get_available_ports

print get_available_ports()
>>> ['/dev/ttyACM0', '/dev/ttyUSB0', '/dev/ttyUSB1']

print get_available_ports(only_free=True)
>>> ['/dev/ttyUSB1']
2 Likes

Iā€™m trying to have this razor work, too.

With a timeout of 3 seconds, it works very well on my computer (ubuntu 14.04).
But on Poppyā€¦ nothing. I oppened the head and removed the USB2AX to test, still nothing.
Any idea, suggestion ?

(Iā€™m using this file https://github.com/HumaRobotics/poppy-walk/blob/master/sensors/razor.py which is pretty much the same as Thomas linked above)

What do you say about ā€œnothingā€? Can you connect to the RAZOR ? The serial port is open ?
Or the output value is always equal to zero ?
I advise you to open the serial port in an ipython console so that you can play with it.
There is somethink to know about RAZOR, when you read a line, the first line is very long with a lot of ā€œzeroā€ characters. That is why I use the ā€œstripā€ method to remove these.

Using your code, I got ā€˜no razor connectedā€™ each time and empty communication (or maybe only zeros as your code strips zeros right away).

But now I have a clean install and I got it to workā€¦

Hello,

Here is my code for Razor: razor.txt (5.4 KB) (itā€™s a python file renamed to be uploaded, with a main function so you can use it alone).

If someone (@Thot ?) could test it, I will then make a pull request to integrate it to pypot.

I tested it in Windows and in ODROID. It works very well. Very nice idea about starting by the end :wink:

Hello,
This is a version that integrate get_available_ports(only_free=True) and a filter for some extraneous characters with ordinal > 127 when I read my captor
razor.py (3.4 KB)

1 Like

Hello @Thot
I would like to know if there have been any advances in the question made by @JuanMiguel, are we capable of having a sensor class that could be used through the REST API?

To manage the razor sensor, we did this class but it is not yet inherited from sensor class.