问:
How to transform x y z coordinates to Tx Ty Tz?
I need to get coordinates of the specific points from 2D CAD file and transform them so that I could use them to move the robotic arm to those points. The problem is that I only get x y z coordinates and the robotic arm needs x y z Tx Ty Tz coordinates to move to the certain position.

Any suggestions?

Edited:

My task: I need robotic arm to go through certain points on PCB board and heat soldering paste. I could do it manually by setting points with pendant. But a much easier way would be to get coordinates of those points from CAD file and write a code using PC.

```<code>MOVL MotionSpeedType(0 - linear mm/s, 1 - angular °/s) Speed (0.1 - 1000 mm/s or Max angular

speed) coordinate X Y Z Tx Ty Tz

ToolNo [Type] (move robot in a cartesian coordinates in linear motion)
</code>```

this is how code for linear motion to a certain point looks like

I only could find this manual.

This is pendant manual maybe it will be helpful.

I am second year student in "Robotics and mechatronics". I'm currently in a internship at the scientific research institution. I really appreciate your help!

答:
You linked a datasheet but not the protocol. I would need to see what the parameters x,y...Ty,Tz relate to specifically on the robot to be able to tell you exactly what to put for the rotations.

That said, I would assume that the rotations specify the end effector pose. Imagine holding a ball with both hands. With the ball in one location (x,y,z), your hands could be on the sides of the ball, or your left hand could be on top and right on bottom, or your left hand could be on bottom and your right on top. In actuality your hands could be anywhere on the ball; the orientation of your hands is called the pose.

Without any knowledge of the protocol, which joints correspond to which command inputs, no knowledge of the controller, and no knowledge of what you're trying to do with this (industrial!) robot, I would say to just put zeros for the Tx,Ty, and Tz parameters.

Zeros for all of the rotation parameters should have the end effector facing in some ordinal direction (straight down, up, forward, etc.). Once you see the "default" orientation, try setting one of the angles to 90 degrees (pi/2 radians). Setting Tx to 90 degrees should cause the end effector to rotate 90 degrees about its x-axis. You can run through all the rotations to identify the primary axes, then use Euler angles (presumably) to specify the pose for the end effector.

But again, this is all assuming the rotations affect the end effector. The rotation parameters could be in Euler anglges, or Tait-Bryan angles, but it's unlikely to be something too exotic.

If you could edit your question with more detail about what you're trying to do and link to the user manual or communication protocol I could give more help, but I don't really have any useful information about your problem, so at the moment all I can give are educated guesses.

:EDIT:

Looking at the pendant manual you linked, section 2.3.2 describes operation in Cartesian mode, where operations occur relative to the XYZ axes defined at the base of the robot. I would probably use these to define the starting position of a board to be soldered (that is, the location of some indexing location on the board relative to the base of the robot), then switch to the tool coordinates mode described in 2.3.4. From here you could feed it information direct from the 2D file, adding Z up/down motions as necessary to contact or come close to the board, depending on heat source (torch v soldering iron).

Section 2.3.5 covers setting up user coordinates, where it looks like you can define zero-index locations and orientations for workstation planes. The graphic at the top of page 70 looks like what you would be after. The neat trick here is that, if you set up the starting locations correctly, once you go to tool mode everything is in tool coordinates, so you don't have to specify any rotations.

As others have mentioned, Euler angles and such can be tricky. I believe you will commonly find Tait-Bryan angles in an XYZ or ZYX arrangement or Euler angles in an XZX or ZXZ arrangement, but there are dozens of ways that these could be setup.

As a final reiteration, you shouldn't really need to worry about those angles. Set everything to zero to see what direction the end effector is pointing. Make adjustments to only one angle until you get "down" relative the board set, then use Cartesian mode to move the tool to the indexing position on the board to be soldered. Define that as the user coordinate, then enter tool mode and feed it X-Y coordinates to do the work.

Hope this helps!


问:
How to determine how long a battery will power a robotic circuit for?
Obviously robotic circuits draw different amounts of power/current. So given the same battery, say, a 9V, then connecting it to 2 different circuits will deplete it at two different rates. Robot/Circuit #1 might drain the battery in 5 minutes. Robot/Circuit #2 might drain the battery in 20 minutes.

What ratings do batteries have that allows us to figure out how long it will power a circuit for? Bonus points: does this same rating uphold for solar panels and, in deed, all power supplies (not just batteries)?

答:
All batteries have an amp-hour rating that says how much charge is in the battery. A triple A baterry and a D cell battery are both 1.5V batteries, but the D cell has a much higher amp-hour rating than a triple A.

You could use the amp-hour rating directly, but what I find more useful is to get a watt-hour rating. This is more useful as robotic applications tend to use battery packs of various voltage ratings in combination with a voltage regulator.

A battery has a nominal voltage; get the watt-hour rating by multiplying the amp-hour rating by the nominal voltage. Now you can divide this watt-hour rating by the power draw of the robot (in watts) to get the number of hours the battery can power the robot.

You can also use this to estimate run time by power ratings for each component before you ever actually build the robot; four 250mW motors total for 1W of power draw. Assuming the Arduino controlling it draws 50mA at 3v3, the controller draws 165mA. This gives a total power draw of 1.165W (again, estimated).

Now, a 1000mAh, 7.2V LiPO battery back has (1Ah x 7.2V) = 7.2Wh of capacity. This means that it will run the example circuit for (7.2Wh / 1.165W) = 6.2 hours = 6 hours and 12 minutes. Again, this is an estimate, which may be more or less depending on whether you run the motors at full capacity for the whole time and the efficiency losses in the voltage regulator and other equipment, but it should be generally correct.

Regarding your bonus points, the other devices you've listed aren't power storage devices. They can run indefinitely, provided they're powered. A solar cell doesn't hold a charge, so it can't run anything for any amount of time if there's no sun. If there is sun, it can supply its rated power as long as the sun is out. Note again though rated power - you can't run a 5W robot on a 1W solar cell. Same applies for all other power supplies. The are power supplies, not power reserves like a battery.

ContentLicense: CC BY-SA 3.0


问:
Matlab: System simulation with dynamic state matrix / input matrix
I have the following system:
$$\dot{x} = A(t)x+B(t)u$$
$$y = x$$

$A(t)$ and $B(t)$ are actually scalar, but time-dependent. If they would be constant, I could simulate the system in Matlab using:

sys = ss(A,B,C,0);
lsim(sys,u,t,x0);

However, it would be nice to simulate the system with dynamic state and input matrix. The matrices are based on measurement data, this means I would have for each discrete time step $t_i$ another matrix $A(t_i)$. Any suggestions how to do that?

答:
When you say the matrices are based on measurement data, do you mean that $A(t)$ varies with your state space output $y$, which should be configured to provide your outputs (measurements), or that you want to actually provide a hard-coded series of parameters (field measurements) to the $A$ matrix?

If you are trying to do the former, have essentially $A=f(y)$, where $y=f(t)$ (because actually $y=f(x)$, but $x=f(t)$ by definition), then you can use ode45. In the function you want to use you can define y = x, then use that to update the parameters in $A$.

If you want the latter, or the former really, you can always brute force it. Setting up some standards real quick, let's say you have:

nSamples, which would be the number of time points in your simulation.

Your time step is dT.

You have nStates, so $size(A) = [nStates,nStates]$. Now assume that your A matrix evolves over time based of field samples (testing, etc.), you should have a bunch of $A$ matrices, such that you actually have $size(A) = [nStates,nStates,nSamples]$.

Now, try this:

x = Initial Conditions;

for i = 1:nSamples

currentA = A[: , : , i];

xDot = currentA * x + B * u;

x = x + xDot * dT;

y = x;

end

As before, if you just want to swap out parameters in $A$ based on $y$ then that's easy to implement too.

x = Initial Conditions;

y = f(x);

for i = 1:nSamples

A = f(y);

xDot = Ax + Bu;

x = x + xDot*dT;

y = f(x);

end

Again, this is just a brute-force method to implement what lsim does for you. It's just numeric integration.

Hope this helps!


问:
How many amps do I want my Switching BEC to provide?
I'm trying to power 7-12 servos, and I was under the impression that each one would need about an amp, but in looking around for an appropriate BEC to supply them, I notice that most seem to output around 1-3.5 amps.

They won't all be running at once, but often, say 4 will be drawing enough juice to move.

Obviously, I'm missing some link in my understanding.  How do I determine how many amps will be needed from the power supply?

答:
There's two possible current requirements to consider here.

Ideally, you need to be able to supply enough current to account for the rated stall current (that is, the current drawn by the servo at its maximum rated torque) of all of your servos simultaneously. Imagine a bunch of your mechanical components getting jammed on each other in some gruesome fashion and busting your servos. You don't want to add insult to injury and fry your BEC in the process as well. If you don't have that number from the datasheet for the servo, you can test it by stalling a servo manually. This number can be quite a bit larger than your normal operating current, often to the point of being impractically large to design for. In the (unlikely) event that you can somehow prove that given servos in your application will never be placed in a stall condition, you can skimp on that a bit. Keep in mind that a servo doesn't have to be actively moving on its own to be stalled; a force trying to move it from its set position can do it as well.

The second, softer requirement is your real-world operating current, which is a lot more application-specific. The amount of current drawn by a motor is dependent on the amount of torque it is exerting to move the load. Measure the current drawn by each servo while moving its real-world load. Add those up for any given group of servos that might be moving at the same time. The largest of those is your maximum normal operating current. Multiply that by 1.5-2 for a safety margin.

See also: What is the best way to power a large number (27) servos at 5 V?


问:
Understanding how solar panels can supply power to robotic circuits
Say I have this solar panel that outputs 6V at 330mA, or ~1.98 Watts. If I connect that to Arduino, which expects a 5V supply at (roughly) 50mA, then the Arduino as a whole requires 5V * .05A = 0.25 Watts to power it. To me, if I understand this correctly, then in perfect weather/sunlight, the solar panel will power Arduino all day long, no problem.

