Skip to content
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

Roll, pitch and yaw sliders in GUI have no effect #19

Closed
spl237 opened this issue May 26, 2017 · 5 comments
Closed

Roll, pitch and yaw sliders in GUI have no effect #19

spl237 opened this issue May 26, 2017 · 5 comments
Labels
Milestone

Comments

@spl237
Copy link
Contributor

spl237 commented May 26, 2017

My reading of the code is that the roll, pitch and yaw sliders should change values in /dev/shm/rpi-sense-emu-imu, specifically the last three pairs of bytes in the file.

Moving the sliders has no effect on these bytes; they stay at zero no matter what the sliders are set to.

The effect of this can be seen in the python code:

from sense_emu import SenseHat
sense = SenseHat()
while True:
  orient = sense.get_orientation()
  print (orient['pitch'])

If this code is run and the pitch slider is moved, the value on the console never changes from 0.0.

Running the same code with e.g. sense.get_temperature() shows the temperature value changing as expected with the slider; it only seems to be the roll, pitch and yaw sliders which have no effect.

@spl237
Copy link
Contributor Author

spl237 commented May 26, 2017

Further investigation suggests that the problem is in imu.py, in the function set_orientation - this reads

    def set_orientation(self, orientation, position=None):
        assert self.simulate_world
        if position is None:
            position = O
        self._orientation = V(*orientation)
        self._position = V(*position)

If I change assert self.simulate_world to assert not self.simulate_world, and add the line self._world_write(timestamp()) at the end of the function, as other similar functions have, the code behaves as expected and values update correctly.

@waveform80
Copy link
Contributor

Weird - with a checkout from the v1.0 tag, I can't reproduce, but I can with the released version. Not sure what's going on there (whether the version in the Raspbian repos was built from an earlier commit - the v1.0 tag is slightly after where I committed the bump in changelog). Anyway, it seems to be fixed in master and it's about time I did a release anyway to get the resizing version out there (was hoping to get time to add fuzzing to the orientation emulation, but that's not happened yet), so I'll get that done shortly.

@waveform80
Copy link
Contributor

Ah, slightly more complex than I thought: depends on the state of the IMU simulation. If perturbed emulation is enabled ("Simulate ... Internal measurement unit" in preferences) then it works, otherwise it fails - that's why it appears to work in some cases but not others (also because the default for the preferences is hardware dependent). Don't think the fix is too complex though - should have it sorted out shortly.

@spl237
Copy link
Contributor Author

spl237 commented Jul 5, 2018

Has anything happened on this? It's over a year since I reported it, and a year and a half since the last commit to this repo, so I'm guessing not? Could we please have a fix asap? We are in the process of preparing documentation for this application, and the fact that it doesn't work properly will become obvious!

@bennuttall
Copy link

I've spoken to @waveform80 about this and he's going to try to fix it shortly:

(12:42:55) waveform: ah, that's why I didn't push it. It only solves part of the problem; when simulation is disabled it allows the sliders to control orientation but the derived gyro and accelerometer readings are still zero (because the world simulation thread is the bit that calculates those, and it's not running)
(12:43:53) ben_nuttall: right. what's the fix?
(12:44:48) waveform: just thinking - there's a reason I didn't do the "simple" thing and just have it update the gyro and accel readings on every move of the sliders; that's because that winds up being ridiculously heavy (CPU wise) on the A+ and Zero which are exactly the platforms on which simulation is disabled by default
(12:45:02) ben_nuttall: ok
(12:45:30) waveform: rather the calculations need to be split out of the simulation thread into a separate method, then some logic added to update the gyro and accel readings from the sliders if and only if some timer has elapsed since the last calculation
(12:46:14) waveform: it's not actually that difficult if you know your way around the code - I can probably get it done soon
(12:46:45) ben_nuttall: ok great
(12:47:15) waveform: and there's several new bits that really need releasing anyway (since the last release, I corrected the gamma output so the display emulation is much more realistic, and improved the rendering logic for resized windows)

@waveform80 waveform80 added this to the v1.1 milestone Jul 6, 2018
@waveform80 waveform80 added the bug label Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants