问:
Ideas for shooting the ball in a soccer robot
What is the best option to use for the shooting system of a soccer robot?

I have already implemented a solenoid-based system for shooting and it works perfectly.
However, I'd like some other methods to check if they are better than mine.

答:
This can depend very much on your requirements - how far away do you need to shoot? How accurately do you need to shoot? Does power draw matter in the shot?

However, some of the following may be of use:

Pneumatic system: If you want unrivalled shot power, this is probably the way to go - you can blast the ball pretty much as hard as you like. It also has minimal electrical current draw because it'd be mainly powered by a compressed tank filled beforehand. However, in a lot of situations this wouldn't be allowed, and it can be bulky and expensive.

Spring based system: You could have a motor which winds a spring up to the desired tension, then releases it. This can be powerful given a powerful enough spring and motor, and relatively cheap to implement. Downsides though are time taken to wind the spring up (so successive rapid shots are difficult) and this could draw quite a lot of power.

Multiple spring based system: As above, but bypasses much of the speed issue by using multiple springs and firing each one when necessary. More expensive and complicated to implement though.

Sheer speed: If you build a very quick robot, and design a "ram" on the front of it, sometimes simply ramming into the ball can be enough to shoot it into the goal. Very simple to implement, and can be effective with a good driver, but makes it much harder to use. A version of this involves putting a flipper on one side of the robot and then spinning the robot around quickly to shoot the ball. Accuracy also suffers with this approach however.


问:
A general question about PID Controller
I have a basic question because I'm trying to understand right now a concept that I thought it was obvious.
Looking at this video he is going to feedback the variable state x with the input of the system, which is a force f.

Now, if I'm correct it is only possibile to feedback variables which share the same units, so I expect to drive a meter through an input variable which is a meter and the difference will be then feed into the PID. Is the example in the video just to show up how to use simulink?
Or I m wrong?

答:
Keep in mind that the PID gains themselves can have units too. So if you have a position error, multiplied by a gain of the appropriate units, you can get a force.

$$
\begin{align}
e &= x - x^d
\\
u_f &= -k_p e - k_d \dot{e}
\end{align}
$$
If $x$ and $e$ have units of [m] and $u_f$ needs to have units of [N], then we get $k_p$ with units of [N/m] and $k_d$ with units of [N/(m/s)]

ContentLicense: CC BY-SA 3.0

Title: A general question about PID Controller


问:
Spinning disk Weapon
I am building a Hobby-weight robot and my weapon of choice is a spinning disk at the front.

As regards the disk I was thinking of buying commercial (grinder-type) disks and change type of disk depending on the "enemy's" chassis construction material. So for instance I would have an aluminum cutting disk if the enemy's chassis is made of aluminum and so on.

First question is therefore; do such disks do the job in practise (or break, fail to cut?)

Secondly, should I use a brushed or brush-less motor for the disk? I actually have ESCs for both but sort of feel a brushed motor will give me more torque while a brush-less motor might give me more speed. So which is more important speed or torque?

I do know - from my uncle who uses metal lathes - that machines that cut metal usually spin at a slower speed (drills, cutting wheels etc)- indeed he likes to say that metal working machines are safer than wood-working ones partially for this reason.

But I am a newbie and really would like to have an effective weapon if possible and breaking or not-cutting disks do not make such a weapon!

Also is it normal practise to use one battery for everything (drive and weapon) or have two separate batteries?

答:
Well grinding machines in general use really high cutting speeds, so a very high revolution speed.
At a metal lathe it is pretty easy to get the force of your tool onto the workpiece. In a robo-fight it's actually not that easy, so i suggest very high speed.
More like an angle grinder</p>

Title: Spinning disk Weapon


问:
Self Powered Quadcoptor
I have this idea or a very curious question in my mind. I am no where near professional though, but i would like it to be answered. </p>

<p>We all know how wind turbines can be used to generate electricity. So is it possible to create a quadcoptor that will start with some minimal power by small battery but in time will sustain and keep its system on by self generating electricity and keep on rotating its rotors on its own without other external supply? </p>

答:
A quadcopter flies because the propellers put the air into motion, which generates a lift. This relies on the air flow around the propellers being relatively unobstructed. As you might imagine it would not fly if you obstructed the propellers with pieces of cardboard for instance.

Wind turbines generate electricity from the wind. If you measured the wind speed before and after the turbine you would see that the wind speed has decreased after passing through the turbine. As such they do obstruct the air flow.

Let's imagine a system with a quadcopter propeller and a wind turbine just underneath it. Because the turbine reduces the wind speed coming out of the whole system, it also reduces the quadcopter lift. To make things worse, the conservation of energy tells us that in an ideal system you can only collect as much energy as what is required to create the lift you lost. In a real system you collect less energy than the lift you lost. So not only would you reduce the lift, you would also collect less energy than what is required to produce the wasted lift.

So I'm afraid the answer is a no. Sorry.

Title: Self Powered Quadcoptor


问:
In PID control, what do the poles and zeros represent?
Whenever I read a text about control (e.g. PID control) it often mentions 'poles' and 'zeros'. What do they mean by that?  What physical state does a pole or a zero describe?</p>

答:
These polynomial transfer functions occur, when you perform a Laplace transform on some linear differential equation which either actually describes your robot or is the result of linearizing the robot's dynamics at some desired state. Think of it like a "Taylor expansion" around that state.

The Laplace transform is the generalization of the Fourier transform to functions which are not periodic. In electrical engineering, the Laplace transform is interpreted as the representation of the system in the frequency domain, i.e. it describes, how the system transmits any frequencies from the input signal. Zeros then describe frequencies that don't get transmitted. And as already mentioned by DaemonMaker, poles are important when considering the system's stability: The transfer function of the system goes to infinity near the poles.

What they mean in a control context:

Poles: They tell you, if a system (that can also be a new system, in which you have inserted a feedback loop with a control law) is stable or not. Usually you want a system to be stable. So, you want all the poles of the system to be in the left half plane (i.e. the real parts of the poles must be smaller than zero). The poles are the eigenvalues of your system matrix. How far they are on the left half-plane tells you how fast the system converges to it's resting state. The further they are away from the imaginary axis, the faster the system converges.

Zeros: They can be convenient if you have a pole on the right half plane or still on the left half plane, but too close to the imaginary axis: By clever modification of your system, you can shift the zeros onto your unwanted poles to annihilate them.


答:
Generating electricity by rotation of rotors

Yes, electric power generators and electric motors are often similar enough to do both tasks -- converting electrical energy to mechanical energy at one time (such as on takeoff), and converting mechanical energy to electrical energy at some other time (such as during landing).

Any system that takes (mechanical) energy out of the wind and converts it to electrical energy is a wind turbine.
Pretty much all commercial wind turbines are mounted on top of a rigid tower.

Generating electricity in the air without a rigid tower

A few airborne wind turbines have been demonstrated.
They convert some of the energy of the wind into electrical energy, and simultaneously use the wind (or balloons) to stay aloft.

All airborne wind turbines that I've seen so far have one or two steel cables tethering them to a winch on the ground.

Airborne wind turbines can potentially produce more electric power at lower cost than wind turbines on a tower.
The cost is lower because a kilometer of steel cable that can support a few tons of tension from the wind is much simpler and lower cost than a 220 meter tower that can resist a ton of bending force from the wind.
The electric power is (potentially) higher because airborne wind turbines can fly higher than a tower, where the wind usually blows faster (has more mechanical energy) than it does closer to the ground.

Other parts of airborne wind turbines are much more complicated than putting wind turbines on a tower.

Generating electricity in the air without any connection to the ground

Many airplanes have a ram air turbine that can generate electricity in the air.

While one might think that the first law of thermodynamics (conservation of energy) might make it impossible to generate more electrical energy with a ram air turbine than the energy is consumed keeping the airplane in the air, a careful analysis shows that there's no physical law that makes it impossible to generate electricity in the air without any connection to the ground.

However, it seems to me that it would be more difficult than keeping a glider in the air, which is already tricky enough.

In principle, gliders can stay aloft indefinitely by extracting energy from the wind (typically from updrafts).
In practice Charles Atger managed to keep a glider in the air 56 hours 15 minutes in 1952.
The FAI stopped recognizing new glider flight-time endurance records after that due to safety concerns.
Occasionally "cloud suck" updrafts put far more energy into a glider than is safe.
In principle a ram air turbine could convert some of that excess energy into electrical energy.

Quadrotors generating electric power

EDIT:
In response to comments that mathematically "prove" that quadrotors use up more electric power just staying airborne than they could possibly generate, let me point out that

"If it happens, it must be possible."

See the 4-rotor (and therefore quadrotor, right?) flying machine photographs in
Google X Buys Airborne Wind Turbine Company Makani Power; Makani technology, Makani photos, etc.

In particular,

"A composite image of Wing 7 generating power autonomously during crosswind flight. Photo by Andrea Dunlap, composite work by Anita Tirapelle." --
(Wing 7 generating power)

(Wing 7 on the ground)

Title: Self Powered Quadcoptor

Body:
I have this idea or a very curious question in my mind. I am no where near professional though, but i would like it to be answered. </p>

<p>We all know how wind turbines can be used to generate electricity. So is it possible to create a quadcoptor that will start with some minimal power by small battery but in time will sustain and keep its system on by self generating electricity and keep on rotating its rotors on its own without other external supply? </p>


问:
Diode or capacitor across terminals of brushed motor
I am currently building a hobby-weight robot (5.44kg) and will be using 2 x 14.4v cordless drill brushed motors to drive my wheels.

I have read somewhere that due to "induced currents" when I turn the motor off (or reverse it presumably?) I should protect it by using a diode or a capacitor across the terminals.

Which should I use (capacitor or diode) and what are the parameters I need to consider for these components (voltage or current)?

Some answers to a similar question discussed capacitors but not diodes. Are diodes relevant?

