问:
Biped State Space Implementation
Currently I working on a humanoid robot using inverted pendulum model and use LQR for walking stabilizer. Input u is Torque, State x is angle and angular velocity and y output is angle.

I got the gain K value that meet my control specification (rise time, steady state error, etc) and the feedback control law like this

So now I got u(torque) value, but I don't know how to use u(torque) to move my actuator (to control 2 angkle servo) because my servo only move using angle as the command input, not torque. Is there any step that must be done to convert torque to angle? Or something? Thank You for the help, need this for my final project.

答:
The problem with most papers about LQR controller is, that they are describing only the half of whole problem. The key aspect of understanding LQR is that an additional "Finite State Machine" (FSM) is used which controls the robot. A good paper which combines LQR with FSM for bipedal locomotion is Bayesian Gait Optimization for Bipedal Locomotion†.

The walking modes are given by the FSM and the parameters are optimized with Bayesian optimization. LQR means only that values inside the programcode are adjusted to the robot. This is good if the same code should control a 2 cm leg and also a 3 cm leg. But LQR itself isn't enough for controlling the robot. A dedicated sourcecode in form of a Finite State Machine has to be implemented first. That's the same principle like Walking with neural networks, machine learning or apprenticeship learning works. These stochastic optimization algorithm can only be used for subspace adjusting of a given robot controller.

† Roberto Calandra, Nakul Gopalan, Andre Seyfarth, Jan Peters, and Marc Peter Deisenroth

Title: Biped State Space Implementation


问:
Linear State Space of a 6DOF robot
I'm new to the field of robotics, so this is a pretty basic question:

I'm assigned with the task of constructing a linear state space model of a 6DOF robotic arm that moves in 3D space. I believe the goal is to transform the original nonlinear problem to a piecewise linear problem for the purpose of designing a controller based on gain scheduling for example, and thus making use of the powerful linear control techniques and design tools.

I'm in the process of linearizing the dynamics using the small disturbance theory, but it is a lengthy, time-consuming process that I feel is not very practical considering the alternatives.

My question is: Is this a common practice in robotics? If not, is it practical and has it ever been done before, or should I consider an alternative approach?

答:
No, this is not a common practice in robotics. You might have heard of an approach sometimes called "computed torque" which is a common implementation of the nonlinear control technique of feedback linearization (based on geometric nonlinear control theory). Most introductory robotics textbooks cover this control technique. Basically, it involves using your model of the robot to cancel out the nonlinear dynamics and provide a stable PD (proportional-derivative) feedback outer loop. It's stability depends on the accuracy of your dynamic model.

The problem with linearization is that it's based on operation (or disturbance) about a set point. However, your set point (desired joint angles) change drastically when operating a 6DoF robot. You can do a linearization at each time-step but that is usually applied to less complex nonlinear systems and estimation (the Extended Kalman Filter, for example).

Also I would only trust using a symbolic math toolbox for your derivations and verify with an independent dynamic model/simulation. It sounds like you might be doing the linearization by hand and I think that is unreasonable for a robotics application with anything other than the simplest 2-3 DoF manipulators. Sympy is free, Matlab has the symbolic toolbox, and Maple is a solid choice as well.

ContentLicense: CC BY-SA 3.0

Title: Linear State Space of a 6DOF robot


问:
Why I'm getting very long terms in the inertia matrix (or dynamics model) of the robot using matlab script?
I'm working on the dynamics model of a RRRR articulated robot, I'm following Euler-Lagrange approach and developing my code in m-file in matlab; I'm looking for dynamic model of this form: $$
D(q) \ddot{q} + C(q,\dot{q})\dot{q}+ g(q) = \tau
$$
where $D$ and $C$ are $4 \times4$ matrices and $g$ and $\tau$ (torque) are $4\times1$ vectors; by formulating the kinetic and potential energies;;

The problem is that, I'm getting very long equations, and the term in $D$ matrix are very huge and nonlinear, involving sin and cos; I'm talking about a several pages per equation;
After I published the code - 7 pages - and the output I got around 45 pages in total;
I searched around there was some guy he faced the same problem before, but there was no helpful proposal.

Any Suggestions ??

答:
Long formulas are to be expected. I actually have derived such equations of motion for a planar RRRR manipulator. I assumed real symbolic variables assume(A, 'real') and run simplify(). Generating code with MATLAB also creates intermediate variables. For the code output (in C) of a lower-triangular column-major order D(q) matrix, I got the following (after some manual clean-up):

 void Mlt (
    const double *restrict in,
    const double *restrict pc,
    const double *restrict ma,
    const double *restrict a,
    const double *restrict q,
    const double *restrict g,
    double *restrict M)
{
/* inputs *
 * ****** *
Inertia and mass
double in[24]; [Ixx, Iyy, Izz, Ixy, Ixz, Iyz]
double pc[12]; [cog_x, cog_y, cog_z]
double ma[4]; [mass]

DH parameters
a is distance along x-axis (linkage length)
double a[4];

generalized coordinates
double q[4];

gravitational constant
double g[1];
 * ****** */

/* outputs *
 * ******* *
double M[16];
 * ******* */

  double t[64];
  t[0] = a[0]*a[0];
  t[1] = a[1]*a[1];
  t[2] = a[2]*a[2];
  t[3] = q[1]+q[2];
  t[4] = cos(t[3]);
  t[5] = q[2]+q[3];
  t[6] = cos(t[5]);
  t[7] = cos(q[1]);
  t[8] = cos(q[2]);
  t[9] = cos(q[3]);
  t[10] = q[1]+q[2]+q[3];
  t[11] = cos(t[10]);
  t[12] = ma[1]*t[1];
  t[13] = ma[2]*t[1];
  t[14] = ma[3]*t[1];
  t[15] = ma[2]*t[2];
  t[16] = ma[3]*t[2];
  t[17] = a[3]*a[3];
  t[18] = ma[3]*t[17];
  t[19] = pc[3]*pc[3];
  t[20] = ma[1]*t[19];
  t[21] = pc[6]*pc[6];
  t[22] = ma[2]*t[21];
  t[23] = pc[9]*pc[9];
  t[24] = ma[3]*t[23];
  t[25] = pc[4]*pc[4];
  t[26] = ma[1]*t[25];
  t[27] = pc[7]*pc[7];
  t[28] = ma[2]*t[27];
  t[29] = pc[10]*pc[10];
  t[30] = ma[3]*t[29];
  t[31] = a[1]*ma[1]*pc[3]*2.0;
  t[32] = a[2]*ma[2]*pc[6]*2.0;
  t[33] = a[3]*ma[3]*pc[9]*2.0;
  t[34] = a[1]*a[3]*ma[3]*t[6]*2.0;
  t[35] = a[1]*ma[3]*pc[9]*t[6]*2.0;
  t[36] = sin(t[3]);
  t[37] = sin(t[5]);
  t[38] = a[1]*a[2]*ma[2]*t[8]*2.0;
  t[39] = a[1]*a[2]*ma[3]*t[8]*2.0;
  t[40] = a[2]*a[3]*ma[3]*t[9]*2.0;
  t[41] = a[1]*ma[2]*pc[6]*t[8]*2.0;
  t[42] = a[2]*ma[3]*pc[9]*t[9]*2.0;
  t[43] = sin(q[1]);
  t[44] = sin(q[2]);
  t[45] = sin(q[3]);
  t[46] = sin(t[10]);
  t[47] = a[0]*a[2]*ma[2]*t[4];
  t[48] = a[0]*a[2]*ma[3]*t[4];
  t[49] = a[0]*ma[2]*pc[6]*t[4];
  t[50] = a[0]*a[3]*ma[3]*t[11];
  t[51] = a[0]*ma[3]*pc[9]*t[11];
  t[52] = a[1]*a[3]*ma[3]*t[6];
  t[53] = a[1]*ma[3]*pc[9]*t[6];
  t[54] = a[1]*a[2]*ma[2]*t[8];
  t[55] = a[1]*a[2]*ma[3]*t[8];
  t[56] = a[1]*ma[2]*pc[6]*t[8];
  t[57] = a[2]*a[3]*ma[3]*t[9];
  t[58] = a[2]*ma[3]*pc[9]*t[9];
  t[59] = q[0]+q[1]+q[2]+q[3];
  t[60] = cos(t[59]);
  t[62] = sin(t[59]);
  t[61] = a[3]*t[60]+pc[9]*t[60]-pc[10]*t[62];
  t[63] = a[3]*t[62]+pc[9]*t[62]+pc[10]*t[60];
  M[0] = in[2]+in[8]+in[14]+in[20]+t[12]+t[13]+t[14]+t[15]+t[16]+t[18]+t[20]+t[22]+t[24]+t[26]+t[28]+t[30]+t[31]+t[32]+t[33]+t[34]+t[35]+t[38]+t[39]+t[40]+t[41]+t[42]+ma[0]*t[0]+ma[1]*t[0]+ma[2]*t[0]+ma[3]*t[0]+ma[0]*(pc[0]*pc[0])+ma[0]*(pc[1]*pc[1])+a[0]*ma[0]*pc[0]*2.0+a[0]*a[2]*ma[2]*t[4]*2.0+a[0]*a[1]*ma[1]*t[7]*2.0+a[0]*a[2]*ma[3]*t[4]*2.0+a[0]*a[1]*ma[2]*t[7]*2.0+a[0]*a[1]*ma[3]*t[7]*2.0+a[0]*a[3]*ma[3]*t[11]*2.0+a[0]*ma[2]*pc[6]*t[4]*2.0+a[0]*ma[1]*pc[3]*t[7]*2.0+a[0]*ma[3]*pc[9]*t[11]*2.0-a[0]*ma[2]*pc[7]*t[36]*2.0-a[1]*ma[3]*pc[10]*t[37]*2.0-a[0]*ma[1]*pc[4]*t[43]*2.0-a[1]*ma[2]*pc[7]*t[44]*2.0-a[0]*ma[3]*pc[10]*t[46]*2.0-a[2]*ma[3]*pc[10]*t[45]*2.0;
  M[1] = in[8]+in[14]+in[20]+t[12]+t[13]+t[14]+t[15]+t[16]+t[18]+t[20]+t[22]+t[24]+t[26]+t[28]+t[30]+t[31]+t[32]+t[33]+t[34]+t[35]+t[38]+t[39]+t[40]+t[41]+t[42]+t[47]+t[48]+t[49]+t[50]+t[51]+a[0]*a[1]*ma[1]*t[7]+a[0]*a[1]*ma[2]*t[7]+a[0]*a[1]*ma[3]*t[7]+a[0]*ma[1]*pc[3]*t[7]-a[0]*ma[2]*pc[7]*t[36]-a[1]*ma[3]*pc[10]*t[37]*2.0-a[0]*ma[1]*pc[4]*t[43]-a[1]*ma[2]*pc[7]*t[44]*2.0-a[0]*ma[3]*pc[10]*t[46]-a[2]*ma[3]*pc[10]*t[45]*2.0;
  M[2] = in[14]+in[20]+t[15]+t[16]+t[18]+t[22]+t[24]+t[28]+t[30]+t[32]+t[33]+t[40]+t[42]+t[47]+t[48]+t[49]+t[50]+t[51]+t[52]+t[53]+t[54]+t[55]+t[56]-a[0]*ma[2]*pc[7]*t[36]-a[1]*ma[3]*pc[10]*t[37]-a[1]*ma[2]*pc[7]*t[44]-a[0]*ma[3]*pc[10]*t[46]-a[2]*ma[3]*pc[10]*t[45]*2.0;
  M[3] = in[20]+t[18]+t[24]+t[30]+t[33]+t[50]+t[51]+t[52]+t[53]+t[57]+t[58]-a[1]*ma[3]*pc[10]*t[37]-a[0]*ma[3]*pc[10]*t[46]-a[2]*ma[3]*pc[10]*t[45];
  M[5] = in[8]+in[14]+in[20]+t[12]+t[13]+t[14]+t[15]+t[16]+t[18]+t[20]+t[22]+t[24]+t[26]+t[28]+t[30]+t[31]+t[32]+t[33]+t[34]+t[35]+t[38]+t[39]+t[40]+t[41]+t[42]-a[1]*ma[3]*pc[10]*t[37]*2.0-a[1]*ma[2]*pc[7]*t[44]*2.0-a[2]*ma[3]*pc[10]*t[45]*2.0;
  M[6] = in[14]+in[20]+t[15]+t[16]+t[18]+t[22]+t[24]+t[28]+t[30]+t[32]+t[33]+t[40]+t[42]+t[52]+t[53]+t[54]+t[55]+t[56]-a[1]*ma[3]*pc[10]*t[37]-a[1]*ma[2]*pc[7]*t[44]-a[2]*ma[3]*pc[10]*t[45]*2.0;
  M[7] = in[20]+t[18]+t[24]+t[30]+t[33]+t[52]+t[53]+t[57]+t[58]-a[1]*ma[3]*pc[10]*t[37]-a[2]*ma[3]*pc[10]*t[45];
  M[10] = in[14]+in[20]+t[15]+t[16]+t[18]+t[22]+t[24]+t[28]+t[30]+t[32]+t[33]+t[40]+t[42]-a[2]*ma[3]*pc[10]*t[45]*2.0;
  M[11] = in[20]+t[18]+t[24]+t[30]+t[33]+t[57]+t[58]-a[2]*ma[3]*pc[10]*t[45];
  M[15] = in[20]+ma[3]*(t[61]*t[61])+ma[3]*(t[63]*t[63]);

}
```


问:
How to detect when a stepper motor has stalled?
How can I detect when a stepper motor has stalled?

A google search led me to some people who say that
when the stepper motor stalls, the current spikes up,
which is easily detectable with a Hall sensor.
(Or, I suppose, by any of the other current sensors mentioned at
"How can I sense the motor's current?"
).

However, I measured the current through (one of the 4 wires of) my stepper motor,
and it's always within a few percent of 0.5 A, whether my stepper driver is holding one position, moving it normally (which in my application is very slowly), or the stepper driver thinks it is telling the stepper to move normally, but the motor has pegged out against the hard limit.
Measuring the current in the +12V power supply going to the stepper motor driver, also seemed to give a fairly constant current.
This may be because I turned down the current limit to that amount on my "chopper" stepper motor driver.

Am I missing some key detail in the "measure the current" approach?

A google search led me to some other people that measure the back-EMF (BEMF) in one coil of the stepper during the time the stepper driver is only driving the other coil.
But that only seems to distinguish between "a motor moving quickly" vs "a motor stopped", and doesn't seem to distinguish between my case of "a motor moving slowly" vs "a motor stopped".

Is there some way to apply the BEMF approach even in a system where I always drive the stepper slowly, and never spin it quickly?

I'm currently using a stepper driver board with the TI DRV8825 chip on it, and I hoped the "fault" pin would tell me when the stepper motor has stalled against my hard stop.
But it doesn't seem to be doing anything -- is it supposed to tell me about a stall, but I just have it wired up wrong?

Is there some other chip or drive technique that detects when the stepper has stalled out against the hard stop?

Is there some other technique for detecting a hard stall that I can "add on" to a system using an off-the-shelf stepper motor driver?

(Is there some other StackExchange site that is more appropriate for questions about motors and motor drivers?)

答:
Unfortunately, as you've discovered, it is difficult to tell if a stepper motor is stalled because the current through the coils of a stepper motor is roughly the same if it is stalled (can't step), holding position, or stepping normally.

You could definitely detect a stall with ease if you added an encoder or used a stepper motor that already had one.

Why do you want to detect the stepper motor stall? Unlike a brushed DC motor, stalling a stepper motor is typically not bad for it. Could you achieve the same purpose with a limit switch?


问:
Do the distance function and steering function in an RRT have to be related?
I am developing an RRT (rapidly exploring random tree) for car-like robots in SE2 space using Dubins steering function and have a question that has implications on the performance of RRTs.

In order for an RRT to be performant, an efficient nearest neighbor data structure needs to be used. There are efficient nearest neighbor data structures for metric spaces (like Euclidean space), however, none that I know of for a non-metric space (like the Dubins space).

This leads me to wonder if I can use a different distance function than the Dubins curve length in my RRT despite using the Dubins steering function to connect states.

答:
I asked this question on OMPL's mailing list. OMPL is an very popular motion planning library. Here is the response: https://sourceforge.net/p/ompl/mailman/message/35918890/

The answer is yes, they should be related.


问:
Sensing an actuator using vision
I am looking forward for a method to sense in real time, using computer vision for a control application.

For this I am unsure of which is the right platform . I am well versed with MATLAB, but I am wondering if it will be able to do the image processing in real time or not.

If there are other platforms which are much quicker, you can please recommend me.

答:
MATLAB is a very powerful platform for doing such applications. I recommend you using it. You can get your images using a USB camera, implement whatever functions to your captured images and then plot your results in a GUI charts or tabs.

Other software you can use is LabVIEW of NI, but you have to know how to use a function block diagram programming language.

Title: Sensing an actuator using vision


问:
What is the typical weight distribution for a brushless motor?
Brushless motors, like regular motors, have different parts (commutator, stater, etc).

What do these various parts weigh?

答:
I took apart a Turnigy D2836 brushless DC motor. Despite the weight listed on the website, the actual weight of the motor without the mounting equipment is 54 Grams.

Here is the breakdown

Magnets: 9 grams, 16.7%

Bottom Can: 6 grams, 11.1%

Top Can: 4.5 grams, 8.33%

Main Axle: 1.5 grams, 2.78%

Middle can: 9 grams, 16.7%

Coils: 6 grams, 11.1%

Leads & plugs: 4 grams, 7.41%

Ferrite core: 14 grams, 25.93%

This motor is an out-runner, so the bottom can and the ferrite core have a ball bearing that is included in the weight, but I did not measure it separately. This can be used as a guide for other motors.


问:
Servo coupler size needed
Hey all I would like to know what type of coupler I would need for this type of servo?

The specs are:

I'm guessing that the 25T means it has 25 teeth in the part that holds the adapters?

So I would guess I would need something like this?

But I also would like to know what size those are called for my servo. I've seen them advertised as 5mm to 8mm. 6mm to 8mm, etc etc so I don't know if those are going to work? Some also just have a smooth round hole without the teeth and I'm not sure if that's something I could use as well?

答:
RC Servos come with several different styles of exit shafts (often called splines due to the teeth that are cut into them).  There are quite a few different styles.  Tooth count (yes, 25T means 25 tooth) is a major indicator of the styles; but, some styles have the same tooth count but different diameter so you cannot go by tooth count alone.

Two of the most popular RC Servo Manufacturers are HiTEC and Futaba
The companies make motors with several different spline/shaft sizes

Futaba's most common sizes are 1F(15 tooth),2F(21 tooth),3F(25 tooth),4F(25 tooth)

HiTEK's most common sizes are A1(15 tooth),B1(25 tooth),C1(24 tooth),D1(15 tooth)

HiTEK also some motors with an H25T spline which matches the popular Futaba 3F spline.

I can't tell for sure; but, it looks like the JX Servo uses a  25T (probably 3F-style) spline.

ServoCity lists has several different Servo Couplers

This coupler is a 3F style

Title: Servo coupler size needed


问:
Controllling an industrial robotic arm
How can you control a servo driver (delta, ...) with an industrial PC?

To control position and velocity of a servo you need PWM signal to the servo drive (amplifier), but how do we create the signal and using which component?  Would a 555 timer be sufficient?

答:
Controlling a Servo from a PC is more than just generating a PWM signal

The indication that you want to control the PWM signal for the Servo from a PC implies that your want to close the servo control loop yourself.  I have done that before and it is VERY HARD (it took us several thousand man hours to create).  Much of the code has to reside in the Windows Driver/HAL layer to get the response time you need.  PC's (or at least Windows PC's) are not designed for the realtime response that is needed to close a servo control loop (typically 500uS loop time with better than 5uS determinism).

If you want to control an industrial servo from a PC, I recommend you either use an external diver/controller Ex: SureServo; or, if you are going to use a desktop PC, you could use one of the PCI controllers Ex: OmsMotion.

A lot of the decision depends on what exactly you want to do (high power complex coordinated motion profiles, simple on/off high power motor, or low power control).

Title: Controllling an industrial robotic arm


问:
Do magnets affect IMU values?
Im in the process of making a robot which requires 12 3x10mm cylindric magnets for the construction. They are 30mm from the center of the robot where I plan to have the IMU.

I was thinking about using MPU-6050. Do magnets affect the values? If yes, is there a solution for it? like maybe I could have a shield or something around the IMU?

答: You might be able to do "hard iron" calibrations to cancel out the effects of the magnets if they are fixed in relation to the magnetometer. One strategy people use to avoid interference is to make a mast and put the magnetometer at the top of the mast away from the other electronics.</p>

Title: Do magnets affect IMU values?


答:
I didn't work on matlab with vision,but if you want another choice you can always use c++/in visual studio with opencv libraries
Or java in eclipse,but opencv function for c++ are easier and there are much more tutorials</p>

Title: Sensing an actuator using vision

Body:
I am looking forward for a method to sense in real time, using computer vision for a control application.

For this I am unsure of which is the right platform . I am well versed with MATLAB, but I am wondering if it will be able to do the image processing in real time or not.

If there are other platforms which are much quicker, you can please recommend me.


问:
Quadcopter flight controller - black smoke?
I bought a qx95 and after a few flights, maybe 3, there was black smoke that fizzled out of the what looks like the flight controller. And since then, anytime I give throttle - the fpv video feed cuts signal.

I'm assuming what I fizzled was some sort of limiter / power converter for the video?

My question is - what do I need to replace? Was that the flight controller or camera? Any thoughts on what I need to replace or repair?

答: If the quad is a manufactured model, not a home built one, then the power would follow the same grouping I would take a look at the regulator circuit as it sounds that the voltage is dropping due the amp supply not being great enough. I would assume controller board being that it sounds like the regulator cooked and that's where it would be located.</p>


问:
DC motor pid control
Would a 12V geared DC motor (about 140rpm) (with an encoder) PID controlled as a servo give a study response when subjected to a load?</p>

答:
I'm assuming you mean 12V geared DC motor.

It can give a stable response.  In fact, this is done all the time.   Plus, if the load is relatively stable, and the gears and other transmission elements have enough friction, you may not even need to use PID - a simple proportional controller might be good enough.

But your question is not sufficient for providing a specific answer to a particular design option, because you can also implement a PID controller for a 12V geared motor under load and have it not work.   It just depends on the specifications of motor, the gears, the power supply, the controller (amp), the software, and the load.

Title: DC motor pid control


问:
Localization within a map with gyro, accelerometer and magnetometer
My goal is to locate precision within a known map.

If the size of the map is known, a rectangle 4 x 3 m, and I know the initial position and orientation of the robot, after a certain period of time here moved randomly, can you know at what point of the map I am?

I use the MPU 9250 sensor, gyro, accelerometer and magnetometer sensor.

答: From the acceleration relatively to time you can get  velocity and distance simply by ingrating ,and by how much you have moved added to your initail position  with respect to the orientation you get the position,meaning imagine you moved forward orientation is the same you add the distance to y then moved to right straight you add the distance to x,but when you move in x,y together  imagine you are in a triangle with the orientation as your angle </p>


问:
How can I use an RC servo to rotate more than 360 deg and still maintain positional accuracy?
RC Servos are great because they are low cost, widely available, easy to control, and pretty accurate.  One disadvantage is that they usually have very limited range of motion.  This is because they are mostly for use on actuating RC control surfaces that rarely move more than 120 degrees.

Our FTC robotics teams uses them a lot; but, often we need to rotate more than 120 deg and often would like 360 deg or more.  Robot design requires the solution to be small and light weight as it will usually be at the end of an extension arm.  The game rules (and practicality) requires the solution to use a 3-wire RC servo.  Also, space and alignment issues usually make using external gear sets problematic.

Last season we needed a large "grabber" at the end of our arm and resorted to using a continuous rotation servo the rotated until it torque limited.  This worked but was far from ideal as it over-stressed the servo and we had minimal control on the "grabber" - we could open it or close it.

Our ideal solution would be small, light-weight, and inexpensive (add less than 50% to the weight, cost, or the length of any dimension of motor).

Given our constraints, how can we rotate an axis more than 360 deg and still maintain positional accuracy?

答:
While originally creating this question I ended up finding an RC servo that can do this.

HiTECH makes an RC servo (HS-785HB) that uses a muti-turn potentiometer rather than a standard rotary potentiometer is its position senor.  This allow the servo to rotate 3.5 turns (1260 degrees!!!) while still maintaining positional control.  It is pretty slow (almost 10 sec to do a full rotation) but it has an immense (1.8A) stall torque.  The thing is a beast!

It is also called a Winch Servo (as @tuskiomi mentioned) since it is commonly used as a sheet winch on RC sailboats.  Note that from what I have seen, not all Winch Servos are multi-turn.  So far this is the only one I have found.


问:
What battery capacity would be required to run a component for an hour?
I have a 9.8kW Component that runs at 51.8 Volts. That means I need a battery that has about 9.8kWh of energy to run the component for an hour

For the sake of simplicity, say I have some batteries that just happened to match that voltage (51.8V) simply laying around. How many mAh would that battery need to be to run this for an hour? My instinct is to simply say 98 Ah, but this doesn't seem right..

答:
Power (Watts, milliWatts, etc.) is given by:

$$
P = IV \\
$$

where $I$ is current in (milli)Amps, $V$ is voltage in Volts, and $P$ is power in (milli)Watts, respectively. Energy (Watt-hours, milliWatt-hours, etc.) is given by:

$$
E = P\Delta t \\
$$

(assuming constant power output), where $E$ is energy in (milli)Watt-hours and $t$ is time in hours. Finally, electric charge is given by:

$$
Q = I \Delta t \\
$$

where $Q$ is current charge in (milli)Amp-hours and $I$ and $t$ are as defined before.

So, if you have an application where you want 9.8 kW to run for an hour, then ideally you would want an available energy reserve of:

$$
E = P\Delta t \\
E = (9.8\mbox{kW})(1\mbox{hr}) \\
\boxed{E = 9.8 \mbox{kWh}} \\
$$

As you've hinted at, batteries aren't rated in Watt-hours; they're generally rated in Amp-hours. There's an easy conversion, though - substitute the equation for power!

So, instead of:

$$
E = P\Delta t \\
$$

You would use:

$$
E = (IV) \Delta t \\
$$

which you can rearrange for the battery's current charge:

$$
E = V(I \Delta t) \\
E = VQ \\
\boxed{Q = \frac{E}{V}} \\
$$

Now you know the energy reserve you'd like to have: 9.8 kWh, and you know the voltage you're going to operate at: 51.8 V, so plug those in and get the answer:

$$
Q = \frac{9.8 \mbox{kWh}}{51.8\mbox{V}} \\
\boxed{Q = 0.189 \mbox{kAh}} \\
$$

Note the units because they're important. If you use energy as kiloWatt-hours, then the output is kiloAmp-hours. Multiply by 1,000 to get to Amp-hours:

$$
\boxed{Q = 189 \mbox{Ah}} \\
$$

I'll make an important note now about an aspect of this problem that you didn't ask. I mentioned available energy reserves because you generally can't get all of the charge from a battery without physically damaging the battery. Allowable depths of discharge vary by battery style and chemistry, so a deep-cycle lead-acid battery might allow you to get down to 10-20% of full charge without damage, but a lithium ion battery might only let you get to 40% of full charge without damage.

Generally speaking, a quality battery manufacturer should provide a plot of expected battery life in charge/discharge cycles versus depth of discharge. It's up to you, the engineer, to choose what tradeoffs are allowable.

For example, you might choose to use a deep discharge (down to 5-10% of full charge) and knowingly damage the battery in exchange for longer operation between charges and/or a lower pack weight - this might be the case for a robotics competition.

Or, you could use a small discharge (only down to 80% of full charge) because it is acceptable to have a large battery bank - this might be the case for a solar power installation.

Whatever the case, you should recognize that your available charge is some percentage of the rated battery charge:

$$
Q_{\mbox{available}} = \eta Q_{\mbox{rated}} \\
\boxed{Q_{\mbox{rated}} = \frac{Q_{\mbox{available}}}{\eta}} \\
$$

So, if you know that you want to discharge down to 40% of full charge, then you are saying that you want to use 60% of the full charge of the battery. If you know how much charge you would like to have, then you can calculate that you need a battery rated to:

$$
Q_{\mbox{rated}} = \frac{ Q_{\mbox{available}} } {0.6} \\
\boxed{Q_{\mbox{rated}} = (1.67) Q_{\mbox{available}}} \\
$$

You need a battery rated to 67% more (or higher) than what you calculated you need to ensure you only ever discharge to 40%.


答:
As @Abdul mentioned, and accelerometer measures acceleration which when integrated (adding together successive measurements over time) becomes velocity and when velocity is integrated you get position.  So (in theory) you can use the accelerometer to track position.

The challenge with this is that in the real world you have error.  As error is integrated over time it gets works and then when that is also integrated it gets WAY worse.

Last year our robotics team made a robot that focused on autonomy (the ability to drive itself).  Initially we used the drive encoders to track robot position and orientation; but, when the wheels slipped or the robot was bumped it would go off path.  To fix that, we added and accelerometer to correct.  The initial results were impressive.  You could bump the robot and it would return to the target path.  Then one competition we had a several minute delayed start and rather than driving straight it immediately turned right and climbed the ramp.  Epic Fail.

There are ways to correct (some) for the accumulated error.  One technique is to use a Kalman Filter.  Since the robot starts and stops a lot, the average acceleration should be zero.  Also, you can compensate for bearing errors by using the magnetometer to detect and compare bearing changes.  Another option is to use points where you know your robot's position, velocity, or orientation to correct calculated values.

The bottom line is that yes you can use and accelerometer to track potion; but, you will have to deal with accumulated error.  The better you handle that the better your positional accuracy will be.

Title: Localization within a map with gyro, accelerometer and magnetometer

Body:
My goal is to locate precision within a known map.

If the size of the map is known, a rectangle 4 x 3 m, and I know the initial position and orientation of the robot, after a certain period of time here moved randomly, can you know at what point of the map I am?

I use the MPU 9250 sensor, gyro, accelerometer and magnetometer sensor.


问:
Robot with Double Integrator Model
Does the robot described by Double Integrator Model is holonomic ?

Let's say we have a robot with dynamics described by equations

\begin{cases}
\dot x = v,  &  \\
\dot v = \frac {1}{m}u
\end{cases}
Where, $x$ is the position of the robot, $v$ is the velocity and $u$ is robot's control input.

Can we call this robot a holonomic robot ?

答:
A holonomic robot is one where the number of degrees of freedom is equal to the number of controllable axes.

In your case, you are controlling acceleration (one axis of control) but there is also only one degree of freedom - position. So, the robot is holonomic.

An example of a non-holonomic robot would be a differentially steered robot, like a micro mouse or a tank. There you can only control the left and right wheel speeds, but you can move to any x/y position AND you can be at any position with any heading. You can control two things, but the vehicle can move in three ways - forward/backward, rotate, and then left and right by rotating, driving forward, then rotating again.

Similarly, an Ackerman steered vehicle is also non-holonomic. There you can only control speed and steering angle, but again you can arrive at any x/y position with any heading. Again, two axes of control but three degrees of freedom.

Title: Robot with Double Integrator Model


问:
How to connect an infrared remote control to PC or Arduino or Raspberry Pi?
I bought my kid a robotics kit with several motors and an infrared remote control (you can steer the robot using IR remote control).

Now I want to take it to the next level and control the robots from a PC or a Raspberry Pi.

What is the simplest approach to do this?

I am thinking about 2 possible ways:

Find out the protocol the existing remote control uses and then emulate the IR signals using Arduino (Arduino is sending the IR signals).

Find a piece of hardware, which presses the buttons on the remote control and control it via to Arduino (Arduino is sending signals to the button pushers, the remote control is sending the IR signals to the robot).

答:
Read Ada Fruits Tutorial along with many other sources of IR tutorials out there.

Then for an Arduino I would use (and have used) Ken's IRremote Library as it has several examples, several device protocols and requires only a TSOP38238. And is quickly adaptable to others.

Look at the GitHub Network of Forks, as there are others who have added other device protocols.


答:
Holonomic means that the controllable degrees of freedom in a system is equal to the total degrees of freedom.

I'm guessing you might be having difficulty differentiating between states and degrees of freedom which are both simple concepts, but sometimes confused with one another.

1st comment: The [robot] system you describe has a single degree of freedom. It just translates in a single direction like forwards and backwards. But not side to side, nor does it spin. Not a very interesting robot.

2nd comment: The double integrator has two states. You can assign them as

$$x_1 = x$$
and
$$x_2 =v$$
3rd comment: The system has one input, $u$, a force

So Answer: Yes, it's holonomic. There are two states (position and velocity), but only one degree of freedom and one controllable degree of freedom (forwards and backwards).

Example of a non-holonomic system: A wheel that rolls but also 'yaws' to steer a vehicle

OwnerDisplayName: kiabonov

Title: Robot with Double Integrator Model

Body:
Does the robot described by Double Integrator Model is holonomic ?

Let's say we have a robot with dynamics described by equations

\begin{cases}
\dot x = v,  &  \\
\dot v = \frac {1}{m}u
\end{cases}
Where, $x$ is the position of the robot, $v$ is the velocity and $u$ is robot's control input.

Can we call this robot a holonomic robot ?

OwnerDisplayName: docscience


问:
Industrial servo motor
How to control an industrial servo motor?

The specific motor dive I am looking at is a Delta adsa-a2 series AC Servo Drive.

I know that we can connect the motor driver to the software that the company provides; but, i want to control it using a code written in c++ or c.

I see it has a USB connector

What data should i send?

答:
The answer is yes you can

I looked at at the users manual for the asda-a2 and it looks like it will close the servo control loop for you and also gives you several good control options.  All the Sections I refer to are in that manual.

First - This looks to be a very powerful AC Servo.  BE CAREFUL!!!  You can easily break an finger or maybe even sever one off.  Be sure to install a cover to protect yourself as well as a safety interlock and Emergency Stop (E-Stop) button that will interrupt power to the motor.  There has been more than one time my code did not work as I expected it to or something else happened.

There are several control options available that you can use depending on the level of control you want/need.

You can configure the drive to operate off of discrete signals (see section 3.4).  That way the controlling computer just has to turn a line on or off to execute the pre-programmed operation (like start and stop) or set a voltage to control speed, etc. (no commands required).

You can send the drive commands over RS232/RS485 (see diagram in 3.6.2) or USB (see section 3.7) or CANopen (see section 3.9).  With the commands I saw, it looks like you do pretty much anything.  It looks like they use ModBUS which is a pretty easy protocol and there are libraries to support it depending on what type of computer you are going to use.

Control modes (and commands) are described in Sections 6-9

It will be a bit to learn; but, the drive seems well documented.

I recommend you start simple (AND SLOW!) and move up from there.  Start by configuring things mostly from the Control Panel and execute the commands from there. Maybe just a simple velocity control (start/stop) or positional control (jog).  Always have your (or somebody else's hand on the E-Stop just in case.

Title: Industrial servo motor


问:
How to locate an object on a known surface
I am building a small robot on wheels. The robot will be moving at a small speed in a square area of known dimensions. I need to locate the robot and know its position at any given moment so I can correct its trajectory.
I can add parts to the robot, like some sort of flag or lighting object.
It's preferable not to put any border around the area, since it would limit the flexibility of the project.

Added Info

The size of the robot is about 28 x 25 x 11cm. It will go on land and
the surface will be ideally flat (but since the friction between the
surface and the wheels can vary in different places, I need to know
if the robot arrived to the destination or not, and corrections need
to be done respectively).

I can place beacons around the field or any sort of sensors, as long as I can remove them easily and transport them.

The surface will be about 1.5x1.5m, depending on the range of the sensors, or the method used for localization.

The robot can start from a determined position.

Some methods

I thought of triangulating the position using two ultrasonic sensors placed at the two edges of the field. Although I am not sure if the US sensors will provide a sufficient angle and range to cover the entire area. I am also concerned about the precision.

Someone pointed to me that I could use two infrared sensors placed at the two edges, and make them turn 90deg both ways and scan the area. As soon as they find something, the position of the object can be found using triangulation.
Although I still don't know if these methods work well for a moving object.

If you think that one of the methods that I described is the way to go, please give me more insight on how to implement it in my project.

Here is an illustration of the path that the robot should go along. The basic idea of the project is that the robot should sow seeds at regular intervals, for example every 10cm; this is why I need to know if the robot really covered 10cm after the seed before, and if it has to turn.

I thought of making an imaginary grid: I tell the robot the position that it has to reach, then knowing the position of the robot I can make it turn until it is pointing in the direction of the arriving point and then it covers the distance between it's position and the arriving point.

I am very new to robotics, therefore I would really appreciate a detailed answer.

答:
Robots usually locate themselves on a field using sensors.  None of the sensors are perfect as they each have their own limitations; hence, the more sensors the better.

Here are some sensor options:

Motor Encoders on the wheels to track the distance and turns

IMU/Gyro to track acceleration and calculate speed and position

Magnetometer to correct bearings against magnetic north

GPS (usually for large outdoor distance)

Range detectors to look for walls or objects to reference off

Line detector (for lines or path markers on the floor)

Optical Surface Texture detection (like a laser mouse uses)

LIDAR imaging

Camera imaging (sometimes stereo-graphic)

Beacon detector (some fields have beacons placed on them for reference)

Generally the FTC (First Technology Challenge) robots that have good autonomous programs have at least four different sensor types that they use for positioning.


问:
Build (Assembly kits?) the frame of a robot
I am fairly knowledgeable about robotics programming, and stuff like that; but, I am a total ignorant about how to actually "build" a robot.

My question is: What materials do you recommend to build a robot and where can I buy them. It does not matter what kind of robot. I know that a robotic arm is very different from a mobile robot.  I know the theory.

Other than Lego bricks (which I have heard of), I am imaging silicon frames... I really don't know.

I have developed some very fair and nice devices with image processing, computer vision and stuff. I also know how to program several kinds of motors etc.
I just don't know how to put all of this inside a nice frame and show it to the world

答:
I mentor several FTC (First Tech Challenge) Robotics Teams.  These teams build medium size robots (about 50cm cube starting size).

For this size, there are four Building Systems that are the most common

Tetrix

Matrix

Actobotics

8020 Extrusions (There are lots of other suppliers too)

These solutions are all very flexible allow a large about of options on how to build frames and attach motors, wheels, sensors, etc. and are designed for reuse.

Hotwired Robotics (one of our local FTC teams) wrote a great overview of the different Building Systems.

Shameless Plug

Why not find a First Robotics Team near you and offer to be a help Mentor?  You can learn from them how to build a robot and they can learn from you how to program one.


问:
Why doesn't this kalmanfilter filter anything? Reduce disturbances and noises with LQG controller
I have a state space model which look like this:

$$
\ \begin{bmatrix} \dot{x} \\ \\\dot{\tilde{x}} \end{bmatrix} =\begin{bmatrix} A - BL& BL \\ 0 & A-KC \end{bmatrix} \begin{bmatrix} x\\ \tilde{x} \end{bmatrix}+\begin{bmatrix} B & I & 0\\ 0 & 0 & K \end{bmatrix}\begin{bmatrix} r\\ d\\ n \end{bmatrix}\
$$

$$
\begin{bmatrix} y\\ e \end{bmatrix} = \begin{bmatrix} C &0 \\ 0& C \end{bmatrix}\begin{bmatrix} x\\ \tilde{x} \end{bmatrix} + \begin{bmatrix} 0 & 0 &0 \\ 0 & 0 &1 \end{bmatrix}\begin{bmatrix} r\\ d\\ n \end{bmatrix}
$$

This state space model represents this picture:

If you still not understand how. Look at this video:
https://youtu.be/H4_hFazBGxU?t=2m13s

Notice the estimation error: $\tilde{x} = x - \hat{x}$

So I've made som Octave code which are very similar to MATLAB code if you have the MATLAB control package installed. Octave have a free control package and symbolic package to use.

```<code>clc
clear

