The answers to your questions:
-
During "normal" operation i control the cart using a bldc motor, controlled by an odrive, that operates with a triple PID cascade at 8khz
However during testing i move the cart by hand, since I wanted to isolate the problem source.
I want the sensors to be accurate also when there is some unexpected behavior from the actuation side. -
the touch sensors are Left and Right "track limit" sensors and basically are just some pulled-down switches, and are therefor really bouncy.
-
The accurate count of the pulses is so important because they are the basis of the angle and position(also velocity for both dimensions) calculations made on the raspberry pi. So for instance if the angle pulses are lost, the simulation and therefore the controller might think that the upright position of the pendulum is achieved before having reached the upright position on the physical system. Please remember I initialize the pulse counting at the bottom stable position of the pendulum. If initially (for example) 10 pulses are counted to achieve the upper stable position on the physical system, after a loss of pulses during operation the angle of the physical system is not discretized by the pulses correctly, meaning that for instance the teensy only counted 9 pulses during the same travel to the upright position, leading to a false representation in simulation and the controller receiving garbage values. This is particularly bad if I want to train RL agents on this system, since collected data on such a system would not be necessarily markovian, and moreover would not mirror the physical world.
-
No I am not sure if serial communication does not block my code. In fact that is one of my former questions, since I am not that familiar with the Arduino libraries.
In fact it might be a good idea to send serial data on a fixed schedule. Any ideas on how to implement that nicely on the arduino, are there any good libraries for that?
As mentioned already my information flow is as follows:
physical System -> Arduino sends serial packages -> raspberry pi listens to packages -> publishes data at 10Hz on redis inmemory server-> calculates control -> sends actuation at 20hz
At the moment I am sending "action data" to the odrive through PWM which has a max frequency of 20 hz. that is the only bottleneck at the moment. I guess also the serial chip on the raspberry pi could represent a bottleneck in the future, because i will send "actuation" via another communication method.
Any suggestions ?
thanks in advance