Would I seriously damage the cordless drill (presumably quite tough) motor if I did nothing?

And don't motor controllers have any form of inbuilt protection for the motors anyway?

答:
The motor's aren't so much at risk here, poorly designed motor drivers are. The purpose of the diodes is to drain the exces energy generated (by disconnecting the motor) to the battery of your robot. When an electric motor is running by means of external power and that power is removed, it starts acting like a generator. If it can't deliver the power it is generating to something, the voltage over the motor terminals will keep rising until something releases it's magic smoke.

If you look at the direction of the diodes in the attached image, you will see that the diodes enable the motor to drain it's exces power to the battery, thus saving your driver. By the way, the round things with the arrow in them, are the switches, they are called MOSFETs.

The cap over the motor terminals is there to short out high frequency noise generated by power supply, the motor itself or something else. Make sure the cap is bipolar if you use one, otherwise it will blow if you reverse the motor. The size doesn't have to be huge, use something like 100nF.

What motor driver are you using? If you could provide me with a type, I can tell you whether or not you need the diodes, a small cap is always a good idea.


问:
Amperage on brushed motors
I am currently building a hobby-weight (5.44kg) robot and will be using 2 x 14.4 cordless driller motors for my wheels.

The thing is I keep reading about high amperages when working with r/c models such as quadcopters BUT when I connect my cordless driller motor to my bench power supply and monitor current draw it never rises above 3.2 Amps even when I try to stop the motor by hand.

Of course in the arena in the event of a stand off I have plastic wheels which will slip so I am not too concerned about stall currents.

I am now left wondering whether I have mis-calculated or whether people make a lot of fuss about high currents for nothing. or do these currents only perhaps really apply to brush-less motors?

答:
The stall amps are dependent on your type of motor, there are motors with stall currents into the 100's of amps, and some into a few milli amps. 3.2 Amps isn't a lot, but it isn't impossibly little either. The motor's used by quadcopters are brushless, they generally are way higher powered, into hundreds of watt's and more. </p>

<p>Make sure your power supply isn't current limited to 3.2 A. You are probably fine with a motor driver capable of something like 4A. </p>

Title: Amperage on brushed motors

Body:
The stall amps are dependent on your type of motor, there are motors with stall currents into the 100's of amps, and some into a few milli amps. 3.2 Amps isn't a lot, but it isn't impossibly little either. The motor's used by quadcopters are brushless, they generally are way higher powered, into hundreds of watt's and more.

Make sure your power supply isn't current limited to 3.2 A. You are probably fine with a motor driver capable of something like 4A.


问:
Rotate (and stop) a large disk in very tiny increments
In a lab build I'm doing, I'm stuck at this problem, so I am fishing for suggestions.

I'm creating a turn-table type setup where I need to make readings (with a nanotube-tip probe I've already designed, similar to an AFM probe) on the very edge/circumference of a 10 cm radius disk (substrate).

The current hurdle is: I need to get the substrate disk to move circularly in steps of 0.1 mm displacement -- meaning, I occasionally need to STOP at certain 0.1mm-increment positions.

What would be a way I can achieve this, assuming an accurate feedback system (with accuracy of say ~0.1 mm, e.g., with quadrature optical encoders) is available if needed for closed-loop control?

Specs of commonly sold steppers don't seem to allow this kind of control. I'm at the moment trying to study how, e.g. hard disks achieve extreme accuracies (granted they don't have such large disks).

Certainly, direct-drive like I'm currently building (see below image) probably doesn't help!

答:
You can use stepper motors easily:

Given the 20cm diameter, this is around 63cm circumfence. Your target stepsize is around 0,1mm. This means the motor should do around 6300 steps per revolution.
If you take a common stepper motor, which has a step size of around 1,8° per step. So the motor performs 200steps/per revolution. your target is 6300.
Now we know the motor should have (6300/200) around 32times more accuracy.

So you have 2 different options:

1. Use a gearbox with minimum ratio of 1:32

 Advantage: Still lot of force

Disadvantage: It is pretty slow

2 Use some Stepper magic and let him microstepping. There are drivers with around 128 times microstepping.

 advantage: Still decent velocity

 disadvante: looses most of this force.

You could also combine this two methods... This is no problem at all.


问:
How to convert PID outputs to appropriate motor speeds for a quad copter
I am building an autonomous robot using PID control algorithm. So, far I have implemented PID using online resources/references. I am testing for stabilizing an axis of the quad copter. However, I am not successful to stabilize even one axis.
Description: My input for the PID is an angle value i.e the orientation of the quad copter measured by AHRS (a Gyroscope that measures angles) and the motors take integer values as speeds. What I am doing is,

```<code>motor_right_speed = base_speed + adjusted_value;
motor_left_speed = base_speed - adjusted_value;
adjusted_value += PID_output;
</code>```

Where ajusted_value is a buffer that accumulates or subtracts the PID output value based on either PID output is +ve or -ve.

I also tried,

```<code>motor_right_speed = base_speed + PID_output;
motor_left_speed = base_speed - PID_output;
</code>```

Both don't seem to be working.

I have tested using a wide range of P gain values (from very small to very large), but the quad copter only oscillates; it does not self-correct. Your help with suggestions would be greatly appreciated. Thanks!

答:
I have been there before :) First double check that everything else is working. My IMU was not working in flight at first, but I didn't realise it because I only ever had tested it with the motors off. The vibrations made my algorithm go crazy. The sensors built-in low-pass filter helped.

Next a gyro measures angular rates, not angles. So you can know the speed at which you are turning around an axis, but not the angle itself. You could integrate the angular rate and get the angle, but the gyro drift would soon send you back down on the ground. In order to achieve angular stabilisation you need an accelerometer. And if you needed to maintain a precise heading you would need a magnetometer.

This said with just a gyro you can stabilise the angular rate in what some call the "manual" mode. Piloting in this mode requires skills but it's not impossible to learn. For this the input of the PID is an angular rate, and the output is a difference to apply between opposed motors (based on your pseudo-code I'm assuming you have a + configuration, X is is not much more complicated).

The correct formula to stabilise the roll rate only is the second one you used: motor_right_speed = base_speed + PID_output; motor_left_speed = base_speed - PID_output; You want to be careful about making sure the output remains within the motors bounds. My experience is that PD controllers work the best for roll/pitch stabilisation (leave the I term null). Start at 0 for all the constants, raise P until the quad oscillates slightly, then increase D until the oscillations from P dampen. Repeat until D cannot compensate the oscillations and use the last stable pair of constants. In order for this to work you have to use a test rig. If you try to stabilise only 1 anglular rate in flight you will crash.

I would recommend not assuming the problem is with the PID: based on what you said it's not unlikely the issue is somewhere else. In any case try to isolate the different units of your program and test them independently. It's much harder to debug a whole system than its separate components. Good luck, you'll be happy when it works!


问:
What are some low cost alternatives for lidar?
It need not be as effective as lidar or it may have some disadvantages when compared with lidar.   What are the probable alternatives?

Edit:
I'm intending to use it outdoors for navigation of autonomous vehicle. Is there any low cost LIDAR or is there any alternative sensor for obstacle detection?

答: I think the time-of-flight cameras would suffice for your application and are cheaper than laser scanners (which are much more precise).</p>


问:
Humble beginnings
I want to learn robotics and build my first robot. I am looking for a well supported kit that is simple enough and can walk me through, the initial stages of my intellectual pursuit in Robotics. I want to be able to do the basic things first and build a solid foundation in robotics. And then I want to be able to use the solid foundation, to gain confidence in my ability to build new and interesting robotic contraptions. In other words, I want to be able to follow the rules off the game to gain a solid foundation and then once I'm comfortable with what I know, I want to break free of the rules and start making my own robots.

I would like help with 2 things,

I would like to begin my robotics learning with a good kit that can walk me through my initial stages. I expect that this initial stage might take quite a while. So, any recommendations for how I can start and/or what kit I can buy, to get my feet wet, would be helpful.

I would like suggestions for "other" actions I can take, that will set me on a path to gain confidence in my knowledge of robotics.

A little bit about myself. I have a BS and MS in IT. So I am not new to programming. I like to code in golang and haskell. I do not know if it is possible, but it would be awesome if I can write the software aspect of all my robotic projects in haskell.

Thanks

答:
I got drawn into Robotics by a Lego Mindstorms lab course at our university, in which the participants were divided into 2 teams whose robots had to compete against each other in some predefined task. That was shortly before the NXT were introduced. In my experience, a Lego Mindstorms kit is a good way for "software people" to get into Robotics because it doesn't overwhelm you with electronics and manufacturing-related questions when you just want to build e.g. a line follower robot. The NXT kits can also be flased with many different kinds of custom firmware that is available on the Interent. There is also a LabVIEW interface, if i recall correctly.

Another good starting point may be Arduino boards or anything from this company:
http://www.vexrobotics.com/
I used them to order some parts i needed for a mechatronics class project. A Parrot AR drone may also be interesting. Or look for game engines or simulators if you want to stay away from hardware at first.

Title: Humble beginnings


问:
ros node does not seem to do anything
I have the following code for the ros turtlesim:

```<code> #include <ros/ros.h>
#include <std_msgs/String.h>
#include "geometry_msgs/Twist.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void disruptcb(geometry_msgs::Twist msg) {
    ros::NodeHandle pubHandle;
    ros::Publisher publisher = pubHandle.advertise<geometry_msgs::Twist>("turtle1/cmd_vel", 1000);
    ros::Rate loop_rate(2);

        double dist1=(rand()%100);
        double dist2=(rand()%100);
        std::cout<<dist1<<std::endl;
        dist1=dist1;
        dist2=dist2;
        msg.linear.x+=dist1;
        msg.angular.z+=dist2;
        std::cout<<msg<<std::endl;
        ROS_INFO("hello" );
        publisher.publish(msg);

}
int main(int argc,char** argv){
    srand(time(NULL));
    ros::init(argc,argv, "things_going_wrong");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("/ros_1/cmd_vel",1000,&disruptcb);
    ros::spin();
}
</code>```

the idea behind this code is to introduce a random error to then practice error recovery in my code but this node does not appear to do anything at all. I do know that my other nodes are running but this one just doesn't appear to do anything, it doesn't exit it just hangs. Anybody know how to fix this?

答:
I have tried your code. When publishing a message on "/ros_1/cmd_vel" your disruptcb will be called.

```<code>rostopic pub /ros_1/cmd_vel geometry_msgs/Twist '{linear: {x: 1, y: 2, z: 3}, angular: {x: 1,y: 2,z: 3}}'
</code>```

But I can't connect to your outcome message "turtle1/cmd_vel". Try to advertise it inside the main function:

```<code>ros::Publisher* publisher;
void disruptcb(geometry_msgs::Twist msg) {
    ...
    publisher->publish(msg);
}
int main(int argc,char** argv){
    ros::init(argc,argv, "things_going_wrong");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("/ros_1/cmd_vel",1000,&disruptcb);
    publisher = new ros::Publisher(nh.advertise<geometry_msgs::Twist>("turtle1/cmd_vel", 1000));
    ros::spin();
    delete publisher;
}
</code>```

Then outcome message will also be observed:

```<code>rostopic echo /turtle1/cmd_vel
</code>```

Title: ros node does not seem to do anything

Body:
I have tried your code. When publishing a message on "/ros_1/cmd_vel" your disruptcb will be called.

rostopic pub /ros_1/cmd_vel geometry_msgs/Twist '{linear: {x: 1, y: 2, z: 3}, angular: {x: 1,y: 2,z: 3}}'

But I can't connect to your outcome message "turtle1/cmd_vel". Try to advertise it inside the main function:

ros::Publisher* publisher;
void disruptcb(geometry_msgs::Twist msg) {
    ...
    publisher->publish(msg);
}
int main(int argc,char** argv){
    ros::init(argc,argv, "things_going_wrong");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("/ros_1/cmd_vel",1000,&disruptcb);
    publisher = new ros::Publisher(nh.advertise<geometry_msgs::Twist>("turtle1/cmd_vel", 1000));
    ros::spin();
    delete publisher;
}

Then outcome message will also be observed:

rostopic echo /turtle1/cmd_vel


问:
Recursive Tree Representation for Multi Agent Robots?
I have been going through a code base for multi agent motion planning. And I came across a recursive tree building algorithm for the agents. I haven't been able to figure out the algorithm. Does anyone know what it is called? Or any other similar kinds of algorithms so I could read more about it?

Here is what I got from the code:
The node of the tree is as follows -

```<code>>   struct AgentTreeNode {
>     int begin;
>     int end;
>     float minX, maxX, minY, maxY;
>     int left;
>     int right;   };
</code>```

Each node has a max and min value for x and y. And also a begin, end, left and right value.

Then the tree is split either horizontally or vertically based on which limits are longer (x or y). And an optimal value is found and agents are split.

Then these split agents are recursively build again.

Thank you very much.

答:
It sounds like a KD-tree

If it is a KD-tree, the four floats seem a little redundant, bounding boxes can be calculated on the fly when traversing the tree, you only need to record the splitting plane in the node.

I would guess that begin and end describe range of indices of agents belonging to the current node and left and right are indices of left and right subtree of the current node.


问:
Is there an advantage to multiple magnetometers for heading computation
I'm building an autonomous sail boat (ripped out the guts of an RC sail boat and replaced with my own mainboard etc.)

The controller board I have can accommodate both an MPU9150 and an HMC5883. Is there any advantage is using both magnetometers for a tilt-compensated heading? I'm thinking that I could compute the unit vector with soft/hard iron offsets removed for both, and then average  the two vectors to get one slightly better one?

Not sure if it would yield a better result though.

答:
Not really.

With careful planning, experimentation and testing to minimize effect of servo motor magnetic field affecting the sensor (by placing sensor as far away as possible and mathematically iron compensation via angle table), one should be able to achieve accuracy of a few degrees, which should be sufficient for the said application.  (This excludes the case of sensor error detection via multiple sensors)


问:
biped walking using Genetic Algorithm
I am working on a project but I lack advanced programming knowledge, especially about genetic algorithms. I am developing a prototype using WEBOTS 7.4.3 for the simulation. The project is to use genetic algorithms to evolve the gait of a biped robot. I have developed a physical model, but I am still uncertain about the motor choice. For the algorithm part, I find it hard to understand how to set the algorithm parameters and how to determine the fitness function. Could you please suggest a fitness function?

Thank you for your help and efforts.

答: If you're only trying to walk forward the fitness function could be the distance covered by the biped. If you're also trying to control the heading, you could define a slightly more complex function which correlates the covered distance and the heading input.</p>

Title: biped walking using Genetic Algorithm


问:
Can I make an automatically-parking robot car with IR sensor?
It would be easy to understand if you imagine a robotic vacuum cleaner. (For some models) It goes back to a specific place automatically to recharge. Like this, I want to make a robot which automatically goes to the place where a specific signal(like infrared ray) is emitting.
Following is the scenario that i've imagined.

1.Set the IR emitter in a specific place of a room. It always emits Infrared ray.

2.I connect 4 IR receiver to my 4WD robot car - front, left, right, and back side.

3.They receive IR from the emitter. I earn the distance from the emitter to each receiver with the intensity of IR.

4.With these values, Arduino find out which receiver is closest from the emitter and choose the direction to go.

But I could't know this will be possible. Because IR is a kind of light ray, so I can't get the distance with the difference of arrival time(like Ultrasonic). I searched several kinds of IR sensors, but they were only for sensing the possibility of collision.

So my question is these..

Can I get the distance and the direction from IR emitter to my arduino device with an IR receiver?

If I can, then how many IR receivers do I need? And if I can't, what can I use to substitute IR emitters and receivers?

I guess IR can be interrupted because of sunlight or other light. So I guess I need some daylight filter. Do you think it's essential??

答:
You can use time of flight to calculate the distance of an object using infrared; this is very commonly done. Some good, cheap IR sensors are sold by Sharp. You'll have to linearize the output to compute the actual distance as shown here: http://www.acroname.com/articles/linearizing-sharp-ranger.html.

You can operate the IR emitter used to find the parking spot at a different frequency than the IR emitters used for computing distances and then band-pass filter both to make sure there is no interference.

You should be able to drive towards the parking spot with just a single IR, turning in order to maximize the signal strength. Two would probably work better, where you turn in order to make the IR intensity on both equal (these would be placed in the front of the vehicle, probably similar to where headlights would be placed).

I believe the Sharp IR rangers already do some filtering, but I'm not sure as to what extent. In terms of sunlight, there's a ton of discussion about this topic if you just google it.


答: If you use several IR receivers (say, 9 of them) spaced out over a $90^\circ$ arc at regular intervals, you will have constructed a makeshift sensor for detecting the angle of a remote IR emitter.  Between that and moving (and/or rotating) known distances with your vehicle, you should be able to triangulate the location of the nearest IR source.</p>

Title: Can I make an automatically-parking robot car with IR sensor?

Body:
It would be easy to understand if you imagine a robotic vacuum cleaner. (For some models) It goes back to a specific place automatically to recharge. Like this, I want to make a robot which automatically goes to the place where a specific signal(like infrared ray) is emitting.
Following is the scenario that i've imagined.

1.Set the IR emitter in a specific place of a room. It always emits Infrared ray.

2.I connect 4 IR receiver to my 4WD robot car - front, left, right, and back side.

3.They receive IR from the emitter. I earn the distance from the emitter to each receiver with the intensity of IR.

4.With these values, Arduino find out which receiver is closest from the emitter and choose the direction to go.

But I could't know this will be possible. Because IR is a kind of light ray, so I can't get the distance with the difference of arrival time(like Ultrasonic). I searched several kinds of IR sensors, but they were only for sensing the possibility of collision.

So my question is these..

Can I get the distance and the direction from IR emitter to my arduino device with an IR receiver?

If I can, then how many IR receivers do I need? And if I can't, what can I use to substitute IR emitters and receivers?

I guess IR can be interrupted because of sunlight or other light. So I guess I need some daylight filter. Do you think it's essential??


问:
Two State Linear Actuator
I need two state linear actuator. You can have a look at the picture to understand what I mean.

Don't care about the hand !

(source: robaid.com)

I need to electrically move the things like this squares up and down. Bidirectional linear actuators are needed.
What is the cheapest and tiniest actuator (or sth else) that I can use to move this squares up and down. There are just two states ('up','down'). Don't care how much higher a square rises, when it is up.

答: What you are looking for is called a solenoid.</p>

ContentLicense: CC BY-SA 4.0

Title: Two State Linear Actuator


问:
PID Tuning Quadcopter Problem
I am tuning PID for quadcopter, the problem i have is that with different base Throttle, i seems that i have to adjust different PID gains in order for the quadcopter to balance! </p>

答:
I found the reason, in my original code, i just use one stage PID.
The right one should comprise of 2 cascaded PIDs: rate PID and stablized PID

Title: PID Tuning Quadcopter Problem


问:
Wheeled Robot Motion Primitives: Is throttling forward and crab motion considered as one?
I am simulating a wheeled robot of six-wheels and can be independently steered, like MER-Opportunity.
The wheeled robot can perform throttling forward,

```<code>||---|| <--wheel orientation
||   ||
||---||
</code>```

crab-motion,

```<code>//---// <--wheel orientation when heading is 45
//   //
//---//
</code>```

and turning on the spot.

```<code>//---\\ <--wheel orientation
||   ||
\\---//
</code>```

My question is: Is it correct to say that I have 2 motion primitives? Throttling forward is basically crab-motion with heading zero.

答:
While I am not really sure what you exactly mean by "motion primitive", having the ability to do the "crab-motion" enables you to translate regardless of your orientation and without changing it (assuming 180 degrees of steering) which would not be the case if you had only one pair of steerable wheels (like in cars, remember the parallel parking problem).

Note however that this is still non-holomonic motion system unless the wheels are omniwheels (you cannot rotate and translate independently).


问:
Short distance ball transport
I'm looking for a way to transport balls (diameter 50mm) 220 mm up with over a slope with a length of 120 mm. Currently I'm considering the usage of a belt system but I cannot seem to find a good belt system.

Because of space constraints within my robot, normally I would probably take a nylon belt and jam nails trough it to make little slots and then use that. However this would result in considerable reduction in available space as it means that I have to also take into account the extra space required for the nails on the way back. This means that ideally there would be a way to reduce the space used by the nails on the way back.

Does anybody have a good solution for this?

答:
You don't need to modify or mutilate a belt in any way to be able to use it as a ball elevator.

Simply place the belt upside-down above the balls, and and use it to roll the balls uphill.

 <-- similar to what's happening in this part of the animation

In this case, the inner ring represents your belt and the outer ring represents the ramp.

Title: Short distance ball transport


问:
Robot docking for self-recharging
I want to build a simple obstacle avoider robot, but this time I want it to be self-recharging so I am building a dock for this purpose, so I want it to be able to locate the dock and go for it when battery voltage is lower than a fixed value.

I am having trouble to chose the right components for locating the dock, I think I am going to use an IR emitter on the dock so the robot can head toward it when battery is low (let's forget about the orientation problem for the moment, but if you have any thoughts about it that will be helpful) but I am not sure if the robot is able to detect the IR LED (or whatever) from a long distance (over 10 meter)

Is it possible to use this solution for this distance? If not, what do you suggest?

(If there is a simple ready solution to buy that's ok, let's say I have no budget limit)

答:
It will be up to you to pick an IR LED (or a set of them) that provide enough power to differentiate from ambient light.  Unless I'm reading your question incorrectly, there should be no issue with putting many LEDs at the docking station to multiply the power.

Keep in mind that you can always flash the source LED(s) at a known frequency or in some more complicated pattern to make that signal separable from other light sources.

Title: Robot docking for self-recharging


问:
How do I get this transformation matrix?
I've just started taking a robotics course and I am having a little problem.
I need to rotate the $O_i-1$ coordinate system into a position, where $X_i-1$ will be parallel with $X_i$.

The transformation matrix is given, but I have no idea how I can figure out this transformation matrix from the picture that can be found below.

Actually, I know why the last vector is [0 0 0 1] and the previous vector is [0 0 1 0], but I can't figure out why the first vector is [$\cos q_i$ $\sin q_i$ 0 0] and the second [$-\sin q_i$ $\cos q_i$ 0 0].

答: This is a standard rotation matrix with pure rotation about the Z axis.  See for more info: http://en.wikipedia.org/wiki/Rotation_matrix</p>


答:
Why do you need to have the motor at the axis? Wouldn't it be much easier to have several at least one motors at the edge of the disc and the disc would lie on wheels (the smaller the more accurate)? There could still be a pivot in the middle but just with ball bearings instead of a motor. If the surfaces are clean this should be accurate and by far easier to build.

If this is incomprehensible I'll do a drawing.

[I'd have preferred for this to be a comment, but lack the reputation and wanted to be helpful]

EDIT: Here have crappy drawings; I hope they bring the general idea across though.
It would be quite important to have a force pulling (or pressing if it is convenient to have something above the disc) the disc down so that you have more friction; then normal rubber wheels would be enough I think (with the benefit of having smooth motion).
I'm not sure what you mean by skate bearings as wheels; the wheels should have friction in contact with the disc. The non-motorized wheels (to support the disc) could have ball bearings as hubs.

On a side note, the design you proposed in the question is quite likely to cause the disc to wobble even if there is a only a slight misalignment or vertical force on the disc.

It might also be advisable to mount all those things on a material that doesn't change volume too much based on temperature/humidity.

Title: Rotate (and stop) a large disk in very tiny increments

Body:
In a lab build I'm doing, I'm stuck at this problem, so I am fishing for suggestions.

I'm creating a turn-table type setup where I need to make readings (with a nanotube-tip probe I've already designed, similar to an AFM probe) on the very edge/circumference of a 10 cm radius disk (substrate).

The current hurdle is: I need to get the substrate disk to move circularly in steps of 0.1 mm displacement -- meaning, I occasionally need to STOP at certain 0.1mm-increment positions.

What would be a way I can achieve this, assuming an accurate feedback system (with accuracy of say ~0.1 mm, e.g., with quadrature optical encoders) is available if needed for closed-loop control?

Specs of commonly sold steppers don't seem to allow this kind of control. I'm at the moment trying to study how, e.g. hard disks achieve extreme accuracies (granted they don't have such large disks).

Certainly, direct-drive like I'm currently building (see below image) probably doesn't help!


问:
USB instead of RS232
RS232 is not popular as it used to be and is mainly replaced by USB [wikipedia]. Problems such as mentioned in this question doesn't help its reputation either.

In a new system design therefore, one could think of using USB instead of Serial Port for communication. However, it still seems like RS232 is the serial communication protocol/port of choice.

Why is that? I understand changing old machinery that work with RS232 is costly, but what prevents new system designers from using USB instead of RS232?

答:
Simplicity, i guess. A USB implementation (chips and driver software) is usually more complex than good ol' RS232, which can even be found in many 8-bit microcontrollers. While USB has many protocol mechanisms and is designed to deal with many participants over a bus, a RS232 connection doesn't have any of that. Instead, it's the "rawest" form possible of sending bytes over a wire.

Although Arduino and increasing spread of USB-to-serial adapters show promise that USB will eventually become as dominant as RS232 used to be.

Title: USB instead of RS232


问:
Detect road surface in a traffic scene point cloud
I want to analyze a traffic scene. My source data is a point cloud like this one (see images at the bottom of that post). I want to be able to detect objects that are on the road (cars, cyclists etc.). So first of all I need know where the road surface is so that I can remove or ignore these points or simply just run a detection above the surface level.

What are the ways to detect such road surface? The easiest scenario is a straight and flat road - I guess I could try to registrate a simple plane to the approximate position of the surface (I quite surely know it begins just in front of the car) and because the road surface is not a perfect plane I have to allow some tolerance around the plane.

More difficult scenario would be a curvy and wavy (undulated?) road surface that would form some kind of a 3D curve... I will appreciate any inputs.

答:
RANSAC is usually used to segment planes from the point cloud (see: http://www.pointclouds.org/documentation/tutorials/planar_segmentation.php).

As an alternative, when you detect objects that are on the road you could neglect surfaces/points for which the curvature is close or equal to zero. However, this requires you to have some way to get the curvature information, for example, normals (see: http://pointclouds.org/documentation/tutorials/normal_estimation.php).


问:
Where does Gazebo set the GAZEBO_MODEL_PATH environment variable?
I'm starting out with Gazebo (1.5) at the moment and am following a tutorial off the internet. In order to get Gazebo to find the model, the author advocates manually exporting the GAZEBO_MODEL_PATH environment variable via

```<code>export GAZEBO_MODEL_PATH=[...]/models:$GAZEBO_MODEL_PATH
</code>```

But that will only work for the current terminal. So I wanted to change the environment variable permanently.

The Gazebo User Guide claims that GAZEBO_MODEL_PATH, along with all the other environment variables, is set by /usr/share/gazebo-1.5/setup.sh but my (virgin) Gazebo install doesn't list it:

```<code>export GAZEBO_MASTER_URI=http://localhost:11345
export GAZEBO_MODEL_DATABASE_URI=http://gazebosim.org/models
export GAZEBO_RESOURCE_PATH=/usr/share/gazebo-1.5:/usr/share/gazebo_models
export GAZEBO_PLUGIN_PATH=/usr/lib/gazebo-1.5/plugins
export LD_LIBRARY_PATH=/usr/lib/gazebo-1.5/plugins:${LD_LIBRARY_PATH}
export OGRE_RESOURCE_PATH=/usr/lib/i386-linux-gnu/OGRE-1.7.4

# This line is needed while we're relying on ROS's urdfdom library
export LD_LIBRARY_PATH=/opt/ros/fuerte/lib:${LD_LIBRARY_PATH}
</code>```

But when I start Gazebo, GAZEBO_MODEL_PATH is already set to $HOME/.gazebo/models, so it must be set somewhere. I guess I could probably simply add GAZEBO_MODEL_PATH to the setup.sh script, but since it is set somewhere, I'd still like to know where and whether it is better practice to set it in there.

答:
This is more of a Linux than a Gazebo problem. You can just add this line

```<code>export GAZEBO_MODEL_PATH=[...]/models:$GAZEBO_MODEL_PATH
</code>```

to your ~/.bashrc file.

Body:
This is more of a Linux than a Gazebo problem. You can just add this line

export GAZEBO_MODEL_PATH=[...]/models:$GAZEBO_MODEL_PATH

to your ~/.bashrc file.


问:
Inverse Kinematics of Parallel Manipulator (Delta Robot)
Let me start off by saying that I am currently going to university majoring in computer engineering.  I love software/hardware and I especially love robotics and I want to apply my knowledge of software/hardware in robots.  I have never taken a formal class on robotics, so I don't really know where to start or how to approach the mathematics that robots entail.

Currently, I am interested in calculating the inverse kinematics of a delta robot. To clarify a bit more, I am trying to determine the required joint angles that will position the end-effector of the delta robot to a specific location given some x,y,z coordinate.  The delta robot that I will be basing my design off of is shown in the image below.

Based off of some research that I have been doing for the past few days, I found that the sort of mathematics involved are usually like those of Denavit-Hartenberg parameters, Jacobian matrices, etc.  I am going to be honest, I have never encountered Denavit-Hartenberg parameters or Jacobian matrices and I don't even know how to apply these to solve the kinematics equations and let alone find the kinematics equations.  Most of the articles that I have read, mainly deal with serial manipulator robots and the mathematics in finding the kinematics equations of those serial manipulators.  I couldn't really find any good material or material that was easy to understand given my current situation on parallel manipulators.

I wanted to ask my question here in the hopes that someone in the community could direct me to where I can start on learning more on obtaining the inverse kinematics equations of parallel manipulators and solving those equations.

Any help will be much appreciated.

Thank you.

答: Introductory robotics books should cover this, for example: Introduction to Robotics: Mechanics and Control by J. Craig.</p>


答:
For these sorts of problems, I always like to attempt to solve them myself. And they're surprisingly simple when you think about them geometrically. Parallel mechanisms are especially easy because each part of the mechanism can be considered separately, and each part is very simple.

The base part (at the top of the image) contains three servo motors. Think about one motor. When the end effector (blue triangle) is in some position, what angle does the motor need to be?

Imagine a sphere centered on one corner of the end effector triangle. The radius of the sphere is the length of the arm attached to that corner. Now imagine the servo arm swinging, tracing out a circle. Where does this circle intersect the sphere?

This is a pretty simple problem to solve. Think of the servo arm sweeping out a plane. That plane intersects the sphere:

... creating a circle. Now the problem is just the intersection of two circles. Find the two intersection points, and choose the one that makes most sense (the one that  puts the servo arm into its possible angle range.

Added: For an intuitive explanation of inverse kinematics for serial manipulators, that avoids horrible Denavit-Hartenberg parameters, try my old Inverse Kinematics Article.

Title: Inverse Kinematics of Parallel Manipulator (Delta Robot)

Body:
Let me start off by saying that I am currently going to university majoring in computer engineering.  I love software/hardware and I especially love robotics and I want to apply my knowledge of software/hardware in robots.  I have never taken a formal class on robotics, so I don't really know where to start or how to approach the mathematics that robots entail.

Currently, I am interested in calculating the inverse kinematics of a delta robot. To clarify a bit more, I am trying to determine the required joint angles that will position the end-effector of the delta robot to a specific location given some x,y,z coordinate.  The delta robot that I will be basing my design off of is shown in the image below.

Based off of some research that I have been doing for the past few days, I found that the sort of mathematics involved are usually like those of Denavit-Hartenberg parameters, Jacobian matrices, etc.  I am going to be honest, I have never encountered Denavit-Hartenberg parameters or Jacobian matrices and I don't even know how to apply these to solve the kinematics equations and let alone find the kinematics equations.  Most of the articles that I have read, mainly deal with serial manipulator robots and the mathematics in finding the kinematics equations of those serial manipulators.  I couldn't really find any good material or material that was easy to understand given my current situation on parallel manipulators.

I wanted to ask my question here in the hopes that someone in the community could direct me to where I can start on learning more on obtaining the inverse kinematics equations of parallel manipulators and solving those equations.

Any help will be much appreciated.

Thank you.


问:
Using kinect for medical application but without computer. Is it possible?
I have to use kinect for an application. However,  the final work must be mobile: it means no computer. Consequently, I thought using a microcontroller to handle data from kinect. But is it possible? My job is mesuring some points of a body (axis X, Y, Z) and get back these coordinates. I don't know if I'm enough accurate. </p>

答:
There are some microcontrollers which can act as a USB host, E.G. NXP LPC4357. However, microcontrollers tend to have very little RAM. The LPC4357 for example has only 136kB. If you use all of this to store an image, you'd only be able to store a resolution of 373x373 pixels!  The USB host stack and other code are probably going to need quite a bit too.

My advice would be to use a small computer which can do the job, E.G. Raspberry Pi. These tend to have many megabytes of RAM, they run Linux and you can get drivers for them. They aren't big (compared to a Kinect), and fairly low power.


答:
At least in the microcontroller level:

Serial ports (usually TTL or LVTTL) are still the most common way to communicate, since most simple microcontrollers don't have a USB controller.

For instance: most 8-bit AVR or PIC microcontrollers don't have USB, a few 32-bit ARM microcontrollers do, but they all usually have serial ports.

Conversion from TTL/LVTTL serial communication to RS-232 requires a "simple" logic level conversion, which can be done with very cheap ICs (MAX232/MAX3232)

Conversion from TTL/LVTTL serial communication to USB when your microcontroller does not have a USB controller usually requires using a slightly more expensive IC (FTDI) which does not have any through-hole packaging options, only surface mount.

There are a few details relative to the protocol one has to pay attention to when using USB devices in general, such as the current level it may request from the USB host. With serial ports, you only have to worry about 3 to 5 fixed parameters that have to be consistent in your system (baudrate, # of stop bits, parity, etc).

Title: USB instead of RS232

Body:
RS232 is not popular as it used to be and is mainly replaced by USB [wikipedia]. Problems such as mentioned in this question doesn't help its reputation either.

In a new system design therefore, one could think of using USB instead of Serial Port for communication. However, it still seems like RS232 is the serial communication protocol/port of choice.

Why is that? I understand changing old machinery that work with RS232 is costly, but what prevents new system designers from using USB instead of RS232?


问:
Build a ROS robot with SLAM without laser
I've build a simple wheeled robot based on two continuous servos, controlled by Raspberry Pi running ROS-groovy, with a smart phone mounted on top to provide additional sensors.  I'd like to situate the bot in a room and have it move to various points on command.  I don't have laser ranger finder but do have a good ultrasonic ranger finder and kinect sensors.

What are the typical ROS setup for this?

The idea I'm thinking is to personally (e.g. manually) map my room using kinect and use this map using only the ultrasonic range finder sensors and IMU in the lightweight robot.  Would this be possible?

答:
A kinect mounted on your robot is enough for mapping and localization. There are a few different packages that will work:

rgbdslam can create a 3d map using a kinect

You can use depthimage_to_laserscan to take in a depth image from the kinect and output a laser scan message which you can then use with gmapping for mapping, and the nav stack to navigate your robot.

If you have a ring of ultrasonic rangers on your robot, you can use those for gmapping and navigation, though the kinect will certainly work better.


问:
Sending a smartphone's GPS wireless
I'm building camera device which is able to take pictures of paragliders in mid air.

To let the camera know where the glider is I thought about using GPS data from the pilot's smartphone.

My question is: What are possible ways to transmit the GPS data to the groundstation and which can be considered a good solution?

I thought about sending the data to a server via some mobile network, but a direct communication solution would be preferable.

The pilot has mid-air pretty good mobile reception and the maximum distance between pilot and ground station is around 3km.

答:
I can't comment yet (reputation limitation) so I've had to make a few assumptions...
Option one:
Write an app for the smartphone that communicates with a server (over mobile data) that the ground station is also in contact with - when the ground station indicates an image has been taken, the server through the app instructs the phone to transmit it's GPS location.
Option two:
This still requires an app to be written but this time it would pass the gps data to an attached arduino device with an RF module that communicates with the ground station Radio Frequency Module.

There are alternatives to communicating with the ground station but still achieving the same result.
An arduino device interfaced with the smartphone logs the gps data with a timestamp which is matched up with the timestamp that the ground station records when it takes an image.

Edit: It should be noted however that options one and two approaches require that a particular camera is assigned to a particular paraglider - as there is no way to know which paraglider the camera took an image of to know which smartphone to retrieve the gps data from.

Title: Sending a smartphone's GPS wireless


问:
How to find the height of a rock with a rover?
So, I am designing a rover that will navigate to a rock, and then calculate the height of the rock. Currently, my team's design involves using an ultrasonic rangefinder and lots of math. I was interested in what sensors you would use to solve this problem, or how you would go about it? Assume that the rover has already located the rock.

Additional Info: We are using an Arduino Uno to control our rover. It is completely autonomous.

答:
Given the scales we are talking about I think the lumberjack technique would not work. Lumberjacks walk away from a tree until they visually measure an angle of 45 degrees between the bottom and the top of the tree: at that point they are standing at a distance from the tree which is equal to its height, and which they can measure easily walking back to the tree. It only works because the lumberjack is small in comparison to the tree so model approximations such as "the eyes of the lumberjack are at ground level" or "the ground is perfectly horizontal" hold true enough to not impact the final result too much. I don't think it would work well enough on a rover and a 7" rock. Note that if you wanted to go this route anyway you could implement it with a camera or a laser rangefinder, and you could use any angle and trigonometry formulas.

Because the rock is small I would use a mechanical trick. Maybe use a pole with a sonar pointing down that you would place directly above the rock. You could use a pendulum to make sure it's vertical even if the rover is on uneven ground. Or you could develop a device like a forklift that you would place above the rock and progressively lower until you hit the rock. You would then know the height based on the position of the stepper/servo driving the lifting part.

That's the way I would go with this challenge, I encourage others to post their answers if they have different ideas because there might be plenty of other interesting solutions!


问:
Which is more useful? Instantaneous rate of change of displacement or Average rate of change of displacement?
Instantaneous rate of change of displacement is given by,

```<code>v(t) = (s(t + dt) - s(t))/dt, where dt tends to 0
</code>```

while average rate of change of displacement is given by,

```<code>v(t) = (s(t[n]) - s(t[n-1]))/(t[n] - t[n-1])
</code>```

The first one gives the slope or derivative of a displacement function at a particular instant of time and thus varies with time. I was wondering how is it going to help me calculate the velocity of my robot's end effector, which is the foot of the leg of the robot(bipedal). If i make a reading of the position of the robot every 1ms to keep the approximation as accurate as possible, my instantaneous velocity would be zero wouldn't it? Since my robot wouldn't have moved anywhere in 1ms time. Agreed, 't' would increment as t+dt, dt == 0.001s. Then v(t) would be v(0.001) = s(0.002) - s(0.001) which is zero, because there is no displacement in that small time frame, right? Am I doing something wrong here? Or on the other hand, do I just use average rate of change?
I have this question, since, if there is a manipulator, in my case the foot of my robot, and it's trajectory is given by a 3x3 homogenous matrix,

```<code>[{c(t),-s(t), 0},
 {s(t), c(t), 0},
 {  0,    0,  1}], where c,s are cos(theta) and sin(theta)respectively,
</code>```

if on paper, this is differentiated, this would give me a spatial/body velocity matrix as

```<code>[{0, -d(theta)/dt, 0},
 {d(theta)/dt,  0, 0},
 {    0,        0, 0}]
</code>```

So how do I compute this differentiation in code. I just need something of the sort of a pseudocode.

答:
You are confusing continuous time concepts and discrete time concepts. The instantaneous velocity is a continuous time concept and doesn't directly apply to systems where time is measured discretely, e.g. every 1 ms. If you have a system where dt is very small, what you call average velocity is an approximation of the instantaneous velocity. To my knowledge, for real systems there is no practical way to directly measure instantaneous velocity so this approximation is the best we can do.

So the example you give of measuring displacement every 1ms is really a discrete time example. Also, your intuition is off: if you have non-zero velocity then no matter how small dt is (except dt=0) there will be a change in real position. Depending on how good your measurement system is, though, you may not be able to measure that change.


问:
Learning Materials for Beginners in Robotics and Quadrocopters
I am a web developer. I am fascinated by Quadrocopters and i am trying to learn how to build one and basically i am trying to jump into robotics fields. I don't have much electric circuit and electronics knowledge so i did some research on how to build and what type of knowledge you would require to develop such flying machine. So i started learning basics of electronics from Lessons In Electric Circuits by Tony R. Kuphaldt

The books are very interesting but i could not find a technique so that i can implement what i learn from the books. Basically i am just going through the stuffs, and understanding them little by little. What i want to know is that what is the right way and effective way to learn electronics and electric circuit from your experience and i should i do now so that i can increase my learning speed so that i can achieve my goal.

While i was researching i came across topics such as mathematical modelling and modelling the quadrocopters first and them implementing them on real. How can i gain such knowledge to model something mathematically and implement such in real life? How much math and what areas of mathematics do i need to learn and how can i learn such?

Now you have idea what i want to learn and achieve. Can you please suggest me a road map or steps i need to take to gain such knowledge and skill to develop myself, so that in near future i would be able to build such flying machines on my own.

答:
I was in a very similar situation about a year ago, and I now have a flying aircraft. Below is what worked for me, but many other routes are possible.

First I purchased an almost ready to fly quadcopter kit from a well-known manufacturer. I only had do a bit of soldering, assemble the frame, configure the flight controller, and bind the transmitter. While this step may not seem necessary, it allowed me to develop a basic understanding of how the system works as a whole. I had no prior RC knowledge. It also allowed me to learn how to fly, and to have realistic expectations about how a well-tuned quadcopter should behave.

Then I got an Arduino and basic sensors. At this point I was not sure I would end up building my very own quadcopter. I just wanted some toys to play with and see what I could do without spending too much money. I am a hobbyist programmer so the C++ part was not a problem. You are a web developer so you will have to learn how to program real software ;-) This step allowed me to confirm I could connect a microcontroller and a few sensors without blowing up the house. Eventually I ended up with a working inertial measurement unit (IMU), combining gyroscope accelerometer and magnetometer data into an accurate representation of the device orientation in space.

It then became clear that building a quadcopter was a realistic target. I spent a little more money to purchase motors, propellers, ESCs, a radio receiver (I already had the transmitter from my first quadcopter) and a few wooden sticks for the frame. With some more programming efforts I eventually got everything to fit in together nicely.

The whole process took me about a year and I'm still working on it. It's worth noting that along the way I also learnt about a few unnecessary things, like servo motors, barometers, and sonars. I did not mean to take the fastest route. If like me you have a day job and a life this is at least a 6 months long project. In order to keep me motivated I posted my steps on a blog and I only set myself realistic targets: I did not start thinking I would build a quadcopter, instead I thought I would learn the Arduino basics and refined my goals as I progressed.

I went to uni (10 years ago) and I had a basic level in physics, mathematics, and electronics. The difficult skills I had to learn were 3D vector geometry and controller theory. 3D geometry is for the IMU. I used quaternions because Arduino requires optimisations for speed. Matrices and a better microcontroller is probably a more reasonable choice. Controller theory is to implement and tune the PID controllers which drive the motors so as to keep the aircraft level. These are all skills that you can learn online. I never bought a book for this project. I also didn't model my quadcopter mathematically like you seem to suggest.

This is my experience, I hope it is helpful to you. I'm sure the challenges will be different for you anyway. If I had to summarise I would urge you to purchase some components/parts and see what you can do with them because learning quadcopters is more about practice than theory. Good luck!


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

答:
I've wanted to do something similar, so hearing of your experiences would be great.

The best thing I think would be to get a colorimeter, and build a calibration table into your code. Since paint can vary by manufacturer or medium additive (possibly even output levels if the tubes clog some), you could have the robot print its own test pattern. This would also calibrate to the resolution of the color mixer, since you might not have 255 distinct and evenly spaced levels of paint release per color.

Let's say your magenta was stepped with a screw thread attached to a stepper motor. If this thread only had an obscure number of 82 turns to adjust paint release levels, with higher output in the middle of the curve, then the test pattern would show the result of 82 different output levels of your magenta.

Using a colorimeter under diffused ambient lighting, you can determine what colors are output by which flow settings. Then, create a lookup table in your program to do the translation. To increase color resolution, you could even account for premixed colors (shades of brown, green, gray, etc).

Let me know how it goes


答:
I think the biggest reason that RS232 has stayed around is the simplicity in implementing common use-cases in embedded hardware - like sending a sequence ASCII bytes between two devices for control. The use-cases for sending information at the much higher speeds available with USB are not worth the trade-off in complexity caused by implementing the USB protocol's signalling.

As the requirements for higher speeds appear, I wouldn't be surprised if RS-485 became more common with it's very simple physical interface and high (up to 10Mb/s) data rates.

Title: USB instead of RS232


问:
how to power extra usb devices for beaglebone black
I'm building a robot that uses a beaglebone black, however I have several different usb devices that I want to connect to it (microphone, usb sound device and some other things). Now I have heard that the usb output of the beaglebone doesn't power more then 0.1A. So the combined draw of these usb devices is likely to exceed this by a fair margin. So I started looking for powered usb hubs to use instead. However these tend to be powered by 220V and my robot currently only has a 12V power supply and a converter to 5V for the beaglebone. Which given the size expense and inefficiency of converting power to 220 from 12V and then back again doesn't seem very good. Is there a good method for fixing this? </p>

答:
Yes this is pretty easy to solve, you just need basic soldering skills.

Just open the cables of your additional USB-devices, you will see 4 wires. 2 of them are for the data, just leave them. The other two are for powersupply, just connect them to your 5V power supply. But make sure you have to right ones, otherwise your device will start producing magic smoke.

In 90% of all cases the wires are colored, so you can see what is the use of a specific wire. But dont trust this, especially if you use cheap equipment. Better measure them.


答:
Use a self-powered hub. Look at the power adapter from the mains (220v). In almost all instances, it is converting 220vac to 5vdc (sometimes 5vdc and rarely 12vdv).

Cut the power adapter cable to the hub in half after determining which half of the cable pair  is negative and which is positive (see picture below). Often it's as obvious as the red wire is positive, but ALWAYS CHECK WITH YOUR MULTIMETER.  Splice the hub power cable into your existing 5vdc or 12vdc power and plug into your hub.

Using a hub is preferable to injecting the external 5V into your BeagleBoard because there is less chance for the magic smoke to be forced out by a bad connection, improper voltage, or polarity. Also higher power to all devices is usually achieved by letting the hub handle the power negotiations from the bus.

Title: how to power extra usb devices for beaglebone black

Body: I'm building a robot that uses a beaglebone black, however I have several different usb devices that I want to connect to it (microphone, usb sound device and some other things). Now I have heard that the usb output of the beaglebone doesn't power more then 0.1A. So the combined draw of these usb devices is likely to exceed this by a fair margin. So I started looking for powered usb hubs to use instead. However these tend to be powered by 220V and my robot currently only has a 12V power supply and a converter to 5V for the beaglebone. Which given the size expense and inefficiency of converting power to 220 from 12V and then back again doesn't seem very good. Is there a good method for fixing this? </p>


问:
Denavit-Hartenberg convention
There are two different conventions that can determine DH parameters.   What is the difference between Craig's [1, Sec 3.4] convention and the Spong [2, Sec. 3.2] convention?
I know that both methods must have the same response.

[1]: Craig, John J. Introduction to robotics: mechanics and control. Addison-Wesley, 1989.

[2]: Spong, Mark W., Seth Hutchinson, and Mathukumalli Vidyasagar. Robot modeling and control. Wiley, 2006.

答:
Craig uses the modified DH parameters, while Spong uses the classic DH parameters.

The difference between them are the locations of the coordinates system attachment to the links: in the modified DH, the coordinates of frame $O_{i}$ is put on axis $i$, while in the classic DH convention the coordinates of frame $O_{i}$ is put on axis $i+1$.

Update (2014.10.26)

Reading Craig's book again, I noted that the modified DH matrix is also different because of the order of the applied transformations. I edited the Wikipedia link with the different DH matrix.

Title: Denavit-Hartenberg convention


问:
Motor for weapon for Hobbyweight
I am currently building a hobby-weight (5.44kg) robot. The weapon will be a vertical spinning disk at the front. It will probably be a commercial one from the hardware store or I could maybe get one made.

I have 2 cordless drill motors to drive my wheels so I should be ok there, but I am still lost where it comes to what motor I should get for my weapon. I am now inclined to think it should be brush-less although I am still open to other opinions.

Can anyone please recommend a good motor (in-line brush-less) or brushed motor that will give me the speed and strength I need for the weapon?

答:
I would start by looking at cordless power tools that do the job you want. It sounds like you want a lot of speed and power for cutting through another robot. Well, you want a cordless saw:

Don't forget the mount the motor so that when the saw hits the enemy, it throws the enemy upwards, and pushes your robot down. For this saw, it means having the motor on the right of your robot.

Added: OK, so you have a 5.44k weight limit. Well, there are a few smaller cordless saws available, like the Makita SH01W which weighs 1.5kg. By taking off some of the casing, you might get that down to 1.25kg. I wouldn't bother with a drill motor for the saw, as it wouldn't be fast enough. A saw really needs that kinetic energy to stop it getting stuck.

If you find yourself over the weight limit, and can't get under it, then you could go for a brushless motor. These have a better power:weight ratio than brushed motors, so you could save another 500g perhaps. But the downside is that you now have to spend time attaching it securely to the saw's gearbox. OK if you have the time, skill and equipment. But something to bear in mind.

Title: Motor for weapon for Hobbyweight


答: You should read this paper: "Lipkin 2005: A Note on Denavit-Hartenberg Notation in Robotics".  It explains the 3 main DH parameter conventions and how they differ.

Title: Denavit-Hartenberg convention

Body:
There are two different conventions that can determine DH parameters.   What is the difference between Craig's [1, Sec 3.4] convention and the Spong [2, Sec. 3.2] convention?
I know that both methods must have the same response.

[1]: Craig, John J. Introduction to robotics: mechanics and control. Addison-Wesley, 1989.

[2]: Spong, Mark W., Seth Hutchinson, and Mathukumalli Vidyasagar. Robot modeling and control. Wiley, 2006.


问:
How can I dynamically control the amount of torque necessary to rotate something for a test rig?
I'm looking to build a test rig for a robot that rotates a 1" diameter pipe 180º (roll not yaw or pitch). I am currently testing a motor's performance when subjected to various kinds of PWM (high duty cycle, low duty cycle, etc). I would like to characterize how this performs under various loads.

Is there a simple mechanical mechanism I can attach to a fixture and insert into or around the pipe that lets me control how easy or difficult it is to rotate?

I am thinking of something like a drill bit chuck that fits inside the pipe and expands or a circular clutch that clamps down around pipe to add resistance when one tightens a thumbscrew. I would like to go from no resistance to full stop for a 4N•m motor. I would like to be able to test how 'sticky' the pipe is using a torque wrench.

I imagine this would be very simple but I can't think of something that would do this!

答:
Well, the torque produced by a DC motor is proportional to the current running through it. Simply attach a DC motor to the end of the pipe, and control the current somehow.

The problem with this is that the torque is all in one direction. If you need to test your system in both directions, then you'll also need some way to reverse the direction of the current.

The other problem is that a DC motor's torque isn't perfectly constant as it rotates. If you need perfectly constant and controllable torque, then you'll the following will solve both problems:

Couple the motor to the pipe using a torque sensor. Use a PID controller to allow you to control the torque. This way you can control the torque accurately and very dynamically.


问:
How to read data from i2c using i2cget?
I'm new to embedded devices and am trying to understand how to use i2cget (or the entire I2C protocol really).

I'm using an accelerometer MMA8452, and the datasheet says the Slave Address is 0x1D (if my SAO=1, which I believe is referring to the I2C bus being on channel 1 on my raspberrypi v2).

From the command line, I enter

```<code>sudo i2cget -y 1 0X1d
</code>```

It returns

```<code>0X00
</code>```

I think that means I'm attached to the correct device.

So now, I'm trying to figure out how do I get actual data back from the accelerometer?

The i2c spec says

```<code>i2cget [-y] i2cbus chip-address [data-address [mode]]
</code>```

So I have tried

```<code>sudo i2cget -y 1 0x1D 0x01
</code>```

where 0x01 is the OUT_X_MSB. I'm not sure entirely what I'm expecting to get back, but I figured if I saw some data other than 0x00, I might be able to figure that out.

Am I using ic2get wrong? Is there a better way to learn and get data from i2c?

The datasheet for my accelerometer chip is at http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Accelerometers/MMA8452Q.pdf

答:
the Slave Address is 0x1D (if my SAO=1, which I believe is referring to the I2C bus being on channel 1 on my raspberrypi v2)

SA0 is actually a pin on the chip (pin 7 by the datasheet). Changing it's value allows you to specify the address, helping to avoid address clashes. So it depends on how you've connected that pin in your circuit.

From the datasheet:

The MMA8452Q's standard slave address is a choice between the two sequential addresses 0011100 and 0011101. The
  selection is made by the high and low logic level of the SA0 (pin 7) input respectively

If you have SA0 already set to '1' then it's probably worth looking at the values from all the data registers: 0x01 to 0x06. If the device is outputting low values it's possible the MSBs will be 0.

Title: How to read data from i2c using i2cget?


问:
Power switch and common ground on a battle robot
I am constructing a 5.44Kg Hobby-weight battle robot and one of the safety rules is that the robot must have a power switch that turns off power to the motors (and weapon).

The robot has three sub-systems; the drive motors (one battery), the weapon (another battery) and some lighting (a small 9 volt battery).

I have read that since all these will be connected to the same receiver it is important to have all the electronics sharing a common ground for everything to work properly.

Now I know that usually it is the "live" wire that is connected to the switch, but I was thinking of hitting two birds with one stone and connecting all the ground wires (rather than the live wires) to the switch. In this way I still turn off power and also have a common ground. In terms of safety (shorts) etc I am not too concerned because I am using XT 60 connectors and have been careful to use only female plugs for the power leads (so no prongs are visible).

It seems to me that it should work and still be safe enough especially since I am not dealing with mains voltage levels here, but on the other hand I don't want to look stupid.

Does this way of connecting to the switch make sense or am I violating some unwritten law? Is this normal practice? Would it effect the circuitry in any way to have the grounds connected together?

I was also thinking of using a switch from a PC power supply; as far as I know this is rated for reasonably high currents. In my case I will have 3 cordless motors, each of which might be drawing up to 5 amps when under load, so say 15 amps in all. Has anyone out there ever used such switches or did you buy high current ones? In that case what should I ask for?

Thanks.

答:
I can say:"Yes it works"

Are there any recommendation not doing this? I cannot say, but it works.

The problem you may get is with a weak design. You have to be sure, that there is not any switch/sensor/relay/wire which is able to bypass the main switch.

I'm not sure whether the PC-switch will work, because a computer usually has a power consumption of less then 1000W. This means a current of around 5Amps (10Amps for the US).

If you draw around 20Amps, this may exceed the capability of the switch.

I suggest using an EMO switch.They usually can handle currents of 50Amps+ and it you know what to do with something went wrong. Just Smash it.


问:
gazebo import robot gives error
I'm trying to import the tutorial robot given at this link

However this gives the following error:

```<code>Error [Param.cc:181] Unable to set value [1,0471975511965976] for key[horizontal_fov]
Error [Param.cc:181] Unable to set value [0,100000001] for key[near]
Error [parser_urdf.cc:2635] Unable to call parseURDF on robot model
Error [parser.cc:278] parse as old deprecated model file failed.
Error [parser_urdf.cc:2635] Unable to call parseURDF on robot model
Error [parser.cc:278] parse as old deprecated model file failed.

Error [parser.cc:278] parse as old deprecated model file failed.
</code>```

This sugest something is wrong with parsing but does not actually point towards any line of my code (the example is only 103 lines long).

```<code>    <link name='chassis'>
      <pose>0 0 .1 0 0 0</pose>
      <collision name='collision'>
        <geometry>
          <box>
            <size>.4 .2 .1</size>
          </box>
        </geometry>
      </collision>

      <visual name='visual'>
        <geometry>
          <box>
            <size>.4 .2 .1</size>
          </box>
        </geometry>
      </visual>

      <collision name='caster_collision'>
        <pose>-0.15 0 -0.05 0 0 0</pose>
        <geometry>
          <sphere>
          <radius>.05</radius>
        </sphere>
      </geometry>

      <surface>
        <friction>
          <ode>
            <mu>0</mu>
            <mu2>0</mu2>
            <slip1>1.0</slip1>
            <slip2>1.0</slip2>
          </ode>
        </friction>
      </surface>
    </collision>

    <visual name='caster_visual'>
      <pose>-0.15 0 -0.05 0 0 0</pose>
      <geometry>
        <sphere>
          <radius>.05</radius>
        </sphere>
      </geometry>
    </visual>
  </link>
  <link name="left_wheel">
    <pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
    <collision name="collision">
      <geometry>
        <cylinder>
          <radius>.1</radius>
          <length>.05</length>
        </cylinder>
      </geometry>
    </collision>
    <visual name="visual">
      <geometry>
        <cylinder>
          <radius>.1</radius>
          <length>.05</length>
        </cylinder>
      </geometry>
    </visual>
  </link>

  <link name="right_wheel">
    <pose>0.1 -0.13 0.1 0 1.5707 1.5707</pose>
    <collision name="collision">
      <geometry>
        <cylinder>
          <radius>.1</radius>
          <length>.05</length>
        </cylinder>
      </geometry>
    </collision>
    <visual name="visual">
      <geometry>
        <cylinder>
          <radius>.1</radius>
          <length>.05</length>
        </cylinder>
      </geometry>
    </visual>
  </link>
  <joint type="revolute" name="left_wheel_hinge">
    <pose>0 0 -0.03 0 0 0</pose>
    <child>left_wheel</child>
    <parent>chassis</parent>
    <axis>
      <xyz>0 1 0</xyz>
    </axis>
  </joint>

  <joint type="revolute" name="right_wheel_hinge">
    <pose>0 0 0.03 0 0 0</pose>
    <child>right_wheel</child>
    <parent>chassis</parent>
    <axis>
      <xyz>0 1 0</xyz>
    </axis>
  </joint>
  </model>
</sdf>
</code>```

This is on ubuntu 14.04. Is there any hint at what I'm doing wrong or what information can I provide to better come to a solution

答: I found the solution, I should just have looked better at the tutorial as I missed a few lines of code. </p>

Title: gazebo import robot gives error


问:
Image processing in bright lights
We are working on a project which requires us to detect and hit a ball. We are trying to accomplish the task by detecting the position of ball by processing the input from a camera. The problem is that we are required to do this in very bright lights. The bright lights are making it difficult to detect the white colored ball.

Is there a way we can write the code such that it automatically reduces the intensity of lights in the image?

Is there an efficient way to extract only the V component from the HSV image?

We have very limited experience with image processing so any alternative approach to detecting the object will also be helpful

答:
First, you need to identify whether your camera is up to the task or not. If the camera, seeing the very bright lights, just gives you a complete "white" for all different colors, there is absolutely nothing you can do in software to compensate for it.

That said, the first step is to adjust your camera. If you don't want to get in the coding yet, just take a photo of your bright lights with that camera, open it with gimp for example and reduce its brightness. If you as a human can start to distinguish the colors, then you can also do that in software. If reducing brightness simply gives you gray color, then the color information is simply lost at the time the camera took the photo.

Take this with a grain of salt though, as taking a photo with the camera and a video are different things.

Solution 1: If your camera is controllable, you might be able to change settings on it to reduce the sensor exposures to light before producing the image/video. This completely solves your problem, because then it's as if you are not in bright lights any more.

Solution 2: If you can distinguish colors, even if barely, then you can process the image by your own software and reduce the brightness. For this, you need to convert the format of the image received by your camera to HSL and then reduce the Lightness before converting it back to the format your image processing algorithm understands. If your camera outputs RGB for example, you can search for "RGB to HSL" on the internet for code in many languages freely available.

Title: Image processing in bright lights


问:
How to control an Arduino Board with wireless PS3 controler?
I'm currently building a hexapod bot, composed with an Arduino Mega board and an USB SSC-32 (from Lynxmotion).
But now I want add a PS3 wireless controller to move my hexapod, I have made some search but nothing realy interesting. Maybe the Servoshock module but it seems works only with the ServoshockShield, a kind of Arduino card with Servo output.

Can I use the ServoShock module alone ?

Can I connect it with Rx/Tx port of the Arduino Mega board ?

Do you have other solution for me ? Board with documentation and sources codes ?

Thank you all

答: The ServoShock module works by itself, you just have to wire the connections.  If you use the shield, it's plug and play.  You can pull the button/axes states and write servo position outputs using the SPI bus, there's a Arduino library at the ServoShock documentation page at www.servoshock.com.</p>


问:
kinect - development kit to aid obstacle-avoiding robot?
Some friends and I are interested in working on a robot. I know little to nothing about robotics, but do have a lot of experience with programming. Before we start, I am hoping that I can find some development kits or libraries that will help aid the goals of the robot. Which are:

Robot needs to move from point A to point B. While moving, it needs to detect rocks (approx. 1 foot diameter) on ground. It needs to detect rocks that are big enough to stop it, turn away from them, and proceed.

In theory, we will want to detect the kinect's angle via the accelerometers, and use that data to obtain Cartesian coordinates of the ground from the kinect's sensors. Later, we will want a way to assemble a 'map' in the robot's memory so that it can find better paths from A to B.

Right now we aren't concerned with the motors on the robot - only the vision element. Ie, I am not really interested in software that interfaces with the motors of the robot, only only something that interfaces with the kinect.

答:
You should start here
http://wiki.ros.org/gmapping
Or if you are unfamiliar with ROS, start doing the beginner tutorials.
After that set up your Robot and install ROS on it.
gmapping will automatically build a map of your room as you move the robot around.

Finally after having a map file, all you need is to set up the navigation
http://wiki.ros.org/navigation

There you will see the robot in your map and can tell it to go to any point inside that map.

It will use the global map of your room for global path planning and then if it encounters an obstacle on the way it will detect it using the kinect (or any other sensors like sonar or PSD) and replan a new path.


问:
Motor controller calibration
I bought 2 brushed motor controllers from China to use with my hobby-weight battle robot  (http://www.banggood.com/ESC-Brushed-Speed-Controller-For-RC-Car-Truck-Boat-320A-7_2V-16V-p-915276.html).

These are intended for use with my 2 cordless drill motors which will be driving the left and right wheel respectively. The robot will therefore be steered in "tank mode" by varying the speed and direction of rotation of the 2 motors using the two joysticks on my Turnigy 9x transmitter.

My question is: I have seen videos on youtube where people calibrate brushless motor controllers (ESCs) using some system of pushing the joystick on a standard transmitter forward and listening to tones and then doing the same for reverse and so on.

However when I asked the suppliers about a similar procedure for these brushed controllers, all they could say is that they did not need calibration. The exact words were "It seems that you're talking about transmitter for copters,but this ESC is for RC car or boat. You pull the trigger, it goes forward, you push the trigger, it reverse. And you don't need to calibrate it, just plug it, then it can work."

My transmitter is not one of those gun shaped ones used for cars. So am I in trouble with these controllers or should they work correctly out of the box as the supplier seems to be implying?

You may fairly ask why have I not just tried this out and the simple answer is that my LIPO charger has not yet arrived and I therefore cannot power anything up as yet.

答:
The calibration in other ESCs is used to compensate for different ranges of the input that different transmitters/receivers produce -- if you push the throttle all the way forward, your system will generate some width of PWM pulses. This might not be identical to full throttle on other system, so you can calibrate to use the full range of the ESC.

It should definitely not be critical to calibrate the range.

Title: Motor controller calibration


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

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

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

Normalize the weights

Multiply each weight by the total number of particles

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

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

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

答:
For an example of python code that properly implements resampling, you might find this github project to be useful:
https://github.com/mjl/particle_filter_demo

Plus, it comes with its own visual representation of the resampling process, that should help you debug your own implementation.

In this visualization, the green turtle shows the actual position, the large grey dot shows the estimated position and turns green when it converges.  The weight goes from likely (red) to unlikely (blue).

Title: Particle filters: How to do resampling?


问:
Changing tank drive (differential) mode to single joystick drive mode
I bought 2 brushed motor controllers from China to use within my hobby-weight battle robot (http://www.banggood.com/ESC-Brushed-Speed-Controller-For-RC-Car-Truck-Boat-320A-7_2V-16V-p-915276.html).

These are intended for use with my 2 cordless drill motors which will be driving
the left and right wheel respectively. The robot will therefore be steered in
"tank mode" by varying the speed and direction of rotation of the 2 motors using
the two joysticks on my Turnigy 9x transmitter.

I am seeking to refine the model and make it easier to operate so does anyone know of a way in which I can somehow synchronize the motors to get a single joystick steering system?  My transmitter has 9 available channels so if this is part of a solution then I am fine with it. I also have an Arduino available if needs be.

答:
It depends on what transmitter you use, but I would try to find settings for channel mixing on it.

You should mix +throttle input to +left and +right output and + turn to -right and +left.


问:
Is the input of ESC really limited at 50 Hz and will the PID controllers work properly?
Based on the wiki page of ESC, the ESC generally accepts a nominal 50 Hz PWM servo input signal whose pulse width varies from 1 ms to 2 ms

http://en.wikipedia.org/wiki/Electronic_speed_control

For our project, we integrate a flight controller for our UAV, Naza m-lite and we want to implement position control. We already have localization and we can control the quadrotor by applying servo width to roll, pitch, yaw and thrust throttle. Since the ESC only accepts 50 Hz, will the PID controller work at only 50 Hz?

答:
First things first: the information on wikipedia refers to ESCs in general, and not a specific one.  You should consult the datasheet on your particular ESC model to make sure that it does in fact use 50 Hz.

You also seem to have a misconception about how the PID controller and ESC are coupled together; in fact, the PID controller can work at whatever frequency it wants.  The output of the PID will be some value, and in order to send that value to the ESC you will need to convert it to a pulse-width modulated (PWM) signal on the frequency that the ESC uses for input.


答:
The issue you're running into is often referred to as sample impoverishment. We can see why your approach suffers from it with a fairly simple example. Let's say you have 3 particles and their normalized weights are 0.1, 0.1, 0.8. Then multiplying by each weight by the 3 yields 0.3, 0.3, and 2.4. Then rounding yields 0, 0, 2. This means you would not pick the first two particles and the last one would be picked twice. Now you are down to two particles. I suspect this is what you have been seeing when you say "due to the roundoff errors, I end up having less particles."

An alternative selection method would be as follows.

Normalize weights.

Calculate an array of the cumulative sum of the weights.

Randomly generate a number & determine which range in that cumulative weight array to which the number belongs.

The index of that range would correspond to the particle that should be created.

Repeat until you have the desired number of samples.

So, using the example above we would start with the normalized weights. We would then calculate the array [0.1, 0.2, 1]. From there we calculate 3 random numbers say 0.15, 0.38, and 0.54. This would have us pick the second particle once and the third particle twice. The point is that it gives the smaller particles a chance to propagate.

One thing to note is that while this method will deal with impoverishment it can lead to a suboptimal solutions. For instance, it may be that none of the particles really match your given location well (assuming you're using this for localization). The weights only tell you which particles match best, not the quality of the match. As such when you take additional readings and repeat the process you may find that all your particles group at a single location that is not the correct location. This is usually because there were no good particles to start.

Title: Particle filters: How to do resampling?

Body:
I understand the basic principle of a particle filter and tried to implement one. However, I got hung up on the resampling part.

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

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

Normalize the weights

Multiply each weight by the total number of particles

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

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

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