% ladda bibliotek - Load GNU octave library - Free to download
pkg load symbolic
pkg load control

% Parametrar
m1 = 10; m2 = 7; M = 1000;
Ap = 40; Am = 20;
Pp = 20; Pm = 10;
b1 = 3000; b2 = 1000;
L = 0.1; g = 9.82; mu = 0.3;

% Tillstånd vid statiskt - When this model are a statical point
% the state are:
x1 = 0.65;
x2 = 0;
x3 = 0.2;
x4 = 0;
x5 = 5*pi/180;
x6 = 0;

% Symboliska variabler
syms k1 k2 k3

% Statisk beräkning - Statistical calculations using symbolic solve
Equation1 = -k1/m1*x1 + k1/m1*x3 - b1/m1*x2 + b1/m1*x4 + Ap*10/m1*Pp - Pm*Am*10/m1*x2;
Equation2 = k1/M*x1 - k1/M*x3 + b1/M*x2 - b1/M*x4 - g*mu*x4 - k2/M*x3 + k2*L/M*x5;
Equation3 = 3*k2/(m2*L)*x3 - 3*k2/m2*x5 - 3*k3/(m2*L^2)*x5 - 3*b2/(m2*L^2)*x6 + 3*g/(2*L)*x5;

[k1, k2, k3] = solve(Equation1 == 0, Equation2 == 0, Equation3 == 0, k1, k2, k3);
k1 = double(k1);
k2 = double(k2);
k3 = double(k3);

% Dynamisk beräkning - Dynamical calculations for the state space model
A = [0 1 0 0 0 0;
     -k1/m1 (-b1/m1-Pm*Am*10/m1) k1/m1 b1/m1 0 0;
     0 0 0 1 0 0;
     k1/M b1/M (-k1/M -k2/M) (-b1/M -g*mu) k2*L/M 0;
     0 0 0 0 0 1;
     0 0 3*k2/(m2*L) 0 (-3*k2/m2 -3*k3/(m2*L^2) + 3*g/(2*L)) -3*b2/(m2*L^2)];

B = [0; Ap*10/m1; 0 ; 0; 0; 0]; % Input matrix
C = [0 1 0 0 0 0]; % Output matrix
I = [0; 1; 0 ; 0; 0; 0]; % Disturbance matrix.

% LQR
Q = diag([0 0 0 40 0 0]);
R = 0.1;
L = lqr(A, B, Q, R); % The control law - LQR gain matrix

% LQE
Vd = diag([1 1 1 1 1 1]);
Vn = 1;
K = (lqr(A',C',Vd,Vn))'; % A way to use LQR command to compute the Kalman gain matrix

% LQG
a = [(A-B*L) B*L; zeros(6,6) (A-K*C)];
b = [B I zeros(6,1); zeros(6,1) zeros(6,1) K];
c = [C zeros(1,6); zeros(1,6) C];
d = [0 0 0; 0 0 1];
sysLQG = ss(a, b, c, d);

% Simulate the LQG with disturbance and white gaussian noise
t = linspace(0, 2, 1000);
r = linspace(20, 20, 1000);
d = 70*randn(size(t));
n = 0.1*randn(size(t));
x0 = zeros(12,1);
lsim(sysLQG, [r' d' n'], t, x0)
</code>```

This will result if I got noise $0.1*randn(size(t))$ . $y1 = y$ and $y2 = e$

But let say I got no noise at all! I got this:

That means that $\tilde{x}$ has no function at all! Something is wrong. I have tried diffrent values at the $C$ matrix, but have not get an estimation error to look at.

Question: $$ $$
What is wrong with my model? I want to control this so the model and stand against the disturbance and noise. But now, the model just accepting the disturbance and noise.

Does the observer(kalmanfilter) need to have disturbance too?

EDIT: $$ $$
If I simulate this new state space model with the same options and code I had before:
$$
\ \begin{bmatrix} \dot{x} \\ \\\dot{\tilde{x}} \end{bmatrix} =\begin{bmatrix} A - BL& BL \\ 0 & A-KC \end{bmatrix} \begin{bmatrix} x\\ \tilde{x} \end{bmatrix}+\begin{bmatrix} B & B & 0\\ 0 & B & K \end{bmatrix}\begin{bmatrix} r\\ d\\ n \end{bmatrix}\
$$

$$
\begin{bmatrix} y\\ e \end{bmatrix} = \begin{bmatrix} C &0 \\ 0& C \end{bmatrix}\begin{bmatrix} x\\ \tilde{x} \end{bmatrix} + \begin{bmatrix} 0 & 0 &0 \\ 0 & 0 &1 \end{bmatrix}\begin{bmatrix} r\\ d\\ n \end{bmatrix}
$$

I get this. All I did was to add disturbance to the kalmanfilter too. And insted of $I$ matrix, I replace it with $B$ matrix.

But the problem is that if I simulate an LQR with only state feedback, not the kalmanfilter (observer). I get this:

There are both red and green color in this picture. You have to zoom in. The red color is the LQG simulation and the green color is the LQR simulation(the simulation wihout the kalmanfilter). You can se that the kalmanfilter does not filter anything. Why?

Here is a short code sample:

```<code>% LQG
a = [(A-B*L) B*L; zeros(6,6) (A-K*C)];
b = [B B zeros(6,1); zeros(6,1) B K];
c = [C zeros(1,6); zeros(1,6) C];
d = [0 0 0; 0 0 1];
sysLQG = ss(a, b, c, d);

% Simulate the LQG with disturbance and no white gaussian noise
t = linspace(0, 2, 1000);
r = linspace(20, 20, 1000);
d = 2*randn(size(t));
n = 0*randn(size(t));
x0 = zeros(12,1);
[yLQG, t, xLQG] = lsim(sysLQG, [r' d' n'], t, x0);

% Simulera LQR med störning
sysLQR = ss(A-B*L, [B B], C, [0 0])
x0 = zeros(6,1);
[yLQR, t, xLQR] = lsim(sysLQR, [r' d'], t, x0);

plot(t, yLQR, 'g', t, yLQG(:,1), 'r');
</code>```

答:
I'm not sure if this answers the question but I think there is a mismatch between the block diagram and the state equations.

In the first block of the state transition matrix (top-left $A-BL$) you use the state $x$ to control your system, but that's what you're estimating with the Kalman filter, so you don't know $x$. My guess, that part should be $\dot{x}=Ax$. That means you've to change the sign of the top-right block to get $\dot{x}=Ax-BL\tilde{x}$.

On the other hand, from the measurement equations, your Kalman filter does not get the sensor noise, so you probably need to change your matrices to get $y=Cx+n$.

That's as far as I can get. Hope this helps.


问:
What is the difference between object pose estimation and object tracking?
In papers the terms object pose estimation and object tracking are used side by side with different meanings. Can somebody explain me the difference?

答:
"Pose" is a commonly used term that means position and orientation, where object tracking would just care about position but not necessarily the orientation.

So, for a vehicle on the street, you would want to know its pose so you could determine both where it is and if it is facing you or not.

For other applications, position alone is sufficient; think objects on a ballistic trajectory like basketballs, baseballs, etc. There the orientation doesn't matter.


答:
When someone is referring to object tracking, he most likely talks about estimating the location of an object in an ordered sequence of images (e.g. a video). In this case, for most images, you already know where to expect an object (namely close to its location in the last image) and can use several detections to estimate the speed so that your prediction gets better. The location in tracking can be the region in the image in which the object is visible or even the 6d pose of the object. Main problems in tracking are occlusions or several similar objects in the scene. (think about a person walking through a group of other people)

Pose estimation is rather referring to computing the pose given a single image, in most cases with prior knowledge (e.g. texture or shape) of the object. Pose estimation can be used while tracking an object.

Title: What is the difference between object pose estimation and object tracking?

Body: In papers the terms object pose estimation and object tracking are used side by side with different meanings. Can somebody explain me the difference?


问:
Best way to detect a range of key points in the image of a given cloth article
I am designing a robot which irons and folds clothes autonomously. For this purpose, I need the robot to detect a certain number of key points in a given cloth in order to execute a certain folding or ironing algorithm. The following images best describe what I actually mean by key points

;,

For example for a T-shirt, the above image shows the desired key points.

For example for a trouser, the above image shows the desired key points.

My first thoughts:

My first plans were to use neural networks detect various key points after recognising if the cloth is a t-shirt, trouser etc. But I believe, the problem with this approach is that collecting a lot of data sets to train the neural network to detect these key points is a massive task. Furthermore, I am not even sure if neural networks can produce the results I am looking for because generally, neural networks work well differentiating well defined varying classes of items like for example cats and dogs.

So my question is, is there a better way to achieve what I am trying to do? Any help is appreciated thank you.

UPDATE

Ideally, what I want to do is identify or recognise each of these key points precisely; meaning, for example, the system should know where the collar region for a t-shirt and track its location at all times. I need to know what each key points are (is it a zip area or shirt's shoulder or a collar region) in order to execute a certain folding algorithm. So in this case, I believe, convexity defects do not work.

答:
Neural networks are not the solution to every problem in robotics. </p>

<p>Have a look at the convex hull of the object and convexity defects. </p>

Body:
Neural networks are not the solution to every problem in robotics.

Have a look at the convex hull of the object and convexity defects.


问:
Nearest-neighbor data structure for non-Euclidean configuration space
I'm trying to implement a nearest-neighbor structure for use in an RRT motion planner. In order to do better than a linear brute-force nearest-neighbor search, I'd like to implement something like a kd-tree. However, it seems like the classical implementation of the kd-tree assumes that each dimension of the space can be split into "left" and "right". This notion doesn't seem to apply to non-Euclidean spaces like SO(2), for instance.

I'm working with a serial manipulator arm with fully rotational links, meaning that each dimension of the robot's configuration space is SO(2), and therefore non-Euclidean. Can the kd-tree algorithm be modified to handle these kinds of subspaces? If not, is there another nearest-neighbor structure that can handle these non-Euclidean subspaces while still being easy to update and query? I also took a look at FLANN, but it wasn't clear to me from their documentation whether they can handle non-Euclidean subspaces.

答:
A simple option for approximate neighbor search in non-euclidean spaces is using $sqrt(N)$ samples in the search. This has been implemented in OMPL, see ompl::NearestNeighborsSqrtApprox< _T > Class Template Reference.

This reduces complexity to $O(sqrt(N))$.


问:
How can a load be balanced between multiple AC electric drive motors?
I have a three wheeled vehicle in a tricycle configuration attached to a fixed frame. Each wheel is powered by an AC electric motor. The AC motors are fed by motor controllers that take a speed demand. The single main wheel (which is also steerable) has a lower gear ratio than the rear wheels so it has a theoretical higher top speed.

When the vehicle drives in a straight line each of the motor controllers are given identical speed requests. Unfortunately feedback from the controller indicates that some motors are pushing while some are pulling. In particular we have a common scenario where one rear wheel is pushing while the front wheel is trying to slow down. The third wheel will often have almost no current.

What can be done to make all three motors work together and avoid situations where they fight?  Is there a way to change the request to the motor controller to encourage the drives to work together? Do we have to switch from a speed request setup to a current control setup? If so what is the appropriate way to control the motors then?

Let me know if I haven't included any important details and I will update my question.

答:
You're facing a problem that's normally solved mechanically, with 2 or 4 wheels, by a differential gearbox.  Technically, you'd be able to adapt a 4WD differential to a 3WD case, but you'd have to use a single motor for that.

The concept you're looking for is an electronic differential, although I'm not sure where to find resources on building and calibrating your own.  It might be as simple as switching your motor controllers to just set identical torque, based on a desired average speed between the 3 of them.

The bottom line, though, is that you can't expect to set 3 motors to the same speed and have them follow 3 paths of different lengths while maintaining the same distance from each other.


问:
IMU alignment methods
I have an IMU that is outputting the following for its measurements:

```<code>accelx= 0.000909228 (g's)
accely= -0.000786797 (g's)
accelz= -0.999432 (g's)
rotx= 0.000375827 (radians/second)
roty= -0.000894705 (radians/second)
rotz= -0.000896965 (radians/second)
</code>```

I would like to calculate the roll, pitch and yaw and after that the orientation matrix of the body frame relative to the NED frame.

So I do

```<code>roll = atan2(-accely,-accelz);
pitch =atan2(-accelx/sqrt(pow(accely,2)+pow(accelz,2)));
sinyaw = -rotycos(roll)+rotzsin(roll);
cosyaw = rotxcos(pitch)+rotysin(roll)sin(pitch)+rotzcos(roll)*sin(pitch);
yaw = atan2(sinyaw,cosyaw);
</code>```

and I get:

```<code>roll = 0.000787244
pitch = -0.000909744
yaw = 1.17206
</code>```

in radians.

However the IMU is also outputting what it calculates for roll, pitch and yaw.

From the IMU, I get:

```<code>roll: -0.00261682
pitch: -0.00310018
yaw: 2.45783
</code>```

Why is there is a mismatch between my roll, pitch and yaw and that of the IMU's?

Additionally, I found this formula for the initial orientation matrix.

Which way of calculating the orientation matrix is more correct.
R1(roll)*R2(pitch)*R3(yaw), or the form above?

答:
The roll and pitch angles that you calculate using the accelerometer measurements will only be correct if (1) the IMU is non-accelerating (e.g., stationary), and (2) the accelerometer measurements are perfect. Thus, they can only be used to initialize the tilt (roll and pitch) of the IMU, not to calculate roll and pitch during acceleration. An external measurement of yaw angle is required to initialize the yaw angle.

See these answers:

What information an IMU gives to a drone?

Multicopter: What  are Euler angles used for?

for some background.

Say the accelerometer measurements are $f_x$, $f_y$, and $f_z$; the gyro measurements are $\omega_x$, $\omega_y$, and $\omega_z$, and the magmetometer measuremenst are $b_x$, $b_y$, and $b_z$.  The roll angle ($\phi$) and pitch ($\theta$) angle can be initialized if the IMU is not accelerating using
\begin{eqnarray}
\phi_0 &=& \tan^{-1}\left(f_y/f_z\right) \\
\theta_0 &=& \tan^{-1}\left(-f_x/\sqrt{f_y^2+f_z^2}\right)
\end{eqnarray}
The yaw angle ($\psi$) can be initialized using the magnetometer measurements. Given the roll and pitch angles, the magnetic heading ($\psi_m$) can be calculated from $b_x$, $b_y$, and $b_z$. Given the magnetic declination at the system location, the true heading (or initial yaw angle, $\psi_o$) can be calculated.

Once the IMU is initalized in an unaccelerated state, the gyro measurements can be used to calculate the rates of change of the Euler angles while the IMU is moving:
\begin{eqnarray}
\dot\phi &=& \omega_x +\tan\theta\sin\phi\,\omega_y +\tan\theta\cos\phi\,\omega_z \\
\dot\theta &=& \cos\phi\,\omega_y -\sin\phi\,\omega_z \\
\dot\psi   &=& \sec\theta\sin\phi\,\omega_y +\sec\theta\cos\phi\,\omega_z
\end{eqnarray}
The rates of change of the Euler angles are then numerically integrated to propagate the Euler angles.  The coordinate transformation matrix at each instant of time can then be obtained from the Euler angles.

This will work if your IMU never pitches up or down to $\pm90^\circ$.  In that case it will be better to calculate and propagate quaternions instead of Euler angles. (Euler angles can always be calculated from the quaternions.)

Alas, the gyros are not perfect.  Say that the gyros have bias errors, then these bias errors will also be integrated with time to result in the Euler angled "drifting".  For this reason, an extended Kalman filter is often used to calculate the orientation of the IMU, aided by other measurements (magnetometer, accelerometer, and a GPS, for example). But that's another topic :)

Title: IMU alignment methods


问:
Biped State Space Implementation
Currently I working on a humanoid robot using inverted pendulum model and use LQR for walking stabilizer. Input u is Torque, State x is angle and angular velocity and y output is angle.

I got the gain K value that meet my control specification (rise time, steady state error, etc) and the feedback control law like this

So now I got u(torque) value, but I don't know how to use u(torque) to move my actuator (to control 2 angkle servo) because my servo only move using angle as the command input, not torque. Is there any step that must be done to convert torque to angle? Or something? Thank You for the help, need this for my final project.

答:
The servomotor is already a closed-loop servomechanism that uses position feedback to control its motion and final position. Your servo is an integrated servomotor, and then it contains the following equipment in a single package:

a small closed-loop controller (e.g. PI) which regulates the physical greetness per kind of motor directly linked to the produced torque (e.g. the absorbed current of the internal DC motor). In the industrial servos, the controllers are a standard industrial component on power electronics components like MOSFETs or IGBTs;

a rotable potentiometer feeding the current value of the angle back to the controller (so that you can also get the angle value over the command channel) and then closes the loop;

The motor.

Therefore, in order to implement  $u = -Kx$ you would need to get control of the signal (now computed by the internal controller) directly linked to the torque (e.g. the absorbed current in the case of DC motor).

Title: Biped State Space Implementation


问:
DC gearmotor stall current and battery capacity
I'm working on a self-balancing robot project and am in the process of motor sizing. I've read that with self-balancing robots the motors need to switch direction quickly, which can cause them to briefly draw more than twice the stall current if changing from full speed in one direction to full speed in the other direction.

So I'm wondering if, when I find a motor with a suitable rated torque to drive the robot, would I need to work out if the battery can supply a current twice (or more) times the stall current of the motors/how long it would last before being drained?

e.g.

Motor Stall Current: 5000mA = 5A

12v Ni-MH Battery: 3800mAh = 3.8Ah
$$I_{stall} = (5A*2) = 10A \,\,\,\,\,(2\, motors)$$

$$C_{battery} = 3.8Ah$$
$$$$
$$I_{stall} = \frac {C_{battery}}{t}$$
$$t = \frac {C_{battery}}{I_{stall}}$$

$$t = \frac {3.8Ah}{10A} = 0.38h$$

So the battery could supply twice the stall current for 0.19h.

Am I understanding this correctly?

答:
You will almost never get the motors to sink their stall currents... But yes, your robot will last 0.38 hours.
Also, it's good to know that you should not reach the 80% of the battery's nominal voltage (at least not in LiPo or NiMh). So be careful!</p>


问:
Cheap light fast industrial robot?
Why are there no simple industrial robots (mainly for simpler tasks like pick and place) that are:

Cheap (<=3000$),

Lightweight (<=10kg),

Fast (600mm/s at end effector),

Most of the robots I have looked at cost more than 10K$. Many of cheap ones use 3D printed (plastic) components.  I'm not sure whether these robots can survive the continuous and long operating hours in factories.

What's the bottleneck developing such a system?
Why haven't established companies not entered this market?

Could someone give some insight on this?

答: High quality, low backlash gear reducers cost almost \$1,000 a piece. You need one on all 6 joints. High powered servo motors cost $500+ each. High quality bearings that allow for high pre-loading are a few hundred each. Add the electronics, aluminum body, labor, etc. and it adds up quickly.</p>

Title: Cheap light fast industrial robot?


问:
How rotate a point around an arbitrary line in 3D?
I have a body with origin at point A which is represented in homogeneous coordinate of matrix 4x4 and I would like to rotate it around an arbitrary vector in 3D space.

I understand how to rotate the body around its own frame axis, but I'm not sure how to rotate it around any vector in space.

答:
For a general point in 3D space, $P=(x,y,z)$, and a vector, $V$, which is defined by a line between two points, $P_1=(x_1,y_1,z_1)$ and $P_2=(x_2,y_2,z_2)$, (i.e. $V=P_2-P_1$), the transformation of the point around that vector by an angle, $\theta$, is given by:

$\left(
\begin{array}{c}
 x' \\
 y' \\
 z' \\
 1 \\
\end{array}
\right)=T^{-1}.R_x{}^{-1}.R_y{}^{-1}.R_z.R_y.R_x.T.\left(
\begin{array}{c}
 x \\
 y \\
 z \\
 1 \\
\end{array}
\right)$

Where:

$P_{transformed}=(x',y',z') \\$

$T=\left(
\begin{array}{cccc}
 1 & 0 & 0 & -x_1 \\
 0 & 1 & 0 & -y_1 \\
 0 & 0 & 1 & -z_1 \\
 0 & 0 & 0 & 1 \\
\end{array}
\right) \\$

$R_x=\left(
\begin{array}{cccc}
 1 & 0 & 0 & 0 \\
 0 & \frac{c}{d} & -\frac{b}{d} & 0 \\
 0 & \frac{b}{d} & \frac{c}{d} & 0 \\
 0 & 0 & 0 & 1 \\
\end{array}
\right) \\$

$R_y=\left(
\begin{array}{cccc}
 d & 0 & -a & 0 \\
 0 & 1 & 0 & 0 \\
 a & 0 & d & 0 \\
 0 & 0 & 0 & 1 \\
\end{array}
\right) \\$

$R_z=\left(
\begin{array}{cccc}
 \cos (\theta ) & -\sin (\theta ) & 0 & 0 \\
 \sin (\theta ) & \cos (\theta ) & 0 & 0 \\
 0 & 0 & 1 & 0 \\
 0 & 0 & 0 & 1 \\
\end{array}
\right) \\$

$d=\sqrt{b^2+c^2} \\$

$U=(a,b,c): \text{A unit vector in the direction of the vector, V.}$


问:
Using C++ to control a drone
I am relatively new to using drones and was wondering if someone more experienced in the topic could lend a hand. I am familiar with C++ and OpenCV, a facial recognition software that has libraries in C++. I would like to be able to use the software to control the drone (engaging it/turning off or on. Flight patterns would be a plus).

In other words I need someone to point me in the right direction to finding the right materials so that my C++ code can control the drone. If anyone can point me to the reading materials or specific drones to purchase I would be extremely grateful.

Note, I used quadcopter as a tag because I did not have enough reputation to use drone

答:
From a very basic standpoint, you're talking about turning on and off motors using code. I'm not sure what drone you're planning on using (building your own?), but there's a lot of great motor controllers out there. Adafruit makes some great motor hats that work with a Raspberry Pi, if you decide to go that route (you'll still need an H Bridge).

If you want something more advanced, like a full on flight controller, I'd point you to GitHub as a starter, where there's a lot of stuff already out there.

It may be a good first start to get a motor (or motors) running as a sort of 'hello world', and then move to drone control from there.

Title: Using C++ to control a drone


问:
How can I convert RGB colors to CMYK for my airbrush robot?
I am developing a robot which paints using an airbrush (3D painting). I intend to use several colors as a CMYK printer, but I do not know how to do the conversion of RGB colors in the computer to the dosage of colors in CMYK.</p>

答:
According to rapidtables.com, the following formulae convert [24-bit] RGB color to CMYK:

The R,G,B values are divided by 255 to change the range from 0..255 to 0..1:

  R' = R/255

  G' = G/255

  B' = B/255

The black key (K) color is calculated from the red (R'), green (G') and blue (B') colors:

  K = 1-max(R', G', B')

The cyan color (C) is calculated from the red (R') and black (K) colors:

  C = (1-R'-K) / (1-K)

The magenta color (M) is calculated from the green (G') and black (K) colors:

  M = (1-G'-K) / (1-K)

The yellow color (Y) is calculated from the blue (B') and black (K) colors:

  Y = (1-B'-K) / (1-K)

Formulae at javascripter.net appear to be equivalent, although complements are computed in a different order.


答:
I propose to use a flight controller (FC software like Betaflight) connected to an Arduino or Raspberry Pi.

The new F3 or F4 flight controllers have, in general, I2C/SPI interfaces where you can call the FC functions.

Title: Using C++ to control a drone

Body:
I am relatively new to using drones and was wondering if someone more experienced in the topic could lend a hand. I am familiar with C++ and OpenCV, a facial recognition software that has libraries in C++. I would like to be able to use the software to control the drone (engaging it/turning off or on. Flight patterns would be a plus).

In other words I need someone to point me in the right direction to finding the right materials so that my C++ code can control the drone. If anyone can point me to the reading materials or specific drones to purchase I would be extremely grateful.

Note, I used quadcopter as a tag because I did not have enough reputation to use drone


问:
What's the diffrence between $H_2$ and $H_\infty$ control?
There a two controllers named $H_2$ and $H_\infty$.
Can someone explain if:

They have have guaranteed stability margins?

Do they have a Kalman filter?

Are they for both SISO and MIMO systems?

Can I use them with LQG?

Which one is best?

If you know how to create a basic $H_2$ and $H_\infty$. Can you please show me step by step?

答:
In short answer:

yes

Kalman filter is a special case of an $H_2$ observer

Yes

Yes ... LQG is just Kalman filter + LQR controller, which are both special cases of $H_2$

Depends on the use case. $H_2$ minimizes error function 2-norm while $H_{\infty}$ minimizes maximum error

Very complicated

The somewhat longer answer:

$H_2$ and $H_{\infty}$ control are both advanced robust-control strategies used for linear systems considering a bounded range of external disturbances plus modelling uncertainties (e.g. element 1,1 of the system $A$ matrix is in the range 1.1-1.5). For such systems, these controllers have the advantages of:

(sub)optimal control

robust1 performance and stability guarantees

A more complete description of $H_{\infty}$is here.

The theory behind them is significantly more complex than Kalman or LQR. Matlab does have tools for designing these controllers (e.g. here) but even knowing the theory the tools are somewhat cumbersome to use. I can't imagine trying to use those tools not knowing the theory.

1This means for any real system with parameters within the specified uncertainty ranges the performance will be within a calculated bound.

ContentLicense: CC BY-SA 4.0


答:
You could use ROS. There's  AR Drone Autonomy for well.. Parrot AR-Drones.
TUM ARDrone from the Technical University of Munich, who used that with OpenCV to control a drone.
You can simulate a drone using Hector.

Or simply search google for quadcopter ROS

Title: Using C++ to control a drone


问:
BBC Micro bit PWM link to CC3D quad controller
I am trying to create the following set up as a project in education:

QAV250 quad with CC3D controller

2xBBC Micro:bits used as the receiver, giving out 50 Hz PWM signals to the CC3D controller - one does throttle and yaw, one does pitch and roll.

2xBBC Micro:bits sending out controlling signals

I can get past the receiver setup wizard and even arm the quad, however I'm getting erratic behaviour, particularly for the throttle. Despite commanding it low, the throttle sometimes remains high.

I don't know if this is linked but on the receiver calibration page of LibrePilot, the input values only update every second (PC plugged into the CC3D). Should these update more frequently? Also, the image of where the sticks are during calibration rarely moves.

Possible reasons I have thought of are:

BBC Micro:bit runs at 3 V. Is this insufficient for the PWM signal (although I just tried with a Raspberry Pi and Adafruit PWM adaptor and the same laggy behaviour shows on LibrePilot)

Is there a syncing issue in the PWM? (i.e. two Micro:bits outputting PWM signals which aren't synchronised). Unfortunately the Micro bit doesn't reliably cope with four simultaneous PWMs, hence the need to use two.

My goal is to show the power of the Micro:bit, despite the fact it's aimed at children, but is this just too much for it?!

答:
Ok I think I'm getting somewhere. Two issues found:

When the Micro:bit runs off two AA batteries the 3v output can drop significantly as the batteries run down. The CC3D wasn't liking the even lower voltage. I've now cut a USB cable up and wired it to the ESCs' BEC output at 5v. Much better signal now.

When the throttle is raised above the neutral detent, I was expecting a gentle increase in motor power. Instead you get a power a little below take off power. This scared me before even fitting the props! Now I've got some more confidence in the system, I've managed to sustain a good hover.

Still need to improve stability but that is normal  use of LibrePilot.


问:
What is a control loop?
I've seen with drones that the norm of programming them is to create three loops,  for each axis, but I'm not quite sure what a control loop is when the code must run in a sequential manner. </p>

<p>Programmatically,  what IS a control loop? </p>

答:
A control loop is:

Get a reference

Get a feedback

"Decide what to do" given the reference and feedback

Perform an action (or not) based on the decision.

This process continuously repeats.

Generally, if you have multiple control loops on one controller, you perform each step in turn for each control loop - get all references, get all feedbacks, run the actual control algorithm to generate the control signal, then write the control signal as appropriate.

Title: What is a control loop?


答:
I think Chuck's answer is quite accurate. Just to add, there are two types of control loops. What Chuck has described is a closed control loop, and hence has a feedback loop to make sure the output is same as reference input or the set point.

Open loop, on the other hand, doesn't need a feedback loop as the control action is independent of the process output.

Title: What is a control loop?

Body:
I've seen with drones that the norm of programming them is to create three loops,  for each axis, but I'm not quite sure what a control loop is when the code must run in a sequential manner. </p>

<p>Programmatically,  what IS a control loop? </p>


答:
ROSflight is a relatively new ROS-based autopilot built on top of STM32 family of microcontrollers -- most notably the F1.

It was built mainly as a research platform so the code is very organized and lean. It was first written in C and is now being ported to C++. The flight controller firmware talks to an on-board companion computer using the MAVLink protocol and exposes IMU (and other sensors) at a rate of 1000Hz through the ROS network using pub/sub.

The ROSflight autopilot firmware takes care of attitude estimation, stabilization, mixing, and RC while the high-level controllers written in C++/Python (using ROS) run on the on-board computer and direct the autopilot based on your specific application. This is where you would use OpenCV to do image segmentation / recognition and control off of visual information.

The same research lab that built ROSflight has publicly available ROS high-level controller starter code for multirotors and fixed wing planes (github.com/rosplane).

Title: Using C++ to control a drone


问:
Mobile robot pose estimation
I want to plot the path of a vehicle via the estimation of egomotion based on essential matrix.

Everything was fine with openCV and the following function.

```<code>function [ xnow] = estimate_pose_test( points1, points2, K,xLast )

%%%%OpenCV%%%%%

  E = cv.findEssentialMat(points1, points2, 'CameraMatrix',K, 'Method','Ransac');
 [R, t] = cv.recoverPose(E, points1, points2,'CameraMatrix',K);
 ry= asin(R(1,3));
 u=[t(1,1);t(3,1);ry];

%%%%%%%%%Opengv%%%%%%
% for i=1:size(points1,2)
%     I1(:,i)=points1{i}';
%     I2(:,i)=points2{i}';
% end
%  temp = K \ [I1; ones(1,size(I1,2))];
%  I1_norms = sqrt(sum(temp.*temp));
%  I1n = temp ./ repmat(I1_norms,3,1);
%
%  temp = K \ [I2; ones(1,size(I2,2))];
%  I2_norms = sqrt(sum(temp.*temp));
%  I2n = temp ./ repmat(I2_norms,3,1);
%
%  X = opengv('fivept_nister_ransac',I1n,I2n);
%  R = X(:,1:3);
%  t = X(:,4);
%  ry= asin(R(1,3));
%  u=[t(1,1);t(3,1);ry];
%

 theta=xLast(3)+u(3);

 if(theta>pi)
    theta=theta-2*pi;
elseif(theta<-pi)
    theta = theta+2*pi;
 end

s = sin(xLast(3));
c = cos(xLast(3));
% actual value added with the new control vector

xnow=[xLast(1:2)+[c s; -s c]*u(1:2);theta];

end
</code>```

points1 and points2 are corresponding SURF features.
  K is internal calibration matrix.

However, I want to use OpenGV librairy. OpenGV expects normalized coordinates on the unit sphere, so I started by transforming the measurements as recommended in the previous link and shown in the commented part in the above function.

The plotted path was totally wrong and the results between Opencv and Opengv are different.

For example for the same two consecutive frames, from opencv, I obtained the following rotation and translation:

```<code>R1 =

    0.9999    0.0016   -0.0153
   -0.0017    1.0000   -0.0054
    0.0153    0.0055    0.9999

t1 =

    0.1159
    0.1042
   -0.9878
</code>```

And with OpenGv,

```<code>R2 =

    0.9998   -0.0059   -0.0167
    0.0060    1.0000    0.0050
    0.0166   -0.0051    0.9998

t2 =

    0.2776
   -0.0771
    0.6458
</code>```

There is not even a constant scale factor between t2 and t1.
Where is the problem? in plotting the resuts or in the estimation itself?

Edit
I know that the function I wrote dosen't really make sense but it is just a test function to illustrate the problem I faced with OpenGV.
First, what I want to do is to track the state of a vehicle defined by a reduced state vector $q_k=(x,z,\theta)$ in order to estimate, afterwards, the uncertainty on the position, because I'm working with a probabilistic approach where:
$q_{k|k-1}=f(q_{k|k-1},u_{k-1})$
So, I need the values of control vector $u$ that's why I'm deriving $dx$, $dz$ and $d\theta$ from the outputted $R$ and $t$. Then, I'm plotting the path from the control vector values just to verify that i'm deriving them correctly by comparing the plotted path to the ground truth.
Regarding the coordinate reference system, I'm using the following definition:
 so the vehicle is moving in the $XZ$ plane and the rotation is around the $Y$ axis that's why I'm using $t(1), t(3)$ as position and $ry$ as rotation in the the control vector.

答:
I'm having a really hard time understanding what you're doing or why, so I'm going to try to break down your code as I understand it, pointing out along the way why I think what you're doing doesn't make sense. This isn't meant to be demeaning or anything, it's my problem in that I haven't done enough (any) CV work to make sense of it.

Here goes:

```<code>%%%%OpenCV%%%%%`

E = cv.findEssentialMat(points1, points2, 'CameraMatrix',K, 'Method','Ransac');
[R, t] = cv.recoverPose(E, points1, points2,'CameraMatrix',K);
</code>```

Okay, great - give some key points between two frames and see how they shift, then estimate your (change in) position given those points and the camera matrix. I understand this.

```<code>ry= asin(R(1,3));
u=[t(1,1);t(3,1);ry];
</code>```

Okay you lost me. You are given a perfectly good rotation matrix R, and then... what? You're trying to find the rotation about the y-axis? It looks like you're trying to use the definition of a rotation matrix, given on the Wikipedia page as:

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

But, the problem here is those zeros - you don't have them in your output $R$ matrix. You do not have a matrix that is strictly a rotation about the $y$ axis. What's more is the fact that you said,

I want to estimate the pose of a robot defined by (x,y,theta).

So, what rotation are you expecting? If you rotate about the $y$ axis, then what you're saying is that you want to rotate points in the x-z plane. But, if you don't have any z-axis points, then all you're doing is rotating the x-axis points and you're not rotating the y-axis points at all. Verify this by looking at the second row of that matrix definition:
$\left[\begin{array}{ccc}
0&1&0 \\
\end{array}\right]$ - it exactly preserves the second row (y-values) of your points matrix.

Maybe this is what you want though, because the points you keep from the translation vector are the first and third, the $x$ and $z$ values. But again, you said you want to keep the $x$ and $y$ values, and this is where my lack of understanding of your inputs is hurting me. Maybe you are providing the inputs points1 and points2 as a 3xn matrix of points, [x;0;z], and everything is processing correctly. However, I did note that you can also pass a 2xn matrix of points, so again I'm not sure what your data set is or how you're expecting the output to look.

But beyond that, I'll skip the OpenGV section as it's commented out and go to:

```<code>theta=xLast(3)+u(3);
</code>```

So here it looks like you're attempting a successive rotation by adding the previous rotation angle ry, from xLast, to the current value of rotation, ry.

(Side note here - I would call the rotation something like dTheta to show it's a difference value, like dx/dt, for example, but that's a nit-picky kind of point.)

```<code>if(theta>pi)
  theta=theta-2*pi;
elseif(theta<-pi)
  theta = theta+2*pi;
end
</code>```

Bounds checking, okay.

```<code>s = sin(xLast(3));
c = cos(xLast(3));
</code>```

Setting up for... a rotation matrix??

```<code>% actual value added with the new control vector
xnow=[xLast(1:2)+[c s; -s c]*u(1:2);theta];
</code>```

And now mashing up the new rotation matrix with the previous information.

I mentioned the term "successive rotations" a bit ago, but you should read more about the homogeneous transform (PDF). Basically, you're allowed to do successive transforms just by multiplying the two together.

First, compose the matrix:

$$
H = \left[\begin{array}{ccc}
R & t \\
\left[\begin{array}{ccc}
0 & 0 & 0 \\
\end{array}\right] & 1 \\
\end{array}\right]
$$
Any time you get a new update, just post-multiply the new matrix. So, for example, on your first iteration, you'll get the pose of the second frame relative to the first:

$$
^1H_2 = \left[\begin{array}{ccc}
^1R_2 & ^1t_2 \\
\left[\begin{array}{ccc}
0 & 0 & 0 \\
\end{array}\right] & 1 \\
\end{array}\right]
$$

Your second iteration will give you the third frame relative to the second:

$$
^2H_3 = \left[\begin{array}{ccc}
^2R_3 & ^2t_3 \\
\left[\begin{array}{ccc}
0 & 0 & 0 \\
\end{array}\right] & 1 \\
\end{array}\right]
$$

BUT, what you really care about is the third frame relative to the first, so just multiply the two transforms together:

$$
^1H_3 = (^1H_2)(^2H_3) \\
$$

Want to get the fourth frame relative to the first? Easy -

$$
^1H_4 = (^1H_3)(^3H_4) \\
$$

And so on. You'll get:

$$
^1H_n = (^1H_{n-1})(^{n-1}H_n) \\
$$

The incremental adjustment, $^{n-1}H_n$, is the output of each iteration because you get $^{n-1}R_n$, the incremental rotation, and $^{n-1}t_n$, the incremental translation.

All this is to say that (I think) you should stop re-inventing the wheel. You dissolve a rotation matrix into an angle just to re-create a rotation matrix later. If you want to get the rotation matrix and translation vector at the end, just pull the appropriate parts: R = H(1:3,1:3); and t = H(1:3,4);. If you want, you can pull the individual components dX = t(1);, dY = t(2);, and dZ = t(3);. I use the delta variable names dX, etc. as a reminder that these are all relative translations from the first frame.

Regarding orientation, you should really be looking at a more proper conversion of the rotation matrix. You could use Euler angles or quaternions, but you really should not be trying to pull a single rotation angle from a single value in a matrix.

So, if I had your code to write again, I would probably go:

```<code>function [ xnow] = estimate_pose_test( points1, points2, K,xLast )
%%%%OpenCV%%%%%

E = cv.findEssentialMat(points1, points2, 'CameraMatrix',K, 'Method','Ransac');
[R, t] = cv.recoverPose(E, points1, points2,'CameraMatrix',K);
xnow = xLast*[R,t; zeros(1,3),1];
</code>```

This keeps xnow and xLast as the 4x4 transform, but again if you really wanted the x/y/z values they're just the 3x1 vector starting at (1,4) in the homogeneous transform. Also, as mentioned, you should really be using a different method of displaying the rotation angle. You can keep the rotation matrix for internal stuff, but maybe Euler angles or Tait-Bryan angles would be the best for displaying a value to a user.

PS - I would guess the X you get from the OpenGV code is actually the full homogeneous transform matrix, so you save a step by not needing to make it yourself (not that it's hard).

Title: Mobile robot pose estimation

Body:
I'm having a really hard time understanding what you're doing or why, so I'm going to try to break down your code as I understand it, pointing out along the way why I think what you're doing doesn't make sense. This isn't meant to be demeaning or anything, it's my problem in that I haven't done enough (any) CV work to make sense of it.

Here goes:

%%%%OpenCV%%%%%`

E = cv.findEssentialMat(points1, points2, 'CameraMatrix',K, 'Method','Ransac');
[R, t] = cv.recoverPose(E, points1, points2,'CameraMatrix',K);

Okay, great - give some key points between two frames and see how they shift, then estimate your (change in) position given those points and the camera matrix. I understand this.

ry= asin(R(1,3));
u=[t(1,1);t(3,1);ry];

Okay you lost me. You are given a perfectly good rotation matrix R, and then... what? You're trying to find the rotation about the y-axis? It looks like you're trying to use the definition of a rotation matrix, given on the Wikipedia page as:

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

But, the problem here is those zeros - you don't have them in your output $R$ matrix. You do not have a matrix that is strictly a rotation about the $y$ axis. What's more is the fact that you said,

I want to estimate the pose of a robot defined by (x,y,theta).

So, what rotation are you expecting? If you rotate about the $y$ axis, then what you're saying is that you want to rotate points in the x-z plane. But, if you don't have any z-axis points, then all you're doing is rotating the x-axis points and you're not rotating the y-axis points at all. Verify this by looking at the second row of that matrix definition:
$\left[\begin{array}{ccc}
0&1&0 \\
\end{array}\right]$ - it exactly preserves the second row (y-values) of your points matrix.

Maybe this is what you want though, because the points you keep from the translation vector are the first and third, the $x$ and $z$ values. But again, you said you want to keep the $x$ and $y$ values, and this is where my lack of understanding of your inputs is hurting me. Maybe you are providing the inputs points1 and points2 as a 3xn matrix of points, [x;0;z], and everything is processing correctly. However, I did note that you can also pass a 2xn matrix of points, so again I'm not sure what your data set is or how you're expecting the output to look.

But beyond that, I'll skip the OpenGV section as it's commented out and go to:

theta=xLast(3)+u(3);

So here it looks like you're attempting a successive rotation by adding the previous rotation angle ry, from xLast, to the current value of rotation, ry.

(Side note here - I would call the rotation something like dTheta to show it's a difference value, like dx/dt, for example, but that's a nit-picky kind of point.)

if(theta>pi)
  theta=theta-2*pi;
elseif(theta<-pi)
  theta = theta+2*pi;
end

Bounds checking, okay.

s = sin(xLast(3));
c = cos(xLast(3));

Setting up for... a rotation matrix??

% actual value added with the new control vector
xnow=[xLast(1:2)+[c s; -s c]*u(1:2);theta];

And now mashing up the new rotation matrix with the previous information.

I mentioned the term "successive rotations" a bit ago, but you should read more about the homogeneous transform (PDF). Basically, you're allowed to do successive transforms just by multiplying the two together.

First, compose the matrix:

$$
H = \left[\begin{array}{ccc}
R & t \\
\left[\begin{array}{ccc}
0 & 0 & 0 \\
\end{array}\right] & 1 \\
\end{array}\right]
$$
Any time you get a new update, just post-multiply the new matrix. So, for example, on your first iteration, you'll get the pose of the second frame relative to the first:

$$
^1H_2 = \left[\begin{array}{ccc}
^1R_2 & ^1t_2 \\
\left[\begin{array}{ccc}
0 & 0 & 0 \\
\end{array}\right] & 1 \\
\end{array}\right]
$$

Your second iteration will give you the third frame relative to the second:

$$
^2H_3 = \left[\begin{array}{ccc}
^2R_3 & ^2t_3 \\
\left[\begin{array}{ccc}
0 & 0 & 0 \\
\end{array}\right] & 1 \\
\end{array}\right]
$$

BUT, what you really care about is the third frame relative to the first, so just multiply the two transforms together:

$$
^1H_3 = (^1H_2)(^2H_3) \\
$$

Want to get the fourth frame relative to the first? Easy -

$$
^1H_4 = (^1H_3)(^3H_4) \\
$$

And so on. You'll get:

$$
^1H_n = (^1H_{n-1})(^{n-1}H_n) \\
$$

The incremental adjustment, $^{n-1}H_n$, is the output of each iteration because you get $^{n-1}R_n$, the incremental rotation, and $^{n-1}t_n$, the incremental translation.

All this is to say that (I think) you should stop re-inventing the wheel. You dissolve a rotation matrix into an angle just to re-create a rotation matrix later. If you want to get the rotation matrix and translation vector at the end, just pull the appropriate parts: R = H(1:3,1:3); and t = H(1:3,4);. If you want, you can pull the individual components dX = t(1);, dY = t(2);, and dZ = t(3);. I use the delta variable names dX, etc. as a reminder that these are all relative translations from the first frame.

Regarding orientation, you should really be looking at a more proper conversion of the rotation matrix. You could use Euler angles or quaternions, but you really should not be trying to pull a single rotation angle from a single value in a matrix.

So, if I had your code to write again, I would probably go:

function [ xnow] = estimate_pose_test( points1, points2, K,xLast )
%%%%OpenCV%%%%%

E = cv.findEssentialMat(points1, points2, 'CameraMatrix',K, 'Method','Ransac');
[R, t] = cv.recoverPose(E, points1, points2,'CameraMatrix',K);
xnow = xLast*[R,t; zeros(1,3),1];

This keeps xnow and xLast as the 4x4 transform, but again if you really wanted the x/y/z values they're just the 3x1 vector starting at (1,4) in the homogeneous transform. Also, as mentioned, you should really be using a different method of displaying the rotation angle. You can keep the rotation matrix for internal stuff, but maybe Euler angles or Tait-Bryan angles would be the best for displaying a value to a user.

PS - I would guess the X you get from the OpenGV code is actually the full homogeneous transform matrix, so you save a step by not needing to make it yourself (not that it's hard).


问:
Create 2 weird sensor reading 254
I am programming my Create 2 with Arduino Uno. It worked fine a few weeks ago, then I just left it there, charging it about once a week. Now when I try to play with it again, I find that it starts to send weird sensor data.

For example, the value of light bumper data (package ID 45) supposes to be within the range of 0-127. It used to be fine. But now I receive 254 when there is no obstacle in front of the robot. Same issue happens to many different sensor readings.

Can someone help me with this problem?

答:
Try to reset your Create 2:

Send a 7 via the serial port to reset it.

OR

Press and hold Dock and Spot on the robot for 10 seconds. When the button is released, Roomba will play the reset tone.

This helped me once when I had problems with the serial interface.

Keep in mind that the baudrate will be reset to 115200.

Title: Create 2 weird sensor reading 254


问:
GPS message: compute ephemeris data and pseudo-ranges from subframes
I have raw GPS data (see end of the question for details if you think the protocols are relevant), and I need to extract/compute ephemeris and pseudoranges (my goal is to replace the recursive least squares that the receiver solves to compute the position with a home-brewed method based on sensor fusion). Concerning the ephemeris, I have access to the 3 first subframes of each of the 25 frames of the GPS message. Documentations/books/etc that I have found just vaguely mention that the first subframe contains clock data, and the two others contain ephemeris data. However, none of them precisely says what the words in these subframes are, and how I can use them to compute orbital information (I'm assuming that I only want satellite positions?). Can anyone give me pointers to some references on how to do this? Or (even better), is there any open-source code that already implements this?

I really appreciate your help.

Details on the data: They have been transmitted by a Ublox EVK-7p using the UBX RXM-EPH and RXM-RAW protocols.

RXM-EPH: satellite ID (4 byes), HOW word (4 bytes), followed by three 32-byte arrays corresponding to subrames 1 to 3 of the GPS message.

RXM-RAW: time of week, week, num of satellites, reserved (?) , carrier phase, pseudo-range, doppler, and so on....

Update: I found this which seems to answer most of my questions. It is from 1995 though.

答:
So the RXM-RAW and RXM-EPH messages come from IS-GPS-200H interface control document found here.
http://www.gps.gov/technical/icwg/IS-GPS-200H.pdf

But these are not exactly the same as RXM-RAW RXM-EPH messages. Namely there is a byte offset because the ublox messages contain a header and a checksum.

But this file here should be helpful to what you want to do.
http://gnsstk.sourceforge.net/gps_8c-source.html#l00714.

Remember to multiply by the correct scale factor to make sure your units are right. (semi circles are not the same thing as radians).

A good method for checking your work would be to use rtklib to get your ublox to output it's messages to a a rinex.o file and compare to the code that you wrote.


问:
Programming Roomba other than Create 2 using RaspberryPi
Do other Roombas have an Open Interface like the Create2? Can I send commands to my 780 like the Create 2?

I am trying to control my Roomba 780 I made a 8pin FDTI connector to USB and my roomba beep once when plugged in. The logic level is 3.3V

Here is my python code:

```<code>#!/usr/bin/env python

import serial
import time

#start usb connection able with Roomba
usbCom = serial.Serial(port='/dev/ttyAMA0', baudrate=115200)

#initialze roomba and put it in safe mode
usbCom.write(bytes.fromhex('80'))
time.sleep(.1)
usbCom.write(bytes.fromhex('83'))
time.sleep(.1)

#spot mode clean
usbCom.write(bytes.fromhex('87'))
</code>```

I've sent my serial data from my Raspberry PI to my Roomba but it is not responding, it seems to stop at the first line when I send a byte.

答:
Problem solved.

I was connected to the wrong serial port.  Connecting to '/dev/ttyUSB0' fixed it.


问:
Unmet dependencies error when installing ROS indigo on Ubuntu 14.04.3
I'm following these instructions on how to install Indigo: http://wiki.ros.org/indigo/Installation/Ubuntu

When I enter the command: sudo apt-get install ros-indigo-desktop-full I get the following output:

```<code>Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:

ros-indigo-desktop-full :
Depends: ros-indigo-desktop but it is not going to be installed
Depends: ros-indigo-perception but it is not going to be installed
Depends: ros-indigo-simulators but it is not going to be installed
Depends: ros-indigo-urdf-tutorial but it is not going to be installed

 unity-control-center :
Depends: libcheese-gtk23 (>= 3.4.0) but it is not going to be installed
                        Depends: libcheese7 (>= 3.0.1) but it is not going to be installed

E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
</code>```

According to the instructions I am following, unmet dependencies should be solved with either the command

```<code>sudo apt-get install xserver-xorg-dev-lts-utopic mesa-common-dev-lts-utopic libxatracker-dev-lts-utopic libopenvg1-mesa-dev-lts-utopic libgles2-mesa-dev-lts-utopic libgles1-mesa-dev-lts-utopic libgl1-mesa-dev-lts-utopic libgbm-dev-lts-utopic libegl1-mesa-dev-lts-utopic
</code>```

or

```<code>sudo apt-get install libgl1-mesa-dev-lts-utopic
</code>```

However when I try to use these commands I get unable to locate package errors such as

```<code>E: Unable to locate package libgl1-mesa-dev-lts-utopic
</code>```

I'd appreciate any advice on how to solve these dependency issues.
I've already asked on ROS Answers but received no answer, and the technician in charge of the computer lab I'm working in hasn't yet found a solution, so... help me stack exchange, you're my only hope.

P.S. I'm assuming that this question goes in the robotics section because it's related to ROS, but if this belongs in the Ubuntu or main stack overflow section please let me know.

Edit: things I have tried so far

1. sudo apt-get update and sudo apt-get upgrade, changed nothing.

2. When I type in apt-cache libgl1-mesa-dev-lts-utopic I get E: Invalid operation libgl1-mesa-dev-lts-utopic

3. When I type in apt-cache search libgl1-mesa-dev-lts-utopic I get no output.

4. When I type in ls /etc/apt/sources.list.d I get ros-latest.list  ros-latest.list.save

答:
libgl1-mesa-dev-lts-utopic has been moved to xenial:release repository. See This.
In order to install it follow this link or execute sudo apt-get install --install-recommends linux-generic-lts-xenial xserver-xorg-core-lts-xenial xserver-xorg-lts-xenial xserver-xorg-video-all-lts-xenial xserver-xorg-input-all-lts-xenial libwayland-egl1-mesa-lts-xenial           xserver-xorg-dev-lts-xenial mesa-common-dev-lts-xenial libxatracker-dev-lts-xenial libgles2-mesa-dev-lts-xenial libgles1-mesa-dev-lts-xenial libgl1-mesa-dev-lts-xenial libgbm-dev-lts-xenial libegl1-mesa-dev-lts-xenial

And after succesfully completing it execute sudo apt-get install ros-indigo-desktop-full

EDIT: If you are reinstalling ros on the machine then do this-

```<code>sudo apt-get purge ros-indigo*
sudo apt-get autoremove
sudo apt-get install ros-indigo-desktop-full
</code>```

Body:
libgl1-mesa-dev-lts-utopic has been moved to xenial:release repository. See This.
In order to install it follow this link or execute sudo apt-get install --install-recommends linux-generic-lts-xenial xserver-xorg-core-lts-xenial xserver-xorg-lts-xenial xserver-xorg-video-all-lts-xenial xserver-xorg-input-all-lts-xenial libwayland-egl1-mesa-lts-xenial           xserver-xorg-dev-lts-xenial mesa-common-dev-lts-xenial libxatracker-dev-lts-xenial libgles2-mesa-dev-lts-xenial libgles1-mesa-dev-lts-xenial libgl1-mesa-dev-lts-xenial libgbm-dev-lts-xenial libegl1-mesa-dev-lts-xenial

And after succesfully completing it execute sudo apt-get install ros-indigo-desktop-full

EDIT: If you are reinstalling ros on the machine then do this-

sudo apt-get purge ros-indigo*
sudo apt-get autoremove
sudo apt-get install ros-indigo-desktop-full


问:
Using gmapping without ROS?
Is gmapping on OpenSLAM.org still maintained? Or is the maintenance entirely over in ROS ( https://github.com/ros-perception/slam_gmapping/tree/hydro-devel/gmapping ). When trying to compile gmapping without ROS I noticed that it still has Qt3 as a dependency which made me think no one uses or maintains OpenSLAM's gmapping anymore. Is this accurate? How does OpenSLAM's gmapping vs ROS's gmapping compare in terms of performance and accuracy?

Thanks!

答: Gmapping at openslam is not maintained by anyone now. You can use ros gmapping. Its accuracy will depend on your sensor but it will work pretty good if numbers of points are sufficient for scan match e.g. indoor conditions.</p>

Title: Using gmapping without ROS?


问:
How can I create a robot like the EZ-B using a regular Arduino?
I am interested in building a robot like the EZ-B, sold by ez-robot.com. It comes with an SDK for Visual Studio and has direct scripting in runtime through a USB, Bluetooth, Wi-Fi, IRC or HTTPS connection.

If I get a regular Arduino board, will I be able to control it remotely in the same way? From what I've read, an Arduino needs to hold the instructions in its own memory, but I would rather have the brain in the computer, feeding signals back and forth to the microcontroller.

Also, is Arduino alone, a step down as the website niceley puts it?

答: Unfortunately, I have no experience with ez-b, but I have looked over the site a little bit. I do, however, have lots of Arduino experience. The program is, indeed, stored on the board's local memory. However, it is very possible to write a program that can interact with your computer. With my Arduino, I often write programs that communicate with my computer over USB. To communicate over Wifi will require additional hardware. There is a Wifi "shield" that can be attached to your Arduino, but this runs at around $60.


问:
Handling changing frames in ROS
I have a robot that is inherently symmetric in nature. Sometimes one side is the base while the other is the end-effector and vice versa. This 'mode' can change while the robot is moving around.

Judging from the URDF tutorials wiki, it looks like the commonly used URDF package in ROS is static and so the base of the robots is assumed to stay the base. Are there ways to get around this so that I can still use the TF package?

答: Always save the last transforms and whenever the base_link changes publish all the transforms using saved ones accordingly.</p>

Title: Handling changing frames in ROS