问:
Optimal-time acceleration sequence of a line-following robot following a moving obstacle
Say we have a line-following robot that has a moving obstacle in front, that is a one-dimensional problem. The moving obstacle is defined by its initial state and a sequence of (longitudinal) acceleration changes (the acceleration function is piecewise constant). Let's say the robot can be controlled by specifying again a sequence of acceleration changes and its initial state. However, the robot has a maximum and minimum acceleration and a maximum and minimum velocity. How can I calculate the sequence of accelerations minimizing the time the robot needs to reach a goal. Note that the final velocity must not necessarily be zero.

Can you briefly explain how this problem can be addressed or point me to some references where an algorithm is described? Or point out closely related problems?

Furthermore, does the solution depend on the goal position or could the robot just brake as late as possible all the time (avoiding collisions) and still reach any goal in optimal time?

A more formal problem description:
Given the position of the obstacle $x_B(t) = x_{B,0} + \int_{t_0}^t v_B(t) dt$, and the velocity of the obstacle $v_B(t) = v_{B,0} + \int_{t_0}^t a_B(t) dt$, where $a_B$ is a known piecewise constant function:

$$a_B(t) = \begin{cases} a_{B,1} & \text{for } t_0 \leq t < t_1 \\
a_{B,2} & \text{for } t_1 \leq t < t_2 \\
\dots & \\
\end{cases}$$

and given the initial state of the line-follower $x_{A,0}, v_{A,0} \in \mathbb{R}$ we search for piecewise constant functions $a_A$, where $a_{min} \leq a_A(t) \leq a_{max}$, $v_{min} \leq v_A(t) \leq v_{max}$ and $x_A(t) \leq x_B(t)$ (collision freeness) holds at all times. Reasonable assumptions are e.g. $v_B(t) \geq 0$ and $x_{B,0} \geq x_{A,0}$. Among the feasible solutions I would like to pick those minimizing $\int_{t_0}^{\infty} x_B(t) - x_A(t) dt$ or a similar objective. Approximation algorithms are also ok.

Some numbers for those who would like a test input:
http://pastebin.com/iZsm2UhB

答:
Assuming constant accelerations, "stopping" (slowing) distance can be calculated with:

$$
x = x_0 + v_0 t + \frac{1}{2} a t^2 \\
$$

where $x_0$ is your initial position, $v_0$ is your initial speed, $a$ is your acceleration, and $t$ is time. Assuming you are trying to get from one constant speed to another constant speed, you can calculate the time required to achieve the speed change with:

$$
v = v_0 + a t \\
t = \frac{v - v_0}{a} \\
$$

You question isn't especially clear to me - do you know the moving obstacle's acceleration profile before the challenge starts? Do you program your line-following robot completely before the start of competition? (i.e., you don't just look at the distance between yourself and the obstacle?)

If you know and program everything in advance, then you should have your robot as close to the obstacle as possible any time the obstacle is about to have a positive acceleration and you should leave the correct "stopping" distance between yourself and the obstacle any time the obstacle is about to have a negative acceleration. You have to take the obstacle's slowing and accelerating distances into account as well.

I would start at the end - you know your speed ($0$) and position ($x_{\mbox{end}}$) at the end of the course, and you should be able to calculate the obstacle's position, speed, and acceleration at the end of the course as well, by using the speed and position equations together with the acceleration profile.

Assuming obstacle initial conditions of $x_0 = 0$ and $v_0 = 0$ at $t_0 = 0$, then you can calculate the speed and position after the first acceleration period:
$$
x_1 = x_0 + v_0 t + \frac{1}{2} a t^2 \\
x_1 = x_0 + v_0 (t_1 - t_0) + \frac{1}{2} a (t_1 - t_0)^2 \\
x_1 = 0 + 0 (t_1 - 0) + \frac{1}{2} a (t_1 - 0)^2 \\
\boxed{x_1 = \frac{1}{2} a (t_1)^2 \\}
$$

$$
v = v_0 + at \\
v = v_0 + a (t_1 - t_0) \\
v = 0 + a (t_1 - 0) \\
\boxed{v = a (t_1) \\}
$$

For each segment in the acceleration profile N, you can increment the speeds and positions:

$$
x_N = x_{N-1} + v_{N-1}(t_N - t_{N-1}) + \frac{1}{2} a_N (t_N - t_{N-1})^2 \\
v_N = v_{N-1} + a_N (t_N - t_{N-1}) \\
$$

Keep incrementing through the acceleration profile until $x_N >= x_{\mbox{end}}$.

Now, work backwards. This depends in part on the problem definition - you will reach the goal faster if you can "tag" the goal like a baseball player would "tag" home - running over it at full speed. However, you may need to stop at the goal in order to have "reached" the goal. This is a point you should seek clarification on. In any event, the line follower's $x_N$ should be $x_{\mbox{end}}$ and the $v_N$ should be:

$v_{\mbox{max}}$, if the obstacle's $v_N$ at that point is higher than the line follower's $V_{\mbox{max}}$, or

$v_{\mbox{line follower}}$, if the obstacle's speed is lower than your $v_{\mbox{max}}$ at that point, or

0, if you're required to be stationary at the the target.

From your end conditions, work backward, trying to put the line-follower as close as possible to the obstacle while always allowing for braking/slowing distances. You can check your answer by incrementing through the positions and velocities again, this time using differential values:

$$
x_{N_{\mbox{diff}}} = x_{(N-1)_{\mbox{diff}}} + v_{(N-1)_{\mbox{diff}}} (t_N - t_{N-1}) + \frac{1}{2} a_{N_{\mbox{diff}}} (t_N - t_{N-1})^2 \\
$$
$$
v_{N_{\mbox{diff}}} = v_{(N-1)_{\mbox{diff}}} + a_{N_{\mbox{diff}}}(t_N - t_{N-1})\\
$$

where the differential values are $x_{\mbox{diff}} = x_{\mbox{obstacle}} - x_{\mbox{line follower}}$ and $v_{\mbox{diff}} = v_{\mbox{obstacle}} - v_{\mbox{line follower}}$. With these equations you're looking at the differential position - the distance between the obstacle and the line follower - if $x_{\mbox{diff}}$ is ever less than zero you're doing something wrong because it means your line follower is further ahead than your obstacle is!


答: The paper “Optimizing Train Speed Profiles to Improve Regeneration Efficiency of Transit Operations” (in JRC2014-3795.pdf) by Haichuan Tang et al addresses some of the issues mentioned in the question and sets out a dynamic programming method for solving related problems.  The paper's goals are different than yours, but its method and some of its references may be helpful.</p>

ContentLicense: CC BY-SA 3.0

Title: Optimal-time acceleration sequence of a line-following robot following a moving obstacle

Body:
Say we have a line-following robot that has a moving obstacle in front, that is a one-dimensional problem. The moving obstacle is defined by its initial state and a sequence of (longitudinal) acceleration changes (the acceleration function is piecewise constant). Let's say the robot can be controlled by specifying again a sequence of acceleration changes and its initial state. However, the robot has a maximum and minimum acceleration and a maximum and minimum velocity. How can I calculate the sequence of accelerations minimizing the time the robot needs to reach a goal. Note that the final velocity must not necessarily be zero.

Can you briefly explain how this problem can be addressed or point me to some references where an algorithm is described? Or point out closely related problems?

Furthermore, does the solution depend on the goal position or could the robot just brake as late as possible all the time (avoiding collisions) and still reach any goal in optimal time?

A more formal problem description:
Given the position of the obstacle $x_B(t) = x_{B,0} + \int_{t_0}^t v_B(t) dt$, and the velocity of the obstacle $v_B(t) = v_{B,0} + \int_{t_0}^t a_B(t) dt$, where $a_B$ is a known piecewise constant function:

$$a_B(t) = \begin{cases} a_{B,1} & \text{for } t_0 \leq t < t_1 \\
a_{B,2} & \text{for } t_1 \leq t < t_2 \\
\dots & \\
\end{cases}$$

and given the initial state of the line-follower $x_{A,0}, v_{A,0} \in \mathbb{R}$ we search for piecewise constant functions $a_A$, where $a_{min} \leq a_A(t) \leq a_{max}$, $v_{min} \leq v_A(t) \leq v_{max}$ and $x_A(t) \leq x_B(t)$ (collision freeness) holds at all times. Reasonable assumptions are e.g. $v_B(t) \geq 0$ and $x_{B,0} \geq x_{A,0}$. Among the feasible solutions I would like to pick those minimizing $\int_{t_0}^{\infty} x_B(t) - x_A(t) dt$ or a similar objective. Approximation algorithms are also ok.

Some numbers for those who would like a test input:
http://pastebin.com/iZsm2UhB


问:
iRobot Create 2 serial battery power
I don's seem to be able to get any battery power from Create 2. I spliced the original cable it came with, and tried to use the power from red/purple(+) and yellow/orange(-) to power a Raspberry Pi2, with no luck. While the serial-to-USB cable still works, and I am able to command the robot via Python, there seems to be no power coming on the red/purple cables. I tried with a multimeter with no luck, even as I moved the device from passive/safe/full modes. There is no power even when Create 2 is charging/docked.</p>

答:
First off, there's no guarantee the wire colors in the iRobot cable match the colors in the cable made by Tensility. Step one is to get an ohm meter and see if the colors match the pins you expect. If they do, I wonder if you accidentally blew the resettable fuse? See the discussion at the end of the section entitled External Serial Port Mini-DIN Pinout on page 3. Depending on what you've plugged in, you may have pulled more than 200mA. Wait a bit for the fuse to cool, and then with nothing connected to the robot, (carefully) jam a multimeter between pins 6 and 1 on the connector and see if you get battery voltage. If you do, plug your cable in, with nothing attached to the cable but the voltmeter, and see if you get battery voltage where you'd expect it. If that checks out, put an ammeter between the battery power wires and your Pi, preferably in peak detect mode.

Good luck; I hope you have a multimeter.

Please note that while I'm an iRobot employee, the postings on this site are my own and don't necessarily represent iRobot's positions, strategies, or opinions.

Title: iRobot Create 2 serial battery power

ContentLicense: CC BY-SA 4.0


问:
IR 40kHz receiver
These days I'm trying to build IR 40kHz long range receiver. I use ir phototransistor. I don't want to use components like TSOP... I need to make
daylight filter and intensify filtred signal because out of this sensor I wanna use with some microcontroller. Can someone help me? Any idea? Thanks.</p>

答: IR receiver circuits based on phototransistors were widely used in TV sets before the advent of integrated modules, like TSOP, in late '80s. You can take inspiration from old time TV service manuals. In general the phototransistor is polarized via a >100k resistor on the collector, then you need a high-pass filter with high input impedance to reject the effects of ambient IR sources, amplify, bandpass at about 40 kHz and at last shmitt-trigger to a square wave.</p>

Title: IR 40kHz receiver


问:
How to convert between classic and modified DH parameters?
I currently have a description of my 22 joint robot in "classic" DH parameters.  However, I would like the "modified" parameters.  Is this conversion as simple as shifting the $a$ and $alpha$ columns of the parameter table by one row?

As you can imagine, 22 joints is a lot, so I'd rather not re-derive all the parameters if I don't have to.  (Actually, the classic parameters are pulled out of OpenRave with the command: planningutils.GetDHParameters(robot).

答:
Unfortunately it is not as simple as just shifting the a and alpha columns, as the locations of the frames and the directions of their axes can also change when moving from one DH formulation to another.

As you can see in the Wikipedia entry on Modified DH Parameters, these key differences result in a number of changes to how the overall transformation matrix is built.


问:
Solution for INS and GPS integration
I have a GPS module and an IMU (gyro, accelerometer and magnetometer) and I need to build an autonomous navigation system for a quadcopter. It must know its position at any time so that it can track a predefined path. I know that, in order to improve precision, I need to merge both sensors data through a Kalman Filter (or any other technique for that matter, the thing is that the Kalman Filter is way more common according to my research).
The problem is that I am seriously stuck and I know this might be something very simple but I don't seem to find a solution or at least the answer for some of the most basic questions.
As a start, I know how to get the position from the accelerometer readings. I have some filters that help eliminate noise and minimize the integration errors. I also have the GPS readings in latitude and longitude. The first question is, during sensor fusion, how can I make both measurements compatible? The latitude and longitude from the GPS won't simply mix with the displacement given by the accelerometer, so what is the starting point for all of this? Should I calculate the displacement from the GPS readings or should I assume a starting latitude and longitude and then update it with the accelerometer prior to applying the filter?

I have once developed a simple Kalman Filter in which I could plug the new reading values to obtain the next estimate position of a two wheeled car. Now I have two sources of inputs. How should I merge those two together? Will the filter have two inputs or should I find a function that will somehow get the best estimate (average, maybe?) from the accelerometer and GPS? I am really lost here.

Do you guys have any examples of code that I could use to learn? It is really easy to find articles full of boxes with arrows pointing the direction in which data must flow and some really long equations that start to get confusing very soon such as those presented on this article: http://isas.uka.de/Material/Samba-Papierkorb/vorl2014_15/SI/Terejanu_tutorialUKF.pdf (I have no problems with equations, seriously) but I have never seen a real life example of such implementation.

Any help on this topic would be deeply appreciated.

Thank you very much.

答:
I was in exactly the same boat with my master's thesis; wave-based imaging (sonar and radar) seemed so common that all the papers I read assumed you knew the fundamental concept and they were going to show an advanced technique, or they set out deriving everything from Maxwell's equations! That said, I hope this helps.

Essentially, you have two measurements: one that should be really accurate in the short term, but prone to integration error/drift in the long run (the IMU accelerometer readings); and you have one that should be extremely accurate in the long term but is very noisy in the short term (GPS).

I would recommend you look at a complimentary filter, which is an extremely easy way to combine two measurements. Basically:

$$
y_{\mbox{est}} = g * y_1 + (1-g) y_2 \\
$$

That's it. $g$ is a value between 0 and 1 that controls how much weight or "trust" you put in a measurement. $y_1$ would be the more trustworthy input, and $y_2$ would be the less trustworthy input. In your case, maybe try g=0.9 with the IMU as y1 and the GPS as y2. Remember, in the short term - sample to sample - IMU integration should be more accurate.

Now you can of course filter individual measurements before, or output after, or both, but try it first with just the raw measurements.

If you're really into pain and desperately want to use the Kalman filter because it's what all the other academics are doing, this paper (PDF) may be of help as it provides a discrete implementation of a fusing Kalman filter. I wouldn't do it, though. If you're doing something tangible it's engineering, and as engineers we want quality, reliable results, whatever the means! The complimentary filter is literally the one line I wrote, it's super easy to debug, minimal processor requirement, it's intuitive, it works, and did I mention easy to debug?

Try looking around online for "complimentary vs Kalman filter"; I'm not the only advocate.

Title: Solution for INS and GPS integration


问:
What are the best ways to transmit force through air efficiently?
I am taking part in a robotics competition, where the challenge is to create a pair of robots which successfully navigate a series of obstacles. However, the rules state that of the two robots, only one must have a driving actuator. The other must somehow be moved by the other robot, WITHOUT PHYSICAL CONTACT.

I could think of either having sails on the non-driving robot, and moving it with fans on the driving one OR electromangnets on the driving one and permanent magnets with the opposite polarity on the non-driving one. However the problem with both is that efficiency falls off drastically with distance. Thus, I am looking for possible ways to overcome this problem. Thanks :)

Also, the driving robot has a cable power supply, while the non-driving one may only have batteries.

Rulebook: http://ultimatist.com/video/Rulebook2016_Final_website_1_Sep_15.zip

答:
There are very limited options for effectively transmitting force across a distance, other than with projectiles of some kind which won't achieve your goals or be allowed under the rules.

Based on the rules as given (which mentions having an arm on the hybrid robot), I would assume that the hybrid robot is expected to extend an arm above the eco robot's track to either "push" or "pull" the robot using wind power or magnetism. This gets around the distance issue, provided you can reliably keep the arm from making contact with the eco robot.

Another possible route to take which may or may not work would be to mimic the various bristle bots that are out there (toothbrush head robots, hexbugs, etc) and vibrate the entire table to cause the eco robot to move forward, although that would require fairly significant levels of vibration and some way of orienting the bristles to steer.


答: Attach a metal square-shaped frame to the first robot, fill the edges with magnets, take your second robot (should have non actuated free moving wheels, like the ones on chairs) and fill it with opposite magnets on all sides, put it inside that metal square, drive your first robot.</p>

Title: What are the best ways to transmit force through air efficiently?

Body:
I am taking part in a robotics competition, where the challenge is to create a pair of robots which successfully navigate a series of obstacles. However, the rules state that of the two robots, only one must have a driving actuator. The other must somehow be moved by the other robot, WITHOUT PHYSICAL CONTACT.

I could think of either having sails on the non-driving robot, and moving it with fans on the driving one OR electromangnets on the driving one and permanent magnets with the opposite polarity on the non-driving one. However the problem with both is that efficiency falls off drastically with distance. Thus, I am looking for possible ways to overcome this problem. Thanks :)

Also, the driving robot has a cable power supply, while the non-driving one may only have batteries.

Rulebook: http://ultimatist.com/video/Rulebook2016_Final_website_1_Sep_15.zip


问:
Motor for DIY Remote controlled shades
I'm currently undertaking a project to build remote controlled shades from scratch. I currently have every piece figured out except I don't know know much about the motors involved in something like this. I am looking for suggestions on what type of motor to search for. I imagine I need a type that can go forward and back as well as stop when the shade is fully retracted. I don't know what to search for though.

Any help is much appreciated.

答:
Use a stepper motor, to precisely control the position of the shade, unless you also want to have to use limit switches.

If you use a stepper motor, then you can simply calculate the number of rotations required in order to roll the cloth up, or down, sufficiently. Once the number of rotations has been completed, turn off the stepper. In addition, if you use a stepper, you could also have the shade stop half way, two thirds, or whatever proportional open, or closed, that you require, without needing limit switches (or IR switches) along the entire throw of the shade, to tell you where the shade currently is.

If you use a geared motor, then you will require limit switches, or something of that ilk, to stop the shade when it reaches either extreme (i.e., fully open and fully closed).

Common stepper motors include the 28BYJ-48

and the Nema variations

Be sure to chose one with sufficient power (torque) to wind to shade. It shouldn't require too much, but it will depend on the weight of the cloth and the size of the shade.

The stepper motor will need to be controlled by an Arduino (or some other such controller (Raspberry Pi or PIC)), in conjunction with a stepper motor driver (such as a Easy Driver or ULN2003).

Stepper motors are too large a topic to explain here in depth, however the following two tutorials should get you up to speed.

There is a very useful video tutorial, Control a Stepper Motor using an Arduino, a Joystick and the Easy Driver - Tutorial, that you will find very useful.

If you decide to use a ULN2003, then the video tutorial, 28BYJ-48 Stepper Motor and ULN2003 Driver Intro, is extremely informative.

Title: Motor for DIY Remote controlled shades


问:
Comparing LQR and PID controllers for inverted pendulum problem
As far as i can tell, both LQR and PID controllers can both be applied to the cart-pole (inverted pendulum) problem.  What are the pros/cons to using one controller over the other for this particular problem?  Are there any reasons/situations where I should prefer one over the other for this problem?</p>

答:
You are correct in claiming that both PID and LQR can be applied to the linearized form of the cart-pole problem. If you have a look at the answers to the related question Ugo linked to in the comments (specifically Ugo's own answer: https://robotics.stackexchange.com/a/5231/10414), you will see the high level differences between PID (and other classic methods) and LQR (and other optimal methods) for control.

For a more detailed analysis specifically focused on the cart-pole problem, an article was written by Nasir et al which specifically deals with this question, available as a cached PDF on CiteSeerX: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.545.6096.


问:
Dynamic model of a tank like robot
I am planning a tank like robot for hobby purpose. I have control engineering background, however I never applied on robotics.
I would like to test different control theory, namely MPC. I saw a lot of publications regarding the kinematics and inverse kinematics of such a robot, however I am wondering if somebody can point out regarding the dynamics modelling of such a system,taking into account the forces, mass etc?</p>

答: For building a dynamic model from scratch of any differential drive mobile robot (i.e., a tank), the best resource I've found so far is a paper by Dhaouadi and Hatab (PDF link) titled "Dynamic Modelling of Differential-Drive Mobile Robots using Lagrange and Newton-Euler Methodologies: A Unified Framework". It even includes some discussion of how to do the dynamic modeling of the actuators.</p>

Title: Dynamic model of a tank like robot


问:
How to make an "invisible line following robot"?
I would like to build a robot which follows a virtual path (Not a visible path like a 'black line on a white surface', etc).

I'm just enthusiastic by seeing some sci-fi videos which show robots carry goods and materials in a crowded place. And they really don't follow a physical line. They sense obstacles, depth, etc.

I would like to build one such robot which follows a specific (virtual)  path from point A to B.

I have tried a couple of things:

Using a magnetic "Hall effect" sensor on the robot and wire carrying current (beneath the table). The problem here was that the vicinity of the hall effect sensor is so small (< 2cms) that it is very difficult to judge whether robot is on the line or off the line. Even using series of magnets couldn't solve this issue, as my table is 1 inch thick. So this idea flopped :P

Using an ultraviolet paint (on a line) and using UV leds on the robot as sensors. This will give more Zig-Zag motion for the robot. And due to potential threats of using UV light source, even this idea flopped :P

I finally thought of having a camera on top and using image processing algorithms to see whether robot is on the line or diverging.

Is there any better solution than this? Really looking for some creative and simple solutions. :)

