-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AbsoluteIMU ev3dev2 #650
Comments
Can you share the code of what you have tried so far? |
the set_device and sensor always returns an error, I do not have access to the ev3 at this current time so I cannot send the error. |
Try adding a delay after setting the device before creating the sensor object. It takes some time for it to get set up in the kernel. |
I have tried that, it doesn't appear to work even after 5 minutes (I tried doing it through SSH too) |
one second should be more than enough |
I just noticed that you are putting the port in |
And actually this sensor should be automatically detected, so you shouldn't have to mess with the port at all |
Does the sensor show up in the Device Browser on the brick? |
Yes |
The default address is 1, so |
Alright, I got it working. Is there any way to read out each different value at the same time without having to change its mode? also is there any documentation for this specifically |
It looks like there is an |
You will probably have to read Totally untested, but hopefully close... import struct
...
(x_tilt, y_tilt, z_tilt, x_accel, y_accel, z_accel, compass, x_mag, y_mag, z_mag,
x_gyro, y_gyro, z_gyro) = struct.unpack('bbb<h<h<h<h<h<h<h<h<h<h', abs.bin_data) It is also possible to use https://docs.python.org/3.5/library/struct.html#struct-format-strings |
|
This code works assuming that the gyro is plugged into in2, it can easily be changed to work for any other port absport = LegoPort(address='ev3-ports:in2')
absport.mode = 'nxt-i2c'
abs = Sensor('ev3-ports:in2:i2c17') This should setup the sensor and allow it to be accessed, the Sensor class needs to be imported from sensor.lego to use the gyro you must set the mode you want and then call the value To find the mode/value you can find information here: abs.mode = "TILT"
print(abs.value(0)) |
Thanks @1StormDragon! That works perfectly. |
I'm essentially doing what you're describing above - I'm ok running it in "tilt mode" but whenever I try running it in "ALL" mode, which is what I need for my application, then I get all zeros from the bin_data. Flip it to "TILT" mode, and I get my readings... any clue? |
in fact, after thinking things a bit, I suspect there being something to do with the driver. The TILT, GYRO, etc. modes can all be read independently so it's got to have something to do with the driver level at the OS (since the same problem can be seen from the OS :
Any pointer to the driver in the code I could take a look at? Or idea of what else to look for? |
This is wrong.
It looks like only the first few data values are non-zero, so maybe it is not possible to read everything at once? Possible workaround is to set the mode and read one value you need, the change the mode and read another value. It will be slightly slower, but it should work just fine. |
Agreed it looks wrong, but
and if I change the mode...
tadam. That's why I'm thinking it has nothing to do with Python in this case... |
Oops, I forgot to set the mode to |
The fact you are getting all 0s is strange because the driver doesn't actually do anything when you set the mode other than changing the register index and size of data that is being read. The Although I just realized that you are probably using BrickPi3, not EV3, so that is probably the issue. |
I am indeed using BrickPi3. Not sure how that can cause an issue. And 2 stacked boards... and 2 sensors. So I'll try removing one of the boards and go with a single sensor. Although both sensor read from "TILT" without any problem (although I'm not super impressed with the precision... my phone's level is way more precise). But that's a very different problem. What do you have to set, again, under /sys/class/lego-ports/port0/ so that this becomes a /sys/class/lego-sensor/.. ? I forget if/how this can be done directly at the command line versus in Python. |
For starters, since we have determined this is not a python problem, lets open a new issue at https://github.com/ev3dev/ev3dev/issues and continue the discussion there. |
Thanks, done (see here) |
Hello, I'm newbie with EV3DEV and I'm trying to make my absolute sensor working on my ev3. Traceback (most recent call last): Kernel 4.14.117-ev3dev-2.3.5-ev3 Can you help me please ? |
I am attempting to connect an AbsoluteIMU-ACG from mindsensors.com though ev3dev2-python
I have tried a few options but have not been able to figure it out, How would I get this connected and measure the values of it? Thanks.
The text was updated successfully, but these errors were encountered: