问:
How can I compensate for pendulum and cart motion when using an accelerometer to detect the tilt angle?
I have an accelerometer mounted to an inverted pendulum (i.e. a cart-pole robot) which I'm using to measure the tilt angle from the vertical upright position (+y direction).  If the inverted pendulum is held motionless at a fixed angle, the accelerometer essentially detects the gravity direction as a vector $(g_x,g_y)$ and the tilt angle $\theta$ can be determined by

$$\theta=tan^{-1}(\frac{g_x}{\sqrt{g_x^2+g_y^2}}).$$

However, if the inverted pendulum is in motion (e.g. if I'm dynamically trying to balance it like a cart-pole system), the pendulum itself is accelerating the accelerometer in a direction which is not necessarily the gravity direction.  Acceleration from the cart may also distort the measurement of the gravity direction by the accelerometer as well.  In such a case, I don't think the formula above is necessarily appropriate.

Of course, I'm not 100% sure that the swinging motion of the pendulum and the forward-backward motion of the cart are significant enough to distort the angle measurement on the accelerometer.  I presume that if I start with initial conditions close to $\theta=0$ on the pendulum, it shouldn't be that significant.  Nonetheless, if the pendulum is significantly perturbed by a disturbance force, I think the accelerometer's measurements must be compensated in some way.

How can I compensate for pendulum and cart accelerations when using an accelerometer to detect the tilt angle?

答:
If an accelerometer is mounted along the pole axis of a pole-cart system with its axes oriented tangential and normal to the pole rotation, the components of acceleration can be found using rigid body kinematics to yield the following:

Tangential: $S_x = \ddot{X} cos(\theta)-\alpha d-g  sin(\theta)$,

Normal: $S_y = -\ddot{X} sin(\theta)-\omega^2 d-g  cos(\theta)$,

where:

$d$ is the distance from the sensor to the axis of rotation

$\ddot{X}$ is the horizontal acceleration of the cart

$\omega$ is the angular velocity of the pole, and

$\alpha$ is the angular acceleration of the pole

This assumes the pole can be treated as a rigid body and that the cart is limited to motion in the horizontal plane.

Estimating the pole angle, $\theta$, using the measured acceleration components will produce an error if any of $\ddot{X},\omega,\alpha$ are non-zero.

$\theta \approx tan^{-1}\left ( \frac{S_x}{S_y} \right ) = sin^{-1}\left ( \frac{S_x}{\sqrt{S_x^2+S_y^2}} \right ) = cos^{-1}\left ( \frac{S_y}{\sqrt{S_x^2+S_y^2}} \right )$

(Note that the equation in the OP is incorrect.)

Whether this approximation will work with your system really depends on the parameters and the expected magnitudes of the angular velocity, angular acceleration, and horizontal acceleration. Compensating would likely require some additional sensors - e.g., a second accelerometer on the cart and a gyrometer on the pole.


问:
Cant see Kinect Data in ROS
I am working on this project that involves using the Kinect for XBOX 360S with ROS.

I did all the steps mentioned in the ROS Tutorials to have Openni Installed and the Prime sense and other drivers. and when i go to Openni samples i see a output. But in ROS i do a roscore and in another terminal do a roslaunch openni_launch openni.launch. And it loads with the regular calibration warnings and service already registered errors. Then in another terminal i open Rviz which gives a error /.rviz/display_config does not exist. And even though i accept the error and go ahead i see a black window which shows no output ,even if i do all tasks mentioned at the RVIZ Tutorials. Also i tried running "rosrun image_view image_view image:=/camera/rgb/image_color" and it shows up a blank window with no output. How do i resolve this and get ros to show my kinect data??

I need to run RGBDSLAM and use this kinect later.

I am on Ubuntu 12.04 and ROS-Fuerte.

Well when i launch the openni.launch it starts as usual except for the errors ¨Tried to advertise a service that is already advertised in this node.

And when i run a rostopic it just says subscribed to the /camera/depth_registered/points and cursor keeps blinking.
Even subscribing to the rectified topics just says subscribed and nothing more happens.

答:
Try freenect, there are some problems with OpenNI solution.

Firt, install freenect by

```<code>sudo apt-get install ros-fuerte-freenect-stack
</code>```

After installation, connect your kinect (in USB 2.0 port) and run freenect

```<code>roslaunch freenect_launch freenect.launch
</code>```

Then run Rviz and set Fixed frame to /camera_link, you can now add PointCloud2 window and select the right topic to view the input.

```<code>rosrun rviz rviz
</code>```

Hope you enjoy ROS!

ContentLicense: CC BY-SA 3.0

Title: Cant see Kinect Data in ROS

Body:
Try freenect, there are some problems with OpenNI solution.

Firt, install freenect by

sudo apt-get install ros-fuerte-freenect-stack

After installation, connect your kinect (in USB 2.0 port) and run freenect

roslaunch freenect_launch freenect.launch

Then run Rviz and set Fixed frame to /camera_link, you can now add PointCloud2 window and select the right topic to view the input.

rosrun rviz rviz

Hope you enjoy ROS!


问:
FPGAs and stepper motors for precision control
I'm looking at this Dexter robot that uses FPGA controllers to get really accurate position and force sensing on a cheap ($2K) arm. They say that the speed of the processor lets them get this accurate sensing.

I have a couple of questions:

(1) What does processor speed have to with force sensing? Normal clock speeds seem pretty fast.

(2) Why do they use stepper motors if they want the robot to be cheap? Everyone I've talked to has said that for small hobby robots, Dynamixel servos are by far the best choice.

答:
This project is very nice and I was totally obvious to it thanks for spotting it !

In general the difference between FPGAs and classical ASIC integrated circuit is that FPGAs can be re-programmed by the user to emulate certain circuitry. For some task FPGAs are faster than generic processor because of their parallel nature.

(1) What does processor speed have to with force sensing?

Force/torque sensors are rather expensive and the measurements are bias prone, temperature dependent and other cool stuff like that (this is changing thanks to optical force sensing but I didn't see a real life application running yet). So in robotics application they are usually not preferred and motor models based on the position,  its derivatives and current are used (from Dynamixels to kuka LBR4).
In the case of Dexter technical info see here it is what they call Real Time Physics Engine, were they must have fairly complex model (dry friction is not easy to model) of the full robot. The faster you run your model and measurements the faster you can see discrepancies an update the model parameters to have a model matching the measurements. Also if you filter your measurements, if you do it very fast (like FPGA allows) you can reduce considerably the induced delay. Lastly as FPGA call for parallelizing you can run all your sub-model in parallel thus increasing the speed, especially if your model consists of neural network(s).

This gives you a fast model, running 500 faster than typical build (500kHz vs 1kHz, according to their sampling rate), which means that the model can adapt way faster and thus product a better force estimate.

Note also that their advertise their FPGA processor to be well suited for

vision, neural networks, and digital signal processing
  their website

Which are typically applications their parallelization can be employed and speeds up the outcome.

(2) Why do they use stepper motors if they want the robot to be cheap? Everyone I've talked to has said that for small hobby robots, Dynamixel servos are by far the best choice.

I don't think that Dynamixel are Cheap their references with torque measurements are fairly expensive (around $300 each).
From what I gathered they are using 3D printed harmonic drives, in robots like the KUKA LBR4 the harmonic drives are manufactured and this is rather expensive, so using a 3D printed counterpart saves a lot of money.
Last possibility why they use steppers is for the high position precision of the motors, this is an educated guess from going through there website quickly. But in order to have precise translational motion at one meter from the base you need to have even more precise rotational motion which will be amplified by the link length.

On the drive, and design, I am really interested to see how the robot will behave with ware, will so model be good enough to compensate for it ? The 3D printing parts and the belts are going to have some evolution while being used. Typically Nao robots and Baxter robots are also cheap robots and you can literally hear the ware for intensively used robots.


问:
Baxter and Robotics System Toolbox
I am trying to setup a two way communication with the Baxter Robot using the Robotics System Toolbox from MATLAB. However, I am unable to move the arms or record a trajectory using the rosactionclient command. Is there a method to solve this problem?

The examples in the documentation provided by MATLAB uses rosactionclient for the PR2 arm, but is it the same for Baxter as well ?

答:
The quick answer is yes. baxter API  do a search in the page for "Joint Trajectory Action".

You need to have all baxter related software installed.
Also from the first version of the toolbox the use of rosjava was not well documented and especially the use of custom msg/service/ was cumbersome. I hope that they fixed it by now but didn't have the time to look back.

Title: Baxter and Robotics System Toolbox


问:
Inferring joint orientation on multi-joint arm
Not a robotics question in the strictest sense, I guess, but related closely enough, I hope:

I have an arm-like articulated two(-plus-one)-joint appliance that I want to use as a 3D input device. It uses an angle measurement device and two IMUs, which are placed as depicted schematically below:

The blue boxes depict the positioning and orientation of the IMUs (the arrows point to the IMU's relative "forward" direction). The blue dot/highlighted angle represent the angle being measured. The base can rotate around its centre, counting as the third joint, technically, but shouldn't be of too much relevance here. The arm joint rooted at the base has two rotational degrees of freedom, indicated by the red-ish arrows (it can't rotate around the base's up-direction). The unfilled rectangle represents the data I'd like to infer from the other measurements.

edit: I cannot post more accurate schematics here, but if you want to visualise this apparatus a bit better, think of a Geomagic Phantom, except that the lower arm joint is not rotational, but is built more like a classic analog joystick.

Note: The positioning of the sensors, especially of the IMUs at the base and on the second arm joint are fixed, so please do not suggest changing these (I can't).

I'm now wondering how to compute the orientation of the middle link from the data I have: both IMUs return quaternions $q_0$ and $q_2$, respectively (relative to the magnetic north, measured from their relative forward-direction). My representation for the relative rotation between the two arm links is a quaternion ($q_a$) as well (even though it could just as well be directly represented as an angle, but since I'm performing quaternion math anyways, I might as well have it in this form, too). I'm pretty sure that there must be some way to basically compute what an IMU on the middle link (let's call it $q_1$) would measure from the data I have, but I'm not quite sure about my maths here...

My intuition was to compute $q_1 = q_0^{-1} * q_2 * q_a^{-1}$, following from the assumed identity $q_2 = q_0 * q_1 * q_a$, but that doesn't seem to hold. As I feared that the rotation of $q_2$ relative to the joint it resides on influences the computation result, I also computed $q_1 = q_0^{-1} * q_2 * q_{z\pi} * q_a^{-1}$, where $q_{z\pi}$ represents a 90° rotation around the up(=z)-axis.

However, my measurements still seem off when I visualise the movements (the $q_1$ movement seems exaggerated compared to the actually induced movement). What else might I miss here? Is my math faulty, or is it possibly only an implementation mistake I made?

EDIT2: I found that one major flaw of my maths was the lack of calibration. Adding a calibration pose, I was able to compute the relative orientation between the two IMUs in both the visual model and the actual device and go from there. However, to compute the lower link's orientation, I still rely on an equation like $q_1 = q^*_2 * q_a^{-1}$, with $q^*_2$ being the quaternion that rotates from the relative orientation between $q_0$ and $q_2$ in the calibration pose towards their current relative orientation. I'm still not quite sure if that equation is fully appropriate, but it appears to work okay so far.

答:
What else might I miss here?

As pointed out by @Ben, a clear schematics of your robot to make it easily understandable from others.

Maybe it's me missing something but IMU are typically accelerometers and gyroscopes. Meaning that the raw outputs are linear accelerations and rotational velocities. Doing some projection of the gravity vector to retrieve orientation is prone to singularities.

Your problem seems to me relatively close to some pan-tilt control with 2 IMUs.

your intended use is very likely to prove problematic as the nozzel (or end of your arm) will not have the same orientation with respect to the base plan as the altitude evolves

Units quaternions represent a unit vector in the base they are expressed in, associated with a rotation around that vector. So you can not use the same 'simple' math than for rotation matrix, meaning that in order to combine rotation you can not simply multiply the quaternion but need a bit more cumbersome operation see.

I would suggest you to use transformation matrices composed of rotation matrices and translation vectors. This will prove easy to derivate from your clean model, and useful in the long run when you are going to go toward inverse kinematics of you robots. Note that the change from quaternion to rotation matrix is well documented.

edit : re work the explanation of the quaternion math


问:
How to apply Inverse Kinematics with angle constrained servos?
I want to implement Inverse Kinematics and i understand the inverse jacobian method but the servos i have only have a range from -90 to +90 degrees, how can i implement this detail in the algorithm? I can't simply set each joint to its maximum/minimum if the calculated angle is above/below the constraints because if i do future calculations will not understand that the maximum angle is not the correct path</p>

答:
As it seams from the comments you have some redundant mechanism is you want to track a 3D position, if you also want to track an orientation you are down to non redundant mechanism.
Which means that in the first case you might have several IK solution that satisfy your desired position and you can then pick one not violating you actuator constrains. In the second case if actuators constrains are violated by the IK it means you are out of your workspace.

What is a typical approach is to compute the workspace of your arm in Cartesian space, then when you have a desired position (with or without orientation) You can check that this point is in your workspace and if not find the closest point in the workspace.
Then for this point there is a IK solution not violating your actuation limits.
Once you get a solution from the IK you should also check for self-collision, or include that in your workspace description.


问:
Series Elastic Actuator (Passive compliance) vs Impedance or admittance control
I have designed a 2 Degree of Freedom robot using dc motor and gearbox. However, I wanted the robot to be compliant as it'll be used in an unstructured environment with humans. I wanted to know if going SEA is a better option then using an impedance or admittance controller. For the moment I have been able to model the environment as spring and damper. But this model is not very robust. Is it a good idea to do a combination of passive and active compliance? I read in G.A. Pratt's report, and he states that SEA has drawbacks when small motions are required, but isn't this the problem with all compliance control. What are the advantages of SEA over conventional active compliance control methods?</p>

答:
What happens with an elastic actuator is that you have an elastic part between your motor output shaft and the link. This means that you can store energy in this elastic part during the motion, and release it at later stage in the motion.
This is cool for intrinsic mechanical compliance, explosive tasks like hammering or throwing, where a classical joint would be destroyed or not able to provide as much end link velocity.
This comes with the drawback that the control is way more complicated, you have to model the spring effects, when close to human you have to ensure safety as the spring can unload stored energy and hit human way faster than regular joint and last you don't have a very precise control of you end-effector because of all the elastic effects at play.
One way to overcome some of those troubles is to use Variable stiffness Actuators (VSA) that allow to control the stiffness and shift from almost rigid joint to very compliant joint, at the cost of mechanical complexity and additional motor to actuate the stiffness mechanism.

On the other hand you have control techniques to implement software compliance in robot manipulator. What you get is compliance by mean of software, so usually external force measurement is required (F/T sensors, "torque" sensor in the joint). You don't get any of the energy storage/ velocity amplification.
Those techniques are really mature (look for admittance/impedance filters, energy tank based control)  and relatively easy to implement and more importantly easy to tune for your usage. On last benefit of those methods is that you can usually chose different compliance behavior for all axes of you end-effector, eg allowing stiff rotations and stiff vertical motion while allowing very compliant horizontal motion. This is usually great for human interaction as it helps for learning by demonstration and also for assisstive robots as you can chose "forbidden" motion to the user.


问:
Simple PID Loop Question
Let's say, for example, I am controlling a motor's speed by adjusting how much power I feed into it. The motor shaft is connected to some physical device with varying amounts of torque, so in order to keep the speed the same I implement a PID control loop.

Let's say that the base power I am sending the motor is X.
The PID outputs an adjustment value, say Y.

Should I add Y to X for every loop through the PID? Or, should I add only changes in Y to X? For example, if Y changes from 5 to 10, then add 5 to X.

答:
I recently implemented a PID loop for speed control of a treadmill. I used a position encoder to find the speed of the treadmill and used it to find error from a desired speed for the PID controller. The output of the PID controller, called the control signal, is the PWM for the motor. You should see your motors' documentation for speed commands and then serially communicate those to the motor. These speed commands can go from 0% to 100% PWM. 100% would mean that your motor is running at the highest rated voltage meaning highest rated rpm. 50% would mean it is running at half the rated voltage and resulting into half the rated maximum rpm respectively.

You have to map the speed (m/s) into PWM values. You can do this as follows:
Maximum speed = 100% PWM (Must have a value that the motor interprets as full PWM, see motor documentation)

then,

1 = (100% PWM) / Maximum Speed)

and your final PID output should be like:

PID_OUT = (100 % PWM / Maximum Speed)*(Error * Kp + Sum_of_Erros * Ki * Loop_Time + Kd*(Error - Last_Error) / Loop_Time)

Lastly, I am just a noobie. Wait for experienced people for some detailed answers :) .

Hope it helps.

Title: Simple PID Loop Question


问:
Self balancing roboter IMU issue
I build a self-balancing robot, at least that what i should have been.
now i have tried implementing a complementary filter which combines gyro and accelerometer data, but the problem is that the motor and the IMU (MPU 6050) are on the same board and max. an inch away from each other.

So, if i get it right, the vibrations from the Motor do influence the accelerometer way to much, hence i am not getting any applicable result when the robot is set to the ground.

So, what techniques can i apply to get the absolute orientation?

[EDIT]

This, right now, is my code with the complementary filter.
My problem is, that even when the motor is off, the yAngle value varies very much from the yAcc value, although the yAcc value is correct.
Is there any error in my code causing the gyro drift to break the whole filter?

```<code>// 100.0 is dt, 14.375 the gyro-specific resolution
float gyroY = (float)(readY()) / 14.375 / (100.0);
int z = getAccZ();
int x = getAccX();
float yAcc = atan((float)z / (float) x) / PI * 180;
yAngle = 0.98 * (yAngle + gyroY) + (0.02 * yAcc);
</code>```

答:
What sort of values are you getting out of your accelerometer? The raw values you get from an accelerometer will not translate into any form of orientation. Here is some good reading for how to get orientation out of such a mems device.

If noise from your motors really is the issue, I would recommend implementing a Finite Impulse Response (FIR) filter. For example a moving average filter might help you out. I recommend keeping the order of the filter low however, as (depending on your Samples per Second) the higher the order, the slower the response time of the data will be. This could introduce a level of error you will have to be careful of when trying to make your robot balance.

Title: Self balancing roboter IMU issue


问:
laser scanner distance
I'm looking at laser scanners and I see a huge range of detection distances.  The furthest I've see are 30m if you exclude the very expensive ones that claim up to 150m.  My question is what is the reason for the huge difference in range/price.  I would think that with a laser it wouldn't be that difficult to detect something at distances greater than 30m.  What's the physical limitation that makes it so much more expensive to go above 30m for a laser scanner or is there one?</p>

答:
It may be worthwhile to consider how laser scanners work. We know that it is possible to send a beam of light at an object, and detect how long it takes to be reflected back to the sensor to measure its distance.

First of all, we use lasers because reflection of the light from the object is so important. lasers keep the light concentrated in a narrow beam, with minimal refraction. We'll come back to that later.

There are several ways to measure distance. The first is triangulation. This typically depends on good placement of optics, and the CCD sensor the return beam shines onto. You can easily see the problem with a large distance - the angle detected gets increasingly close to $0^\circ$, so that we need sensor components which are very accurate at small scales. We would also like a beam width which is narrow for accurate detection of where the beam is, but there is greater diffraction at narrow beam widths, meaning the return beam of light is not that narrow. Over long distances, the beam gets increasingly wider, because of the small amount of diffraction.

The second way is to measure the round-trip time. Light travels very fast at $3\times 10^8  \textrm{m/s}$. This means that even detecting something at $150 \textrm{m}$ will take $1 \textrm{μs}$. Embedded computers typically have a clock rate of only several megahertz, so even at this large distance, a system would struggle to provide an accuracy of 10%, and that is assuming the data acquisition is as fast - often the peripheral features have a slower clock rate.

The data acquisition is typically much slower, allowing cheaper systems to be built. As to how they can get away with this - an interesting phenomenon is used. If a sinusoidal signal is embedded into the light (via the intensity), the return signal will also be a sinusoidal signal. However, depending on the distance, the signal will have a phase shift. That is, at $0 \textrm m$, there is no phase shift, and if the wavelength is $20 \textrm m$, then an object at $5 \textrm m$ will mean that the light travels $10 \textrm m$, creating a phase shift of $180^\circ$. If the signals are normalized to the same amplitude, taking the difference between the outbound signal, and the return signal, we get another analog sinusoidal signal (note: this is only one method). The amplitude of this depends on the phase shift. At $180^\circ$, we get the maximum amplitude - double of the original outbound signal. We can easily detect the amplitude of this signal even with slow digital circuitry.

The main problem is that the choice of wavelength limits the maximum range. For example, the wavelength of $20 \textrm m$ limits the detection range to only $5\textrm m$. If we simply chose a much longer wavelength, we would get the same percentage accuracy. In many cases, if we want greater absolute accuracy, the system will have a greater cost, since we must more accurately measure amplitude in the face of environmental noise. This may involve a number of changes - for example, a larger laser beam, greater light intensity, and more accurate electronic components, more shielding of noise, and more power to run the system. If any one of these is not good enough, accuracy is affected.

The other problem which affects all methods is the intensity of the return beam. As the distance increases, the intensity decreases. There is not that much scatter of light in air, so attenuation is not so much caused by this. However, even though a laser light is used, there is a very small amount of diffraction. It is not possible to remove this diffraction completely, although it can be decreased with a wider beam width. Diffraction reduces the amount of the returning light beam incident on the sensor. Because the beam width gradually increases, the sensor only receives a small proportion of the returning light. This affects the accuracy of measurements. Using a larger sensor can also increase noise. Therefore, here we also see another limit on the distance. We can increase the distance by increasing light intensity, or increasing beam width. However, increasing light intensity increases power consumption and heat, while increasing beam width requires larger optic lenses, and larger distances between optic components.

Essentially, there is a balance between cost, accuracy, power consumption, and size of the system, and longer distances often requires better components to maintain accuracy.

Title: laser scanner distance


问:
How do timings affect input, sensor fusion, and output?
I'm programming a quadcopter controller. I've managed to make it fly. But, I'm not sure how to set up the timings schedule for each part of the software.

I have several sensors (gyro, accelerometer, magnetometer, barometer) with output at various frequencies. Those data go into the sensor fusion. Then, the fused data goes through a PID controller. The PID output goes into the motors.

So, my questions are:

How often should I read samples from a sensor (read the register over i2c) with relation to the frequency I configure the sensor to?

How should hardware filters such as a low pass filter on the accelerometer be applied here?

How quickly (frequency wise) should I use that data during sensor fusion (such as a complementary filter)? Should the fusion timing be based on when a new sample is ready or do I run the fusion faster or slower than I sample?

How do sensors sampling at different speeds affect fusion? For example, my magnetometer has a max data rate of 100hz, but currently, my gyroscope is running at 200hz.

Should the PID controller run at a different rate from the fusion?

答:
How often should I read samples from a sensor (read the register over i2c) with relation to the frequency I configure the sensor to?

If you sensor provide data at a certain rate you should not read it at a faster rate because it's note bringing any new info to you just repeating an old/depreciated info.

How should hardware filters such as a low pass filter on the accelerometer be applied here?

You should apply you low pass filter on the raw data and feed the filtered data to the fusion algorithm, note that if you filter too much you will get time delays. If you don't explicitly account for them in the fusion and control, you will get poor results

How quickly (frequency wise) should I use that data during sensor fusion (such as a complementary filter)? Should the fusion timing be based on when a new sample is ready or do I run the fusion faster or slower than I sample?

You should run you fusion algorithm every time you get a new measurements, whatever it is, you can tune the frequency of every sensor to allow your fusion algorithm to finish by the time it gets a new measurements.

How do sensors sampling at different speeds affect fusion? For example, my magnetometer has a max data rate of 100hz, but currently, my gyroscope is running at 200hz

It's not an issue a fusion algorithm takes several quantities as inputs with also their variance (ie how trustworthy is the measurements) to derivate a full state estimate. For example if you have a very precise position system but low frequency and fast accelerometers, the position model will be such that the accelerometers are integrated between the measurements of the position sensor, but once you get a next position the measurement "wins" against the estimate.

Should the PID controller run at a different rate from the fusion?

Your control should run as fast a possible but not faster than the fusion because you don't have information update about your current state, typically they run at the same frequency and both as fast as possible based on your hardware power.


答: Using the same terms as your question, the PID contoller should provide a new X, not an incremental value that gets summed to the previous one.  The input to the PID controller should be the difference between desired speed and measured speed in the example you describe.   We call this velocity control, compared with the more typical position control in which the difference between desired position and actual position becomes the input to the PID loop.

Title: Simple PID Loop Question

Body:
Let's say, for example, I am controlling a motor's speed by adjusting how much power I feed into it. The motor shaft is connected to some physical device with varying amounts of torque, so in order to keep the speed the same I implement a PID control loop.

Let's say that the base power I am sending the motor is X.
The PID outputs an adjustment value, say Y.

Should I add Y to X for every loop through the PID? Or, should I add only changes in Y to X? For example, if Y changes from 5 to 10, then add 5 to X.


问:
why is quadrotor motion planning hard?
With introduction of incremental sampling algorithms, like PRM and RRT planning in higher dimensional spaces in reasonable computation time has become possible though it is PSPACE-hard. But why is a quadrotor motion planning problem still difficult even with simplified quadrotor model?

I was solving a dynamic car problem with OMPL, which produced solution within 10s but I set a planning time of 100s for quadrotor, but it still does not find a solution.

答:
One thing you should consider is that the quadrotor is underactuated and has a strong dynamical coupling between translational and rotational dynamics. Hence not all arbitrary trajectories are feasible. You can think about an equivalent problem parallel parking, although the 2 problems are not strictly equivalent.

Based on how your handle that in you planner you might run in the problem described.

Title: why is quadrotor motion planning hard?


问:
How to round of these values to 0
How to shorten these values?

They are the result of a matrix like this.

When I individually run sin(theta1) and such functions, it would give me the correct value as a zero or a one (the angles I am working with are 0 or 90 degrees)

In some cases they may go on to be values like 1.574.

I know there is a round off function in MATLAB, but then I would have to add that function to every element individually. Is there any easier way to achieve this?

PS.: ST stands for sin(Theta) SA for Sin(Alpha) CA for cos(Alpha) and so on..

PPS. : I tried eval function, not working at all.

Edit 1:
The code I am using is as follows:

```<code>init_lib;
clc;
load_robot;

syms q1 q2 q3 q4 q5;

%DH Parameters for the robot:
robot.DH.theta= '[pi/2 pi/2 0 q(4) q(5)]';
robot.DH.d='[q(1) q(2) q(3) 0.1 0.020]';
robot.DH.a='[0 0 0 0 0]';
robot.DH.alpha= '[pi/2 pi/2 0 pi/2 0]';

% We input the joint parameters:
q = [q1 q2 q3 q4 q5];

%Storing the evaulated values of 'q'
Theta=eval(robot.DH.theta);
d=eval(robot.DH.d);
a=eval(robot.DH.a);
alpha=eval(robot.DH.alpha);

A01=dh(Theta(1), d(1), a(1), alpha(1));
A12=dh(Theta(2), d(2), a(2), alpha(2));
A23=dh(Theta(3), d(3), a(3), alpha(3));
A34=dh(Theta(4), d(4), a(4), alpha(4));
A45=dh(Theta(5), d(5), a(5), alpha(5));
A05 = A01*A12*A23*A34*A45;
disp(A05);
</code>```

Where, dh is a function that comes from a predefined library. It basically substitutes the four values into a generalized form of the matrix I posted as the second image.

答:
As you are using the symbolic toolbox, you should declare your angles as symbolic so that the cosine of ${\pi/2}$ is  zero instead of numerically estimated to something close to zero.
Also so you can convert your expression to a function via the matlabFunction() native function from matlab.

Alternatively on matlab you can use round on a matrix and it's rounding every single entry individually.

Title: How to round of these values to 0


答: The best solution that comes to my mind in vpa(). It stands for variable precision arithmetic. If you have a symbolic expression X (I believe a matrix with symbolic entries should work as well), then vpa(X,d) will return all the constants within X as a number with at most d significant digits.</p>

Title: How to round of these values to 0

Body:
How to shorten these values?

They are the result of a matrix like this.

When I individually run sin(theta1) and such functions, it would give me the correct value as a zero or a one (the angles I am working with are 0 or 90 degrees)

In some cases they may go on to be values like 1.574.

I know there is a round off function in MATLAB, but then I would have to add that function to every element individually. Is there any easier way to achieve this?

PS.: ST stands for sin(Theta) SA for Sin(Alpha) CA for cos(Alpha) and so on..

PPS. : I tried eval function, not working at all.

Edit 1:
The code I am using is as follows:

```<code>init_lib;
clc;
load_robot;

syms q1 q2 q3 q4 q5;

%DH Parameters for the robot:
robot.DH.theta= '[pi/2 pi/2 0 q(4) q(5)]';
robot.DH.d='[q(1) q(2) q(3) 0.1 0.020]';
robot.DH.a='[0 0 0 0 0]';
robot.DH.alpha= '[pi/2 pi/2 0 pi/2 0]';

% We input the joint parameters:
q = [q1 q2 q3 q4 q5];

%Storing the evaulated values of 'q'
Theta=eval(robot.DH.theta);
d=eval(robot.DH.d);
a=eval(robot.DH.a);
alpha=eval(robot.DH.alpha);

A01=dh(Theta(1), d(1), a(1), alpha(1));
A12=dh(Theta(2), d(2), a(2), alpha(2));
A23=dh(Theta(3), d(3), a(3), alpha(3));
A34=dh(Theta(4), d(4), a(4), alpha(4));
A45=dh(Theta(5), d(5), a(5), alpha(5));
A05 = A01*A12*A23*A34*A45;
disp(A05);
</code>```

Where, dh is a function that comes from a predefined library. It basically substitutes the four values into a generalized form of the matrix I posted as the second image.


问:
IR pattern projector
I am currently working on a robotics project in which I wish to integrated a depth/object scanner. Now my focus is currently on an IR camera in combination with some sort of IR pattern projector.

Now I am having a hard time finding any sort of IR projector which can project a pattern. I have found several topics suggesting that I use an IR-LED and create a pattern in front of it, but that would mean the projector would take up significant space.

Are there any projectors out on the market in a sensible form-factor for consumers? I came across the Structure Core, but that's only available to OEMs.

答:
One solution you might want to explore is the approach of the Intel Euclide sensor
The form factor is almost matching your specs, and it also contain a set of localization algorithms that run on-board.
The clam from the manufacturer is that the image are more stable in IR that with visible light, hence the solution consists in illuminating the scene with IR and record the image, this info is then matched with the one of visible camera.</p>

Title: IR pattern projector


问:
How do I compute the Jacobian of a two-link manipulator arm?
Really confused on how to do this, a general guideline for how to do this would be very much appreciated.</p>

答: Compute the forward kinematics, then take the partial derivative of each $x$ term with respect to each of the joint angles. </p>


问:
How to set the output in a differential amplifier?
Can anyone please tell me if the sensor output is 0 to +-10V, and I connect the sensor to a differential amplifier to get an output of 0 to 3.3V then what is the input voltage to the differential amplifier from -10v to +10v or (0 to 10 v or -10 to 0v)?

If I use -10 to 10 volts then the differential amplifier adds both the input voltages and gives +20V and with gain, we can adjust it to 0 to 3.3. But, if I use 0 to 10v or 0 to -10V then I get half voltage with the above set gain.

Can anyone please explain?

Thank you!

答:
A differential amplifier amplifies the difference between the signals. If you had a differential amplifier that scales a ±10v differential signal to a 0 to 3.3v signal, it would expect that the maximum input would be a 20v difference between the terminals. That's why you need to apply a 20v signal to the input to get the output you want.

If you have a sensor that outputs from -10v to +10v then you would need to apply 10v to one side of your differential amplifier so that 0v from your sensor corresponds to 1.65v out, -10v is 0v and 10v is 3.3v

ContentLicense: CC BY-SA 4.0


问:
Most material efficient quadcopter frame
I haven't made or flown any quadcopter, but I am fascinated by them.
But when looking at the frame of a lot of designs, after whachting this video I wondered why a lot the frames are in an X shape. Since the most efficient shape would according to the video be something like this >-<, where each corner is 120°.
I also did a quick search on the internet and found this blog which stated the same (however he did not mention the exact angle) and said: "Even though this is not entirely a new idea, it has not yet been widely accepted by the community."</p>

答:
If adjacent motors are 1 unit apart, the overall path-length of an X form is 2√2, or about 2.8284, and the overall path-length of a Steiner form is 1+√3, or about 2.732, which is 3.5% less.  It is likely that hub mounting will decrease either or both of the total lengths by a few percent, but I will ignore that factor for the moment and merely say that the length improvement provided by using a Steiner form is quite small.

In addition, the Steiner form will require either two hubs or one rather-long hub, and may require mounting hardware for spokes at six points instead of four.  Because hub weight often is comparable to the weight of one or more spokes, the Steiner form has a weight disadvantage.  (See “Intro to Multirotors, Theory, Build Log and Tips” for a series of pictures that illustrate relative hub and spoke sizes for a variety of quadcopters.)

A central point, as available with an X-frame, is a convenient location for a battery and a controller that serves all the motors.  For balance, an extra pad for mounting the battery and controller would be needed on the middle bar of a Steiner frame (unless multiple batteries and controllers are used).

Note, the quacopters-drones-quad-flyers page at wowhobbies.com includes a quadcopter, hexacopter and octocopter buying guide, in which several units are characterized by IAS, meaning there is “Inadequate Structural Support (eg: booms are too long and center frame is too weak to support the size of the quadcopter structure or any substantial payload)”.   As size scales up, the crossbar in the Steiner form needs to scale up more than the rest of the arm structure (which will also overpower that form's 3.5% length advantage) else the frame will become structurally inadequate.


问:
Nuc, custom pc or raspberry pi?
For our Minor “Robotics and Vision” we need to use ROS to create a system that can navigate to and from a coffee machine. The available hardware consists of a robotic platform from "Dr Robot", and a manipulator that uses actuators from Dynamixel. The system should use computer vision to navigate the robotic platform and manipulator.

Besides the robotic platform and manipulator, we have a limited budget of 500 euros to get all the other necessary hardware, including the processing device(s).
This/these devices need to run the ROS core and nodes that are responsible for:
-    Analyzing environment with computer vision;
-    Controlling the engines;
-    Controlling the manipulator;
-    Interfacing with a database.

After research we found that we could use a PC, like an Intel NUC or a custom PC. Or we could use several Raspberry Pi’s to run separate nodes, and let them communicate within a network. We tried to find out how much computational power was necessary to fulfill our requirements, but after searching online for a while we could not find a fitting answer.

Our question is if anyone knows how much computation power we need to fulfill our aforementioned requirements, or how we could find out (without spending the entire budget).

EDIT:

The problem for us is that we are using the V-model, which means that we design our entire system before implementing it, therefore we have to decide on what type of hardware we use for the system before we "are allowed" to write any software. This makes it impossible to test it before ordering the computing part.

答:
Edit:

With the new information in your post I would highly recommend going for more computing power than you think you need. It is always to have a little extra wriggle room than to be stuck with not enough.

Raspberry Pi's have the awesome advantage of the easily accesable GPIO. ROS is good but adds extra complexity over a single system. On the flip side, using multiple Raspberry Pi's allows you to develop and prove up each system individually.

Alternatives to the Raspberry Pi are:

pcDuino

BeagleBone Blue (Has 2x 32-bit PRUs. Comparison here and here)

Onion Omega2

CubieBoard6 or CubieAIO

Think about solving the problem differently. I get the impression that you expect to get it working first time without having to re-engineer anything. Instead consider creating a few prototypes first before designing your final system. Similar to the iteration/spiral model

Your first prototype is going to be your proof of concept. I have a philosophy of using computers/processors/equipment that far exceeds my minimum requirements for the proof of concept. That way you can prove that each system works, without having the problem of needing just a little more of this or that.

In your case that would mean that I would start off with a full blown computer (probably something I had lying around spare). It could even mean that you prove up each section on separate hardware and combine it at a later stage.

Then you can refine your design down until you have it running on the minimum hardware required. This will most likely require you to take measurements of the resources and processing power you use.

So how does this all fit into your 500 euro limit? In most cases the requirement is that the final design costs 500 euros. How you get to that final design isn't counted. Even if it is, you can usually get decent second-hand hardware for practically nothing.

Title: Nuc, custom pc or raspberry pi?


答:
This largely depends on the environment and the sensors on your robot.

First, are you required to only use computer vision for navigation? If not, I would recommend at least adding wheel encoders. The encoder can give you pose over time that drifts while vision can update your pose. You can also add a gyro for better heading, but you need to remove bias etc...

Second, can you modify the environment? You can put marker in you environment for the computer vision algorithm. There are types of marker you can use to extract the robot pose. This would probably be your best option if you want to use a computer like raspberry pi. If you are going to try slam or something, you will probably need a better computer.

Edit: The Jetson computers are a pretty good for computer but may just be out of your budget.

Title: Nuc, custom pc or raspberry pi?

Body:
For our Minor “Robotics and Vision” we need to use ROS to create a system that can navigate to and from a coffee machine. The available hardware consists of a robotic platform from "Dr Robot", and a manipulator that uses actuators from Dynamixel. The system should use computer vision to navigate the robotic platform and manipulator.

Besides the robotic platform and manipulator, we have a limited budget of 500 euros to get all the other necessary hardware, including the processing device(s).
This/these devices need to run the ROS core and nodes that are responsible for:
-    Analyzing environment with computer vision;
-    Controlling the engines;
-    Controlling the manipulator;
-    Interfacing with a database.

After research we found that we could use a PC, like an Intel NUC or a custom PC. Or we could use several Raspberry Pi’s to run separate nodes, and let them communicate within a network. We tried to find out how much computational power was necessary to fulfill our requirements, but after searching online for a while we could not find a fitting answer.

Our question is if anyone knows how much computation power we need to fulfill our aforementioned requirements, or how we could find out (without spending the entire budget).

EDIT:

The problem for us is that we are using the V-model, which means that we design our entire system before implementing it, therefore we have to decide on what type of hardware we use for the system before we "are allowed" to write any software. This makes it impossible to test it before ordering the computing part.


问:
What algorithm should I implement to program a room cleaning robot?
For this question assume that the following things are unknown:

The size and shape of the room

The location of the robot

The presence of any obstacles

Also assume that the following things are constant:

The size and shape of the room

The number, shape and location of all (if any) obstacles

And assume that the robot has the following properties:

It can only move forward in increments of absolute units and turn in degrees. Also the operation that moves will return true if it succeeded or false if it failed to move due to an obstruction

A reasonably unlimited source of power (let's say it is a solar powered robot placed on a space station that faces the sun at all times with no ceiling)

Every movement and rotation is carried out with absolute precision every time (don't worry about unreliable data)

Finally please consider the following properties of the robot's environment:

Being on a ceiling-less space station the room is a safe but frustratingly close distance to passing comets, so the dust (and ice) are constantly littering the environment.

I was asked a much simpler version of this question (room is a rectangle and there are no obstacles, how would you move over it guaranteeing you could over every part at least once) and after I started wondering how you would approach this if you couldn't guarantee the shape or the presence of obstacles. I've started looking at this with Dijkstra's algorithm, but I'm fascinated to hear how others approach this (or if there is a well accepted answer to this? (How does Roomba do it?)

答:
I'm not sure if you still need it, but for those who happened to google for this thread, I have made one simple version of the algorithm.

Basically, it tries to build the map of the area while it cleans, and it uses the map to find the nearest unvisted node (part of the room). When it can't find any, that means the room is cleaned (or the uncleaned parts are inaccessible by the robot).

It might be slower than other algorithm, but it can guarantee coverage regardless of starting position, direction and obstacles.

https://github.com/dungba88/cleaner_robot

UPDATE: I have made a demo here and comparing it with a backtracking DFS. So even though my algorithm is O(N^2), it is much more optimized in terms of number of moves and turns.

http://jenova.dungba.org/cleaner/showdown


问:
IMU measurement model
I read in this set of slides on p.11 that the IMU measurements, such as acceleration are affected by bias and noise, as expressed in this equation:

$_B \mathbf {\tilde a} _{WB}(t) =\  \mathbf R_{BW}(t)(_W \mathbf a_{WB}(t) -\ _W \mathbf g) + \mathbf b^a(t) + \mathbf n^a(t)$

where $b^a(t)$ is the bias of the accelerometer, $n^a(t)$ is the noise of the accelerometer, ${\tilde a}(t)$ is the measured acceleration, and a(t) is the true acceleration. As for notations:

Left subscript denotes the reference frame in which the quantity is expressed.

Right subscript {Q}{Frame1}{Frame2} denotes Q of Frame2 with respect to Frame1.

Last of all, noises and bias are all in the body frame.

What I would like to ask is what does the $R$ term in the equation mean and do? I'm guessing it is a rotation, but why is it needed? Sorry if this question seems trivial, but I'm new to all this and my physics is terrible... Thank you!

答:
Maybe this answer is a bit late, but it could be useful for someone else.

Since the true acceleration is defined in the world frame, but the IMU's measured acceleration is defined in the body frame (the same as the IMU), you need the rotation matrix $_B\mathbf{\tilde{a}}_{WB}(t)$ to convert from one acceleration into the other. If you don't consider this matrix, the calculations will be wrong because you'd be mixing measurements observed from different perspectives.

With a practical example, let's suppose you are holding your phone (which we also suppose that already includes an IMU) with the screen pointing up, and you define a vector normal to the screen as a forward direction (this would be the so-called body frame). Then, if you move the phone in that direction, the IMU could measure an acceleration forward. However you, as an external observer, would observe that the phone moved upward rather than forward, because the notion of forward is different from your perspective.
That apparent inconsistency is caused by the different coordinate frames we define and is fixed by knowing the relative transformation between them; in this case, that transformation is the rotation matrix we were talking before.

Title: IMU measurement model


问:
What is the difference between "Sharp Distance Sensors" and "Diffuse Type Sensors" and others?
Searching online I have stumbled across following type of sensors that claim to measure distance. I don't quite understand the difference between them and their pros and cons. Would appreciate if someone can explain the difference between those.
I myself trying to build a bot and want to figure out which sensor to use for opponent detection, balancing between the accuracy, speed and the sensor price)

Sharp Proximity IR sensors (these are fairly affordable)

Diffuse type sensors (these sensors are for some reason very expensive, why?)

Mini Lidar (those sensors are somewhat in between, but still are on the pricey side)

答:
Sharp Proximity IR sensors (these are fairly affordable)

This is a parallax (or triangulation) sensor.  It detects distance by "watching" where a focused beam of light falls on the target.  The range is usually short and different physical designs (different lenses) are used for different ranges.  The color of the object does not matter much as long as the detector can see the inferred dot.  These detectors are commonly used in copiers to detect closed lids and the presence of paper.

Diffuse type sensors (these sensors are for some reason very
  expensive, why?)

These sensors measure distance by the amount of light that is reflected back to the sensor.  All the targets need to be of the same color and reflectivity.  This is because light or white object reflect more light and will trigger the sensor further away then a dark or black object.  Likely, these sensors are expensive because they are adjustable.  Likely, these detectors are used in manufacturing to detect the same type of object over and over again.

Parallax (or triangulation) and diffuse (or reflective) sensors are talked about here.

Mini Lidar (those sensors are somewhat in between, but still are on
  the pricey side)

There are several types of LIDAR or LIght Detection And Ranging technology.  Basically, these detectors measure the distance to the target by exploiting either the phase of the reflective light or the time it takes the light to travel the distance to the target.  Either way, a considerable investment is made into the electronics to measure such features of light.  In general, LIDAR can operate over a much wider range of distances then either of the other two methods mentioned here.  These detectors are used in autonomous automobiles and other such navigation.

LIDAR sensors are talked about here.

I myself trying to build a bot and want to figure out which sensor to
  use for opponent detection,

Most people who build a Sumo-Bot use the parallax or triangulation sensors.  They are cheap and there is a model with a range that is a good fit for a Sumo-Bot arena.  For building a larger robot, especially for navigation purposes, an expensive LIDAR system using spinning mirrors may be necessary.


问:
Mathematical prerequisites for beginning graduate student in robotics
A beginning graduate student in robotics asked me the areas of mathematics that he should brush up on (prerequisites) to begin a masters research program in robotics. What are some good materials/books that are indispensable for a research student? Which ones should we suggest in order that the student develops a solid foundation in robotics?</p>

答:
This depends heavily on what the research topic will be on. For example, is it:

image processing, machine vision...

SLAM

path planning

control

robotic manipulators?

...

Without knowing the area of research, it is not simple to know what mathematics will be required. Having said that, any mathematics required is taught during undergraduate studies anyways, so there are no real requirements. Any domain-specific mathematics generally just needs basic knowledge of matrix algebra to build on top of.

Some programming experience is likely to be required as well.


问:
Particle filters: How to do resampling?
I understand the basic principle of a particle filter and tried to implement one. However, I got hung up on the resampling part.

Theoretically speaking, it is quite simple: From the old (and weighted) set of particles, draw a new set of particles with replacement. While doing so, favor those particles that have high weights. Particles with high weights get drawn more often and particles with low weights less often. Perhaps only once or not at all. After resampling, all weights get assigned the same weight.

My first idea on how to implement this was essentially this:

Normalize the weights

Multiply each weight by the total number of particles

Round those scaled weights to the nearest integer (e.g. with int() in Python)

Now I should know how often to draw each particle, but due to the roundoff errors, I end up having less particles than before the resampling step.

The Question: How do I "fill up" the missing particles in order to get to the same number of particles as before the resampling step? Or, in case I am completely off track here, how do I resample correctly?

答:
I use @narayan's approach to implement my particle filter:

```<code>new_sample = numpy.random.choice(a=particles, size=number_of_particles, replace=True, p=importance_weights)
</code>```

a is the vector of your particles to sample, size is the count of particles and p is the vector of their normalized weights. replace=True handles bootstrap sampling with replacement. The return value is a vector of new particle objects.

Title: Particle filters: How to do resampling?

Body:
I use @narayan's approach to implement my particle filter:

new_sample = numpy.random.choice(a=particles, size=number_of_particles, replace=True, p=importance_weights)

a is the vector of your particles to sample, size is the count of particles and p is the vector of their normalized weights. replace=True handles bootstrap sampling with replacement. The return value is a vector of new particle objects.


问:
How can I stream Kinect V2 tracking data from PC to Raspberry Pi 3 through WiFi?
I'm currently working with Kinect v2. I can do all sort of stuff on PC with it. What I want to do next is, to get the data I want on PC and control the Raspberry Pi with that data (for example, I will move the Pi with motors when I tilt my head to right). I have sorted out the motors and everything but I just don't know how to use that tracking data I have on PC to control the Pi.

I hope the question makes sense, i'm just extremely new to both Pi and Kinect.

Edit: Further clarification of what I'm trying to achieve.

I have a Raspberry Pi which is connect to 2 step-motors through a motor driver. With this setup, I can run a Python script and turn on or off the motors with that.

Now I also have a Kinect V2 connected to my PC.

What I want to achieve is, to issue the 'turn on - turn off' commands from the Kinect which is connected to my pc and not the Pi. I want to tell the pi from my computer, for example, when I turn my head left, turn on the motors connected to the Pi. I can issue the commands through the python script inside the Pi. Now I want to issue those commands from my PC which has the Kinect data and I want to do it through WiFi connection.

Step1: Get the head movement data from Kinect on my PC.

Step2: Send that data to Raspberry Pi, somehow(The step where I have the problem).

Step3: Pi turns on motors according to that data.

I hope this clerifies the problem.

Thanks for the help!

答:
In general in what you describe you have 2 main hardware parts, a sensor(kinect) and actuators (motors). Each might or might not have its dedicated computer to deal with the perception algorithm or control algorithms respectively.

From a software point of view you have 3 main components; the perception algorithms retrieving informations from the sensor and processing it;  the high level decisional algorithm reacting to those information and generating response behavior for your system; and lastly the actuators making the response possible.

Edit:

considering you extended questions you have two solutions:
1. use a middleware  like ROS to handle the communication for you
2. write your own communication protocol ( most likely a kind of server client)

Option 1 will usually bring you more tools and it will be easier to further add components / functionalities in your system. Option 2 it is dedicated you have control over everything.


问:
Why don't bipedal robots ever feature natural movement?
I'm a programmer and I've decided to make some bots for fun. I might start with wheels but my ultimate goal is to make bipedal robots. To that end I first decided to watch a bunch of videos of such bots to see what their motion and parts looked like. One thing that struck me as counter-intuitive is how the forward motion of the robots is being carried out in every example I see.

When a human walks forward, they walk heal-first to toe upon their stride with one leg while pushing off the ground with their opposing heal (Or is it toe). In any case, I don't see any bipedal robots doing this. But why not? It seems to me that given sufficiently replicated feet and legs, bipedal robots should be able to carry out the same motion. Sure, the programming and/or training for this might be difficult but obviously doable. Or am I missing something?

Edit: I do realize that when a person walks, they shift their weight to perform their stride. Also doable though right? There isn't anything magical about the motion of a walking human as far as I know.

答:
From my side I can provide two remarks.
First the human have elastic actuators (muscles) with a lots of sensors for balance. Whereas robots have mostly rigid actuators with a few dampers here and there to avoid breaking the motors on collision, and then they have far less sensing capabilities to maintain balance. So the two are not really comparable.
Another point is that walking is very unstable, you are virtually loosing equilibrium and saving it last minute to go forward. The same strategy is usually not applicable to expensive robots. The main reason being that human have local close loop of control (reflexes) whereas robots need to have complex centralized motion algorithms.

If you want to see human like walking have a look at mechanical systems tailored for that and using the same springy behavior as humans, like
"A bipedal walking robot with efficient and human-like gait" from Collins at ICRA 2015.


问:
Understanding the current limitations of small industrial robots
I am far from an expert on robotics, but I am currently investigating the feasibility of automating a key task in our factory.

We have an application where we would need image recognition and depth sensing to specify a coordinate in 3d space, where an object exists. Think of this as something hanging of a small tree / bush.

Then we need to make to robot arm to move there and using a cutting end effector to cut of the string to the object hanging.

As far as I understand it seems like most industrial robots today need to be pre programmed. Are there any good solutions where you could basically say to the robot:

```<code>moveTo(x,y,z)
cut()
return()
</code>```

where the (x,y,z) coordinates comes from a depth camera setup with image recognition. I am sorry if the questions is too non specific, but I would like to know what the current state of the technology is.

答:
Yes, with some caveats, using machine vision to get the 3D pose of an object and then using an industrial robot with a cutting tool to go to a location is within the capability of current technology.

Talk to your local automation and machine vision vendors.

Perhaps do a little searching on fruit picking robotics as the task is probably similar.


问:
Wearable Accelerometor
I've worked with wiimote accelerometer, but I think now I want to move past that. Mostly because I want to have a wider range of available gestures and I think that using only one accelerometer has too many limitations for what I want to do. I'm looking for something compatible with arduino or RPi. Does anyone have recommendations on how I should do this?</p>

答:
The Mpu6050, or 9150 is great for gesture sensing. The 6050 has a 3 axis accelerometer and a 3 axis gyro. The 9150 has all that, as well as a 3 axis magnetometer.

Theoretically, you can program gestures into it that trigger an external interrupt when they are activated. Unfortunately, Invensense, the makers of the chip have not been forthcoming with documentation on how to do that.

If you want to write the gesture reconization yourself, then there is a library for getting plain data as well as quaternions from the 6050 at https://github.com/jrowberg/i2cdevlib

If you go with the 9150, there is a great resource of code at https://github.com/Pansenti/MPU9150Lib, which includes resources to do some of the higher level processing the 9150 is capable of.

I actually am trying to use the line of mpu's myself, as part of a rocketlogger project. I have some of my code at http://waterrocketry.com It doesn't entirely work yet, but it is still a work in progress, and I hope to have full control of the Data Motion Processing of the 6050 soon.

Good luck with what your building

Title: Wearable Accelerometor


问:
Industrial Controllers - Why not adaptive control and robust control
This is a question I have thinked about under a very long time. What are industrial controllers?

From research I found that PID is the most used in the industry. PID controllers are included in classical control. Then Model Predictive Control(MPC) are used as well. MPC controllers are included in predictive control. LQG controllers are used too and LQG controllers are included in optimal control. For nonlinear systems Fuzzy controller are used and Fuzzy controllers are included in nonlinear control.

Then we have two type of controllers left. They are Model reference adaptive control(MRAC) which are included in adaptive control and H-infinity control which are included in robust control.

So my questions for you are:
Why are Robust Control and Adaptive Control not used in the industry? Are them both still in a developement stage?

Please. Correct me if I'm wrong. Because I really like Robust Control but I not going to learn it if there is not chance for me to use it in industrial work.

答:
In short, adaptive control and robust control (Hinf) are the difficult combination of computationally expensive and complicated to understand. Even if you do an excellent job of implementing one of these controllers, after you have move on to another project (or job) the company still needs someone capable of understanding the controller.

There are applications though; for example robust control is common harddrive servos. But most industrial control problems are quite simple so will try make PID (with variations) work if possible because it's fast and many people know  how to tune them.


答:
If I had to guess, I would say that, in an industrial setting, you have a relatively high degree of certainty about the process you're controlling, and/or there isn't much emphasis on transient performance.

Arguably, transient performance should be where a more complex controller shines. However, in an industrial setting, once the process is running, all running parameters should stabilize and the entire process should reach steady state.

Once in steady state, the integrator term in the PI or PID controller should drive steady state error to zero. Generally speaking, as long as you're not starting or stopping the process, then any controller that can drive steady-state error to zero is probably acceptable. At that point, as ryan0270 pointed out, it comes down to the controller that is easiest to implement, troubleshoot, and maintain.

Further, as I mentioned above, a manufacturer should have a relatively high degree of certainty about the process they're controlling. Another place that robust control shines, in particular, is where the parameters are uncertain. However, the components being used shouldn't be a mystery. Inlet fluids have a routine viscosity, temperature, etc. - once you tune a PID controller, it should be fine as long as the inlet fluid doesn't change from water to something more or less viscous, or the metal doesn't change from steel to aluminum, etc.

And then, where more precise control is required, as you stated in the question, many industries will attempt to model the process to include feed-forward (predictive) control. You model how you think the system will respond and can take proactive control instead of reactive control.

Even with model-based control, you might use the model to establish a "base" (feed-forward) control signal and then a "dumb" PID loop to drive any subsequent errors to zero. This would be how I've seen model-based control.

So, to state again for emphasis - industries typically operate at steady-state.

Title: Industrial Controllers - Why not adaptive control and robust control

Body:
This is a question I have thinked about under a very long time. What are industrial controllers?

From research I found that PID is the most used in the industry. PID controllers are included in classical control. Then Model Predictive Control(MPC) are used as well. MPC controllers are included in predictive control. LQG controllers are used too and LQG controllers are included in optimal control. For nonlinear systems Fuzzy controller are used and Fuzzy controllers are included in nonlinear control.

Then we have two type of controllers left. They are Model reference adaptive control(MRAC) which are included in adaptive control and H-infinity control which are included in robust control.

So my questions for you are:
Why are Robust Control and Adaptive Control not used in the industry? Are them both still in a developement stage?

Please. Correct me if I'm wrong. Because I really like Robust Control but I not going to learn it if there is not chance for me to use it in industrial work.


问:
What mechanical parts can be attached to a 28BYJ-48 stepper motor?
Sorry I am asking a mechanical question here, but, after all, where else people have experience with using motors? If there is a better forum for this, please do guide me.

Everywhere I've seen online, the stepper motor 28BYJ-48 is used in tutorials, to rotate on its own, or, at most, to spin a clothes pin attached to it. I am trying to get Arduino to work for my 10 year old kid. He's got the motor rotating, now what? How does he attach anything to it?

Don't laugh, I made him a wheel out of a raw potato. He is happy with it now. Where can I find any guidance as to what to do next?

答:
From RobotShop.com

You can use the Actobotics 5mm Bore 0.77'' Set Screw Hub

Given that part, you then have lots of options.

OwnerDisplayName: Таня Т.


问:
Tuning Line follower PID constants with Q-learning
I am currently working on a line follower buggy and have managed to tune the PID constants manually. The buggy follows the line at a moderate speed.

I will now like to take things further and learn new things as well. I read about Q-learning and will like to ask if what I am about to implement is on the right track.

I have chosen:

Three states: last three positions of line sensors

Three rewards: middle position, end of track and less wobbling (measured with gyroscope).

Four actions: $Kp$, $Ki$, $Kd$, and Max speed.

The computation will be made on a PC as the robot is wirelessly connected.

Am I on the right track?

How do I make the 3 constants have "states" because as I understand, the actions have to be non-analog ?

Do I create a range of numbers close to the constants I have now and the Q-learning decides which is best ? (It's inefficient to just try random numbers)

答:
I am currently working on a very similar project, the only difference is that I am using a simulation package (MATLAB Simmechanics) where I have modeled a mobile robot with 2 actuated wheels and a castor wheel. I have 4 sensors, as a result, I am not using the "middle position" as a reward but I can easily modify that.

My model takes parameters such as friction, backlash and motor constants into account hence it should be fairly straight forward to apply the model to a real-life scenario - just like yours. Since my line follower robot is a computer simulation I can try random values of Kp,Ki, and Kd, which is certainly an advantage.

Therefore I am suggesting you to start with a simulation and then use those Kp, Ki, Kd, and Max motor speed (PWM) values in your physical model.


问:
trapezoidal vs sinusoidal commutation
How do you know if a commercial driver is working with trapezoidal or sinusoidal commutation? If you measure the 3-phase voltage applied to the PMSM by means of an oscilloscope, will you see a difference?</p>

答: I'm reasonably sure that the sinusoidal wave will look like a sign wave, and that the trapezoidal wave will look more square-ish. The image below explains it better:

Title: trapezoidal vs sinusoidal commutation


问:
Error starting image_view video_recorder using launch file
To record .avi video, I am using video_recorder for the image_view package. I want to do this through the launch file. Here is the how I put it in there

```<code><node pkg="image_view" type="video_recorder" name="video_record_$(arg camera_name)" machine="$(arg machine)" if="$(eval record and enable_camera)">
             <arg name="fps" value="$(arg frame_rate)" />
             <arg name="codec" value="HFYU" />
             <arg name="encoding" value="$(arg image_encoding)" />

     </node>
</code>```

I get error:

```<code>WARNING: WARN: unrecognized 'arg' child tag in the parent element:
</code>```

Unfortunately I could not find a go-to syntax for this and I am new to ROS. Any help is appreciated. Feel free to ask for more details.

答:
Here is the reference you are looking for: http://wiki.ros.org/roslaunch/XML

In this particular case, you probably want to use the args attribute inside the <node> node. From this page on the <node> node:

args="arg1 arg2 arg3"(optional)

  Pass arguments to node.


问:
DH Parameters with offset base
I'm looking at a pan tilt (RR) system. I want to define the kinematics between a world frame and the end effector. Every example I've seen looks at the world frame as being at the first joint (the zero frame). Can DH parameters be used with an offset base? My initial thought is yes, and that you define your world frame, your base frame, and your joint frames.Then there is an extra T matrix, but that one doesn't change since the transformation between your world frame and the fixed base frame is fixed.   Thanks</p>

答:
You're correct-ish, but technically the DH parameters should go from actuated axis to actuated axis, so you would leave the (unactuated) base frame out completely and just go world coordinate to the first actuated axis.

You could of course just treat the base as a joint that you just never actuate ($\theta =0$).

Title: DH Parameters with offset base


问:
explanation of kalman filter
I have gone through my lecture notes but I can't seem to figure out the five different steps of a Kalman filter and how these steps are  Divided into prediction and correction and how the state and the uncertainty evolves with each step. I would appreciate it if someone could explain it to me please </p>

答:
The Kalman filter applies to situations where we want to track a process state using a sequence of measurements (observations). The Kalman filter gives us a recursive way to estimate the process state.

Broadly, the Kalman update can be separated into a predict stage and an update stage.

In the prediction stage, we carry our estimates of the state forward in the absence of new measurements.

To start the prediction, we have an estimate of the state mean and the state error covariance. This is either from initialization conditions or from a previous update step. Further, we also have knowledge of the system dynamics, i.e. we have a model for how the system will evolve. Using this, we calculate ('predict') what the new value for the state will be.

Starting from the previous estimate of the state mean, we revise our estimate of the state mean using the system dynamics. This calculating is called prediction because we are estimating the state value in the future without any new measurements to guide us. This prediction of the state mean is the first part of the predict stage.

The system model often has some source of uncertainty (process noise term). We do not know what values this noise term took. We track this increase in uncertainty by revising (predicting) the state error covariance. This is second part of prediction stage.

Now we can move on to the update stage. The update stage is run only in the circumstance that we obtain a new measurement. We want to use this measurement to glean some information regarding the true value of the state. Then, we want to update the state estimate (mean), and state error covariance so that we are ready to go back to the prediction.

The update step can be broadly split into 3 steps.
1. To get the information out, we calculate the 'innovation' i.e. difference between the measurement and the predicted value for the measurement.
2. We calculate a Kalman gain filter (some understanding of the MMSE estimator is helpful to track the math here).
3. Then, we update the state mean by applying the innovation. Think of this as a correction to our estimate of the state based on the observation. Similarly we update the covariance of the state error. This is to reflect the decrease in uncertainty of the state from the observation.

To understand the above steps in Kalman filters, you might find it helpful to review MMSE estimators and conditional means. There are plenty of youtube videos on these topics. I suggest you start there. It will make the update steps very intuitive.

A couple of related comments.

In typical textbook examples, the Kalman filter is presented as a sequence of [predict, update, predict, update, ...]. In robotics practice, it is more common to see something like [predict, predict, ..., update, predict, predict,...]
i.e. we have a lot more prediction than update, because measurements are often sporadic.

The state space of a Kalman filter is constructed with a lot of care. We want to it to be sufficiently detailed so that, conditioned on the state, the future evolution of the process is independent of the past observations. On the other hand, we want the state to be a minimal representation so that the calculations are easier. Since this influences several design choices, this is something to keep in mind.

Title: explanation of kalman filter


问:
Unscented Kalman Filter VS Extended Kalman Filter on stability
The Extended Kalman filter is more or less a mathematical "hack" that allows you to apply these techniques to mildly nonlinear systems.

The problem with Extended Kalman Filter is if I initialize the filter with poor conditions (i.e., the initial state), it will quickly diverge. If propagation and/or measurement updates happen at too great a timestep, it will quickly diverge.

I my view, EKF is not good for control engineering, due to the risk of diverging.

So my question is if Unscented Kalman Filter(UKF) is a better choise for me if I want to be sure that my controller is stable?

Or should i use the static original Kalman-Bucy Filter? I'm working with feedback systems.

答:
You mentioned that EKF wasn't very robust for your application. This means that the continuous time model is considerably non-linear. In this setting, the UKF is better than the EKF and handles the non-linearity better.

The original static Kalman-Bucy filter does not seem like a promising choice since it targets continuous time linear systems. So, between them, I would still lean towards UKF.

You might want to look at indirect feedback Kalman filters. Section 2 of the following reference describes a non-linear continuous time application similar to what you would encounter in robotic arm movement problems.

https://pdfs.semanticscholar.org/7d78/9dd851ccf6100a3045ab9347b35eb86a9106.pdf


答:
You are correct in the sense that you just need an extra transformation from your world frame to the first frame (fixed) in you D-H parametrization. This transformation might be fixed or time varying (if you consider a mobile base robot for instance), but is not part of the D-H parametrization.

In other words, your D-H parametrization describes the kinematic of a joint collection in a generic way, then you have a transformation from world frame to  the first joint which is not part of the D-H parametrization and should more be considered as on off-set.

Title: DH Parameters with offset base

Body: I'm looking at a pan tilt (RR) system. I want to define the kinematics between a world frame and the end effector. Every example I've seen looks at the world frame as being at the first joint (the zero frame). Can DH parameters be used with an offset base? My initial thought is yes, and that you define your world frame, your base frame, and your joint frames.Then there is an extra T matrix, but that one doesn't change since the transformation between your world frame and the fixed base frame is fixed.   Thanks</p>


答: Yes, you can just set up an additional transformation matrix from the global coordinate system to the first system at the base of the robot.  These terms will all be constants.   As @Chuck mentions, this is probably not technically D-H notation but the math works and it is simple to do.  </p>

Title: DH Parameters with offset base


问:
Is there any C++ library I could use to program a robotic manipulator involving forward and inverse kinematics?
I came across robotics library (RL), but quite unclear about its real purpose. Is it a FK/IK solver library or simply an graphical simulator?. RL has poor documentation, so its not clear how to use it. Im looking for some C++ library where there APIs to solve FK/IF analytically. Thank you.</p>

答: I recommend KDL. It is kind of de facto kinematic library for the robotics community. It has both forward and inverse kinematic solver as well as generic capabilities to model your robot. You can use it as a stand-alone C++ library or with ROS.


问:
Configuration space of rotating link
I have only recently started reading Steve LaValle's book on motion planning. It mentions that a rotating link with a fixed pivot has a configuration space of a unit circle.

Since the configuration space is the set of all possible configurations the link can have, i.e. all possible angles from 0° to 360°, shouldn't the c-space be a line rather than a circle?

Also, for a 2 link robotic arm in the same plane, how is the c-space a 2-tourus even though the joints rotate in the same plane?

Lastly what's the difference between the representations shown below?

答:
Since the configuration space is the set of all possible configurations the link can have, i.e. all possible angles from 0° to 360°, shouldn't the c-space be a line rather than a circle?

You are correct that a rotating link has one variable $\theta$ that can attain any value in the range $[0, 2\pi]$ (let's talk in radian). However, the configuration space of the link is not simply a line segment because the link being at $\theta = 2\pi$ is identical to it being at $\theta = 0$. In other words, the link can keep rotating forever while the variable $\theta$ simply runs in loops, like a clock.

If there was an ant walking on the line segment to the right, when the ant reaches $\theta = 2\pi$, it would somehow be teleported and appear at $\theta = 0$ and continue walking like nothing happened.

This is essentially the same as gluing both ends of the line segment together. That's why you have a circle instead of only a line segment.

Also, for a 2 link robotic arm in the same plane, how is the c-space a 2-tourus even though the joints rotate in the same plane?

I understand that this may be confusion between the robot's workspace and the robot's configuration space.

The joints rotate in the same plane so their workspace is a subset of that two-dimensional plane.

Now for the configuration space of this robot, the same argument as above applies. Initially, you can think of a configuration space as a square whose corners are $(\theta_1, \theta_2) = (0, 0)$, $(\theta_1, \theta_2) = (0, 2\pi)$, $(\theta_1, \theta_2) = (2\pi, 2\pi)$, and $(\theta_1, \theta_2) = (2\pi, 0)$.

The first link (the one attached to the base) of the robot could continue rotating forever while the joint value $\theta_1$ would only vary within the range $[0, 2\pi]$. If there was an ant walking from left to right on the square, the ant could continue walking forever as previously. It is like the left edge and the right edge are glued together.

The second link could also keep rotating forever while the joint value $\theta_2$ could only run between $0$ and $2\pi$. In the end, this is like gluing the top edge and the bottom edge together.

In topology, this gluing process is called identification.

Finally, when you glue the two pairs of edges of the square together, you get a 2-torus.

(image from https://en.wikipedia.org/wiki/Torus)

Lastly what's the difference between the representations shown below?

The two images show the same thing before and after the identification (gluing) process. Notice the arrow heads on the edges of the square in the left image. They tell you which sides match and how they should be aligned when being glued together.

Title: Configuration space of rotating link


问:
Learning about embedded systems
The last robotics project I worked on involved autonomous outdoor navigation, using a microcontroller for lower-level control and a computer for image processing and decision making. I worked more with the higher-level software and another guy on the team did the electrical and embedded systems. I would like to be capable of doing everything, including stuff with embedded, but I'm not sure where to look for information. If I were to have done the project from scratch on my own, I'd need to know:

What microcontroller to use

What motors are required

What motor controllers to get, and how to interface with the controllers

What encoders to use for motor feedback, and how to write drivers for them

What batteries to use and how to safely power everything

If I were trying to learn about higher-level software, I'd probably take a few courses on Udacity. Are there any good resources out there like that for this kind of low-level stuff?

答:
While I don't know about any online resources for what you want, I learned my skills by trying and failing, probably the best method to learn this sort of stuff if you have the time to do it. If you don't have much time, your best bet is probably just googling  stuff that you need to know.

A lot of good information can also be found in university thesis or research papers, also a lot of quality parts from reputable manufacturers come with really good documentation on how to use them. The documentation can sometimes be overwhelming, but at least it will point you in the right direction.

And if you did't find anything you need after the steps above, just ask here, that's why this site exists.

Title: Learning about embedded systems


问:
How can I calculate speed and torque of stepper motor screw
I want to choose stepper motor screw with slider for use it to shift cube with side 5 cm and wight 250 g .

I found this motor .. how can I calculate speed and torque of slider

答:
I would use input electrical power as a guideline for the output mechanical power. Power is voltage times current, (in volts and amps for a power in watts), and power is also force times speed (in newtons and meters per second for a power in watts). I would assume the motor is 80% efficient and the screw is 70% efficient for some reasonable ballpark estimates. </p>

<p>You can convert revolutions to linear motion via the pitch - every revolution is 0.003 meters. The rated motor speed isn't listed, but you can use it to get the rated linear speed. Efficiency losses will "eat" your output force. </p>

Body:
I would use input electrical power as a guideline for the output mechanical power. Power is voltage times current, (in volts and amps for a power in watts), and power is also force times speed (in newtons and meters per second for a power in watts). I would assume the motor is 80% efficient and the screw is 70% efficient for some reasonable ballpark estimates.

You can convert revolutions to linear motion via the pitch - every revolution is 0.003 meters. The rated motor speed isn't listed, but you can use it to get the rated linear speed. Efficiency losses will "eat" your output force.


问:
OpenCV get topdown view of planar pattern by using intrinsic and extrinsic from cameraCalibrate
Originally I have a image with a perfect circle grid, denoted as A

I add some lens distortion and perspective transformation to it, and it becomes  B

In camera calibration, A would be my destination image, and B would be my source image.
Let's say I have all the circle center coordinates in both images, stored in stdPts and disPts.

```<code>//25 center pts in A
vector<Point2f> stdPts;
for (int i = 0; i <= 4; ++i) {
    for (int j = 0; j <= 4; ++j) {
        stdPts[i * 5 + j].x = 250 + i * 500;
        stdPts[i * 5 + j].y = 200 + j * 400;
    }
}
//25 center pts in B
vector<Point2f> disPts = FindCircleCenter();
</code>```

I want to generate an image C that is as close as A, from input: B, stdPts and disPts.
I tried to use the intrinsic and extrinsic generated by cv::calibrateCamera. Here is my code:

```<code>//prepare object_points and image_points
vector<vector<Point3f>> object_points;
vector<vector<Point2f>> image_points;
object_points.push_back(stdPts);
image_points.push_back(disPts);

//prepare distCoeffs rvecs tvecs
Mat distCoeffs = Mat::zeros(5, 1, CV_64F);
vector<Mat> rvecs;
vector<Mat> tvecs;

//prepare camera matrix
Mat intrinsic = Mat::eye(3, 3, CV_64F);

//solve calibration
calibrateCamera(object_points, image_points, Size(2500,2000), intrinsic, distCoeffs, rvecs, tvecs);

//apply undistortion
string inputName = "../B.jpg";
Mat imgB = imread(imgName);
cvtColor(imgB, imgB, CV_BGR2GRAY)
Mat tempImgC;
undistort(imgB, tempImgC, intrinsic, distCoeffs);

//apply perspective transform
double transData[] = { 0, 0, tvecs[0].at<double>(0), 0, 0,,tvecs[0].at<double>(1), 0, 0,  tvecs[0].at<double>(2) };
Mat translate3x3(3, 3, CV_64F, transData);
Mat rotation3x3;
Rodrigues(rvecs[0], rotation3x3);

Mat transRot3x3(3, 3, CV_64F);
rotation3x3.col(0).copyTo(transRot3x3.col(0));
rotation3x3.col(1).copyTo(transRot3x3.col(1));
translate3x3.col(2).copyTo(transRot3x3.col(2));

Mat imgC;
Mat matPerspective = intrinsic*transRot3x3;
warpPerspective(tempImgC, imgC, matPerspective, Size(2500, 2000));

//write
string outputName = "../C.jpg";
imwrite(outputName, imgC); // A JPG FILE IS BEING SAVED
</code>```

And here is the result image C, which doesn't deal with the perspective transformation at all.

So could someone teach me how to recover A? Thanks.

答:
Added

OK, guys, simple mistake. I previously used warpPerspective to warp images instead of restoring. Since it works that way, I didn't read the doc thoroughly. It turns out that if it is for restoring, the flag WARP_INVERSE_MAP should be set. Change the function call to this, and that's it.

```<code>warpPerspective(tempImgC, imgC, matPerspective, Size(2500, 2000), WARP_INVERSE_MAP);
</code>```

Here is the new result image C:

The only thing concerns me now is the intermediary tempImgC, which is the image after undistort and before warpPerspective. In some tests with different artificial B s, This image could turn out to be a scaled-up version of B with distortion removed. That means a lot of information is lost in the outter area. And there is not much to use for warpPerspective. I'm thinking maybe to scale down the image in undistort and to scale it up in warpPerspective. But I'm not sure yet how to calculate the correct scale to preserve all the information in B.

Added 2

The last piece of the puzzle is in place. Call getOptimalNewCameraMatrix before undistort to generate the new camera matrix that preserves all the info in B. And pass this new camera matrix to undistort and warpPerspective.

```<code>Mat newIntrinsic=getOptimalNewCameraMatrix(intrinsic, distCoeffs, Size(2500, 2000), 1);
undistort(imgB, tempImgC, intrinsic, distCoeffs, newIntrinsic);
Mat matPerspective = newIntrinsic*transRot3x3;
warpPerspective(tempImgC, imgC, matPerspective, Size(2500, 2000), WARP_INVERSE_MAP);
</code>```

The result image C is the same in this case. But there is a big difference for other cases. For example, with another distorted image B1.

The result image C1 without new camera matrix looks like this.

And the result image C1 with new camera matrix maintains the information in B1

Added 3

I realized that as each frame captured by camera needs processing and efficiency is important, I can't afford to use undistort and warpPerspective for each frame. It's only reasonable to have one map and use remap for each frame.

Actually, there is a straight forward way to that, which is projectPoints. Since it generates the map from destination image to source image directly, no intermediary image is needed and thus loss of information is avoided.

```<code>// ....
//solve calibration

//generate a 3-channel mat with each entry containing it's own coordinates
Mat xyz(2000, 2500, CV_32FC3);
float *pxyz = (float*)xyz.data;
for (int y = 0; y < 2000; y++)
    for (int x = 0; x < 2500; x++)
    {
        *pxyz++ = x;
        *pxyz++ = y;
        *pxyz++ = 0;
    }

// project coordinates of destination image,
// which generates the map from destination image to source image directly
xyz=xyz.reshape(0, 5000000);
Mat mapToSrc(5000000, 1, CV_32FC2);
projectPoints(xyz, rvecs[0], tvecs[0], intrinsic, distCoeffs, mapToSrc);
Mat maps[2];
mapToSrc = mapToSrc.reshape(0, 2000);
split(mapToSrc, maps);

//apply map
remap(imgB, imgC, maps[0], maps[1], INTER_LINEAR);
</code>```

Body:
Added

OK, guys, simple mistake. I previously used warpPerspective to warp images instead of restoring. Since it works that way, I didn't read the doc thoroughly. It turns out that if it is for restoring, the flag WARP_INVERSE_MAP should be set. Change the function call to this, and that's it.

warpPerspective(tempImgC, imgC, matPerspective, Size(2500, 2000), WARP_INVERSE_MAP);

Here is the new result image C:

The only thing concerns me now is the intermediary tempImgC, which is the image after undistort and before warpPerspective. In some tests with different artificial B s, This image could turn out to be a scaled-up version of B with distortion removed. That means a lot of information is lost in the outter area. And there is not much to use for warpPerspective. I'm thinking maybe to scale down the image in undistort and to scale it up in warpPerspective. But I'm not sure yet how to calculate the correct scale to preserve all the information in B.

Added 2

The last piece of the puzzle is in place. Call getOptimalNewCameraMatrix before undistort to generate the new camera matrix that preserves all the info in B. And pass this new camera matrix to undistort and warpPerspective.

Mat newIntrinsic=getOptimalNewCameraMatrix(intrinsic, distCoeffs, Size(2500, 2000), 1);
undistort(imgB, tempImgC, intrinsic, distCoeffs, newIntrinsic);
Mat matPerspective = newIntrinsic*transRot3x3;
warpPerspective(tempImgC, imgC, matPerspective, Size(2500, 2000), WARP_INVERSE_MAP);

The result image C is the same in this case. But there is a big difference for other cases. For example, with another distorted image B1.

The result image C1 without new camera matrix looks like this.

And the result image C1 with new camera matrix maintains the information in B1

Added 3

I realized that as each frame captured by camera needs processing and efficiency is important, I can't afford to use undistort and warpPerspective for each frame. It's only reasonable to have one map and use remap for each frame.

Actually, there is a straight forward way to that, which is projectPoints. Since it generates the map from destination image to source image directly, no intermediary image is needed and thus loss of information is avoided.

// ....
//solve calibration

//generate a 3-channel mat with each entry containing it's own coordinates
Mat xyz(2000, 2500, CV_32FC3);
float *pxyz = (float*)xyz.data;
for (int y = 0; y < 2000; y++)
    for (int x = 0; x < 2500; x++)
    {
        *pxyz++ = x;
        *pxyz++ = y;
        *pxyz++ = 0;
    }

// project coordinates of destination image,
// which generates the map from destination image to source image directly
xyz=xyz.reshape(0, 5000000);
Mat mapToSrc(5000000, 1, CV_32FC2);
projectPoints(xyz, rvecs[0], tvecs[0], intrinsic, distCoeffs, mapToSrc);
Mat maps[2];
mapToSrc = mapToSrc.reshape(0, 2000);
split(mapToSrc, maps);

//apply map
remap(imgB, imgC, maps[0], maps[1], INTER_LINEAR);


问:
I am looking for some basic mechanical parts to build structures(prototypes)?
I am looking for something like this part in these photos:

to make my robot ideas as prototype. But I don't know it's name! Also if there are better options I will happy to know.

答:
Perforated square tubing or "bolt together" framing.

You might also consider 80/20-style T-slot framing.

I'm not associated with McMaster-Carr, but I'm a big fan of theirs. You can find perforated square tubing on their site here and you can find 80/20-compatible T-slot framing here.

Of course, if you're looking for 80/20 framing, you could always go to the 80/20 website.


问:
What kind of sensor do quadcopter uses?
over the last 5 years I had 2 quadcopter as a gift.
the first one was basic, manual, I had to manually set the 4 motor speed for it not to crash during take off and I was alway controlling the amount of thrust myself.

1/ Why was that necessary? if you send the same thing to the 4 motor they should spin at the same rate and thus provide the same thrust no?

The second one was a smartphone controlled drone, you just hit the take off button and the thing fly and stay at the same place/altitute.

To do that I could see an ultrasonic sensor below the drone. if I made it fly above a mattress it would crash.

2/ Ok that nice but what about high altitude? what if my drone is hovering a 500m, what kind of sensor can I use to make him stay at the same place and altitude.

I already fiddled with GPS and I don't think it's fast/precise enought.

Thanks.

答:
The first quadcopter probably only had a gyroscope to assist in roll/pitch/yaw control. For real motors, sending the same value will not provide the same rotation speed (it will always vary at least a little). Also, for 4 different real rotors, spinning at the same speed will not produce the same thrust. That is why you had to adjust takeoff motor speeds. In flight, unless you produce exactly, and I mean exactly, the correct thrust to offset the quadcopter's weight you will always need to adjust the thrust to maintain hover since the system itself doesn't know that it's rising/falling.

As you guessed, the second quadcopter was using an ultrasonic sensor to know it's height. It probably also had a more advanced gyroscope and algorithm to hold roll/pitch. At high altitudes where the ultrasonic is not effective, barometers are usually used. This will not be terribly accurate in an absolute sense, but it will be able to tell the computer algorithms if the system is rising or falling which is enough to hold still.

Title: What kind of sensor do quadcopter uses?