答: Anki uses optical sensors in their toy cars to implement line followers. The optical sensors are sensitive in the IR range. The fact that the lines cannot be seen is easily explained: The lines are coated with black color which is transparent in the IR range. Paliogen black L 86 or Paliogen black S 84 by BASF are such colors. If you place barcodes along the lines you can even get absolute positioning informations from the optical sensors.</p>


问:
Mobile Robot path reconstruction by using IMU acceleration and Yaw angle
I hope you can help me with my project.

I'm using a skid-steering wheeled mobile robot for autonomous navigation and I'd like to find a way to be able to perform path reconstruction in Matlab.

By using only the robot encoders (installed on the robot) and the yaw rate information (which come from a very accurate IMU sensor mounted on the robot frame), I can successfully do the path reconstruction.
(I'm using XBOW-300CC sensor)

The problem is that I would like to try to reconstruct the path by using only the IMU yaw rate and the IMU acceleration values for X and Y axis.

I'm able to obtain velocity and distance by integrating two times the IMU acceleration values but my problem is that I don't know how to use this data.

Do I have to use a rotation matrix to pass from the IMU frame to the robot frame coordinates?
I'm asking this because I use a rotation matrix for the encoder values which come from the robot encoder.

At the moment, I use these equations for robot encoders and IMU yaw rate:

```<code>tetha(i)=(yaw(i)+yaw(i-1))/2*(encoder(i)-encoder(i-1))+tetha(i-1); %trapezoidal integral

Rx=[1 0 0;0 cos(-roll_angle(i)) -sin(-roll_angle(i)); 0 sin(-roll_angle(i)) cos(-roll_angle(i))];
Ry=[cos(-pitch_angle(i)) 0 sin(-pitch_angle(i)); 0 1 0; -sin(-pitch_angle(i)) 0 cos(-pitch_angle(i))];
Rz=[cos(-tetha(i)) -sin(-tetha(i)) 0; sin(-tetha(i)) cos(-tetha(i)) 0; 0 0 1];
R2=Rz*Ry*Rx;

disp=R2 *[encoder_displacement(i) 0 0]';
X_r(i)=disp(1);
Y_r(i)=disp(2);
Z_r(i)=disp(3);

X(i)=x0+sum(X_r(1:i));
Y(i)=y0+sum(Y_r(1:i));
Z(i)=z0+sum(Z_r(1:i));
</code>```

Do I still have to use R2 matrix?

Thank you a lot

答:
If you aligned the IMU "well", then this should be a relatively trivial problem. Consider your statement that you can reconstruct the path using only "robot encoders" (wheel encoders?) and the yaw rate. Now, if you have the IMU configured such that the X-axis is the forward/reverse direction, then double-integrating the x-axis accelerometer should duplicate the wheel encoder information. The only information the Y-axis accelerometer should tell you is if the robot is sliding sideways.

If you have the IMU aligned "poorly" then you could have some projection of the x- and y-axis along the forward/reverse axis, at which point you would need to take the correct projection from each and add them together to get the forward distance.

Regarding rotation matrices, whatever you're doing currently to apply it to the (wheel encoder?) robot encoder should work the same when you convert the acceleration data to distance.

:EDIT:

Assuming your yaw angle is a z-axis rotation, your rotation matrix should look like:

$$
R = \left[ \begin{array}{ccc}
\cos{\theta} & -\sin{\theta} & 0 \\
\sin{\theta} & \cos{\theta} & 0 \\
0 & 0 & 1 \end{array} \right] \\
$$

You should have some starting heading, $\theta_0$. You also need a starting velocity $v_0$ and a starting position, $p_0$. Now, you get samples at some update rate, where the time between samples, the sample time, is $dT$. So, from physics, you can calculate your new distance and velocity:

$$
p_N = p_{N-1} + v_{N-1} dT + \frac{1}{2} a_N dT^2 \\
v_N = v_{N-1} + a_N dT \\
$$

where $N$ indicates the current sample and $N-1$ indicates the previous sample. In this instance your initial conditions, $p_0$ and $v_0$ are used and you get your first update, $p_1$ and $v_1$ from your first accelerometer reading. I've used $p$ for position instead of $x$ to try to keep the concepts separate - the accelerometer will give you some position, but it doesn't get to be a coordinate until you've reconciled it back to your world coordinates. This is done with the rotation matrix:

$$
\left[ \begin{array}{ccc}
x_N \\
y_N \\
z_N \end{array} \right] = R_{N-1} * \left[ \begin{array}{ccc}
p_N \\
0 \\
0 \end{array} \right] \\
$$

Here I've shown the $N-1$ rotation matrix, the rotation matrix based on the previous yaw reading (or starting heading, if you're considering the first sample), but your choice of which angle to use (previous sample, current sample, an average, etc.) shouldn't actually make a big difference for the same reason that trapezoidal integration and rectangular integration both converge on the same result. As long as the sample time is sufficiently short relative to the motion of your vehicle, any errors accumulated going one direction should generally be canceled out going the other.

I would say if you wanted the most reasonable yaw estimate, use the average of the previous and current headings:
$$
R = (R_{N} + R_{N-1})/2 \\
$$

So, to summarize, I would try the following:

$$
\theta_N = \mbox{read(yaw)} \\
a_N = \mbox{read(x-axis IMU)} \\
$$

$$
\theta_{\mbox{mean}} = (\theta_N + \theta_{N-1})/2 \\
R = \left[ \begin{array}{ccc}
\cos{\theta_{\mbox{mean}}} & -\sin{\theta_{\mbox{mean}}} & 0 \\
\sin{\theta_{\mbox{mean}}} & \cos{\theta_{\mbox{mean}}} & 0 \\
0 & 0 & 1 \end{array} \right] \\
$$

$$
p_N = p_{N-1} + v_{N-1} dT + \frac{1}{2} a_N dT^2 \\
v_N = v_{N-1} + a_N dT \\
$$

$$
\left[ \begin{array}{ccc}
x_N \\
y_N \\
z_N \end{array} \right] = R * \left[ \begin{array}{ccc}
p_N \\
0 \\
0 \end{array} \right] \\
$$

Now, as a final note, again, I would leave the y-axis accelerometer out of everything because you'll find one of two scenarios:

The IMU is located on the center of rotation of the vehicle, so you don't actually ever get a y-axis acceleration during normal operation, or

The IMU is not located on the center of the rotation of the vehicle, so you get a y-axis acceleration any time you turn. In this instance, any y-axis acceleration only indicates rotation, which you already know from the z-axis rotation.

In both cases, assuming the vehicle isn't sliding sideways, the y-axis accelerometer isn't providing you any forward/reverse information. It's only providing you either nothing (case 1) or a more obfuscated form of rotation (case 2) that you already get from your yaw angle. So, just leave it off.


答:
I have a short answer for your question. This is for a ROS enabled robot only.
There are many ways to do this, but this is how I have done it. I used ROS and Kuka Youbot. It could be any robot using ROS. It is very helpful to know ROS if you plan to be in robotics.

Use ROS
Then use GMapping to map your environment. Example room or hallway and save the map.
Then using RVIZ, give the goal position in the map.

Title: How to make an "invisible line following robot"?

Body:
I would like to build a robot which follows a virtual path (Not a visible path like a 'black line on a white surface', etc).

I'm just enthusiastic by seeing some sci-fi videos which show robots carry goods and materials in a crowded place. And they really don't follow a physical line. They sense obstacles, depth, etc.

I would like to build one such robot which follows a specific (virtual)  path from point A to B.

I have tried a couple of things:

Using a magnetic "Hall effect" sensor on the robot and wire carrying current (beneath the table). The problem here was that the vicinity of the hall effect sensor is so small (< 2cms) that it is very difficult to judge whether robot is on the line or off the line. Even using series of magnets couldn't solve this issue, as my table is 1 inch thick. So this idea flopped :P

Using an ultraviolet paint (on a line) and using UV leds on the robot as sensors. This will give more Zig-Zag motion for the robot. And due to potential threats of using UV light source, even this idea flopped :P

I finally thought of having a camera on top and using image processing algorithms to see whether robot is on the line or diverging.

Is there any better solution than this? Really looking for some creative and simple solutions. :)


问:
How can I control a fast (200Hz) realtime system with a slow (30Hz) system?
We are currently designing a mobile robot + mounted arm with multiple controlled degrees of freedom and sensors.

I am considering an architecture in two parts:

A set of realtime controllers (either Raspeberry Pis running an RTOS such as Xenomai or bare metal microcontrollers) to control the arm motors and encoders.  Let us call these machines RTx, with x=1,2,3… depending on the number of microcontrollers.  This control loop will run at 200Hz.

