It looks like you are adding a constant for noise, so it makes sense the envelope output is a constant offset from the clean. I would think you need to add gaussian noise to simulate more realistic noise. Guassian noise would be centered around the clean signal.
I'm not sure if this helps or not, but Discovery models manufactured before November 2005 do not contain the entirety of the SCI set. For more information on this, see the first paragraph of the SCI specification for Discovery Series. It is possible that your robot is one of the unlucky ones. Unfortunately, I'm not aware that the OSMO upgrade modules for ...
I don't have time to do a full code review here, but the short version of why you're getting the error is that, as the error states, you're trying to remove an element from queue that either wasn't added or was already removed.
I don't think your code is doing what you think it's doing, so I would highly suggest you attach a debugger and step through your ...
I'm not sure if/how pyserial works with a bytearray, but the way it is typically done is with the struct library. Here is some sample code:
ser = serial.Serial("/dev/ttyUSB0", 57600)
# compute left and right wheel velocities
right_vel = int(velocity + (rotation/2))
left_vel = int(velocity - (rotation/2))
cmd = struct....