Now let's say we wire up 4 motors to the Arduino, each of which draw 250 Watts. Now the Arduino + 4 motors are drawing ~1.25 Watts. But since the panels are still outputting 1.98 Watts, I would think that (again, under perfect sunlight) the panel would power the Arduino and motors all day long, no problem.

Now we add 4 more motors to the Arduino circuit, for a total of 8 motors. The circuit is now drawing 1.25 Watts + 1 W = 2.25 Watts. I would expect the solar panel to no longer be capable of powering the circuit, at least properly.

My first concern here is: am I understanding these 3 scenarios correctly? If not, where is my understanding going awry?

Assuming I'm more or less on track, my next question is: can solar panels be "daisy chained" together to increase total power output? In the third case above, is there a way to add a second solar panel into the mix, effectively making the two panels output 1.98 Watts * 2 = 3.96 Watts, which would then make them capable of powering the Arduino and its 8 motors (yet again, assuming perfect weather/sunlight conditions)?

答:
Your scenarios are correct.

You can connect multiple solar cells together to get increased current or increased voltage. Wire them in series (positive to negative) to boost voltage, wire them in parallel (positives to positive) to boost current capacity.

As a final note, I would caution running near the maximum capacity of the solar cell. The voltage of the cell will drop as load increases; you can see the specifications for the cell you're looking at and see the "open circuit" voltage is 7.0V, while the "peak voltage" is 6.0V. The more load you put on the solar cell the lower the output voltage goes.

If you manage to lower the output voltage below the minimum for a voltage regulator (which you should absolutely be using considering the voltage swings), then you will brownout the voltage regulator.

When this happens you could either have the voltage regulator shutoff (best case scenario). When it turns off it stops drawing power, which reduces the load on the solar cell. When this happens, the reduced load causes the voltage to recover. When this happens the regulator turns back on. You wind up cycling power to your board a LOT and it could damage it.

OR the voltage regulator could try to "hold on" and just pass the lower voltage. At this point you are providing the dirty power directly to your microcontroller. This could do anything from power cycle as described above to flat-out frying your board. There is a thread about brownout detection and handling over at the Arduino forums if you're interested.


问:
Wiring necessary to route power from any one of several rechargeable batteries
I'm looking for my robotics project to draw its power from one of 3 rechargeable batteries; basically whichever has the most "juice" in it. From the initial research I've already done, I believe I could connect each rechargeable battery (probably LiPo) to a diode, and then wire each of the 3 diodes in series.

However, being so new to robotics/electronics, I guess I wanted to bounce this off the community as a sanity check, or to see if there is a better way of achieving this. Again, what I am looking for is a way for the circuit to automagically detect that battery #1 has more power than battery #2, and so it "decides" to draw power from #1. The instant #1 is depleted or deemed "less powerful" than #2, the #2 battery takes over. Thoughts/criticisms?

答: Is there a need to draw from the batteries sequentially? If you wire the batteries in parallel you drain them all at the same time, so you don't need to worry about swapping dead batteries for fresh. </p>


问:
Discover vector/angle between stereo camera pose and vehicle body
I have a calibrated stereo camera system that is mounted in a passenger car which means I am able to retrieve a point cloud from my stereo image. However, I need to find how well is the camera aligned with the vehicle - read: if the camera is perfectly facing forwards or not. I guess it will never perfectly face forwards so I need to get the angle (or rather 3D vector) between "perfect forwards" and "actual camera pose".

What came to my mind is to drive the vehicle possibly perfectly forwards and use stereo visual odometry to detect the angle of vehicle movement as seen by camera (which is the vector I am looking for). The LIBVISO library for visual odometry can output a 3D vector of movement change from one stereo frame to another which could be used to detect the needed vector.

The only problem may be to actually be able to drive perfectly forward with a car. Maybe an RTK GPS could be used to check for this or for correction. Will anyone have a suggestion on how to proceed?

The stereo camera I use consists of 2 separate Point Grey USB cameras. Each camera is mounted on a windshield inside the car with a mount like this one. The cameras were calibrated after mounting. The stereo baseline (distance between the cameras) is about 50 cm.

答:
Sounds to me like you just need a one-shot test to check (stereo) camera alignment. I would just get a sheet of plywood screwed to a frame you can orient to the car. I would do this rather than trying to move the car because car micro motions are a pain.

So, with some crude ASCII art:
O===O L

where the L is the plywood rig in front of your car. As long as you've taken care to make the rig square you can measure the distance between the edges and key features on the car. This ensures the plywood is square to the front of the car.

All of this is so you can get a point cloud of a flat sheet.

:EDIT:

I had originally said find the normal of the sheet, this is the direction the camera is pointing. After some thought last night, the normal of the sheet is going to be the mirror of the camera orientation.

Consider some more crude ASCII art. Always assuming the plywood is perfectly square and plumb and assuming the camera is pointing down and to the right:

\ |

What you will get from the camera's point of view is based on the camera's assumption that it is the one that is always pointed correctly, so it will represent the plywood in the scene with:

--  \

The orientation of the plywood as it rotates from the XY plane (assuming Z is distance from the cameras) is in the opposite direction the camera is rotated from straight ahead because these are two different aspects of the same rotation matrix.

That is to say, the camera will be rotated some amount relative to world coordinates (the car and thus the plywood), expressed by the rotation matrix $E$. The world (plywood) is rotated relative to the camera by $E^{-1}=E^T$

Cosine terms fall on the diagonal while sine terms are all skew symmetric off-diagonal, so transposing the rotation matrix is equivalent to using a negated rotation angle.

That is, the degree to which the normal of the plywood plane is rotated will be given by some rotation matrix $E'$, where $E'=E^{-1}$ and where $E$ is the rotation matrix of the camera. Using the inverse/transpose property of the rotation matrix, $E(\theta)^{-1}=E(\theta)^T=E(-\theta)=E'$.

Phew!


问:
Spring with electronically adjustable stiffness
I would like to build a mechanical module that acts like a spring with electronically controllable stiffness (spring rate).

For instance, let's imagine a solid, metallic cube, 0.5 m each side. On the top side of the cube, there is a chair sitting on top of a solid mechanical spring. When you sit on the chair, it would go down proportionally to your weight, and inversely proportional to the spring's rate.

What I want is that this spring's rate be electronically adjustable in real time, for instance a microcontroller system might increase the spring's rate when it detects a larger weight.

I'm using this example to best describe what I want to achieve because I'm not a robotics specialist and I don't know the inside terms.

Is there already an electro-mechanic module as the one I'm describing? (obviously nevermind the cube and the chair, it's the spring I'm interested in).

答:
Like jwpat said, I think the only package you'll find for what you're looking for is active suspension, but good luck getting official support from the manufacturer unless you have some automotive OEM sponsorship.

Note that jwpat linked to adaptive suspension parts, which vary damping as mentioned, not active suspension, which uses an actuator to do things more similar to what you are looking for.

For guidelines on building your own, I would look at available literature on series elastic actuators, which are essentially linear actuators that drive springs.

Essentially, you use the (linear fixed) spring constant and a desired force to estimate what the spring compression should be (this would be your input), then you use position feedback on the spring to get actual spring compression. Use PID control or whatever else you like to drive the spring compression to yield the desired force.

Note that you get to pick the force, so if you want the spring to be nonlinear or of varying constants you can just choose what you want.

All of this assumes what you have asked for is the best solution to your problem. What effect are you going for that you need variable spring constants? Are you looking for a constant force output or some kind of constant displacement? Are you looking for a nonlinear spring or user-selectable springs? More information on your problem will let us give you better help.

Hydraulics can also give you what you're looking for, but, even though you asked for electro-mechanical, hydraulics are usually out of the scope of most people's projects.


答:
I'm not sure why you are trying to make it hard than it is. If you have 4 servos that are in use at one time, that draw an amp each, you need 4 amps, period. BECs are convenience components, that are used because R/C servos used to burn out if provided with more than 5 volts. 6 Nicad batteries, which was the most common configuration before LiPo technology came around,  worked out to 9.6 volts (6 X 1.2v). BECs are available in many sizes, and greater than 3.5 amps is common.

If the requirement is greater than what is available, you simply provide your own voltage/amperage to the servos - often straight from a 6v battery, again the BEC is/was just a convenience component. If you do this with excessive current (more than the controller can pass through) you need to remove the red wire from the plug that goes into the controller, and supply voltage via that red wire. the black wire, needs to be both a ground connection for the signal, so it can not be removed from the controller, but it also needs to be the negative connection for power. The need to do this is pretty uncommon. The controller power connections are just straight pass through.

If you are using a plain R/C receiver the rule of thumb is the circuit board can handle about 6 amps max. A good digital servo will draw 2 amps at full power, but in most cases, what I have seen used in robotics are not good servos, so your guess of about an amp is reasonable.

Title: How many amps do I want my Switching BEC to provide?

Body:
I'm trying to power 7-12 servos, and I was under the impression that each one would need about an amp, but in looking around for an appropriate BEC to supply them, I notice that most seem to output around 1-3.5 amps.

They won't all be running at once, but often, say 4 will be drawing enough juice to move.

Obviously, I'm missing some link in my understanding.  How do I determine how many amps will be needed from the power supply?


问:
Can I use Bipolar stepper motor driver to drive Unipolar motor in Unipolar configuration?
Can I use Bipolar stepper motor driver to drive Unipolar motor in Unipolar configuration ?</p>

答:
It depends on the bipolar motor driver you're using.

A driver chip like the L293D (or various more powerful equivalents) would usually be configured as two full H-bridges to drive two simple DC motors forwards or backwards - or to drive the two coils of a bipolar stepper motor.

However it can be configured as four half-bridge drivers, to independently drive four coils in simple on/off mode.  So these could be the four coils of a unipolar stepper.  For example there's a description here:
http://mechatronics.mech.northwestern.edu/design_ref/actuators/stepper_drive1.html

If on the other hand you are using a ready-made driver that doesn't allow wiring changes, it may not be possible to drive unipolar steppers with it.  So if you have a specific driver in mind, I'd recommend first looking for a datasheet, or manufacturer's advice, to see if this is possible.


问:
Control both Velocity and Position (Linear actuator)
I am trying to control the velocity + position of a linear actuator.

At this moment I am able to control the position or the velocity. But I'm trying to control both. What the control has to do: Let the linear actuator drive to a position i.e. 0 to 100 cm with a constant velocity of 1cm/s.

I control the actuator using a PWM signal. And I measure the velocity and position using a position sensor on the shaft.

What kind of control is preferred, PID in cascade?
If so, what would the code look like?
Any other kind of control would function better?

EDIT:
A more describing picture.

I want a velocity controlled position controller.
Hopefully this will make it clear

EDIT

My first try is with a trapezoid wave. Maybe there is an easy way without too much calculation power to change it to an s-curve. Then the acceleration/jerk will be a lot smoother.

I let the microcontroller calculate 3 different formulas, afterwards it will calculate it using loop iteration. This way I can use one PID for the position. The parameters in the following code will fictional:

```<code>AccelerationLoops: 5                     //[Loops]
Velocity:          100                   //[mm/s]
DeltaPosition:     7.5                   //[mm]
Looptime:          5                     //[ms]
Loopfactor:        1000 / Looptime       //[-]
VelocityLoop:      Velocity  /Loopfactor //[mm/loop]
VelocityFactor:    VelocityLoop * .5 / AccelerationLoops
                                         //[mm/loop]  (.5 found by integration)
Loops:             DeltaPosition / VelocityLoop / AccelerationLoops
                                         //[Loops]
</code>```

Formula

```<code>Formula1:      VelocityFactor * x^2
LastF1:        Last value of Formula1 Formula1(5)

Formula2:      VelocityLoop * x - LastF1

Formula3:      VelocityFactor * (Loops - x)^2 + DeltaPosition)
</code>```

Using the parameters of above it will generate the following setpoint:

```<code>0   0,00
1   0,05
2   0,20
3   0,45
4   0,80
5   1,25
6   1,75
7   2,25
8   2,75
9   3,25
10  3,75
11  4,25
12  4,75
13  5,25
14  5,75
15  6,25
16  6,70
17  7,05
18  7,30
19  7,45
20  7,50
</code>```

A big problem with the code above is that the amount of acceleration loops is a constant. It cannot be changed except when you already know the amount of loops it will take.

I will be using two separate Arduinos, they will be connected using a CAN-bus connection. Anyway, they won't communicate through it unless the load becomes too high. This will make master/slave impossible. Also the system has to be modular: adding another actuator to the circuit won't be a problem. The actuator is speed controlled by using a PWM signal. The linear sensor will deliver a 0-10v signal which i will reduce to 0-5v by a simple voltage divider. The loop will be around 5 to 10 ms, will depend on the maximum looptime.

Arduino has a 10-bit (0-1023) ADC but use of oversampling I will probably try to increase it to 12-bit. To not decrease the reading speed I will decrease the prescaler of the ADC.

The PWM output is 8-bit (0-255), I am trying to find a way to further increase. Because I think 255 steps are too low for my application.

Because the Arduino has limit internal memory, precalculating all the positions is impossible.

Thank you all for the help so far!

答:
I'd say this problem is very much similar to The aerial refueling problem: sketch of a feedback controller whose one possible solution is then explained in https://robotics.stackexchange.com/a/5263/6941.

EDIT

The minimum-jerk position profile (i.e. the s-curve) that lets the system go from the initial position $x_0$ to the desired position $x_d$ in $T$ seconds is:

$$
x\left(t\right)=x_0+\left(x_d-x_0\right) \cdot \left(10\left(\frac{t}{T}\right)^3 - 15\left(\frac{t}{T}\right)^4 + 6\left(\frac{t}{T}\right)^5\right),
$$

where $t \in \left[0,T\right]$ specifies the time granularity, thus the number of set-points.

Finally, $x\left(t\right)$ will be the reference for the position PID.

ContentLicense: CC BY-SA 4.0


答:
I don't think you can control speed and position at the same time - what happens if you don't change the position reference but you have some non-zero speed reference? Did you want the output to stay still or go to the command speed?

I think what you are looking for is a software-imposed actuator authority limit. In this case you can just limit the output of the controller. I don't know what your actuator inputs are, but for the controller I would try something like:

```<code>dT = sampleTime;
input = positionRef;
feedback = positionFbk;
outputLimit = actuatorSpeedLimit;

errorP = input - feedback;
errorI = errorI + errorP;
errorD = (errorP - prevError)/dT;
prevError = errorP;

output = kP * errorP + kI * errorI + kD * errorD;

if abs(output) > outputLimit
  output = sign(output) * outputLimit;
end
</code>```

Now, as I mentioned, I don't know what your inputs to the actuator are. The model above assumes the output of the PID controller is a reference speed that you pass to the actuator. You cap the speed reference you pass to the actuator giving an electronic form of actuator saturation. The controller will continue to command higher and higher velocities until you reach a position close to the reference position, at which point it will begin to back off. It will back off below the outputLimit at which point the electronic saturation eases and control resumes like normal.

If your actuator uses a position input and it determines its  own speed response, then the actuator probably uses a proportional controller, where the actuator speed it utilizes is given by:

vActuator = $(1/\tau)$(positionRef - positionFbk);

where here $\tau$ is the actuator's time constant. In this case you can estimate the actuator speed and throttle your position that you pass to the actuator, provided you can measure or estimate the time constant. Resuming the above code:

```<code>output = kP * errorP + kI * errorI + kD * errorD;

estVelocity = (1/\tau)*(output - feedback);

if abs(estVelocity) > actuatorSpeedLimit
  output = (\tau) * actuatorSpeedLimit + feedback;
  output = sign(estVelocity) * output;
end
</code>```

Where again, in this example, your controller output is a position you pass to the actuator instead of a speed you pass to the actuator. You can do the same if you provide an acceleration to the actuator, but I don't think I've ever seen a linear actuator accept an acceleration as an input.

:EDIT:

Despite the fact that this question has been marked as answered (and I've been downvoted!), I would add that you could split the controls.

You are going for synchronized actuators, so have one actuator use PID to get to a command setpoint and the other actuator use PID to adjust its speed based on the first one. This sets up a master/slave or leader/follower, where the master follows the position reference and the slave follows the master.

As with any other PID controller, you can tune the slave to whatever threshold you want to achieve your desired speed difference tolerance.

Title: Control both Velocity and Position (Linear actuator)

Body:
I am trying to control the velocity + position of a linear actuator.

At this moment I am able to control the position or the velocity. But I'm trying to control both. What the control has to do: Let the linear actuator drive to a position i.e. 0 to 100 cm with a constant velocity of 1cm/s.

I control the actuator using a PWM signal. And I measure the velocity and position using a position sensor on the shaft.

What kind of control is preferred, PID in cascade?
If so, what would the code look like?
Any other kind of control would function better?

EDIT:
A more describing picture.

I want a velocity controlled position controller.
Hopefully this will make it clear

EDIT

My first try is with a trapezoid wave. Maybe there is an easy way without too much calculation power to change it to an s-curve. Then the acceleration/jerk will be a lot smoother.

I let the microcontroller calculate 3 different formulas, afterwards it will calculate it using loop iteration. This way I can use one PID for the position. The parameters in the following code will fictional:

```<code>AccelerationLoops: 5                     //[Loops]
Velocity:          100                   //[mm/s]
DeltaPosition:     7.5                   //[mm]
Looptime:          5                     //[ms]
Loopfactor:        1000 / Looptime       //[-]
VelocityLoop:      Velocity  /Loopfactor //[mm/loop]
VelocityFactor:    VelocityLoop * .5 / AccelerationLoops
                                         //[mm/loop]  (.5 found by integration)
Loops:             DeltaPosition / VelocityLoop / AccelerationLoops
                                         //[Loops]
</code>```

Formula

```<code>Formula1:      VelocityFactor * x^2
LastF1:        Last value of Formula1 Formula1(5)

Formula2:      VelocityLoop * x - LastF1

Formula3:      VelocityFactor * (Loops - x)^2 + DeltaPosition)
</code>```

Using the parameters of above it will generate the following setpoint:

```<code>0   0,00
1   0,05
2   0,20
3   0,45
4   0,80
5   1,25
6   1,75
7   2,25
8   2,75
9   3,25
10  3,75
11  4,25
12  4,75
13  5,25
14  5,75
15  6,25
16  6,70
17  7,05
18  7,30
19  7,45
20  7,50
</code>```

A big problem with the code above is that the amount of acceleration loops is a constant. It cannot be changed except when you already know the amount of loops it will take.

I will be using two separate Arduinos, they will be connected using a CAN-bus connection. Anyway, they won't communicate through it unless the load becomes too high. This will make master/slave impossible. Also the system has to be modular: adding another actuator to the circuit won't be a problem. The actuator is speed controlled by using a PWM signal. The linear sensor will deliver a 0-10v signal which i will reduce to 0-5v by a simple voltage divider. The loop will be around 5 to 10 ms, will depend on the maximum looptime.

Arduino has a 10-bit (0-1023) ADC but use of oversampling I will probably try to increase it to 12-bit. To not decrease the reading speed I will decrease the prescaler of the ADC.

The PWM output is 8-bit (0-255), I am trying to find a way to further increase. Because I think 255 steps are too low for my application.

Because the Arduino has limit internal memory, precalculating all the positions is impossible.

Thank you all for the help so far!

Body:
I don't think you can control speed and position at the same time - what happens if you don't change the position reference but you have some non-zero speed reference? Did you want the output to stay still or go to the command speed?

I think what you are looking for is a software-imposed actuator authority limit. In this case you can just limit the output of the controller. I don't know what your actuator inputs are, but for the controller I would try something like:

dT = sampleTime;
input = positionRef;
feedback = positionFbk;
outputLimit = actuatorSpeedLimit;

errorP = input - feedback;
errorI = errorI + errorP;
errorD = (errorP - prevError)/dT;
prevError = errorP;

output = kP * errorP + kI * errorI + kD * errorD;

if abs(output) > outputLimit
  output = sign(output) * outputLimit;
end

Now, as I mentioned, I don't know what your inputs to the actuator are. The model above assumes the output of the PID controller is a reference speed that you pass to the actuator. You cap the speed reference you pass to the actuator giving an electronic form of actuator saturation. The controller will continue to command higher and higher velocities until you reach a position close to the reference position, at which point it will begin to back off. It will back off below the outputLimit at which point the electronic saturation eases and control resumes like normal.

If your actuator uses a position input and it determines its  own speed response, then the actuator probably uses a proportional controller, where the actuator speed it utilizes is given by:

vActuator = $(1/\tau)$(positionRef - positionFbk);

where here $\tau$ is the actuator's time constant. In this case you can estimate the actuator speed and throttle your position that you pass to the actuator, provided you can measure or estimate the time constant. Resuming the above code:

output = kP * errorP + kI * errorI + kD * errorD;

estVelocity = (1/\tau)*(output - feedback);

if abs(estVelocity) > actuatorSpeedLimit
  output = (\tau) * actuatorSpeedLimit + feedback;
  output = sign(estVelocity) * output;
end

Where again, in this example, your controller output is a position you pass to the actuator instead of a speed you pass to the actuator. You can do the same if you provide an acceleration to the actuator, but I don't think I've ever seen a linear actuator accept an acceleration as an input.

:EDIT:

Despite the fact that this question has been marked as answered (and I've been downvoted!), I would add that you could split the controls.

You are going for synchronized actuators, so have one actuator use PID to get to a command setpoint and the other actuator use PID to adjust its speed based on the first one. This sets up a master/slave or leader/follower, where the master follows the position reference and the slave follows the master.

As with any other PID controller, you can tune the slave to whatever threshold you want to achieve your desired speed difference tolerance.


问:
Measurement and physics model fusion
I am combining two position measurements of a ball from two sensors in real time to obtain one triangulated position in x,y,z coordinates. As the data exchange of the measurements carries some latency, the data has to be extrapolated be able to obtain the current position. Due to extrapolation an error appears in the triangulated data.

I know that when the ball is in the air, the velocity of the ball should be constant in x and y directions and the velocity in the z direction should decay with g. The velocities in x and y however oscillate as function of time around a mean value which is the actual x respectively y velocity. The same goes for when I compute the acceleration in the z direction. It oscillates as function of time around g.

Given that I know how the ball should behave, i.e. that vx and vy should be constant and that the acceleration in the z direction should be z, how can I impose these conditions to better estimate the triangulated position?

答:
Kalmnan filters are typically used for sensor fusion. You create a model for what you expect the process to look like, use your sensors as inputs, and the output is the filtered estimate. I'm not going to go over implementation in detail as there is plenty of information about these filters available online; I hope this points you in the right direction and if you have a specific question about it then by all means make a new question and I or someone else here can answer it.

I'm interested in your use of two sensors to triangulate (trilaterate) a ball. How are you using two sensors to fix a 3 dimensional coordinate?

Title: Measurement and physics model fusion


问:
Converting a 2D array of bits to a connectivity map (Code Debugging)
I'm working on an robot that would be able to navigate through a maze, avoid obstacles and identify some of the objects (Boxes in which it has to pot the balls)  in it. I have a monochromatic bitmap of the maze, that is supposed to be used in the robot navigation.

Up till now, I have converted/read the bitmap image of the maze into a 2D array of bits. Right now I am writing a code that should convert the 2D array (that represents the maze) into a connectivity map so that I could apply a path planning algorithm on it. Mr. @Chuck has helped me by providing a code in MATLAB. i have converted that code into C++, however the code isn't providing the right output. Kindly see the code and tell me what I am doing wrong.

I am sharing the link to the 2D array that has been made, the MATLAB code, and my code in C++ to convert the array into a connectivity map.

Link to the 2D array:-

https://drive.google.com/file/d/0BwUKS98DxycUZDZwTVYzY0lueFU/view?usp=sharing

MATLAB CODE:-

```<code>Map = load(map.mat);
nRows = size(Map,1);
nCols = size(Map,2);
mapSize = size(Map);
N = numel(Map);
Digraph = zeros(N, N);

for i = 1:nRows
  for j = 1:nCols
    currentPos = sub2ind(mapSize,i,j);
    % left neighbor, if it exists
    if (j-1)> 0
      destPos = sub2ind (mapSize,i,j-1);
      Digraph(currentPos,destPos) = Map(currentPos)*Map(destPos);
    end
    % right neighbor, if it exists
    if (j+1)<=nCols
      destPos = sub2ind (mapSize,i,j+1);
      Digraph(currentPos,destPos) = Map(currentPos)*Map(destPos);
    end
    % top neighbor, if it exists
    if (i-1)> 0
      destPos = sub2ind (mapSize,i-1,j);
      Digraph(currentPos,destPos) = Map(currentPos)*Map(destPos);
    end
    % bottom neighbor, if it exists
    if (i+1)<=nRows
      destPos = sub2ind (mapSize,i+1,j);
      Digraph(currentPos,destPos) = Map(currentPos)*Map(destPos);
    end
  end
end
</code>```

Code in C++:-

```<code>int **digraph = NULL;
digraph = new int *[6144];

for (int i = 0; i < 6144; i++)
{
    digraph[i] = new int[6144];
}

for (j = 0; j < 96; j++)
{
    for (z = 0; z < 64; z++)
    {
        currentPos = sub2ind[j][z];
        digraph[currentPos][currentPos] = 0; //------NEW ADDITION-----------

    if ((z - 1) >= 0)
        {
            destPos = sub2ind[j][z - 1];
            digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z - 1];
        }

    if ((z + 1) < 64)
        {
            destPos = sub2ind[j][z + 1];
            digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z + 1];
        }

    if ((j - 1) >= 0)
        {
            destPos = sub2ind[j - 1][z];
            digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j - 1][z];
        }

    if ((j + 1) < 96)
        {
            destPos = sub2ind[j + 1][z];
            digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j + 1][z];
        }
    }

}

ofstream connectivityMap;
connectivityMap.open("diGraph.txt");

for (int l = 0; j < 100; l++) // printing only 100 elements
{
    for (int k = 0; k < 100; k++)
    {
        connectivityMap << digraph[l][k] << " ";
    }
}
</code>```

答:
What is the problem you're having with the file?

The only two things I notice off the bat are that you aren't outputting an endline character between rows on your output stream and that it looks like you're initializing the digraph variable in an odd manner. As I mentioned previously, it's been a long time since I've used c++, but could you not just call int digraph[6144][6144] = {0};?

For the endline character,

```<code>for (int l = 0; j < 300; l++) // printing only 300 elements
{
    for (int k = 0; k < 300; k++)
    {
        connectivityMap << digraph[l][k] << " ";
    }
//End the line when you're done outputting rows
connectivityMap << endl;
}
</code>```

Lastly, note that you're only outputting the first 300 columns of the first 300 rows - you're looking at the upper left 300x300 portion of the digraph. digraph[a][b] will equal 1 if a and b are connected; as you have a straightforward map this means it will equal 1 if they are neighbors and neither is a wall.

:EDIT:

I think I see most of the problems you're having with this.

Here is the map image I made from your map text file. Note that you have a lot of pixels in the map, but it's really a low-resolution map that has been blown up.

Here is a map image I made that is functionally equivalent but much smaller in resolution. Instead of having 6144 points, the small map has 84. I'm not sure how the black squares with the white 'X's should be treated, so I counted them as walls, though I think it would probably make more sense if they were paths and your start/end position. You should replace the 0's with 1's in those locations if this is the case.

You are getting entries on the diagonal in your digraph because your map is very basic. Point 1 connects to point 2, point 2 to 3, then 3 to 4, etc., so you wind up with 1's (path exists) on the diagonals. Matlab has a function called imwrite that you can use to generate images from matrices; I used this function to generate the digraph images below.

Aside from the scale, the small digraph and large digraph have the same data regarding path connectivity. If you want to avoid keeping such a large, sparse matrix (it's all zeros on the upper/lower triangles because you don't have any paths from start to the middle of the map or start to finish!) then you can check out some of the other methods of map representation in this document on creating directed graphs.

Lastly, here's a link to the Matlab script I wrote to generate the images and digraphs.

Body:
What is the problem you're having with the file?

The only two things I notice off the bat are that you aren't outputting an endline character between rows on your output stream and that it looks like you're initializing the digraph variable in an odd manner. As I mentioned previously, it's been a long time since I've used c++, but could you not just call int digraph[6144][6144] = {0};?

For the endline character,

for (int l = 0; j < 300; l++) // printing only 300 elements
{
    for (int k = 0; k < 300; k++)
    {
        connectivityMap << digraph[l][k] << " ";
    }
//End the line when you're done outputting rows
connectivityMap << endl;
}

Lastly, note that you're only outputting the first 300 columns of the first 300 rows - you're looking at the upper left 300x300 portion of the digraph. digraph[a][b] will equal 1 if a and b are connected; as you have a straightforward map this means it will equal 1 if they are neighbors and neither is a wall.

:EDIT:

I think I see most of the problems you're having with this.

Here is the map image I made from your map text file. Note that you have a lot of pixels in the map, but it's really a low-resolution map that has been blown up.

Here is a map image I made that is functionally equivalent but much smaller in resolution. Instead of having 6144 points, the small map has 84. I'm not sure how the black squares with the white 'X's should be treated, so I counted them as walls, though I think it would probably make more sense if they were paths and your start/end position. You should replace the 0's with 1's in those locations if this is the case.

You are getting entries on the diagonal in your digraph because your map is very basic. Point 1 connects to point 2, point 2 to 3, then 3 to 4, etc., so you wind up with 1's (path exists) on the diagonals. Matlab has a function called imwrite that you can use to generate images from matrices; I used this function to generate the digraph images below.

Aside from the scale, the small digraph and large digraph have the same data regarding path connectivity. If you want to avoid keeping such a large, sparse matrix (it's all zeros on the upper/lower triangles because you don't have any paths from start to the middle of the map or start to finish!) then you can check out some of the other methods of map representation in this document on creating directed graphs.

Lastly, here's a link to the Matlab script I wrote to generate the images and digraphs.


问:
Circuit Design and Simulation
I want to design some circuits of my own. My area of expertise is in Computer Science Engineering. I have listed out the components which are essential in the circuit. I want a software which can be used to design and simulate circuits for real time projects. Please suggest me the best among them. Thank you.

@AkhilRajagopal

答: I usually use LTspice, which uses the same physical models as the alternatives listed by Chuck. LTSpice models can be directly imported to Eagle, which is somehow state of the art programm to PCB-design.</p>

Title: Circuit Design and Simulation


问:
7DOF inverse kinematics spherical wrist
Is it possible to apply kinematic decoupling for a 7 DOF 7R manipulator with spherical wrist?  If it is possible, can anyone suggest a reference on how to apply this approach with a redundant manipulator with spherical wrist, or explain why it is not possible?

I'm working with Robotic Toolbox (matlab) and the numeric algorithm can find the inverse kinematics solution without a problem if I don't specify the orientation.  And I was thinking about solving the problem a second time considering the spherical wrist.  Will this approach work?

答:
I believe kinematic decoupling used to be the standard procedure for 6 DOF arms.  (6R with spherical wrist).  Where you would solve the 3 DOF position IK first, then 3 DOF orientation IK.

If you have a spherical wrist, I don't think there is any reason why you can't decouple your problem like this.  However, I assume you now have a 4 DOF arm to reach a 3D point.  You have 1 redundancy, so your IK will probably give you a number of solutions.  So you should do your orientation IK on top of all these...

That being said, i don't believe anyone does it like this anymore.  I know at least my kinematics library of choice (OpenRave) can solve 7 DOF IK problems.  It does so by discretizing the extra DOF(s).

Title: 7DOF inverse kinematics spherical wrist


答:
The first thing to realise is that this is not a control problem, this is a planning problem. If you conflate the two, you are making life much more complex than it needs to be.

Solution - Motion planning

The traditional way to achieve what you want is to have two loops. The outer planning/supervisory loop generates way-points for specific points in time, while the lower level PID loop generates the appropriate PWM signals to keep the motor as close as possible to those way-points.

The more way-points you generate, the more closely you can track both velocity and position. Older systems often ran their floating point planning loop at a much lower rate than their integer PID loop, but these days even modest micro-controllers have more than enough compute power to do full trajectory planning of multiple axes at the PID control rate.

Simple example

While the example you drew is an s-curve trajectory profile, it is easier to explain the principles by looking at a simple trapezoidal profile.

Let's say you want to move from 0 to 36mm in 9 seconds with cruise  velocity (feed rate) of 6mm/s and an acceleration of 2mm/s/s. You might plan a move in 9 steps as follows:

\begin{array} {|r|r|}
\hline
time        & t & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\
\hline
acceleration& a & 0 & 2 & 2 & 2 & 0 & 0 & 0 & -2 & -2 & -2\\
velocity    & v & 0 & 2 & 4 & 6 & 6 & 6 & 6 & 4 & 2 & 0\\
position    & d & 0 & 1 & 4 & 9 & 15 & 21 & 27 & 32 & 35 & 36\\
\hline
\end{array}

In this case, at time $t=0$ you would inject position $d=1$ into your PID (plus acceleration $a=2$ and velocity $v=1$ if your PID loop has acceleration and velocity feed forward). At $t=1$ you would inject $d=4$ into your PID and so on until at $t=8$ you command the PID to move to the final position $d=36$, then at $t=9$ the system should have stopped moving.

Implementation

The limitations of your system will limit your implementation.

If you are CPU limited on your micro-controller but have plenty of memory to store path profiles, you may want to pre-calculate the way-points.

If you have plenty of CPU, you may want to calculate way-points on the fly.

If you are limited in both CPU and memory, you may need to either lower your way-point generation frequency or use integer interval arithmetic to calculate approximation more quickly.

Complications

If you find that your actuator jumps between way-points rather than moving smoothly, then you need to either reduce the time between way-points or optimise (tune) your PID loop for your motion (for example, reduce the proportional gain, increase derivative gain and/or increase the velocity/acceleration feed-forward gains). The moment you start using your PID loop to tune for expected motion however, you are making the motion worse for other kinds of move.

I see from comments that you want two linear actuators to match each other.

In this case, while the PID loops for each actuator will need to be run independently, the way-point inputs into those PID loops can be shared.

How closely each servo loop follow each other will be determined by how closely they follow the idealised trajectory as defined by the way-points.

If your individual PID loops are tuned well enough, and you set sensible limits on following error, the overall error between the two actuators should be at most the sum of their following errors, and is likely to be much less on average.

By the way, my experience on this comes from writing the control software for a 2x2m dual gantry cartesian robot. Even though we were accelerating the gantries up to 1m/s at 1g, we rarely had a following error of more than a few hundred microns, & the error between the two ends of the gantry was usually an order of magnitude lower. If we had used s-curve rather than trapezoidal move profiles, our errors would probably have been an order of magnitude lower still, but this was the 90's and micro-controllers had much lower floating point performance, so we went for simple & fast over complex & slow.


问:
Improving Velocity estimation
I have a sensor reduction model which gives me a velocity estimate of a suspension system(velocity 1) .

This suspension system estimate velocity is used to calculate another velocity(velocity 2) via a transfer function/plant model.

Can I use velocity 2 to improve my velocity estimate (velocity 1) through Kalman filtering or through some feedback system.??

V1 is "estimated" using these two sensors.That is fed into a geroter pump (Fs in diagram) which pumps fluid to manupulate the damper viscous fluid thereby applying resistance to the forces applied to the car body. There is no problem did I have an velocity sensor on the spring.I could measure it accurately but now I only have an estimate. I am trying to make the estimate better.Assume I have a model/plant or transfer function already that gives me the V2 given a V1.

答:
If you have transfer function such that
$$
\frac{V_2}{V_1} = H \\
V_2 = H V_1 \\
$$
Then wouldn't your estimate of $V_1$ be given by inverting the transfer function?

$$
V_1 = H^{-1} V_2
$$

The problem is that you can't use this to measure $V_1$, and here's why:

Your measurements are an estimate of $V_1$.
$$
V_{est} = f(V_1)
$$
You feed that estimate into the pump and get a flow output.
$$
V_2 = H V_{est}
$$
Now, if you invert the plant, you do NOT get a measurement of $V_1$, you get a measurement of your original estimate.
$$
V_{est} = H^{-1} V_2
$$
It's like you are trying to draw your own ruler and then use that ruler to see if you drew the ruler correctly. It's a circular definition that's not going to get you anything useful.

Title: Improving Velocity estimation


问:
What are the frequencies used for within drones?
What are these frequencies used for within the drone technology, and why these values?

35 MHz

433 MHz

868 MHz

2.4 GHz

5.8 GHz

答:
Spectrum licensing

There are only a limited number of frequencies in unlicensed bands which can be used for radio control, and different countries have different licensed bands for different uses.

For instance:

35MHz is available for RC use in many countries in Europe, but other countries use a whole variety of other frequencies below 100MHz.

I found a wealth of information on this at the UK Radio Control Council website.

433MHz is in the ISM Band in Region 1

That's the "industrial, scientific and medical radio bands" for use in "Europe, Africa, the Middle East west of the Persian Gulf including Iraq, the former Soviet Union and Mongolia".

868MHz is allowed for "Non-Specific Short Range Devices in Europe" within certain limits.

Finally, both 2.4GHz and 5.8GHz are ISM Bands with worldwide availability.

I found much of this information in the ISM-Band and Short Range Device Regulatory Compliance Overview document from Texas Instruments.

Frequency characteristics

In terms of actual use, different frequencies have different advantages and disadvantages. So in general:

Lower frequencies require a larger antenna and generally have a lower data rate, but require less power and have fewer line of sight issues.

Higher frequencies have more bandwidth available, so you can get more/wider channels and a higher data rate (see the Shannon Hartley theorem) and you can can use smaller antenna, but line of sight starts to become a major issue, and you need more power for the same range.


问:
DC Motor PID control with unstable velocity feedback
Currently I am building a omnidirectional robot with 4 DC Motors with embedded incremental encoder.

However, with a constant pwm input, i am not able to control the motor to rotate in a "relatively stable" state, refer to the figure, it can be observed that the linear speed of the motors can varied in 10cm/s range. I believe one possible reason is the PWM signal generated from my Arduino Mega Controller is not good enough.

And my problem is how can I implement a stable PID controller in this case? As the speed of the motor varies even with the same input, I believe extra work like adding a filter is needed?

Any advice is appreciated >.< Thank you

答:
Have you checked the supply voltage of the sensors? Sometimes PWM can cause problems.
If that is not the problem try to measure the voltage/current directly on the sensor using a scope. If this is stable something else is wrong in your circuit or arduino

EDIT: think I read it wrong. Is the driver you are using correct? is the signal which the arduino delivers good? Sometimes a pull-up resistor will do the trick.

If everything functions well, the PID values are not chosen correctly. Try using the ziegler and nichols method if this is posssible


答:
Forgive me I seem to get caught up in people looking for answers to a question they didn't ask a few times already. So given this question;

"How do I determine how many amps will be needed from the power supply?"

You can roughly guess it, in your case you say 4 servos drawing an amp each, 4 amps total.

Pick any BEC that will supply greater than 4 amps, there are plenty available from the other answer I already gave.

Then apply a logging circuit to validate your estimate; Make your own that logs both current and voltage, or buy a simple already build device that is made just for that purpose such as an Eagle Tree Logger

There is no magic formula to find correct amperage. Only real world usage and observation will give you a more precise estimate. Any such formula would not account for your mechanical design, friction, drag, gravity etc.


问:
Highspeed with gearbox or low speed for brushless motor?
I'm attempting to control a small vehicle at relatively slow (.5 m/s - 1 m/s) speeds, but with extreme accuracy (1mm). For the drive system, I'm considering using brushless motors as they have a much greater power / volume ratio than I am able to find with brushed motors, especially at this small size.

I will be using wheels between 1" and 2" diameter, so the RPM I will be looking for is between 150 - 500 RPM at max. This would suggest either driving the motors at a low speed directly, or driving them at a high speed and gearing them down. As I understand it, both setups will give high torques, as brushless motors decrease torque with speed. With brushed motors, it's quite obvious that a gearbox is necessary as otherwise there is no torque in the system, but here the choice isn't as clear, which is why I am asking.

tl;dr Use brushless motors at high speed with gearbox or low speed (ungeared) for high torque / low speed / high precision application?

答:
Page 7 of this PDF states that, "A permanent magnet DC brushless motor behaves like any permanent magnet DC brush motor."

You can read more about DC motor operation at this MIT site. I'm not sure if you've got a typo or what you're trying to say, but your question states, "brushless motors decrease torque with speed," after you state that using a gearbox and directly controlling the motor at low speed both, "will give high torques."

If you're looking to do speed control at a very low percentage of the motor's speed, I would suggest using a gearbox simply because you won't have much headroom to modulate the motor's speed. For example, assume the motor's top speed is 50,000RPM. You want to control the motor to 150RPM +/- 10RPM, which means that, if you're going to directly operate those motors at low speed with no gearbox, you need to be able to control the motor speed to within +/- 0.02% of the top speed. This will be hard, and you would probably actually want control within +/-1RPM, or 0.002% of top speed.

If you were to use a 100:1 gearbox, then top output speed becomes 500RPM, which means now you have to control motor speed to +/- 2%, or 0.2% for the +/-1RPM case, which suddenly becomes far more manageable.

The downside to using a gearbox is that they are physical, mechanical devices, meaning that they will have friction, backlash, and other drawbacks. Essentially you wind up paying a percentage of your motor's power for the advantage that speed becomes easier to control.

tl;dr - use gearboxes.


问:
Calculate required motor torque through Harmonic Drive
I have a term project which is controlling a two-link manipulator with harmonic drive installed at each joint.
To control, i used Computed control method to determine the torque needed for each joints based on the formula:
 $$\tau_i =M(\theta)(\ddot{\theta_i}+K_d\dot{e}+K_pe)+V+G  $$

To calculate the torque that each motor needs to produce through harmonic drive, i use:
$$\tau_{motor} =(J_m+J_g)\rho\ddot{\theta_i}+\frac{\tau_i}{\rho\eta_g}$$
where:
 $\rho$ and $\eta_g$ are gear ratio and efficiency of the harmonic drive. $J_m$ and $J_g$ are the motor and gear inertia, respectively.

after these calculation, i can see the effect of harmonic drive in the system by comparing input torque from motor in the model with harmonic drive ($\tau_{motor}$) to that torque in the model without harmonic drive ($\tau_i$)

But my professor doesn't agree the formula $\tau_{motor}$ i used. He want me to include the stiffness $k$ of the harmonic drive.

This is what i have done

P/S: This model which consists of two-link manipulator+harmonic drive at each joint is built in MATLAB.

Can anyone suggest me the formula about it?

Thank you so much.

答:
Page 50 of Hamid D Taghirad's 1997 PhD dissertation from McGill University gives a series of equations for harmonic drive torques, and the top of page 51 gives the following fantastic model for the harmonic drive:

WG is the wave generator (input); fs is the flexispline (output); N is the gear ratio, then the springs and dampers are deflection and friction losses at various stages in the harmonic drive. If you neglect the input/output frictional losses ($T_{f1}$, $T_{f2}$, and $T_{f3}$), then you're left with what I believe your professor was looking for,

$$
I_{drive} \tau_{drive} = -k_{fs}*(\frac{1}{N} \theta_{input} - \theta_{output}) - b_{fs}(\frac{1}{N} \dot{\theta}_{input} - \dot{\theta}_{output})
$$

where again, fs is the flexispline. Essentially the major components of the drive forces are due to structural damping and springiness of the flexispline deforming while the input rotates. Note that here I'm using the gear ratio as input : output, as harmonic drives are reducers. If $N = \frac{50}{1}$, then the input divided by the gear ratio gives the reduced input angular position or speed. If you define gear ratio as the inverse of how I've used it then you would multiply by N instead of divide by it.

Here are some great design tips for selecting harmonic drives, too, if anyone's interested.


问:
Guidance for compensating internal forces on closed loop chain
I'm working on a legged robot and generating joint torques. Basically the robot seems to be statically stable to some extend. The robot goes instable if the center of pressure moves to the border of the feet. I'm looking for some method to move away the center of pressure  from the feet edges after having calculated my joint torques. In Sentis thesis ( http://ai.stanford.edu/~lsentis/files/Thesis-Sentis-2007.pdf ) , it is mentioned that he somehow manages to cancel out the internal forces to keep the feet flat against the supporting surfaces.

Does anyone has got experience in dealing with internal forces? As far as I understood the literature one can modify the nullspace of the calculated torques to achieve that the COP remains in the geometrical center of the considered foot. I'm looking for methods apart from the virtual linkage model as it did not seem to work for me or someone with whom I could discuss the virtual linkage model described in ( http://ai.stanford.edu/~lsentis/files/tro-2010.pdf ) as I might not have it understood it correctly.

答:
Sentis' lab at UT Austin has open source code that implements many of the control topics mentioned in his thesis. You can check it out here: https://github.com/liangfok/controlit

Specifically for the internal forces monitoring, you can checkout: https://github.com/liangfok/controlit/blob/b8f3ba056b5329e26b9519c8923c43ae58f0dcd9/controlit_core/include/controlit/VirtualLinkageModel.hpp

OwnerDisplayName: someguy


问:
Adding an Actuator or Force to a (Featherstone) Articulated Rigid Body Model
I'm working on a project where I need to model a system that is essentially comprised of a series of ball-and-socket joints attached to a base, which is attached in turn to a prismatic joint (rail).

I've read Roy Featherstone's Rigid Body Dynamics Algorithms cover-to-cover, and I've also read the Dynamics section from the Springer Handbook of Robotics (also written by Featherstone).

It took me a long time to get acclimated to using his "spatial vector" and "spatial matrix" notation, but after re-creating all of his notation by hand as an exercise it works out to just be a nice way of concatenating 3x3 and 3x1 matrices and vectors into 6x6 and 6x1 matrices and vectors. The maths he invents to perform operations can be a bit tedious to read as he hijacks some standard notation, but overall everything is very compact, very easy to implement in MATLAB.

My problem is this: How do I add actuators to the model? He walks through explicitly configuring the joint definitions, link definitions, etc., but when it comes to actuators or applied forces he says something like, "Just add a $\tau_a$ here and Bob's your uncle!" - it's not discussed at all. In the Handbook of Robotics he suggests introducing a false acceleration to the fixed base to add the gravitational force term, but doesn't show how to add it in local coordinates nor does he mention how to add the actuator input.

Any help would be greatly appreciated. I've considered starting over with a different book, but it's going to be a great expense of my time to re-acclimate myself to a different set of notation. I'd like to move forward with this, but I feel like I'm just a few inches shy of the finish line.

答: If you haven't come across the Rigid Body Dynamics Library (RBDL) you might want to look at how they implement it, and/or contact the author Martin Felis.</p>


问:
Structuring EKF to estimate pose and velocity with odometry inputs
I have a differential drive robot for which I'm building an EKF localization system.  I would like to be able to estimate the state of the robot $\left[ x, y, \theta, v, \omega \right]$ where $x, y, \theta$ represent the pose of the robot in global coordinates, and $v, \omega$ are the translational and rotational velocities. Every mobile robot Kalman filter example I've seen uses these velocities as inputs to prediction phase, and does not provide a filtered estimate of them.

Q: What is the best way to structure a filter so that I can estimate my velocities and use my measured odometry, gyroscope, and possibly accelerometers (adding $\dot{v}$ and $\dot{\omega}$ to my state) as inputs?

My intuition tells me to use a prediction step that is pure feedforward (i.e. just integrates the predicted velocities into the positions), and then have separate updates for odometry, gyro, and accelerometer, but I have never seen anyone do this before. Does this seem like a reasonable approach?

答: The OpenPilot EKF implementation as described at the OpenPilot Firmware Development INSGPS Algorithm page does have the velocity vector as part of its state. The linked paper GPS-aided INS Solution for OpenPilot by Dale E. Schinstock, Kansas State University describes in quite a bit of detail how they've implemented it.


问:
Torque of coreless DC micro motor
I would like to build a small two-wheeled robot similar to the one shown here.

In order to keep the robot small, I intend to use two coreless micro motors like the one shown bellow. The power source would be 2 AAA or AA batteries, in order to reach 3 V. These batteries would represent the bulk of the weight of the robot. The rest of the robot would be virtually weightless.

The specifications of one of such motor are:

```<code>Motor diameter: 6 mm
Motor length: 12 mm
Output shaft: 0.8 mm
Output shaft length: 4 mm
Voltage: 3 V
Current: 17 mA (stall 120 mA)
Frequency: 22000 RPM
</code>```

My question is if small DC motors of this type have enough torque to even make the robot start moving. I have been unable to find torque info on these kind of motors and I suspect the weight of the robot could be too much for them to handle. Do you know the typical torque of such motor? Is there another type of (cheap) motor more appropriate for this project?

答: I don't know if you will have enough torque, but if/when you try it out, you might have better luck if you don't put any wheels on there.  The Solarbotics Photopopper Photovore, uses similar un-geared motors and just uses a bit of heat-shrink tubing for a wheel.  (However, it only has a solar cell and capacitor, so is much lighter than your bot).

OwnerDisplayName: Gonçalo Ribeiro

Title: Torque of coreless DC micro motor


问:
Confused about the variables in RobotC?
I'm trying to program advanced functions in RobotC but I'm not too sure I'm doing it right. I want to specify the motor port I'm using, but I assigned names to all the motors. Funny thing though, they don't exactly work the same as regular variables.

For instance, motor[port7]'s alternate name is light_blue.

```<code>#pragma config(Motor,  port7,           light_blue,    tmotorVex393, openLoop)
</code>```

I'm not really sure if these are new variables, or just specifications.  Anyway, here is the variable's signature:

```<code>int motor[tMotor motor]
</code>```

My code plans on doing something similar to this:

```<code>void testThing (Motor motorName)
{
  motorName = someValue;
}

testThing(light_blue);
</code>```

But with the int/motor hybrid variable/unidentified I'm not sure how well that would work out. Or at all.

答:
The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

```<code>#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}
</code>```

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

```<code>#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc
</code>```

If i was to look at your code, and accept its functionality as literal then the following would work;

```<code>#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          light_green,   tmotorNXT, PIDControl, encoder)

void testThing (tMotor&  motor_name)
{
    tmotor_name = light_green;
}

task main()
{
    tmotor motor_to_use = light_blue;
    testThing(motor_to_use);
    motor[motor_to_use] = 20; // will actually move light_green since testThing function changed its value
}
</code>```

It's hard to guess what it is you are trying to actually do

Title: Confused about the variables in RobotC?

Body:
The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc

If i was to look at your code, and accept its functionality as literal then the following would work;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          light_green,   tmotorNXT, PIDControl, encoder)

void testThing (tMotor&  motor_name)
{
    tmotor_name = light_green;
}

task main()
{
    tmotor motor_to_use = light_blue;
    testThing(motor_to_use);
    motor[motor_to_use] = 20; // will actually move light_green since testThing function changed its value
}

It's hard to guess what it is you are trying to actually do


答:
Great question!  Your intuition is correct.

I would do this:

Put the state $x$, and expected velocities at the current time $t$, $v $ as the vector to estimate.

Use estimated velocities to predict next state $$\hat{x}(t+1)=f(x(t),v(t))$$

Use odometry measurements from $t$ to $t+1$ to form an estimate of the state. The difference between this and $x$ is your innovation, $y_o$. Fuse with the predicted state. $$\hat{x}'(t+1)=UpdateStep(\hat{x}(t+1),y_o(t+1)$$

Use accellerometers to form a second estimate of state, which is also fused. You now have an estimate of the state at $t+1$ using all available information.
$$\hat{x}''(t+1)=UpdateStep(\hat{x}'(t+1),y_a(t+1)$$

Now, the velocities, assuming the filter is running "fast" and you can rely on a constant curvature path are whatever $v$ and $\omega$ explain the difference in the robot states. Use the difference to provide an estimate of the velocities, which is used to update the velocities in the state of the robot.
$$\hat{v}(t+1)=UpdateStep(\hat{v}(t+1),GetVelocityEstimate(\hat{x}(t),\hat{x}(t+1))$$

The design of a filter is very much up to the engineer, and in the end you may want to try several variants to see what works best.

Some other variants

Swap odometry, velocities, and accells to produce the prediction of state. You'll have to see what works better

Use a single integration of accellerometers to produce a velocity update before doing your forward prediction. In effect, you are "daisy chaining" EKFS, one to estimate your velocity, then using that velocity to predict your state, which is updated by other means. This will likely be much simpler and less likely to break.

Good luck!

Title: Structuring EKF to estimate pose and velocity with odometry inputs

Body:
I have a differential drive robot for which I'm building an EKF localization system.  I would like to be able to estimate the state of the robot $\left[ x, y, \theta, v, \omega \right]$ where $x, y, \theta$ represent the pose of the robot in global coordinates, and $v, \omega$ are the translational and rotational velocities. Every mobile robot Kalman filter example I've seen uses these velocities as inputs to prediction phase, and does not provide a filtered estimate of them.

Q: What is the best way to structure a filter so that I can estimate my velocities and use my measured odometry, gyroscope, and possibly accelerometers (adding $\dot{v}$ and $\dot{\omega}$ to my state) as inputs?

My intuition tells me to use a prediction step that is pure feedforward (i.e. just integrates the predicted velocities into the positions), and then have separate updates for odometry, gyro, and accelerometer, but I have never seen anyone do this before. Does this seem like a reasonable approach?


问:
Implementing a torque-controlled method on a position-controlled robot
I am working with a position-controlled manipulator. However, I want to implement a torque-controlled method on this robot. Is there any way to convert a torque command to a position command?

I try to find research papers on this but I have no idea where I should start or which keywords I should use in searching. Do you have any suggestion?

答:
We find this recent paper by Andrea Del Prete, Nicolas Mansard, Oscar Efrain Ramos Ponce, Olivier Stasse, Francesco Nori quite interesting:

Implementing Torque Control with High-Ratio Gear Boxes and without Joint-Torque Sensors

The authors presented a framework for implementing joint-torque control on position controlled robots.


问:
Detecting the presence of a person in a room
I am working on my first hobby project and I'm not very familiar with sensors yet. I am trying to build a system which detects the presence of a person in a small room with a single entrance/exit door.

The idea is when the first person enters the room, the lights turn on and any following person doesn't affect state of the lights. After the last person leaves, the lights should turn off. In a programmatic sense, the lights should turn on when present person count is greater than 0.

I have explored my options and found out that infrared sensors are usually used for this type of problem. What I am not sure is how to detect whether person has entered or left, so I would like to ask for some help with this.

答:
I think that most instances of a project like this use a motion sensor to detect if people are in the room rather than trying to count the number of people in the room as that would require knowing if someone was entering or leaving the room. The problem with a motion sensor to drive the lights that a person who enters and then becomes still (at a computer, TV, asleep, etc.) can cause the motion sensor to fail to detect a person in the room, causing the lights to turn off.

You could try to count people in the room, but, as mentioned, this requires knowing not just that someone passed the threshold but also knowing the direction they were going. This could be done with a really simple light curtain on either side of the door and then watching to see which sensor triggers first.

The light curtain doesn't need to be complicated; you can use one IR transmitter and one IR photocell for each "curtain". When the received intensity drops below some threshold you trigger an event. Outside then inside is someone entering and vice versa is someone leaving.

You can also use pressure mat, where again you put one inside and one outside.

Don't forget to take the door into account! If you use IR light curtain you'll have to set up one sensor unit far enough away that the door won't trigger (and thus block) the sensor.


问:
Inverting a transform (Reading J Craig's book on Robotics)
From Introduction to Robotics by J.J. Craig, chapter 2, Page no. 36:

Could anyone explain how that equation was derived/formed? I am stuck on this page due to failing to understand where the equation came from. Thank you.

答:
Given that an homogeneous transformation $T \in SE\left(3\right)$ can be expressed as
$$
T= \left( \begin{matrix} \mathbf{R} & \mathbf{p} \\ 0 & 1\end{matrix} \right),
$$
where $\mathbf{R} \in \mathbb{R}^{3 \times 3}$ is symmetric and $\mathbf{p} \in \mathbb{R}^{3 \times 1}$, then we seek for the inverse $T^{-1}$, such that:
$$
T^{-1}=\left( \begin{matrix} \mathbf{A} & \mathbf{b} \\ c & d \end{matrix} \right).
$$

It must hold:
$$
\left( \begin{matrix} \mathbf{A} & \mathbf{b} \\ c & d\end{matrix} \right) \cdot
\left( \begin{matrix} \mathbf{R} & \mathbf{p} \\ 0 & 1\end{matrix} \right) = \left( \begin{matrix} \mathbf{I}_3 & 0 \\ 0 & 1 \end{matrix} \right).
$$

Therefore, it follows:
$$
\left\{ \begin{matrix} \mathbf{A}\cdot \mathbf{R}=\mathbf{I}_3 \\ \mathbf{A} \cdot  \mathbf{p}+\mathbf{b}=0 \\ c \cdot \mathbf{R}=0 \\ c \cdot \mathbf{p}+d=1 \end{matrix} \right.,
$$

whose solution is:
$$
\left\{ \begin{matrix} \mathbf{A}=\mathbf{R}^{-1}=\mathbf{R}' \\ \mathbf{b}=-\mathbf{R}'\mathbf{p} \\ c=0 \\ d=1 \end{matrix} \right..
$$

To sum up:
$$
T^{-1}=\left( \begin{matrix} \mathbf{R}' & -\mathbf{R}'\cdot\mathbf{p} \\ 0 & 1 \end{matrix} \right).
$$


问:
Which middleware for IPC and multi-threading in a autonomous robot?
Aim: To use multi-threading and inter-process communication(IPC) when coding an autonomous robot.

Platform: Embedded Linux (Yocto)

Constraints : Limited CPU power.

We are building an Autonomous Underwater Vehicle, to compete in the RoboSub competition. This is the first time I am doing something like this. I intent to use a middleware like ROS, MIRA, YART, MOOS etc. The purpose of using one is that I want to modularise tasks, and divide the core components into subsystems, which should be run parallel(by multi-threading). But I have limited computational power (a dual core omap SoC), and the middleware, while robust should also be very efficient.

I need to use a middleware, because I don't want the program to be run on a single thread. My CPU has two cores, and it would be great if I could do some multi-threading to improve performance of the program. The middleware will provide for me the communication layer, so I don't have to worry about data races, or other problems associated with parallel processing. Also I have no prior experience writing multi-threaded programs, and so using parallel processing libraries directly would be difficult. Hence IMO, middlewares are excellent choices.

In your experience, which is the best one suited for the task. I don't really want to use ROS, because it will be having a lot of features, and I wont be using them. I am a computer science student(under graduate freshman, actually) and don't mind getting my hands dirty with one which has not that much features. That's true if only it will take less toll on the CPU.

答: Take a look to rock-robotics.org and github.com/auv-avalon we provide a lot of basic tools already but in the end there is no real best middelware.</p>


答: For maritime robotics, you should definitely take a look at MOOS.  It is a similar middle-ware to ROS, but was originally developed at the Dept. of Ocean Engineering at MIT with Prof John Leonard.  So it has a heavy maritime bent to it, but can of course be used for terrestrial (or aerial) robotics as well.</p>

Title: Which middleware for IPC and multi-threading in a autonomous robot?

Body:
Aim: To use multi-threading and inter-process communication(IPC) when coding an autonomous robot.

Platform: Embedded Linux (Yocto)

Constraints : Limited CPU power.

We are building an Autonomous Underwater Vehicle, to compete in the RoboSub competition. This is the first time I am doing something like this. I intent to use a middleware like ROS, MIRA, YART, MOOS etc. The purpose of using one is that I want to modularise tasks, and divide the core components into subsystems, which should be run parallel(by multi-threading). But I have limited computational power (a dual core omap SoC), and the middleware, while robust should also be very efficient.

I need to use a middleware, because I don't want the program to be run on a single thread. My CPU has two cores, and it would be great if I could do some multi-threading to improve performance of the program. The middleware will provide for me the communication layer, so I don't have to worry about data races, or other problems associated with parallel processing. Also I have no prior experience writing multi-threaded programs, and so using parallel processing libraries directly would be difficult. Hence IMO, middlewares are excellent choices.

In your experience, which is the best one suited for the task. I don't really want to use ROS, because it will be having a lot of features, and I wont be using them. I am a computer science student(under graduate freshman, actually) and don't mind getting my hands dirty with one which has not that much features. That's true if only it will take less toll on the CPU.


问:
Starter Looking For Advice
I'm no professional. At 29 I just became seriously interested in robotics a few months ago and have been researching everything I can since. Now that I've come to understand how far robotics have truly come I have a desire to try to make my own.
Granted, I know nothing about coding or programming. I have no idea where to begin. And I know it'll probably, the first time at least, be something small rather than a huge life altering project.
Thus, if anyone could suggest to me good resources for a beginner I'd massively appreciate it.</p>

答:
As a starter too on this field I am still looking for tips too. Recently I found that I could look into instructable to try things and also found that the raspberry is a great ressource for starter (not all of them but a few ones are a good start in even for people learning to code)

https://www.raspberrypi.org/resources/make/ (I will love to make the robo butler in there)

In instructables, this one could help for example : http://www.instructables.com/id/Johnny-Five-an-automated-turret/ but there are plenty others.

Title: Starter Looking For Advice


问:
Lagging sensor data for PID
Let's say a PID is implemented and the errors are calculated using the sensor data, but the sensor data lags by certain amount of time because of the overhead. And the lag time is smaller than the sampling period, how well does PID performs? What I am thinking is that PID will calculate errors based on past data, and use that to control. How will using a Kalman filter to estimate the actual sensor data help? </p>

答:
A discrete controller cannot feel anything that might vary within a sample period, so don't be concerned about it. Even a lag of one sample period is very negligible as seen by the PID and any technique you might consider to compensate for it will be definitely an overkill.

The right question you should ask yourself is: "is my sample period selected correctly according to the characteristics of the plant I want to control?"

Anyway, for significant lags (i.e. in the order of several sample periods) affecting a system, there exist methods such as the Smith Predictor that come to help you out.

Title: Lagging sensor data for PID


答:
Thank for your nice answer.  But i still have questions.
Applying this equation to my system, I see that:

$\theta_{output}$ and $\dot{\theta}_{output}$ are $\theta_i$ and $\dot{\theta}_i$ I calculated from manipulator.
However, $\theta_{input}$ and $\dot{\theta}_{input}$ are from motor, but where can i get them($\theta_{input}$ and $\dot{\theta}_{input}$) to determine $\tau_{drive}$?

I look at a catalog of a harmonic drive to look for $k_{fs}$ and $b_{fs}$ [for example this HD: link], i only find $k_fs$ but  there are 3 values of stiffness in catalog ($k_1$,$k_2$,$k_3$), which one should i choose? and where can i get $b_{fs}$

Sorry about this kind of question. I'm a newbie in Harmonic Drive.

Title: Calculate required motor torque through Harmonic Drive

Body:
I have a term project which is controlling a two-link manipulator with harmonic drive installed at each joint.
To control, i used Computed control method to determine the torque needed for each joints based on the formula:
 $$\tau_i =M(\theta)(\ddot{\theta_i}+K_d\dot{e}+K_pe)+V+G  $$

To calculate the torque that each motor needs to produce through harmonic drive, i use:
$$\tau_{motor} =(J_m+J_g)\rho\ddot{\theta_i}+\frac{\tau_i}{\rho\eta_g}$$
where:
 $\rho$ and $\eta_g$ are gear ratio and efficiency of the harmonic drive. $J_m$ and $J_g$ are the motor and gear inertia, respectively.

after these calculation, i can see the effect of harmonic drive in the system by comparing input torque from motor in the model with harmonic drive ($\tau_{motor}$) to that torque in the model without harmonic drive ($\tau_i$)

But my professor doesn't agree the formula $\tau_{motor}$ i used. He want me to include the stiffness $k$ of the harmonic drive.

This is what i have done

P/S: This model which consists of two-link manipulator+harmonic drive at each joint is built in MATLAB.

Can anyone suggest me the formula about it?

Thank you so much.


问:
Pull-down resistor for inter-chip and sensor-to-chip communication
I understand the concept of using a pull-up/pull-down resistor when implementing a button/switch with Arduino to avoid a floating state, and in fact I have implemented this quite often.

But I am not too sure if a pull-down resistor is necessary in chip-chip or chip-sensor communication.

I am connecting a coin acceptor to the Arduino (common ground). The coin acceptor's output pin gives a short pulse each time there is a coin inserted. So far I am connecting the output pin of the coin acceptor directly to an Arduino pin and it works without any problem. Is a pull-down resistor (on this line) usually required as precaution in this case?

Also I have the same question when connecting 2 pins of 2 separate Arduino's (also common ground) so that one Arduino can read pulses from the other.

Thanks in advance for any experience shared!

Dave

答:
To your first questions: This depends of the coin acceptor. If the coin acceptor is switching between ground and Vdd then you do not need the pulldown. If the coin acceptor is switching Vdd and floating then you need it.

Anyway if you have some kind of "flying wires" between the arduino and the coin acceptor you should place a pulldown next to the arduino the get a clean signal. The flying wires can "catch" some EMF or act as a capacitor.... Both cases are not good for you.

Your second question: Basically no, but you should use it when you have long connections between them... Anyway in both cases, it won't hurt, so just place them precautiously.


答:
Buy a Raspberry Pi, and an Arduino. You will be buying a few general purpose items like jumber wires, bread boards, single-core wires(for making circuits on bread board), soldering ion etc.

Then you will find tons of projects you can do with the RaspPi and Arduino on the internet to get you started. Pick a project, buy the required sensors, and do it. You shouldn't be just doing the interfacing. Learn the electronics behind the things you use as much as you can. At this point, one thing you can do is to document your works, preferably by starting a blog or something. When you work with arduino, you will learn some arduino  coding, which is pretty simple, and you will get the hand of it easily. Also learn python. A good place for it would be websites like codeacademy, where you can enrol for the course you want. The primary objective of this exercise is to get a general overview about robotics. This would be your gateway to the world of robotics.

Then you could move to more and more advanced projects, and as you grow, you will finally that 'huge life altering project' you wanted to do will come to your head. Let's hope it does. But definitely you will be gaiining a lot of knowledge and life hacks in life if you go down this lane.

Title: Starter Looking For Advice

Body:
I'm no professional. At 29 I just became seriously interested in robotics a few months ago and have been researching everything I can since. Now that I've come to understand how far robotics have truly come I have a desire to try to make my own.
Granted, I know nothing about coding or programming. I have no idea where to begin. And I know it'll probably, the first time at least, be something small rather than a huge life altering project.
Thus, if anyone could suggest to me good resources for a beginner I'd massively appreciate it.</p>


答: Expanding on the motion sensor idea: you could combine that with a door open/shut sensor or basically just a switch that detects when the door is open. After an open/shut event, you could detect if there is motion or not. If there is, set a flag that a person is in the room. That gets rid of the issue where the person may become motionless.  I'm assuming that the state of person present/absent can only change during the open/shut event and I'm also assuming that if there are people inside the room, at least one of them will likely be moving directly following the open/shut event.</p>

Title: Detecting the presence of a person in a room

Body:
I am working on my first hobby project and I'm not very familiar with sensors yet. I am trying to build a system which detects the presence of a person in a small room with a single entrance/exit door.

The idea is when the first person enters the room, the lights turn on and any following person doesn't affect state of the lights. After the last person leaves, the lights should turn off. In a programmatic sense, the lights should turn on when present person count is greater than 0.

I have explored my options and found out that infrared sensors are usually used for this type of problem. What I am not sure is how to detect whether person has entered or left, so I would like to ask for some help with this.


问:
Problems about Complementary Filter IMU tuning
I'm developing a project consists of an IMU controlled by Arduino through which you can send via a radio module, the data to the PC of the three Euler angles and raw data from the sensors.
For filtering I used the code made available by SparkFun: Razor AHRS 9 dof

https://github.com/ptrbrtz/razor-9dof-ahrs/tree/master/Arduino/Razor_AHRS

The code does not provide radio transmissions and is tuned for 50 Hz sampling rate, in fact its parameters are:

```<code>// DCM parameters
#define Kp_ROLLPITCH (0.02f)
#define Ki_ROLLPITCH (0.00002f)
#define Kp_YAW (1.2f)
#define Ki_YAW (0.00002f)
</code>```

in this project data is read every 20ms (50Hz) and records of the sensors are set to the accelerometer odr 50hz and 25 bandwidth. with the gyroscope 50 Hz odr.
In my project I used a gyroscope different, namely that I used L3G4200D frequency odr starting at 100Hz, I set then registers with the 100Hz. My global data rate is 33Hz max, beacouse the use of a radio, i read the complete date with a frequency of 33Hz.
How can i tune the Ki and Kp of my setup? the Kp is the period, I have to consider the frequency odr that I set to register in the individual sensors or i have to set the global system sample rate limited to 33Hz by the radio transmission?

答:
Yes and no.

I just had a quick view at the code which is somehow hard to read what they are actually doing.
But in digital Signal processing the Kp value is never normalized to the samplingtime. Instead the Ki is sometimes.... depends on the implementation.

For digital Signal processing the integral term is dividing the IntegralValue by the SampleTime of the system to normalize it for 1second. In this implementation I cannot see such an operation. This means for you yes the I-Term has to be adjusted : Multiply by 0.02 and divide by 0.03/0.01