A powerful vanilla linux machine running ROS to compute SLAM, mocap, and execute high-level logic (decide the robot’s task and compute the motors' desired position and speed).  This control loop will run at 30Hz.

I know my framework needs to be scalable to account for more motors, more sensors, more PCs (eg. for external mocap).

My main problem is to decide how to have the different RTx communicate with PC1. I have looked at papers related to robots architecture (e.g. HRP2), most often they describe the high level control architecture but I have yet to find information on how to have the low level communicate with the high level and in a scalable way. Did I miss something?

In order to connect the fast RT machines ensuring the motor control with PC1, I have considered TCP/IP, CAN and UART:

TCP/IP: not deterministic but easy to put in place. Is non determinism a real issue (as it will only be used at at slow speed 30Hz anyways)?

CAN: slow, very reliable, targeted to cars ( have seen there are some exemples using CAN with robots but it looked exotic)

UART: if I had only had one RT machine for motor control I would have considered UART but I guess this port does not scale well with many RTx
Is TCP/IP really a no go because of its non-deterministic characteristics? It is so easy to use…

At the moment no solution really seems obvious to me. And as I can find no serious robot example using a specific reliable and scalable solution, I do not feel confident to make a choice.

Does anyone have a clear view on this point or literature to point to?  Are there typical or mainstream communication solutions used on robots?

答:
I think you've taken a good first step; you've divided the problem into a mobile platform (which has uncertainty of position and must navigate) and the arm (which has a fair certainty of position in real time, through encoders).

I have looked at papers related to robots architecture [...] but I have yet to find information on how to have the low level communicate with the high level and in a scalable way. Did I miss something?

From your description, it sounds like you're trying to tie each RTx controller directly to PC1, which is running ROS.  What you've missed is that ROS is designed to handle a group of applications that may produce and consume data at different rates.

What your application needs is a communications bridge — a single interface between your 200Hz loop and your ROS environment.  In other words, instead of tying each RTx controller to PC1, tie all the RTx controllers together and connect that to PC1.

For example, use an I2C Bus to link the RTx systems together, and add another RTx controller to be the "Arm Master" (AM).  The AM's job would be to accept incoming commands in some PC1-friendly format and protocol, and convert those commands to I2C messages.  Then you'd write a ROS app to send commands to the AM.

Another way to do it with I2C would be to put an I2C controller directly on PC1 and write all the arm controlling logic in a ROS app.  This may seem like a more streamlined way to accomplish your goal, but it can make debugging more difficult as you are removing the modularity of the system — you'll have to troubleshoot it as one big complex system instead of two easily testable components.


问:
How to use a POMDP-based planner on top of a probabilistic filter
POMDPs extend MDPs by conceiling state and adding an observation model. A POMDP controller processes either

action/observation histories or

a bayesian belief state, computed from the observations (belief-MDP transformation)

In a complex, real-world system like a robot, one usually preprocesses sensory readings using filters (Kalmann, HMM, whatever). The result of which is a belief-state.

I am looking for publications that discuss the problem of fitting a (probably more abstract) POMDP model on top of an existing filter-bank.

Do you have to stick to the belief-MDP, and hand over the filtered belief-state to the controller?

Is there any way of using history-based POMDP controllers, like MCTS?

How do you construct/find the abstract observations you need to formulate the POMDP model?

答:
I have used POMDP like models on top of a localization algorithm (Adaptive Monte Carlo Localization, from ROS), and a person detector [1][2] to find and follow a person with a humanoid robot. These two algorithms generate the input (observation) for the POMDP model in [1] and [2]. Also in [3] they used a POMDP model with similar input.

As next step we used POMCPs (Partially Observable Monte Carlo Processes [4]) which use Monte Carlo simulations to create a policy because they are able to handle much larger state spaces.
Having continuous states and observations causes problems when trying to find a policy, since there will be an infinite number of observations possible. We used Monte Carlo processes with continuous states [4], but the observations and actions were discretized to prevent the policy tree from growing too wide. There is however work on the use of continuous observations in POMDP, such as presented in [5].

Other work with POMDP like models on a top level are: [6-8].

A. Goldhoorn, A. Sanfeliu and R. Alquézar Mancho. Analysis of methods for playing human robot hide-and-seek in a simple real world urban environment, 1st Iberian Robotics Conference, 2013, Madrid, in ROBOT2013: First Iberian Robotics Conference, Vol 252-3 of Advances in Intelligent Systems and Computing, pp. 505-520, 2014, Springer. http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=7041445

A. Goldhoorn, A. Garrell Zulueta, R. Alquézar Mancho and A. Sanfeliu. Continuous real time POMCP to find-and-follow people by a humanoid service robot, 2014 IEEE-RAS International Conference on Humanoid Robots, 2014, Madrid, Spain, pp. 741-747, IEEE Press. http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=7041445

Luis Merino, Joaqu\'in Ballesteros, Noé Pérez-Higueras, Rafael Ramón-Vigo, Javier Pérez-Lara, and Fernando Caballero. Robust Person Guidance by Using Online POMDPs. In Manuel A. Armada, Alberto Sanfeliu, and Manuel Ferre, editors, ROBOT2013: First Iberian Robotics Conference, Advances in Intelligent Systems and Computing, pp. 289–303, Springer International Publishing, 2014. http://link.springer.com/chapter/10.1007%2F978-3-319-03653-3_22

D. Silver and J. Veness, “Monte-Carlo planning in large POMDPs,”
Proceedings of 24th Advances in Neural Information Processing Systems
(NIPS), pp. 1–9, 2010.

J.M. Porta, N. Vlassis, M.T. Spaan and P. Poupart. Point-based value iteration for continuous POMDPs. Journal of Machine Learning Research, 7: 2329-2367, 2006.

Pineau, J., Gordon, G., & Thrun, S. (2003). Point-based value iteration: An anytime algorithm for POMDPs. In IJCAI International Joint Conference on Artificial Intelligence (Vol. 18, pp. 1025–1030). Citeseer. Retrieved from http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.68.1777&rep=rep1&type=pdf

Ong, S., Png, S., & Hsu, D. (2009). POMDPs for robotic tasks with mixed observability. Proc. Robotics: Science and Systems. Retrieved from http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.149.3849&rep=rep1&type=pdf

Schesvold, D., Tang, J., Ahmed, B. M., Altenburg, K., & Nygard, K. E. (2003). POMDP planning for high level UAV decisions: Search vs. strike. In In Proceedings of the 16th International Conference on Computer Applications in Industry and Engineering (pp. 3–6). Citeseer. Retrieved from http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.125.9134


问:
Could anyone tell me what are these things in a Roomba robot and how to clean them, please?
I'm really in doubt whether it is proper to ask this question here, so I'm apologizing if it is not, I'll delete it.

I have a Roomba robot which has worked for me for more than three years, and now while it is working it is producing some strange sounds, so I've decided to clean it thoroughly.

But when I disassembled it down to this point:

I got stuck with these sort of glass things (marked with the red rectangles at the picture). They are really filthy from the inside and I cannot figure out how to clean them.

Does anyone know how one can remove dust from the inside on these things? May be there are some Roomba creators here.

Thanks in advance.

答:
I don't have one, but I found this article:

http://www.robotreviews.com/chat/viewtopic.php?t=10631

There they say the "cliff sensors" collect a lot of dust and can be cleaned out with a blast of compressed air. From the article, these sensors detect the floor and prevent the Roomba from wandering off the top stair, or some similar mishap.

If these sensors are dirty, apparently it will keep stopping and beeping, thinking its route is blocked.

If you don't have a source of compressed air you can get "canned air" from specialist camera places, but it's expensive. Otherwise, just blowing hard (once per sensor, without getting any spit in there!) may do the trick but be careful not to damage anything...


问:
Wifi module for Zumo robot
I'm a CS student trying to implement a clustering algorithm that would work for a set of robots in an indoor controlled environment. I'm still starting on Robotics and don't have much experiencing in figuring out what will work together.

My plan is to get 6 of these Zumo robots and plug in a wifi module like the Wifi shield. Then, I would use this to do inter communication and execute my algorithm.

My question: Can the wifi module just be plugged in and would it work? If not, how can I go about achieving this task. I see lots of Arduino boards with different names and I'm not sure which works with which, and whether they can be plugged in. Any help would be appreciated.

答:
You will need to determine if the Zumo is Arduino shield pinout compatible.

It appears the Zumo has a compatible microcontroller. This likely means that you would be able to use the Arduino IDE, compiler and libraries to program your robot.

If the Zumo is not pin compatible, you may want to investigate the ESP8266 range of SoCs. They're a microcontroller that can be programmed with the Arduino IDE, and have built in wifi. They're also very light and cheap.

The easiest way to integrate the ESP8266 with the robot may be to use their respective serial connections. When integrating 3rd party components onto your robot ensure that you are using the correct voltage (5V vs 3.3V). If components run on different voltages you may need to use a level shifter.

Title: Wifi module for Zumo robot


问:
making a robot that knows your location
I've just made a radio frequency remote control using PIC microcontroller and I want to do something useful with it. I am thinking of a robot that gets things for you while you are at bed but here comes the question: How am I going to have the PIC determine the location of the remote control calling for it? It can't really be done using a GPS module because it will all be in the house.

What options do I have?

答:
When you're in a closed area with different obstacles and your accuracy is about a meter things will change comparing outdoor navigation. I suggest someways.

Using IR or Laserpoint in the case of Line Of Sight to the robot.

Using Ultrasound to call Robot, it don't need a LOS but it is invaluable,too.

Using a headquarter to determine your location and Navigate robot to your position. for instance use a receiver in each room. Then you will tell your robot, which room you are and then can navigate your robot to your location.

Professional ways include measuring your signal strength in different directions and then determine the most powerful signal strength and folow that way. It is possible by directional antennas which are currently used in BTS (mobile base stations) to estimate locations.

Title: making a robot that knows your location


问:
Is it safe to give 5v through 5v pin of arduino uno r3 while usb cable inserted
Is it safe to give 5v through 5v pin of arduino uno r3 while the USB cable is inserted? I have ESCs connected to it which aren't likely to start in other cases. The 5v and gnd is coming from the BEC circuit of a connected ESC. Please help me. Thanks

答:
See this answer to similar question on the EE Stack Exchange:

The official stance on supplying power directly to the 5V pin on the Arduino Uno is thus:

Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.


问:
Building a controllable "knob"
I am trying to build a semi-analog timer. Something like those old egg timers that you rotate the face of. I want a knob that I can turn that can be read by a microcontroller, and I also want the microcontroller to be able to position the knob. I'd like to implement "stops" by letting the microcontroller push the knob towards certain positions. As it runs down, the knob should turn. This is my first project of this kind; I've built small robots in the past, but it's been many years.

I've considered hacking a servo motor to read its position, but the small hobby servos I've tried are too hard to turn, very noisy, and pick up too much momentum when turned. They don't act like a good knob.

I'm now considering a rotary encoder connected to a motor, but after hunting at several sites (SparkFun, ServoCity, DigiKey, Trossen, and some others), I haven't been able to find anything that seemed appropriate. I'm not certain how to find a motor that's going to have the right kind of low torque.

This seems like it shouldn't be a really uncommon problem. Is there a fairly normal approach to creating a knob that can be adjusted both by the user and a microcontroller?

答: Use a rotatory potentiometer. Interface it to an ADC pin of your micro-controller, and depending on the resolution, you can get anywhere between 256 to 65536 values, which you can then use to set "stops".</p>

Title: Building a controllable "knob"


答:
please see: https://dronesandrovs.wordpress.com/?attachment_id=241#main

It looks like it's safe.

Title: Is it safe to give 5v through 5v pin of arduino uno r3 while usb cable inserted

Body: Is it safe to give 5v through 5v pin of arduino uno r3 while the USB cable is inserted? I have ESCs connected to it which aren't likely to start in other cases. The 5v and gnd is coming from the BEC circuit of a connected ESC. Please help me. Thanks


问:
DualCopter Degree Of Freedom
I am a newbie in this drone field. I am curious to know what type of rotation and translation a dualcopter can achieve ? By rotation and translation i mean can it be able to roll, pitch and yaw like quadcopters?
If not, in any copter what makes them to roll pitch and yaw? Furthermore are there any dualcopter design that have movable wings that will rotate the rotors itself or do up and down motion while flying?</p>

答: Check out this video: https://www.youtube.com/watch?v=csfAOCdkCdU and this relevant one: https://www.youtube.com/watch?v=t369aSInq-E</p>

Title: DualCopter Degree Of Freedom


问:
How can I control fast real time sensor (250Hz) with slow system display(60Hz)
We do some experiments of real time representation of sensor position on TV. In this experiments, we used sensors for collect real time position in 3D at 250Hz and TV for Display the sensor position at 60Hz. Also, we used MATLAB and C++ for programming with OpenGL platform.

In programming, Every iteration dat display on the TV, erase and draw the circle (Object, which is represent real time position on the display). In this program I collect to only 60 points and loose other 190 points in every second, becuase, I think that refresh rate of TV is 60Hz.

I have gone through the thread "How can I control a fast (200Hz) realtime system with a slow (30Hz) system?"(How can I control a fast (200Hz) realtime system with a slow (30Hz) system?), but i don't understand, How to implement two loop on 200Hz and 30Hz.

My Question is, How can we implement in MATLAB/C++? So I can store 250 data of sensors as well as 60 points for real time display on the TV.

If you help me through pseudo code, I appreciate your help.

Thank You in advance.

Please help me.

P.S. Code

```<code>%Display main window using Psychtoolbox

win=Screen(2,'OpenWindow',[1 1 1])

while (1)
  % Setup for data collection at 250Hz
  Error   = calllib('ATC3DG64', 'GetSynchronousRecord',  hex2dec('ffff'), pRecord, 4*numBoards*64);
  errorHandler(Error);
  Record = get(pRecord, 'Value');

  %sensor number
  count=2;

  evalc(['tempPos(1, count) ='  'Record.x' num2str(count - 1)]);
  evalc(['tempPos(2, count) ='  'Record.y' num2str(count - 1)]);
  evalc(['tempPos(3, count) ='  'Record.z' num2str(count - 1)]);

  % Record X and Y position of  sensor 2

  if SensorNumAttached(count)
    % Real time position and minus world origin so that real
    % time position display on the TV
    table1(count,1)=(2.54*tempPos(2,count))-X_world_origin;
    table1(count,2)=(2.54*tempPos(3,count))-Y_world_origin;
  end

  % Some conversion for the Pixel to centimeter ratio
  x_center_new = x_center - (x_ratio * table1(2,1));
  y_center_new = y_center - (y_ratio * table1(2,2));

  % conversiorn for display circle on the TV, is represent the real time poistion of the sensor
  x1  =round(x_center_new - R_num_data);
  y1 = round(y_center_new - R_num_data);

  x2 = round(x1 + 2*R_num_data);
  y2 = round(y1 + 2*R_num_data);

  % Display command for TV.
  Screen('FrameOval',win,[255 0 0], [x1 y1 x2 y2]);
  Screen('Flip',win);
end
</code>```

答:
I didnt see what is your processing unit (preocessor/ADC/DAC etc.) speed?. If your processor speed less than sensors speed you can try "sampling" or "quantization" techniques. you can look to any signal processing book for further readings. If you have fast processor and slow display unit this is not a problem. Just collect/ buffer your sensor readings for a second (or you can use 1/60 sec for fast display) than show all of them in display unit.

This is like controlling analogus systems with digital systems.


问:
What is the learning (control) algorithm inside Cubli?
As in this video: https://www.youtube.com/watch?v=qce5Vguj5Jg

In this new version (did not see the learning part in the past versions), with three to four trials, Cubli can learn to balance on a new surface.

答:
You should start by reading their academic papers:

M. Muehlebach, G. Mohanarajah, and R. D'Andrea, Nonlinear Analysis and Control of a Reaction Wheel-based 3D Inverted Pendulum, in Proc. Conference on Decision and Control, CDC 2013 (Florence, Italy)

M. Gajamohan, M. Muehlebach, T. Widmer, and R. D'Andrea, The Cubli: A Reaction Wheel-based 3D Inverted Pendulum, in Proc. European Control Conference (Zurich, Switzerland), pp. 268-274, July 2013.

M. Gajamohan, M. Merz, I. Thommen, and R. D'Andrea, The Cubli: A Cube that can Jump Up and Balance, in Proc. IEEE/RSJ International Conference of Intelligent Robots and Systems (Algarve, Portugal), pp. 3722-3727, October 2012.


答:
I'm not entirely sure what you're asking for because your question
title mentions control but your question body seems to all be about display. You said,

My Question is, How can we implement in MATLAB/C++? So I can store 250 data of sensors as well as 60 points for real time display on the TV.

If you want to store samples for display at some particular interval, try the following:

```<code>sensorPeriod = 1/250;
displayPeriod = 1/60;
displayInterval = floor (displayPeriod/sensorPeriod);
sensorData = <read sensor>
sensorHistory(end+1) = sensorData;
displayData = sensorHistory(1:displayInterval:end);
</code>```

You can use any integer to select indices of an array in Matlab. The value is optional and if you don't specify it then it defaults to 1. So, for instance, where

```<code>displayData = data(1:end);
</code>```

would put every data point into displayData, the following:

```<code>displayData = data(1:N:end);
</code>```

would take every Nth point and put that into displayData. Dividing display period by the sample period gives the number of samples that occur between each displayed frame. Take the floor of that to get an integer because Matlab can only handle integer indexing of arrays.

:EDIT:

As I go through your code, here are things that I notice:

```<code>% Display main window using Psychtoolbox

win=Screen(2,'OpenWindow',[1 1 1])

while (1)
  % Setup for data collection at 250Hz
  Error   = calllib('ATC3DG64', 'GetSynchronousRecord',  hex2dec('ffff'), pRecord, 4*numBoards*64);
  errorHandler(Error);
  Record = get(pRecord, 'Value');
</code>```

This section all appears to look okay, and it appears to me that Record is the data point you are interested in storing. There is no reference to 'ATC3DG64' or 'pRecord', but there is also no complaint about retrieving data, so I can only assume this works okay. However, I would like to note that the calllib() function accepts arguments inside the parenthesis, not outputs, so I don't see where/how pRecord ever gets updated.

```<code>  %sensor number
  count=2;

  evalc(['tempPos(1, count) ='  'Record.x' num2str(count - 1)]);
  evalc(['tempPos(2, count) ='  'Record.y' num2str(count - 1)]);
  evalc(['tempPos(3, count) ='  'Record.z' num2str(count - 1)]);
</code>```

I do not know why you are using evalc to do this. That function evaluates an argument and copies the output to a variable, but you don't make an output assignment. Instead you're just converting everything to a string to make Matlab parse the string, when you could just leave everything off and call the functions directly. Also, your string conversion doesn't leave you with a proper indexing for the Record.x functions. You wind up calling:

```<code>tempPos(1, count) =Record.x 0
</code>```

when you probably should be calling

```<code>tempPos(1, count) =Record.x(0)
</code>```

If you are using evalc() to suppress the output, you can always do that with a semicolon at the end of the line. I think you should probably re-write this section of code to the following:

```<code>tempPos(1, count) = Record.x(count-1);
tempPos(2, count) = Record.y(count-1);
tempPos(3, count) = Record.z(count-1);
</code>```

Moving on...

```<code>  % Record X and Y position of  sensor 2

  if SensorNumAttached(count)
    % Real time position and minus world origin so that real
    % time position display on the TV
    table1(count,1)=(2.54*tempPos(2,count))-X_world_origin;
    table1(count,2)=(2.54*tempPos(3,count))-Y_world_origin;
  end
</code>```

The function SensorNumAttached() is not a Matlab function, so I don't know what that is checking for. That said, this portion of the code is a little confusing because you switch between indexing the data to the sensor on the columns to indexing on the rows, but otherwise this looks okay.

```<code>  % Some conversion for the Pixel to centimeter ratio
  x_center_new = x_center - (x_ratio * table1(2,1));
  y_center_new = y_center - (y_ratio * table1(2,2));
</code>```

This section of code will not do what you want it to do. This looks like you are trying to update coordinates, but you are combining a relative position with an absolute position. It looks like you are trying to go for:

```<code>displayData = data(1:end);
</code>```0

When in actuality you have:

```<code>displayData = data(1:end);
</code>```1

I may be wrong here, because you never set x_center = x_center_new, which is either a mistake or it could be that x_center is some offset information. I don't think this is the case, though, because there is no x_center(count), which means you don't have a distinct x_center for both sensors. Also of note - you don't reference count in this code at all, so you're updating both sensor displays with only one (#2's) position information. I would suggest you change this code to be:

```<code>displayData = data(1:end);
</code>```2

Moving on. . .

```<code>  % conversion for display circle on the TV, is represent the real time position of the sensor
  x1  =round(x_center_new - R_num_data);
  y1 = round(y_center_new - R_num_data);

  x2 = round(x1 + 2*R_num_data);
  y2 = round(y1 + 2*R_num_data);

  % Display command for TV.
  Screen('FrameOval',win,[255 0 0], [x1 y1 x2 y2]);
  Screen('Flip',win);
end
</code>```

For this section, Screen is also not a Matlab function, so I'm not sure what it does, and R_num_data is not defined in the code snippet you provided, so I don't know what that does, either. I would like to reiterate that, by your code, the display here never showed anything for sensor 1 because your x_center_new used a hard-coded '2' instead of 'count'.

Regarding display, there are two ways that you can go about showing data:

Collect the data in real time, then show the video after the fact.

Collect the data and display in real time.

If you attempt to display in real time, Matlab rendering will almost certainly hamper your data collection as I've found it seems to be generally about 100ms for Matlab to draw a basic scene. Also, if you collect data and display in real time with no bounds on time, you can't pre-allocate the memory for data storage, which can cause the program to run slower. That said, here's some sample code you can throw into your script for display:

Method 1

```<code>nSensors = 2;       % Number of sensors
nOutputs = 3;       % How many outputs each sensor gives you
sampleDuration = 1; % Sample time in [s]
samplePeriod = 1/250; % Sampling period in [s]
displayPeriod = 1/60; % Display period in [s]

nDataPoints = floor(sampleDuration/samplePeriod);

sensorData = zeros(nOutputs,nSensors,nDataPoints);

count = 2;          % Whatever method you want to select the sensor
for i = 1:nDataPoints
  <whatever method you need to get the data>
  Record = get(pRecord, 'Value');
  sensorData(1,count,i) = Record.x(count-1);
  sensorData(2,count,i) = Record.y(count-1);
  sensorData(3,count,i) = Record.z(count-1);

  <any other things you want to do with the data>
end

sampleInterval = floor(displayFreq/sampleFreq);
displayData = nDataPoints(:,:,1:sampleInterval:end);

for i = 1:size(displayData,3)
   <display 'displayData(:,:,i)'>
end
</code>```

Method 2

```<code>nSensors = 2;       % Number of sensors
nOutputs = 3;       % How many outputs each sensor gives you
samplePeriod = 1/250; % Sampling period in [s]
displayPeriod = 1/60; % Display period in [s]

sensorData = zeros(nOutputs,nSensors,0);
displayData = zeros(nOutputs,nSensors,0);

frameAdjustment = 0;
tic;                 % Start a timer
while 1
    <whatever method you need to get the data>
  Record = get(pRecord, 'Value');
  sensorData(1,count,end+1) = Record.x(count-1);
  sensorData(2,count,end+1) = Record.y(count-1);
  sensorData(3,count,end+1) = Record.z(count-1);

  elapsedTime = toc;
  if elapsedTime + frameAdjustment > displayPeriod
    frameAdjustment = elapsedTime - displayPeriod;
    tic;
    displayData(:,:,end+1) = nDataPoints(:,:,end);

    <display 'displayData(:,:,end)'>
  end
end
</code>```

Note in the above code that there is a variable, frameAdjustment. This term can account for the fact that your elapsedTime probably isn't going to sync exactly with your desired frame rate. It remembers how much time you were past the desired display call and calls the next display that much sooner. If the time it takes to display your data is longer than your displayPeriod then you'll wind up displaying every loop iteration. As mentioned earlier, this could mean that you don't build your sensorData history at the correct rate.

It looks like maybe the Screen command could let you bypass the time it takes for Matlab to draw a scene, but I haven't used any third-party Matlab tools so I can't comment on it. Your best bet would be to gather the data first and then display it, but as the designer, it's always up to you.

Title: How can I control fast real time sensor (250Hz) with slow system display(60Hz)

Body:
We do some experiments of real time representation of sensor position on TV. In this experiments, we used sensors for collect real time position in 3D at 250Hz and TV for Display the sensor position at 60Hz. Also, we used MATLAB and C++ for programming with OpenGL platform.

In programming, Every iteration dat display on the TV, erase and draw the circle (Object, which is represent real time position on the display). In this program I collect to only 60 points and loose other 190 points in every second, becuase, I think that refresh rate of TV is 60Hz.

I have gone through the thread "How can I control a fast (200Hz) realtime system with a slow (30Hz) system?"(How can I control a fast (200Hz) realtime system with a slow (30Hz) system?), but i don't understand, How to implement two loop on 200Hz and 30Hz.

My Question is, How can we implement in MATLAB/C++? So I can store 250 data of sensors as well as 60 points for real time display on the TV.

If you help me through pseudo code, I appreciate your help.

Thank You in advance.

Please help me.

P.S. Code

```<code>%Display main window using Psychtoolbox

win=Screen(2,'OpenWindow',[1 1 1])

while (1)
  % Setup for data collection at 250Hz
  Error   = calllib('ATC3DG64', 'GetSynchronousRecord',  hex2dec('ffff'), pRecord, 4*numBoards*64);
  errorHandler(Error);
  Record = get(pRecord, 'Value');

  %sensor number
  count=2;

  evalc(['tempPos(1, count) ='  'Record.x' num2str(count - 1)]);
  evalc(['tempPos(2, count) ='  'Record.y' num2str(count - 1)]);
  evalc(['tempPos(3, count) ='  'Record.z' num2str(count - 1)]);

  % Record X and Y position of  sensor 2

  if SensorNumAttached(count)
    % Real time position and minus world origin so that real
    % time position display on the TV
    table1(count,1)=(2.54*tempPos(2,count))-X_world_origin;
    table1(count,2)=(2.54*tempPos(3,count))-Y_world_origin;
  end

  % Some conversion for the Pixel to centimeter ratio
  x_center_new = x_center - (x_ratio * table1(2,1));
  y_center_new = y_center - (y_ratio * table1(2,2));

  % conversiorn for display circle on the TV, is represent the real time poistion of the sensor
  x1  =round(x_center_new - R_num_data);
  y1 = round(y_center_new - R_num_data);

  x2 = round(x1 + 2*R_num_data);
  y2 = round(y1 + 2*R_num_data);

  % Display command for TV.
  Screen('FrameOval',win,[255 0 0], [x1 y1 x2 y2]);
  Screen('Flip',win);
end
</code>```

Body:
I'm not entirely sure what you're asking for because your question
title mentions control but your question body seems to all be about display. You said,

My Question is, How can we implement in MATLAB/C++? So I can store 250 data of sensors as well as 60 points for real time display on the TV.

If you want to store samples for display at some particular interval, try the following:

sensorPeriod = 1/250;
displayPeriod = 1/60;
displayInterval = floor (displayPeriod/sensorPeriod);
sensorData = <read sensor>
sensorHistory(end+1) = sensorData;
displayData = sensorHistory(1:displayInterval:end);

You can use any integer to select indices of an array in Matlab. The value is optional and if you don't specify it then it defaults to 1. So, for instance, where

displayData = data(1:end);

would put every data point into displayData, the following:

displayData = data(1:N:end);

would take every Nth point and put that into displayData. Dividing display period by the sample period gives the number of samples that occur between each displayed frame. Take the floor of that to get an integer because Matlab can only handle integer indexing of arrays.

:EDIT:

As I go through your code, here are things that I notice:

% Display main window using Psychtoolbox

win=Screen(2,'OpenWindow',[1 1 1])

while (1)
  % Setup for data collection at 250Hz
  Error   = calllib('ATC3DG64', 'GetSynchronousRecord',  hex2dec('ffff'), pRecord, 4*numBoards*64);
  errorHandler(Error);
  Record = get(pRecord, 'Value');

This section all appears to look okay, and it appears to me that Record is the data point you are interested in storing. There is no reference to 'ATC3DG64' or 'pRecord', but there is also no complaint about retrieving data, so I can only assume this works okay. However, I would like to note that the calllib() function accepts arguments inside the parenthesis, not outputs, so I don't see where/how pRecord ever gets updated.

  %sensor number
  count=2;

  evalc(['tempPos(1, count) ='  'Record.x' num2str(count - 1)]);
  evalc(['tempPos(2, count) ='  'Record.y' num2str(count - 1)]);
  evalc(['tempPos(3, count) ='  'Record.z' num2str(count - 1)]);

I do not know why you are using evalc to do this. That function evaluates an argument and copies the output to a variable, but you don't make an output assignment. Instead you're just converting everything to a string to make Matlab parse the string, when you could just leave everything off and call the functions directly. Also, your string conversion doesn't leave you with a proper indexing for the Record.x functions. You wind up calling:

tempPos(1, count) =Record.x 0

when you probably should be calling

tempPos(1, count) =Record.x(0)

If you are using evalc() to suppress the output, you can always do that with a semicolon at the end of the line. I think you should probably re-write this section of code to the following:

tempPos(1, count) = Record.x(count-1);
tempPos(2, count) = Record.y(count-1);
tempPos(3, count) = Record.z(count-1);

Moving on...

  % Record X and Y position of  sensor 2

  if SensorNumAttached(count)
    % Real time position and minus world origin so that real
    % time position display on the TV
    table1(count,1)=(2.54*tempPos(2,count))-X_world_origin;
    table1(count,2)=(2.54*tempPos(3,count))-Y_world_origin;
  end

The function SensorNumAttached() is not a Matlab function, so I don't know what that is checking for. That said, this portion of the code is a little confusing because you switch between indexing the data to the sensor on the columns to indexing on the rows, but otherwise this looks okay.

  % Some conversion for the Pixel to centimeter ratio
  x_center_new = x_center - (x_ratio * table1(2,1));
  y_center_new = y_center - (y_ratio * table1(2,2));

This section of code will not do what you want it to do. This looks like you are trying to update coordinates, but you are combining a relative position with an absolute position. It looks like you are trying to go for:

  x_center_new = <old center> + <difference between old center and new center>;

When in actuality you have:

  x_center_new = <old center> + <difference between origin and new center>

I may be wrong here, because you never set x_center = x_center_new, which is either a mistake or it could be that x_center is some offset information. I don't think this is the case, though, because there is no x_center(count), which means you don't have a distinct x_center for both sensors. Also of note - you don't reference count in this code at all, so you're updating both sensor displays with only one (#2's) position information. I would suggest you change this code to be:

  x_center_new = x_ratio * table(count,1);
  y_center_new = y_ratio * table(count,2);

Moving on. . .

  % conversion for display circle on the TV, is represent the real time position of the sensor
  x1  =round(x_center_new - R_num_data);
  y1 = round(y_center_new - R_num_data);

  x2 = round(x1 + 2*R_num_data);
  y2 = round(y1 + 2*R_num_data);

  % Display command for TV.
  Screen('FrameOval',win,[255 0 0], [x1 y1 x2 y2]);
  Screen('Flip',win);
end

For this section, Screen is also not a Matlab function, so I'm not sure what it does, and R_num_data is not defined in the code snippet you provided, so I don't know what that does, either. I would like to reiterate that, by your code, the display here never showed anything for sensor 1 because your x_center_new used a hard-coded '2' instead of 'count'.

Regarding display, there are two ways that you can go about showing data:

Collect the data in real time, then show the video after the fact.

Collect the data and display in real time.

If you attempt to display in real time, Matlab rendering will almost certainly hamper your data collection as I've found it seems to be generally about 100ms for Matlab to draw a basic scene. Also, if you collect data and display in real time with no bounds on time, you can't pre-allocate the memory for data storage, which can cause the program to run slower. That said, here's some sample code you can throw into your script for display:

Method 1

nSensors = 2;       % Number of sensors
nOutputs = 3;       % How many outputs each sensor gives you
sampleDuration = 1; % Sample time in [s]
samplePeriod = 1/250; % Sampling period in [s]
displayPeriod = 1/60; % Display period in [s]

nDataPoints = floor(sampleDuration/samplePeriod);

sensorData = zeros(nOutputs,nSensors,nDataPoints);

count = 2;          % Whatever method you want to select the sensor
for i = 1:nDataPoints
  <whatever method you need to get the data>
  Record = get(pRecord, 'Value');
  sensorData(1,count,i) = Record.x(count-1);
  sensorData(2,count,i) = Record.y(count-1);
  sensorData(3,count,i) = Record.z(count-1);

  <any other things you want to do with the data>
end

sampleInterval = floor(displayFreq/sampleFreq);
displayData = nDataPoints(:,:,1:sampleInterval:end);

for i = 1:size(displayData,3)
   <display 'displayData(:,:,i)'>
end

Method 2

nSensors = 2;       % Number of sensors
nOutputs = 3;       % How many outputs each sensor gives you
samplePeriod = 1/250; % Sampling period in [s]
displayPeriod = 1/60; % Display period in [s]

sensorData = zeros(nOutputs,nSensors,0);
displayData = zeros(nOutputs,nSensors,0);

frameAdjustment = 0;
tic;                 % Start a timer
while 1
    <whatever method you need to get the data>
  Record = get(pRecord, 'Value');
  sensorData(1,count,end+1) = Record.x(count-1);
  sensorData(2,count,end+1) = Record.y(count-1);
  sensorData(3,count,end+1) = Record.z(count-1);

  elapsedTime = toc;
  if elapsedTime + frameAdjustment > displayPeriod
    frameAdjustment = elapsedTime - displayPeriod;
    tic;
    displayData(:,:,end+1) = nDataPoints(:,:,end);

    <display 'displayData(:,:,end)'>
  end
end

Note in the above code that there is a variable, frameAdjustment. This term can account for the fact that your elapsedTime probably isn't going to sync exactly with your desired frame rate. It remembers how much time you were past the desired display call and calls the next display that much sooner. If the time it takes to display your data is longer than your displayPeriod then you'll wind up displaying every loop iteration. As mentioned earlier, this could mean that you don't build your sensorData history at the correct rate.

It looks like maybe the Screen command could let you bypass the time it takes for Matlab to draw a scene, but I haven't used any third-party Matlab tools so I can't comment on it. Your best bet would be to gather the data first and then display it, but as the designer, it's always up to you.


问:
Is it possible to both move and stabilize a two wheeled robot with no gyroscopes?
With two wheeled robot like this one, I have managed to stabilize it while keeping it stationary. This was done using a digital feedback control system by reading the position of the wheels to determine position, and the natural back electromotive force from the wheel motors was used in the feedback loop to determine velocity. It was kept stable with a PID controller, which was designed using a root locus algorithm to keep it stable and modulate the performance parameters (such as percent overshoot, settling time, etc.). I wanted to attempt to keep it stable while simultaneously propelling it forward, but I couldn't figure out how to go about designing a linear controller that could do that. Is it possible to both propel the robot forward and keep it stable using a feedback controller on the wheels, or is a gyroscope necessary?

答: If you managed to get it stable in a stationary configuration, I don't really see how it would be much more difficult to get it stable for a constant velocity. From a system model point of view it would effectively be the same thing bar some velocity offsets. If the transitions between velocities are not very large it should fall within the range of the natural system perturbations. </p>


问:
Robotic legs technologies
what robotic leg technologies are available.

i'm sorry if this is a basic question i am a software developer looking to get into the field of robotics. i am particularly interested in robotic legs that are similar to those used on Boston Dynamics ATLAS robot.

what is the mechanism required that allows it to move its joints so quickly. if you see any videos of many of Boston Dynamics robots they make an engine sound (presumably because it uses an engine), but i cant find any details in the configuration that is being used.

答:
Their page for the ATLAS robot states the joints are hydraulically activated.

A number of their other big robots also use hydraulics. For example Big Dog uses a small motorbike/go-kart engine to run a hydraulic pump which drives cylinders.

(Very high budget stuff for an individual developer to get into, I suspect.)

Title: Robotic legs technologies


答: It should be completely safe. Assuming that the 5V BEC on the ESC is not damaged then it is providing a regulated voltage to your Arduino. Furthermore, the USB port on the Arduino is protected from back current with Zener diodes, thus protecting whatever may be plugged into that port.


问:
Overheating/Jamming MG996R servo
I have recently purchased my first ever servo, a cheap unbranded Chinese MG996R servo, for £3.20 on eBay.

I am using it in conjunction with a Arduino Servo shield (see below):

As soon as it arrived, before even plugging it in, I unscrewed the back and ensured that it had the shorter PCB, rather than the full length PCB found in MG995 servos. So, it seems to be a reasonable facsimile of a bona-fide MG996R.

I read somewhere (shame I lost the link) that they have a limited life, due to the resistive arc in the potentiometer wearing out. So, as a test of its durability, I uploaded the following code to the Arduino, which just constantly sweeps from 0° to 180° and back to 0°, and left it running for about 10 to 15 minutes, in order to perform a very simple soak test.

```<code>#include <Servo.h>

const byte servo1Pin = 12;

Servo servo1;                // create servo object to control a servo
                             // twelve servo objects can be created on most boards

int pos = 0;                 // variable to store the servo position

void setup()
{
  servo1.attach(servo1Pin);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
}

void loop()
{
  pos = 0;
  servo1.write(pos);         // tell servo to go to position in variable 'pos'
  Serial.println(pos);
  delay(1000);               // waits 15ms for the servo to reach the position

  pos = 180;
  servo1.write(pos);         // tell servo to go to position in variable 'pos'
  Serial.println(pos);
  delay(1000);               // waits 15ms for the servo to reach the position
}
</code>```

When I returned, the servo was just making a grinding noise and no longer sweeping, but rather it seemed to be stuck in the 0° position (or the 180°). I picked the servo up and whilst not hot, it was certainly quite warm. A quick sniff also revealed that hot, burning motor windings smell.  After switching of the external power supply and allowing it to cool, the servo began to work again. However, the same issue occurred a little while later. Again, after allowing it to rest, upon re-powering, the servo continues to work.  However, I am reluctant to continue with the soak test, as I don’t really want to burn the motor out, just yet.

Is there a common “no-no” of not making servos sweep from extreme to extreme, and one should “play nice” and just perform 60° sweeps, or is the cheapness of the servo the issue here?

I am powering the servo from an external bench supply, capable of 3A, so a lack of current is not the issue.

Please note that I also have a follow up question, Should a MG996R Servo's extreme position change over time?

答:
You might be driving the servo beyond its limits.  As noted in the pololu.com article “Servo control interface in detail”:

If you keep making the pulses wider or narrower, servos will keep moving farther and farther from neutral until they hit their mechanical limits and possibly destroy themselves. This usually isn’t an issue with RC applications since only about half of the mechanical range is ever used, but if you want to use the full range, you have to calibrate for it and be careful to avoid crashing the servo into its limit.

Similarly, the arduino.cc article about Servo.WriteMicroseconds says (with emphasis I added):

On standard servos a parameter value of 1000 is fully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle. [...] some [...] servos respond to values between 700 and 2300. Feel free to increase these endpoints until the servo no longer continues to increase its range. Note however that attempting to drive a servo past its endpoints (often indicated by a growling sound) is a high-current state, and should be avoided.

I suggest running a calibration, where you drive the servo to different angles, to find out what parameter values are large enough to drive the servo to its extreme positions without overdriving it.

Title: Overheating/Jamming MG996R servo


问:
Why do 3-axis accelerometers seemingly have a left-handed coordinate system?
Careful inspection of page 35 (figure 58) of the ADXL345 datasheet shows that under gravitational loading only, the chip uses a left-handed coordinate system.  My own experiments with this chip confirm this.

I typically only use the chip to indicate the gravity vector.  So when using this chip, I simply negate the values to get a right handed coordinate system.  But this doesn't seem right.  I assume there is a logical and mathematical explanation for the left-handed coordinate system but i can't figure out what it might be.

答: My best guess for this would be that, with a left-handed coordinate system, gravity is positive when you are right side up and negative when you are upside down. As mentioned in my comment, be careful about how you "transform" your coordinate systems - negating all values just moves you from one octant to another.


问:
Can ultrasonic and button sensors be run in a VEX analog port?
I'm running out of digital ports, and have no sensors that fit the definition 'analog'. Would it be possible to run a touch sensor, a quadrature encoder, or an ultrasonic sensor on an analog port?

I'm thinking not, but I didn't run across anything that said otherwise.

答:
The underlying microcontroller in the VEX Cortex is some sort of STM32F1 or STM32F2. I'm not sure which model exactly (just that it's a ST-made Cortex M3), but they all do have digital I/O capabilities on the pins used for analog inputs. Given the bare microcontroller, you could do so.

However, the VEX Cortex is not the bare microcontroller. According to the documentation, the controller board has been designed to add a much higher input impedance to the analog inputs which would likely interfere with digital operation:

Input Impedance: Analog - The 8 analog inputs each consist of a 470K pull-up to +5V, a series resistance of 10K and a 20K pull-down resistance to the uP.

You can see the difference in the circuit connections on page 13 of the User's Guide (PDF).


问:
How to use specific ESC,BLDC motor through Arduino Uno R3?

Attempt to clean up:

I'm trying to use this motor with this ESC and an Arduino Uno R3.

Typically, I used the PWM pins when I use the Arduino and an ESC, but I can't control the motor even if I use the servo library, and I've also tried sample code from different websites.

The ESC has a beep I can't understand. Sometimes it's high-low-high or high for 4 seconds, but I can't find anything on Google.

Sometimes the motor spins periodically for a short time, but I don't know why. Some sites recommend using flash or bootloader, but I'd prefer to use Arduino PWM or the servo library.

Original post

Specific ESC is Rctimer Mini ESC16A OPTO SimonK Firmware SN16A ESC..

I can only using ESC(Discussed above..) and RCTimer 1806-1450KV Multi-Rotor BLDC Motor.

Typically, I used PWM pins(3, 9, 10, 11-because similar Signal frequency) when using Arduino-ESC.. but, I can control BLDC Motor even i used to Servo library..

I've been used usual websites example code.

Just ESC had unknowable beep .. sometime di-ri-di or di(for 4 seconds)..
I couldn't find that way.. in google (or my country websites)

Sometimes, The Motor spins(In a certain value, periodically) for a short time but I don't know why The motor spins

In google sites, just using flash or Bootloader, but I'll use Arduino PWM or Servo..

So.. Please! would you please help me?
Thank you for reading my thread.

答:
An ESC needs to have the throttle limits adjusted before you can use it. While there are many options you can set from a programming menu (see page 4 of this PDF for reference), the throttle adjustment is pretty straightforward:

Disconnect the battery from the ESC

Send and hold a full throttle signal to the ESC

Connect the battery to the ESC

Wait 2 seconds for a beep-beep (di-di)

Send a zero throttle signal to the ESC

Hold zero throttle until you hear a long beep

If you continue having problems or this doesn't work, check that the battery pack you are using is fully charged and the correct voltage for the ESC you are trying to use.


问:
Multiple control loops with overlapping effects
I'm familiar with using PID to perform closed loop control when there is a single output and a single error signal for how well the output is achieving the desired set-point.

Suppose, however, there are multiple control loops, each with one output and one error signal, but the loops are not fully independent.  In particular, when one loop increases its actuator signal, this changes the impact of the output from other loops in the system.

For a concrete example, imagine a voltage source in series with a resistor, applying a voltage across a system of six adjustable resistors in parallel.  We can measure the current through each resistor and we want to control the current of each resistor independently by adjusting the resistance.  Of course, the trick here is that when you adjust one resistor's resistance, it changes the overall resistance of the parallel set, which means it changes the voltage drop due to the divider with the voltage source's resistance and hence changes the current through the other resistors.

Now, clearly we have an ideal model for this system, so we can predict what resistance we should use for all resistors simultaneously by solving a set of linear equations.  However, the whole point of closed loop control is that we want to correct for various unknown errors/biases in the system that deviate from our ideal model.  The question then: what's a good way to implement closed loop control when you have a model with this kind of cross-coupling?

答:
Typically with a multiple input, multiple output (MIMO) system, a control engineer uses a state feedback controller. This style of controller leverages a state-space model of the system and generally takes the form:

$$
\dot{x}=\mbox{A}x+\mbox{B}u \\
y = \mbox{C}x + \mbox{D}u \\
$$

where $x$ is a vector of states, $u$ is a vector of inputs, $y$ is a vector of outputs, and the time derivative of the states, $\dot{x}$, shows how the states evolve over time, as determined by combinations of states $\mbox{A}$ and inputs $\mbox{B}$. Outputs are also determined by an interaction between states and inputs, but the outputs can be any combination, so the output state and input matrices are different - $\mbox{C}$ and $\mbox{D}$.

I won't go into a large amount of detail regarding state feedback controls, but in general, the matrices $\mbox{A} \rightarrow \mbox{D}$ "map" or associate a particular state or input to another state or input. For instance, if you want to model a system of unrelated differential equations, you would get something like:

$$
\dot{x} = \left[ \begin{array}{ccc}
\dot{x}_1 \\
\dot{x}_2 \\
\dot{x}_3 \end{array} \right] = \left[ \begin{array}{ccc}
k_1 & 0 & 0 \\
0 & k_2 & 0 \\
0 & 0 & k_3 \end{array} \right] \left[ \begin{array}{ccc}
x_1 \\
x_2 \\
x_3 \end{array} \right]
$$
which represents:
$$
\dot{x}_1 = k_1 x_1 \\
\dot{x}_2 = k_2 x_2 \\
\dot{x}_3 = k_3 x_3 \\
$$

If you wanted to add input $u_1$ to the equation for $\dot{x}_1$ and input $u_2$ to $\dot{x}_3$, then you could add a $\mbox{B}u$ term:

$$
\dot{x} = \left[ \begin{array}{ccc}
\dot{x}_1 \\
\dot{x}_2 \\
\dot{x}_3 \end{array} \right] = \left[ \begin{array}{ccc}
k_1 & 0 & 0 \\
0 & k_2 & 0 \\
0 & 0 & k_3 \end{array} \right] \left[ \begin{array}{ccc}
x_1 \\
x_2 \\
x_3 \end{array} \right] + \left[ \begin{array}{ccc}
1 & 0 \\
0 & 0 \\
0 & 1 \end{array} \right] \left[ \begin{array}{ccc}
u_1 \\
u_2 \end{array} \right]
$$

If you want to keep this, but you think that state $x_1$ contributes to how $x_2$ changes, you can add that interaction:

$$
\dot{x} = \left[ \begin{array}{ccc}
\dot{x}_1 \\
\dot{x}_2 \\
\dot{x}_3 \end{array} \right] = \left[ \begin{array}{ccc}
k_1 & 0 & 0 \\
\boxed{ k_{x_1 \rightarrow x_2} } & k_2 & 0 \\
0 & 0 & k_3 \end{array} \right] \left[ \begin{array}{ccc}
x_1 \\
x_2 \\
x_3 \end{array} \right] + \left[ \begin{array}{ccc}
1 & 0 \\
0 & 0 \\
0 & 1 \end{array} \right] \left[ \begin{array}{ccc}
u_1 \\
u_2 \end{array} \right]
$$

When you write these out now, you get:

$$
\begin{array} \\
\dot{x}_1 & = & k_1 x_1 + u_1 \\
\dot{x}_2 & = & k_{x_1 \rightarrow x_2}x_1 + k_2 x_2 \\
\dot{x}_3 & = & k_3 x_3 + u_2 \end{array}
$$

You can keep building up complexity as your system requires. Once you have a model, for state feedback controls, you need to make sure that the system is linear, in that the system doesn't have trig functions or one state multiplying itself or another state, and make sure that it is time invariant, in that the matrices $\mbox{A} \rightarrow \mbox{D}$ don't change with time - no function of (t) in them. You may be able to make some simplifications, such as a small angle approximation to help get your $\mbox{A}$ matrix into the LTI form required for the next step.

Now you can "mask" the entire system into the tidy two equations first shown, hiding the entire $\mbox{A}$ matrix with just the letter 'A', etc. With the Laplace transform you can (hand-wave) evaluate the uncontrolled, open-loop dynamics of the system. You do this by finding the poles of the system, which in term indicate system response.

You can also evaluate the system to see if it is controllable, meaning that you can use your inputs to alter all of the states in a unique manner, and to see if it is observable, meaning that you can actually determine what the values of the states are.

If the system is controllable, you can take information about the states, $-\mbox{G}x$, and feed that into the system, using the information you have about the states to drive them to a desired value. Using only the two initial equations for clarity, when you add the control signal to the input you get:

$$
\dot{x} = \mbox{A}x + \mbox{B}(u - \mbox{G}x) \\
y = \mbox{C}x + \mbox{D}u \\
$$

which becomes:

$$
\dot{x} = \mbox{A}x - \mbox{BG}x + \mbox{B}u \\
y = \mbox{C}x + \mbox{D}u \\
$$

which can be rearranged as:

$$
\dot{x} = [\mbox{A}-\mbox{BG}]x + \mbox{B}u \\
y = \mbox{C}x + \mbox{D}u \\
$$

Where before you system response was driven by the $\mbox{A}$ matrix, now it is driven by $\mbox{A-BG}$. You can again evaluate the poles via the Laplace transform, but now you have a gain matrix $\mbox{G}$ you can use to tune the controller, putting the poles wherever you want, which establishes the time response to be whatever you want.

The process continues, with observers setup to compare the actual system output $y$ with the model's predicted output $\hat{y}$. This is where it's important to note that the outputs don't have to be the same combination of states as you use in the state differential equation - where your states might be a current your output might be a voltage ($R\times I$) so you can make a comparison with a measurable signal on your real system.

Like I said, there is a ton of information involved with modeling systems and designing state feedback controllers, I just outlined the general process as I believe this is scope you were looking for with your question.


问:
Magnetic, low insertion force connector
I'm building a robotic tea-maker/watchdog robot and have a power problem. I would like to be able to have the robot approach a socket and insert the power cord of a cheap immersion heater (120V, 300W, see links below) to turn the heater on. However, the force and precision required to plug it into the wall is beyond the capabilities of my stepper motors/Arduino.

My solution was a magnetic breakaway power cord like the charger on a Mac but at higher voltage. Deep fat fryers have suitable ones (120V, high power, see links below). However, the problem is I need both sides of the connector, and I can only find the magnetic breakaway power cord, not the opposite side, which would normally be built into the deep fat fryer. I don't fancy buying a whole fryer just to get one little part...

Any ideas? Alternatives to a breakaway cord? Anyone know of any (cheap) 120V induction chargers? I'll resort to a mechanical on/off switch and just leave the robot plugged in if I have to, but I was hoping for something a bit sleeker.

Links:

Immersion heater

Fryer cord

答:
I would suggest that your robot activate a relay which controls power to the heater. This is simpler than solving the original problem of developing the mechanical force to plug it in.

You would use a "power relay", rated for at least 120Vac and 2.5A, something like this.
A mobile robot will communicate via internet or local network to a controller which activates a power relay. You will need another small logic board like an ESP8266 to receive communication from your robot and control the relay.

You may need a cascade of relays, i.e. controller sends 5Vdc control signal to a 12Vdc relay, which sends a 12Vdc signal to a 120Vac relay, to then power the heater. There may be some prepackaged "power relay controller" out there that already helps accomplish this as well.

OwnerDisplayName: IzBelle

Title: Magnetic, low insertion force connector


问:
Are there systematic ways to tune the Kalman filter in engineering practice?
Including Q, R, and initial states of x and P.</p>

答: As I understand you are asking for ways to set initial x(the state vector),  initial P (the covariance matrix), the process noise covariance matrix Q and the measurement noise covariance matrix R. For the first two you have to use common sense and any knowledge you have. If you are estimating the position and velocity of a moving vehicle lets say then they should be the initial position of the vehicle and perhaps 0 if you start from stationary. The P matrix can also be calculated based on the uncertainty you have about these initial positions. But you don't have to worry too much about these because they will converge. The R matrix is usually taken from the spec sheet of your sensors and contains the accuracy(variance) of the sensor. This tutorial will help with the estimate of the Q matrix http://www.robots.ox.ac.uk/~ian/Teaching/Estimation/LectureNotes2.pdf. Finally there is a good way to verify if your estimate of Q is good. Just look at the innovation(z-Hx_pred) and innovation covariance matrix. If the innovation for the states is not within 2 std.devs (as taken from the innovation covariance matrix) then you are underestimating the noise.</p>


问:
Do you know where to get the original iRobot Create?
Does anyone out there know where I can get the original iRobot Create?
The company no longer sells them.
It was only 2 years ago that it was sold. It is white and its value is the physical design, that it has a large exposed deck for mounting armatures.
It is preprogrammed to operate in different configurations, eg. spinning, figure 8, following the outline of a wall, etc.
I have an ongoing art project using this model and as they are in operation everyday, I will eventually need to replace them with new ones.
To see a video of one of my projects you can go to https://vimeo.com/119486779
I currently have it working in a spinning motion.</p>

答:
iRobot is no longer selling original Creates.  So your best bet is a secondary market like eBay.

However, the new Create 2 has the same API as the original.  (Using the Serial Command Interface, not the command module).  It did remove some of the lesser used functions like scripting, but added and improved many features.  Additionally, it is a more robust robot overall, and it even has a rechargeable battery.  I'd be surprised if the new Create 2 didn't work for your application.