答:
You may be getting ahead of yourself; this seems to be a mostly photography-based question.  It sounds like you have a setup like this:

```<code>light source -> scene with ball -> camera -> computer -> ball-hitting program
</code>```

You should be troubleshooting this from left to right, starting with the light source (which it sounds like you already did -- it can't be changed).

The next step would be to see if you can change the scene itself -- use a different ball color to hopefully get more contrast.

If that's not possible, see if the camera settings can be adjusted to make the ball easier to see (in other words, look through the camera yourself to see whether the image is OK).

And if the camera can't be improved, then you'd be stuck with writing some image pre-processing code to somehow turn up the contrast to the point where you can see the ball.

Title: Image processing in bright lights

Body:
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

Body:
You may be getting ahead of yourself; this seems to be a mostly photography-based question.  It sounds like you have a setup like this:

light source -> scene with ball -> camera -> computer -> ball-hitting program

You should be troubleshooting this from left to right, starting with the light source (which it sounds like you already did -- it can't be changed).

The next step would be to see if you can change the scene itself -- use a different ball color to hopefully get more contrast.

If that's not possible, see if the camera settings can be adjusted to make the ball easier to see (in other words, look through the camera yourself to see whether the image is OK).

And if the camera can't be improved, then you'd be stuck with writing some image pre-processing code to somehow turn up the contrast to the point where you can see the ball.


问:
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.

答:
In order to do this, you need to have something on the robot that can intercept your "single joystick" signal from the remote control and translate it to left/right wheel speeds.  Your arduino might be able to serve this purpose, with the appropriate shield.

For that calculation, check out this question on calculating left and right motor speeds based on desired throttle and direction.

ContentLicense: CC BY-SA 3.0


问:
Risk of overloading motor controller
I bought 2 brushed motor controllers from China for 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 14.4v motors which will be driving the left and right wheel respectively.

I will be using 4S LIPOs which (when fully charged) have a voltage of 16.8V. Can someone put my mind at rest that the .8 volt excess is unlikely to damage the controller (which is rated for 7.2v - 16v)?

Also is the fact that the motor controllers are rated for 320Amp likely to damage my motors?

I am to be honest not very clear on current and how this is drawn from a LIPO battery. For instance would connecting a LIPO directly to my motor result in a massive discharge or does the motor just "take what it needs" in terms of current? Can someone maybe kindly point me to an article which casts some light on the subject or even more kindly explain it to me here?

答:
No, you should not exceed the voltage rating of the controller -- it's there for a reason.

If the motor itself is rated for 16.8 VDC (or more) then there is no problem connecting it directly to the battery.

If you have questions about electronics specifically, you should post them on the stackexchange site for electronics.

Title: Risk of overloading motor controller


问:
Proportional controller error doesn't approach zero
I'm reading this pdf. The dynamic equation of one arm is provided which is

$$
l \ddot{\theta} + d \dot{\theta} + mgL sin(\theta) = \tau
$$

where

$\theta$ : joint variable.

$\tau$ : joint torque

$m$ : mass

$L$ : distance between centre mass and joint.

$d$ : viscous friction coefficient

$l$ : inertia seen at the rotation axis.

I would like to use P (proportional) controller for now.

$$
\tau = -K_{p} (\theta - \theta_{d})
$$

My Matlab code is

```<code>clear all
clc

t = 0:0.1:5;

x0 = [0; 0];

[t, x] = ode45('ODESolver', t, x0);

e = x(:,1) - (pi/2); % Error theta1

plot(t, e);
title('Error of \theta');
xlabel('time');
ylabel('\theta(t)');
grid on
</code>```

For solving the differential equation

```<code>function dx = ODESolver(t, x)

dx = zeros(2,1);
%Parameters:

m  = 2;
d  = 0.001;
L  = 1;
I = 0.0023;
g  = 9.81;

T = x(1) - (pi/2);

dx(1) = x(2);

q2dot = 1/I*T - 1/I*d*x(2) - 1/I*m*g*L*sin(x(1));

dx(2) = q2dot;
</code>```

The error is

My question is why the error is not approaching zero as time goes? The problem is a regulation track, so the error must approach zero.

答:
If you're only using proportional force, then at some point it will be balanced by the force of gravity -- your error will converge on that balance, not zero.

To compensate for the mass of the arm, you'll need to add an integral force term.  This will increase over time to counterbalance the constant force of gravity.

See also: this answer on the integral term.

ContentLicense: CC BY-SA 4.0


问:
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.

答:
It shouldn't be a problem; when working on cars, it's customary to disconnect the negative terminal of the battery.  This is because the entire chassis of the car is connected to that terminal -- if you were taking off the positive terminal first and your wrench came in contact with any part of the chassis, you'd short something out.  So it's not a terrible idea in terms of positive/negative.

Based on your setup however, you would need to be very careful that the wiring between the switch (attached to a common ground) and the 3 batteries that it connects to will be protected from ever coming in contact with any other ground points (like the frame).  If that happens, the switch will effectively be bypassed and you'll have an out-of-control robot on your hands.

You may want to look for relay-based kill switches if you need to switch a lot of current.


问:
How to convert vertical motion to horizontal?
I am interested in using this miniature motor Squiggle Micro Motor to create very tiny horizontal movements. However, due to very limited space, I can only place it vertically within my project.

Assuming this motor is placed as follows, how can one adapt it to simultaneous movement at a right angle? (Ideally with the X-axis movement matched to the Y-axis movement as well as possible.)

答: Scott-Russell type mechanism. For weeks I was trying to come up with a solution for that exact problem for a engineering project mine. Look it up.</p>


问:
Parameter $r$ of Denavit-Hartenberg
By watching this video which explains how to calculate the classic Denavit–Hartenberg parameters of a kinematic chain, I was left with the impression that the parameter $r_i$ (or $a_i$) will always be positive. </p>

<p>Is this true? If not, could you give examples where it could be negative? </p>

答:
I think this is true.  Although I don't have a formal proof.  I haven't read the original Denavit–Hartenberg paper, but this paper: "Lipkin 2005: A Note on Denavit-Hartenberg Notation in Robotics" explains the 3 main DH parameter conventions and how they differ.  It breaks down each of the 4 parameters into vector forms.  Specifically:

$$
a_2 = \vec{{O}_1 {O}_2} \cdot {x}_2
$$
Where $\vec{{O}_1 {O}_2}$ is the vector between the two frames.  The dot product can be negative, but only if the angle is greater than 90 degrees.  But because of the strict way you construct the frames, I don't think that can happen.

Title: Parameter $r$ of Denavit-Hartenberg


问:
Using i2c's SCL and GPIO pins as SDA
The beaglebone black which I work on has only 2 i2c busses. Say for some crazy reason, i need to use 8 i2c busses. I dont want to chain any of the devices. The idea is to have every device's SDA line separated and use a shared SCL line so i can use the same clock and have as many SDA lines as i want. Since the SCL clock is hardware controlled there wont be any major issues here. The GPIO can do around 2.5mhz of switching so I am happy with that.

If that works out, i can spawn 8 threads to talk on 8 i2c Lines making my solution faster!

Do you think its doable? I would like to hear from you guys as this idea of using 1SCL and GPIO as SDA just popped in my head and i thought of sharing it with you guys.

Cheers!

答:
Unless your I2C hardware components have the ability to use an external clock to drive the clock line of the buses (none that I've heard of), you wouldn't be able to do this by hardware.

You could do this by manually driving the buses. This is called bit-banging. If you do that, you can carefully craft your software driving GPIO pins that act as I2C buses and manage all 8 buses in parallel. You would most likely want to do the bit banging by interrupts.

You can have your piece of software having 8 (global) variables (of a struct) that tell if and what needs to be written to each I2C and if and how much needs to be read as response. Regardless of hardware I2C or software-emulated, this step is actually necessary anyway.

In your bit-banging piece of software, here are some things to look out for:

If at least one bus needs to read/write data, drive the clock.

If parallel threads want to write to the variables, make sure to write them in the correct order and take care of synchronization.

For example:

```<code>/* bus 3 wants to write and read something */
i2c_data[3].address = some_address;
memcpy(i2c_data[3].to_write, whatever, 10);
i2c_data[3].expect_to_read = 5;
atomic_set(i2c_data[3].new_data);
</code>```

where new_data, a flag that the I2C emulation software checks for to know if there is something new to do, is written last and atomically.

If any of the buses wants to start or stop, generate their respective start or stop condition and make sure there is enough setup and hold time before you continue clocking.

If any bus results in a NACK, make sure to at least note it, if not stopping that particular bus.

Of course, this is to make 8 parallel unrelated I2C buses. If your application needs to talk with 8 of the same kind of device, then your bit-banging software would be simpler, since they all start and stop at the same time, even if their data and ACKs are managed separately.

Note that the I2C emulation software is not replicated per thread, but is one managing all of them at the same time.

While I'm always up for using the hardware in ways beyond most people's wildest imagination to get it to do something better or faster, I'd advise you to study your problem a bit more, do some calculations to make sure you actually want to do this.

Emulating hardware through software is very error-prone and slower by an order, there are very many edge cases and needs thorough testing. In short, it's a time-consuming job. Being slower than hardware also means that there is a point where it starts to become beneficial and you need to find that point. Since you have 8 devices and 2 I2C hardware components, you can attach 4 devices to each bus and you need to study if your implementation would actually be faster than that.

You may also think of changing your hardware. A Cypress PSoC for example lets you put as many components as you want (and there is space and resources on the chip) so for example you could put 4 I2C buses (if 8 wasn't possible) and attach 2 devices to each bus. With a PSoC and knowledge in verilog, you can also write your own 8-device I2C bus component implemented in hardware.

Alternatively, you could also think of changing your bus. I2C is a very strict protocol designed to ensure error handling with each byte as well as prevent component cross-talk. You might not need that much restriction and for example you could check the data with CRC so you may not care for intermediate errors.

You could use an SPI bus, which is much simpler and thus easier to emulate. As a bonus, you don't need to be working with an open-drain data bus (as in I2C) which means you can get to speeds that are much higher than I2C. Common support for I2C buses go up to 400Kbps (newer ones go higher) but common devices supporting SPI bus can easily go up to 4Mbps.

That said, talking serially to 8 devices on an SPI bus @4Mbps could indeed be faster than talking to 8 devices in parallel on I2C buses @400Kbps (depending on the protocol). Again, this is something you would need to assess to see which option is more beneficial to you.

Title: Using i2c's SCL and GPIO pins as SDA

Body:
Unless your I2C hardware components have the ability to use an external clock to drive the clock line of the buses (none that I've heard of), you wouldn't be able to do this by hardware.

You could do this by manually driving the buses. This is called bit-banging. If you do that, you can carefully craft your software driving GPIO pins that act as I2C buses and manage all 8 buses in parallel. You would most likely want to do the bit banging by interrupts.

You can have your piece of software having 8 (global) variables (of a struct) that tell if and what needs to be written to each I2C and if and how much needs to be read as response. Regardless of hardware I2C or software-emulated, this step is actually necessary anyway.

In your bit-banging piece of software, here are some things to look out for:

If at least one bus needs to read/write data, drive the clock.

If parallel threads want to write to the variables, make sure to write them in the correct order and take care of synchronization.

For example:

/* bus 3 wants to write and read something */
i2c_data[3].address = some_address;
memcpy(i2c_data[3].to_write, whatever, 10);
i2c_data[3].expect_to_read = 5;
atomic_set(i2c_data[3].new_data);

where new_data, a flag that the I2C emulation software checks for to know if there is something new to do, is written last and atomically.

If any of the buses wants to start or stop, generate their respective start or stop condition and make sure there is enough setup and hold time before you continue clocking.

If any bus results in a NACK, make sure to at least note it, if not stopping that particular bus.

Of course, this is to make 8 parallel unrelated I2C buses. If your application needs to talk with 8 of the same kind of device, then your bit-banging software would be simpler, since they all start and stop at the same time, even if their data and ACKs are managed separately.

Note that the I2C emulation software is not replicated per thread, but is one managing all of them at the same time.

While I'm always up for using the hardware in ways beyond most people's wildest imagination to get it to do something better or faster, I'd advise you to study your problem a bit more, do some calculations to make sure you actually want to do this.

Emulating hardware through software is very error-prone and slower by an order, there are very many edge cases and needs thorough testing. In short, it's a time-consuming job. Being slower than hardware also means that there is a point where it starts to become beneficial and you need to find that point. Since you have 8 devices and 2 I2C hardware components, you can attach 4 devices to each bus and you need to study if your implementation would actually be faster than that.

You may also think of changing your hardware. A Cypress PSoC for example lets you put as many components as you want (and there is space and resources on the chip) so for example you could put 4 I2C buses (if 8 wasn't possible) and attach 2 devices to each bus. With a PSoC and knowledge in verilog, you can also write your own 8-device I2C bus component implemented in hardware.

Alternatively, you could also think of changing your bus. I2C is a very strict protocol designed to ensure error handling with each byte as well as prevent component cross-talk. You might not need that much restriction and for example you could check the data with CRC so you may not care for intermediate errors.

You could use an SPI bus, which is much simpler and thus easier to emulate. As a bonus, you don't need to be working with an open-drain data bus (as in I2C) which means you can get to speeds that are much higher than I2C. Common support for I2C buses go up to 400Kbps (newer ones go higher) but common devices supporting SPI bus can easily go up to 4Mbps.

That said, talking serially to 8 devices on an SPI bus @4Mbps could indeed be faster than talking to 8 devices in parallel on I2C buses @400Kbps (depending on the protocol). Again, this is something you would need to assess to see which option is more beneficial to you.


问:
tracking robot in a room
I'm trying to track a simple robot (e.g. arduino, raspberry pi, even toys) in a room using fixed location kinect sensor(s) and cameras at different parts of the room.  How might one usually use to do this?

Edit 1:  More specifically, I want to know the position (and if possible, orientation) of an moving object in the room using one or more cameras or depth sensors.  I'm new to the area, but one idea might be to use blob or haar to detect the moving object and get its location from kinect depth-map, and I'm trying to find what package I can use for that end.  But for navigation to work I'd have to pre-map the room manually or with kinect.  I can put some sensors on this tracked moving object, e.g. IMU, sonar, but not a kinect.  I am allowed full PCs running ROS/opencv/kinect sdk in the environment, and I can wirelessly communicate with the tracked object (which is presently a raspberry pi running ROS groovy on wheels)

答:
With fixed cameras, background subtraction will get you 90% of the way there.  (Assuming you don't have lots of other moving things around your room).

You should consider tagging your robot with color blobs like they do for RoboCup SSL.  Color segmentation is easy, and can be made to be very fast.

But then you need to write some custom code to recover the pose of your robot.  If you put more standard fiducials on the robot like ARTags, then you get this pose directly.

But then you need potentially large and ugly fiducials on the robot.  If you go with a motion capture system like Vicon or OptiTrack, you only need put some small IR retroreflective markers on the robot.  Then you get the pose of your robot with mm accuracy at hundreds of Hz.

Title: tracking robot in a room


问:
I'd like to use gesture based input for my robot. What are the pros and cons between the Xtion Live and the Kinect?
As in the title, I'd like to implement gesture recognition on my robot and I'm looking for the pros and cons between the Kinect and the Xtion - and also if there are any other sensible options available.

I'm thinking of the following, but open to other suggestions:

Accuracy

Price

Driver quality

Power draw

答:
More driver details:

OpenNI or freenect can be used with the Xtion and the XBox Kinect.

The "Kinect for Windows" requires the Microsoft SDK and drivers. However, there is also a bridge to go from the MSSDK drivers to OpenNI: http://code.google.com/p/kinect-mssdk-openni-bridge/

Also, the latest version of the Kinect for Windows (>=1.5) has a near mode that allows for better operation close to the device, this may be of use depending on the application. I do not believe the Xtion has this mode.

The XBox Kinect and Kinect for Windows appear to have different USB interfaces, so you have to use the right set of drivers depending on which one you have.


问:
Brush-less motor specs vs efficiency for multi-copters
I am looking for some figures surrounding the specs of brushless motors and their relative efficiency (in power usage terms) for multi-copter use.

There are 4 basic specs for motors themselves:
 - Motor width (EG 28mm)
 - Motor height (EG 30mm)
 - "KV" - RPM per volt supplied (EG 800KV)
 - wattage (eg 300w)

This would then be a 28-30 800kv 300w motor.

What i am looking for is a chart containing:
 - Motor spec
 - pack voltage (eg 14.8v)
 - Amps drawn @ various % throttle (10% to 100% say)
 - static thrust from various propellers (11x5, 12x6 etc etc)

Does such information exist?
I know its a BIT subjective as prop and motor designs vary slightly, but a baseline would be a start.

答: You can use the eCalc Multicopter Calculator. You select a set of motors, propellers and battery size and the program will output lots of data: Thrust, Motor efficiency at hover, Current and Voltage at hover, Motor efficiency at maximum power, Current and Voltage at maximum power, etc.</p>


问:
Does RoboRIO support Java 8?
My FRC team will recently upgrade from  CompactRIO  to RoboRIO.

CompactRIO only supports up to Java 1.4.
What version of Java does RoboRIO?

答:
Yes it supports Java 8 Embedded.

Which basically is Java 8 SE without any graphical library support (because the RoboRio is headless).

Beta teams using Java are currently using Java 8 Embedded for Arm as the JVM on the RoboRio, and Eclipse as the IDE with WPILib provided plugins for project development.

Title: Does RoboRIO support Java 8?


答:
The programm you are searching for is http://www.drivecalc.de/

They have all the common motors with lot of data... some "special" motors you won't find there

Title: Brush-less motor specs vs efficiency for multi-copters

Body:
I am looking for some figures surrounding the specs of brushless motors and their relative efficiency (in power usage terms) for multi-copter use.

There are 4 basic specs for motors themselves:
 - Motor width (EG 28mm)
 - Motor height (EG 30mm)
 - "KV" - RPM per volt supplied (EG 800KV)
 - wattage (eg 300w)

This would then be a 28-30 800kv 300w motor.

What i am looking for is a chart containing:
 - Motor spec
 - pack voltage (eg 14.8v)
 - Amps drawn @ various % throttle (10% to 100% say)
 - static thrust from various propellers (11x5, 12x6 etc etc)

Does such information exist?
I know its a BIT subjective as prop and motor designs vary slightly, but a baseline would be a start.


答:
I would like to use P (proportional) controller for now.

Just a proportional controller will never make your error stay at 0. Your system is not damped and a proportional controller acts like an undamped spring. Look at the controller equation that you wrote:

τ=−K(θ−θd)

and compare it to a spring equation:

```<code>F=Kx or F=K(x1-x2)
</code>```

Your controller is acting like a spring, putting torque on the joint proportionally to it's deviation from the reference. You must use at least a PI (proportional and integrating) controller to get rid of the oscillation.

The integrating part of the controller is what makes the oscillations go away and make the steady state error approach 0. It will make your system a bit slower, but you'll have to tune the controller to behave the way you want, faster response means typically more overshoot and vice versa.

If you really need to use a P controller, you have to include a damper on the system.

Title: Proportional controller error doesn't approach zero

Body:
I'm reading this pdf. The dynamic equation of one arm is provided which is

$$
l \ddot{\theta} + d \dot{\theta} + mgL sin(\theta) = \tau
$$

where

$\theta$ : joint variable.

$\tau$ : joint torque

$m$ : mass

$L$ : distance between centre mass and joint.

$d$ : viscous friction coefficient

$l$ : inertia seen at the rotation axis.

I would like to use P (proportional) controller for now.

$$
\tau = -K_{p} (\theta - \theta_{d})
$$

My Matlab code is

```<code>clear all
clc

t = 0:0.1:5;

x0 = [0; 0];

[t, x] = ode45('ODESolver', t, x0);

e = x(:,1) - (pi/2); % Error theta1

plot(t, e);
title('Error of \theta');
xlabel('time');
ylabel('\theta(t)');
grid on
</code>```

For solving the differential equation

```<code>function dx = ODESolver(t, x)

dx = zeros(2,1);
%Parameters:

m  = 2;
d  = 0.001;
L  = 1;
I = 0.0023;
g  = 9.81;

T = x(1) - (pi/2);

dx(1) = x(2);

q2dot = 1/I*T - 1/I*d*x(2) - 1/I*m*g*L*sin(x(1));

dx(2) = q2dot;
</code>```

The error is

My question is why the error is not approaching zero as time goes? The problem is a regulation track, so the error must approach zero.

Body:
I would like to use P (proportional) controller for now.

Just a proportional controller will never make your error stay at 0. Your system is not damped and a proportional controller acts like an undamped spring. Look at the controller equation that you wrote:

τ=−K(θ−θd)

and compare it to a spring equation:

F=Kx or F=K(x1-x2)

Your controller is acting like a spring, putting torque on the joint proportionally to it's deviation from the reference. You must use at least a PI (proportional and integrating) controller to get rid of the oscillation.

The integrating part of the controller is what makes the oscillations go away and make the steady state error approach 0. It will make your system a bit slower, but you'll have to tune the controller to behave the way you want, faster response means typically more overshoot and vice versa.

If you really need to use a P controller, you have to include a damper on the system.


问:
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?

答:
On the video you've linked the reference(x desire) is distance and the feedback variable is also distance, what is different is the input to the system which is force. The magic happens inside the PID where the fine tuning of the gains, which are commonly regarded as abstract values, makes the system behave the way you want. </p>

<p>So you can only compare variables of the same units to input the error to the PID, the PID will take care of calculating the right value no matter what units the input to the system is in. </p>

Title: A general question about PID Controller

Body:
On the video you've linked the reference(x desire) is distance and the feedback variable is also distance, what is different is the input to the system which is force. The magic happens inside the PID where the fine tuning of the gains, which are commonly regarded as abstract values, makes the system behave the way you want.

So you can only compare variables of the same units to input the error to the PID, the PID will take care of calculating the right value no matter what units the input to the system is in.


问:
How to control PID Yaw
My yaw angle varies from -180 degree to 180 degree.

```<code>                                        -170 170
                                   -135            135
                                 -90                  90
                                      45           45
                                          10 -10
</code>```

If my current heading is about 170 degree, then the wind makes it rotate to the left at about -170 degree, then how can PID control it to make it rotate back to the right at 170 degree.

Since, for PID   ERROR = SETPOINT - INPUT
In my case, SETPOINT = 170, and INPUT = -170, the the ERROR = 170 - (-170) = 340.
So instead of moving to the right and apply PWM = 20, it rotate to the left and apply PWM = 340 and come back to the desired position, which is 170 degree?

答:
While the books give general formulas, you need to have enough understanding to adjust them based on your specific application. The textbook definition of error is:

```<code>error = goal - position
</code>```

where position is your current state and goal is the state you wish you were at. While this definition is ok for a cartesian space, in others, as you have observed, is not the best thing.

With your own system, where the goal and position are angles, you have in fact infinite possible values for error.

$goal = 2k'\pi+\alpha$

$position = 2k''\pi + \beta$

and therefore:

$error = 2k\pi + (\alpha - \beta)$

In your case, the error could be 340, 700, 1060, -20, -380 etc. Clearly, depending on what value you choose for the error (all of which are correct), the controller behaves differently. If you choose 1060 over 340 for example, the controller thinks it's much farther from the goal and therefore tries to get to it in much more of a hurry.

You would usually want the minimum movement to reach your goal, so from the values above you would want to choose -20. That's quite easy. Simply choose the value of error in the range $[-\pi, \pi)$ (or $[-180, 180)$ if you want). That would have the minimum absolute value among the infinite choices.

Title: How to control PID Yaw

Body:
While the books give general formulas, you need to have enough understanding to adjust them based on your specific application. The textbook definition of error is:

error = goal - position

where position is your current state and goal is the state you wish you were at. While this definition is ok for a cartesian space, in others, as you have observed, is not the best thing.

With your own system, where the goal and position are angles, you have in fact infinite possible values for error.

$goal = 2k'\pi+\alpha$

$position = 2k''\pi + \beta$

and therefore:

$error = 2k\pi + (\alpha - \beta)$

In your case, the error could be 340, 700, 1060, -20, -380 etc. Clearly, depending on what value you choose for the error (all of which are correct), the controller behaves differently. If you choose 1060 over 340 for example, the controller thinks it's much farther from the goal and therefore tries to get to it in much more of a hurry.

You would usually want the minimum movement to reach your goal, so from the values above you would want to choose -20. That's quite easy. Simply choose the value of error in the range $[-\pi, \pi)$ (or $[-180, 180)$ if you want). That would have the minimum absolute value among the infinite choices.


答:
Shahbaz has the perfect explanation, the PID controller will not solve your problem by itself, what you have to do is figure out a piece of code that reads the angle and the reference, calculates the shortest distance from the reference to the current position and inputs it to the PID controller with the correct sign(+ or -). You can calculate the shortest distance by determining if where you want to go is less or more than 180º from where you are. The math would be simpler if you worked with angles between 0º and 360º because you wouldn't have to deal with negative angles.</p>

```<code>                      |Ref|--->|"piece of code"|--->|PID|--->|Plant|----->
                                      ^                               |
                                      |_______________________________|
</code>```

Title: How to control PID Yaw

Body:
My yaw angle varies from -180 degree to 180 degree.

```<code>                                        -170 170
                                   -135            135
                                 -90                  90
                                      45           45
                                          10 -10
</code>```

If my current heading is about 170 degree, then the wind makes it rotate to the left at about -170 degree, then how can PID control it to make it rotate back to the right at 170 degree.

Since, for PID   ERROR = SETPOINT - INPUT
In my case, SETPOINT = 170, and INPUT = -170, the the ERROR = 170 - (-170) = 340.
So instead of moving to the right and apply PWM = 20, it rotate to the left and apply PWM = 340 and come back to the desired position, which is 170 degree?

Body:
Shahbaz has the perfect explanation, the PID controller will not solve your problem by itself, what you have to do is figure out a piece of code that reads the angle and the reference, calculates the shortest distance from the reference to the current position and inputs it to the PID controller with the correct sign(+ or -). You can calculate the shortest distance by determining if where you want to go is less or more than 180º from where you are. The math would be simpler if you worked with angles between 0º and 360º because you wouldn't have to deal with negative angles.

                      |Ref|--->|"piece of code"|--->|PID|--->|Plant|----->
                                      ^                               |
                                      |_______________________________|


问:
NAO motor model identification
I am trying to create a model for the NAO [robot]'s motors. The figure below shows the step response for the knee motor. Afaik the NAO internally uses a pid controller to control the motor. I have no control over the pid or it's parameters. Thus I would like to treat the motor including pid as a black box. Theoretically it should be possible to model pid+motor as a $pt_2$ system, i.e. a second order lti system.
A $pt_2$ system is defined by the following differential equation:

$$T^2\ddot{y}(t) + 2dT\dot{y}(t)+y(t) = Ku(t)$$.

I tried fitting a $pt_2$ model but was unable to find good parameters.

Any idea what model to use for this kind of step response?

edit:
I tried modifying the equation to add a maximum joint velocity like this:

$$T^2\ddot{y}(t) + (\frac{2dT\dot{y}(t) + m - |2dT\dot{y}(t) - m|}{2})+y(t) = Ku(t)$$
where $m$ is the maximum velocity. The fraction should be equivalent to $min(2dT\dot{y}(t), m)$.

However I am not sure if this is the correct way to introduce a maximum joint velocity. The optimizer is unable to find good parameters for the limited velocity formula. I am guessing that is because the min() introduces an area where parameter changes do not cause any optimization error changes.

答:
Try something like:

```<code>if(angle'> max)
    angle'=max
else if(angle'< min)
    angle'=min
end
</code>```

Try 0.1 (and -0.1) for the max velocity of the servo, I came up with that value from the graph you showed.

Title: NAO motor model identification

Body:
Try something like:

if(angle'> max)
    angle'=max
else if(angle'< min)
    angle'=min
end

Try 0.1 (and -0.1) for the max velocity of the servo, I came up with that value from the graph you showed.


问:
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?

答:
As I guess you found out yourself, the resampling method you are proposing is slightly flawed, as it should not alter the number of particles (unless you want to). The principle is that the weight represents the relative probability with respect to the other particles. In the resampling step, you draw from the set of particles such that for each particle, the normalized weight times the number of particles represents the number of times that particle is drawn on average. In that your idea is correct. Only by using rounding instead of sampling, you will always eliminate particles for which the expected value is less than half.

There are a number of ways to perform the resampling properly. There is a nice paper called On resampling algorithms for particle filters, comparing the different methods. Just to give a quick overview:

Multinomial resampling: imagine a strip of paper where each particle has a section, where the length is proportional to its weight. Randomly pick a location on the strip N times, and pick the particle associated with the section.

Residual resampling: this approach tries to reduce the variance of the sampling, by first allocating each particle their integer floor of the expected value, and leave the rest to multinomial resampling. E.g. a particle with an expected value of 2.5 will have 2 copies in the resampled set and another one with an expected value of 0.5.

Systematic resampling: take a ruler with regular spaced marks, such that N marks are the same length as your strip of paper. Randomly place the ruler next to your strip. Take the particles at the marks.

Stratified resampling: same as systematic resampling, except that the marks on the ruler are not evenly placed, but added as N random processes sampling from the interval 0..1/N.

So to answer your question: what you have implemented could be extended to a form of residual sampling. You fill up the missing slots by sampling based on a multinonmial distribution of the reminders.

Title: Particle filters: How to do resampling?


问:
Selecting a gear reduction: torque vs speed
I have just sized the DC motors I want to use (corresponding to my robot and its intended applications - my figures include a 50% uncertainty factor to account for friction in reducers and other losses). Now I need to actually choose the exact motors I want to buy from the manufacturer (I am targeting maxon motors as I am not an expert and want no problem). I have a few down to earth questions about linking the mechanical needs to the electrical characteristics, among them:

Question #4:

The motor I chose (maxon brushed DC: 310005 found here) has nominal speed = 7630rpm - nominal torque = 51.6mNm. My needs are max speed = 50.42rpm / max torque = 10620 mNm. This means a reduction factor of 151 for speed and 206 for torque. Should I choose a gear closer to 151 or 206?

答: If you choose 151 you'll get the speed but won't get the torque, if you choose 206 you'll get the torque but won't get the speed. You can either play with your needs to be able to use that motor or use another higher torque/speed motor.</p>


问:
A robotics computer with graphics card, lots of computation power, battery, no screen, no keyboard?
I'm working on a robotics platform and we need an on-board Ubuntu machine to run ROS image recognition.

Does anyone know of a good set of computer hardware that has

NO screen

NO keyboard

Built-in battery (for charging separate from the robot)

Quite a bit of compute power (i5+, 4+ GB ram)

I thought about using a laptop, but the keyboard and screen are a lot of extra weight/volume I don't want to carry around. Something like an Intel NUC is appealing, but has no battery.

答:
Yes the Gigabyte Brix or the Intel NUC are the platforms you're searching for:
http://www.gigabyte.com/products/list.aspx?s=47&ck=104
http://www.intel.com/content/www/us/en/nuc/overview.html

I've looked extensively for computer for robots 2 months ago, I don't know if there is anything new since, but I don't know of any small computers with internal battery. You might have to make the power circuit yourself, or ask someone to make it.

ARM processors/computers are getting better everyday but you wont find anywhere near the support you'll find on an Intel based computer. Intel is tried and tested, plug and play.


问:
ROS NavStack with Skid Steering robots
I am migrating from a differential drive design to a skid steering design for my robot, and I want to know how easy would it be to use the NavStack with skid steering. Would there be any problems in terms of localization and things like that?

If I let two wheels on the same side of my robot (two on left side and two on the right side) maintain same velocity and acceleration, would the unicycle model of a differential drive robot still apply for skid steering?

答:
Yes and no.  I think it depends on your needs, and what other sensors you have.

Remember that even diff drive robot wheels slip a little.  And you can never measure the diameter of the wheel accurate enough.  This is why dead-reckoning doesn't work well over long distances.  And why you need other sensors to correct for these errors.

I haven't used the entire ROS Navigation Stack, but I have used parts of it with a skid steer robot.  (In my case I used a Hokuyo, robot_pose_EKF, laser_scan_matcher, and costmap_2d nodes among other custom nodes.)  My setup was enough for the robot to maintain a reasonable 2D location if it didn't drive too far.  But after a long time of driving around, the location and orientation would be way off.  I don't think doing any sort of SLAM mapping would have worked for me.  I found that the ICP algorithm in the laser_scan_matcher was critical to correcting the odometry errors when the robot would turn.

I should mention that I did not have an IMU to feed into the EKF, but i think that would have improved results greatly.  The diameter of my wheels was also way off.  (I would drive a meter, but the robot would think it was only 0.8 or so.)  So if you have better odometry, a laser, and an IMU, then you might be ok.  But i don't know what your application is...

Title: ROS NavStack with Skid Steering robots


问:
How can computer vision distinguish one object being contained by another vs being on top of it?
How do we know that an object is contained inside another object or is just lying on top of it?

Lets take an example of a cup-plate-spoon. The cup is lying on top of the plate. But the spoon is inside the cup. How do we distinguish between the 2 situations? What are the criteria to decide whether A is contained inside B or just lying above B?

I am trying to solve it using kinect.

答: I tried using convex hull method, I found the convex hull of both the regions in 3D. Then, found the amount of intersection they have. If it is significantly high, then one object is lying inside the other. If it is not, then it may be on top of it, or may not be. So I tested that by finding the 2D convex hulls of both the object regions, found the intersection. This gave me if one object lies on top of the other.</p>


问:
Which type of actuator will be suitable for a very strong robot arm?
I wish to build a robotic arm that can lift a useful amount of weight (such as 3-6 kg on an arm that can extend to approx 1.25 meters). What actuators are available to accomplish this? The main factors and design points are:

Not Expensive

5 to 6 DOF

to be mounted on a yet to be designed mobile platform

battery powered

stronger than hobby servos (at least for the 'shoulder' and 'elbow' joints)

not slow to actuate

答: I think your best bet would be regular hobby servos, if they don't have enough torque, use multiple servos in parallel on the same joint. A good option would be the Dynamixel servos from Robotis but they are more expensive than hobby servos, and you would have to hack the communication protocol as they are controlled by ttl/rs232/rs485, or use a usb2dynamixel(or usb2ax) converter. The advantages are their torque, speed and precision.</p>


问:
Understanding a sliding mode controller for quadrotors
I'm really willing to understand and implement such a controller (sliding mode) for a quadrotor.
I've found this interesting document explaining that topic.
If you scroll down until page 381 (don't be scared, the document is just 6-7 pages) you can find the following height control law (equation .19):

$$
U_1 = \frac{m}{\cos{\phi}\cos{\theta}}[c_1(\dot z_r - \dot z) + \ddot z_r + \epsilon_1  sgn(s_1) + k_1 s_1 + g]
$$

The explanation of most of the term should be quite easy, but let's focus on the variable z, the height (or altitude if absolute) of the quadrotor. Anyway the control law "pretends" not only the goal height z (through $s_{1}$) but even the vertical speed $\dot z_{r}$ and vertical acceleration $\ddot z_{r}$ (r means here reference).

Now...to me is not clear whether those variables the setpoints are, that must be reached once the quadrotor reaches its predefined height or they just symbolize an abstract mathematical formalism but are going to be most of the time Zero (because I want to reach the target height with $z = z_{r}$ but $\dot z_{r} = \ddot z_{r} = 0$)

?!?!?

I hope my question is clear. Even if this I put in the title "sliding control" I think it may be helpful for other type of controllers.
Regards

答:
What you say ($\dot{z}_r$ = 0, $\ddot{z}_r=0$) is true in only the most basic systems. As a trivial counter example, consider systems where the desired height is moving: then it should be obvious that $\dot{z}_r$ and $\ddot{z}_r$ will be non-zero.

Even for systems with $z_r = const$, if you want to improve performance you need to start thinking about $\dot{z}_r$ and $\ddot{z}_r$. Imaging you've just changed the set point so $|z-z_r| >> 0$. Your quad can't instantly jump so it will take some time during which $\dot{z}$ will necessarily be non-zero. If you define a profile, with conistent $z_r$, $\dot{z}_r$, and $\ddot{z}_r$ you get much better overall control than just leaving $\dot{z}_r=0$ and $\ddot{z}_r=0$.

To be clear, this doesn't uniquely define $\dot{z}_r$ and $\ddot{z}_r$. That is for the system designer to decide. For best performance, just make sure the system is consistent, i.e. $\frac{d}{dt} z = \ddot{z}_r$ and $\frac{d^2}{dt^2} z_r = \ddot{z}_r$


问:
Strategies for managing power on electrical systems for mobile robots
What are some good strategies to follow while designing power supply for electrical systems on mobile robots?

Such robots typically comprise of systems with

microprocessor, microcontroller, DSP, etc units and boards along with immediate peripherals

Motor control

Analog Sensors(proximity, audio, voltage, etc)

Digital Sensors (Vision, IMU, and other exotica)

Radio comm circuits (Wifi, Bluetooth, Zigbee, etc)

Other things more specific to the purpose of the robot being designed.

Are there unified approaches/architectural rules to designing power systems which can manage clean power supply to all these various units which may be distributed across boards, without issues of interference, common ground, etc? Furthermore, also including aspects of redundancy, failure management, and other such 'power management/monitoring' features?

well explained examples of some such existing power systems on robots would make for excellent answers.

答:
I don't know any "rules", but for complex bots, I create separate "power" unit. It basically consists of the battery, as well as some 7805s/7809s. The 78xx series takes a 12V input and gives an xx V output. Most ICs work well on 5V, and an Arduino needs 9V, so that's what I end up using (Note: the 5V/3V output pins on the Arduino are not really meant to be used much. They don't supply much power, so it's best to have a separate 5V line for your circuitry).

After this, I connect all components in parallel to their respective power pins. It is generally beneficial to power the motor with a separate source (common ground). The motor draws the most current, so the simple act of stopping/slowing a motor can send fluctuations throughout the circuit. If you don't want to do this, at least add bypass capacitors to the motor and the power inputs(Vcc/Gnd) of logic circuits (see here for more on how they work). These solve quite a few interference issues.

If you want to be a bit more sophisticated, you can add zener diodes to the power outputs. Never had to do this myself, but it's apparently a good way of "rationing out" power. There also are "constant current diodes" that you can use--though I've never even seen one of those.

For redundancy, the most you can do (for DC) is put two batteries in parallel and maybe send power to components by different physical routes. Take note of the "physical" there--the placement of the wires may be different (and they may attach do different parts of the board), but the overall circuit should remain unchanged. The reason behind doing this is that not doing this right may lead to power pins being shorted-- two logically separate 5V outputs shouldn't be shorted together, they won't be exactly the same and you'll probably have some heating/leakage.


问:
Tried Normal Distributions Transform with my own files (in correct PCD format) and it throws errors, why?
http://pointclouds.org/documentation/tutorials/normal_distributions_transform.php#normal-distributions-transform

I've used this program with the sample PCD's given and it came out correctly. This was confirmed by experienced users on here. Now I'm trying to use my own pcd's. I didn't want to bother changing the program so I just changed the names to room_scan1 and room_scan2. When I attempt to use them, I get this error:

Loaded 307200 data points from room_scan1.pcd Loaded 307200 data
  points from room_scan2.pcd Filtered cloud contains 1186 data points
  from room_scan2.pcd normal_distributions_transform:
  /build/buildd/pcl-1.7-1.7.1/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp:172:
  int pcl::KdTreeFLANN::radiusSearch(const PointT&, double,
  std::vector&, std::vector&, unsigned int) const [with PointT =
  pcl::PointXYZ, Dist = flann::L2_Simple]: Assertion
  `point_representation_->isValid (point) && "Invalid (NaN, Inf) point
  coordinates given to radiusSearch!"' failed. Aborted (core dumped)

This is the program I compiled: http://robotica.unileon.es/mediawiki/index.php/PCL/OpenNI_tutorial_1:_Installing_and_testing#Testing_.28OpenNI_viewer.29

Before you suggest it, I will let you know I already changed all of the PointXYZRGBA designations to just PointXYZ. It threw the same error before and after doing this. The thing that confuses me is that I looked at my produced PCD files and they seem to be exactly the same as the samples given for NDT.

Mine:

```<code>2320 2e50 4344 2076 302e 3720 2d20 506f
696e 7420 436c 6f75 6420 4461 7461 2066
696c 6520 666f 726d 6174 0a56 4552 5349
4f4e 2030 2e37 0a46 4945 4c44 5320 7820
7920 7a0a 5349 5a45 2034 2034 2034 0a54
5950 4520 4620 4620 460a 434f 554e 5420
3120 3120 310a 5749 4454 4820 3634 300a
4845 4947 4854 2034 3830 0a56 4945 5750
4f49 4e54 2030 2030 2030 2031 2030 2030
2030 0a50 4f49 4e54 5320 3330 3732 3030
0a44 4154 4120 6269 6e61 7279 0a00 00c0
7f00 00c0 7f00 00c0 7f00 00c0 7f00 00c0
</code>```

Sample from NDT page:

```<code>2320 2e50 4344 2076 302e 3720 2d20 506f
696e 7420 436c 6f75 6420 4461 7461 2066
696c 6520 666f 726d 6174 0a56 4552 5349
4f4e 2030 2e37 0a46 4945 4c44 5320 7820
7920 7a0a 5349 5a45 2034 2034 2034 0a54
5950 4520 4620 4620 460a 434f 554e 5420
3120 3120 310a 5749 4454 4820 3131 3235
3836 0a48 4549 4748 5420 310a 5649 4557
504f 494e 5420 3020 3020 3020 3120 3020
3020 300a 504f 494e 5453 2031 3132 3538
</code>```

Does anyone have any ideas?

答: It looks like you have NaN/Inf entries in the data. Try PCL's removeNaNFromPointCloud before applying the algorithm.</p>


问:
Control a 2.4 Ghz AR Drone from the computer
I had a Doyusha Nano Spider R/C mini-copter, it's controlled by a 4ch joystick 2.4 Ghz.

I look for a low cost method to control it from the computer. The software is not a problem, but how can I transform the WIFI or the Bluetooth signal of the computer to an R/C signal compatible with the mini-copter receptor?

Or is there another solution that is low cost?

答: In my university lab we hacked the radio controller with an arduino that receives the inputs from the computer and outputs to the controller. The arduino only substitutes the joysticks. So we still use the 2.4GHz controller to control the drone but matlab is sending control signals to the arduino which sends them to the original 2.4GHz controller, which sends them to the drone. It works! We've can control the drones position within 3cm in a 3x3x3[m] area just by using a PID controller and a stereo camera as the sensor. And this was done in a 20€ plastic quadcopter.</p>


问:
Is the nominal voltage of a motor the voltage to apply to the motor?
I have just sized the DC motors I want to use (corresponding to my robot and its intended applications - my figures include a 50% uncertainty factor to account for friction in reducers and other losses). Now I need to actually choose the exact motors I want to buy from the manufacturer (I am targeting maxon motors as I am not an expert and want no problem). I have a few down to earth questions about linking the mechanical needs to the electrical characteristics, among them:

Question #1:

Maxon (or the other manufacturers) states a "nominal voltage" in the characteristic sheets. Is that the voltage you should apply to the motor? This may be a dumb question but I have followed the full maxon e-learning course and read about other tutorials on the web and I could not find this information anywhere. Can anyone who knows about motors confirm?

I have followed some theoretical and practical courses on the web but I find it hard to find answers to my down to earth question...

答: To control the power of a DC motor you control the voltage applied to it. So no, it's not the "only" voltage you can apply to the motor. The nominal value is a reference so we know what to what specs the motor was engineered. You can input more than the nominal voltage to get more power but it may for example get a bit hotter than it is supposed to, as it wasn't designed to work continuously at a higher voltage. You won't kill a 12V motor by making it work at 20V for 2 minutes, specially Maxon motors which are very well built. </p>


答:
The problem is here:

Since, for PID   ERROR = SETPOINT - INPUT

This is only true for linear systems.  In your system, your error never exceeds $180^\circ$ no matter how many times you rotate -- modular arithmetic is affecting your calculation.  (For the PID to work properly for angles, you would need to keep track of the absolute yaw value, which would indicate how many rotations you've done in one direction or the other.  That would only be relevant to cases where the error corresponds to the amount of "twist" in a rope or cable that connects 2 rotating elements.)

The simple solution is to say

```<code>ABS_ERROR = SETPOINT - INPUT
if ABS_ERROR < 180
    ERROR = ABS_ERROR
else
    ERROR = ABS_ERROR - 360
</code>```

However, this could result in some instability if your system has a lot of momentum (large $K_d$ term).  So a more correct solution would account for whether ABS_ERROR combined with that momentum should take the "long way" around instead of attempting to stop, change directions, and rotate the "shorter" distance.

Title: How to control PID Yaw

Body:
The problem is here:

Since, for PID   ERROR = SETPOINT - INPUT

This is only true for linear systems.  In your system, your error never exceeds $180^\circ$ no matter how many times you rotate -- modular arithmetic is affecting your calculation.  (For the PID to work properly for angles, you would need to keep track of the absolute yaw value, which would indicate how many rotations you've done in one direction or the other.  That would only be relevant to cases where the error corresponds to the amount of "twist" in a rope or cable that connects 2 rotating elements.)

The simple solution is to say

ABS_ERROR = SETPOINT - INPUT
if ABS_ERROR < 180
    ERROR = ABS_ERROR
else
    ERROR = ABS_ERROR - 360

However, this could result in some instability if your system has a lot of momentum (large $K_d$ term).  So a more correct solution would account for whether ABS_ERROR combined with that momentum should take the "long way" around instead of attempting to stop, change directions, and rotate the "shorter" distance.


问:
Is a simple range sensor described below sufficient to implement particle filter localization?
I am trying to implement a monte carlo localization/particle filter localization with a simple range sensor. The range sensor only sees in the direction the robot is heading and returns back any obstacle in its line of sight. If there is no obstacle, then the sensor returns back the distance to the boundary wall i.e. there is no maximum range for sensor.

But, the problem is that i am not able to locate the robot's position. Now, I am feeling is it cause the sensor is not powerful enough. Is it feasible to do localization with such a sensor or should I change the sensor type?

Please tell me what you guys think?

答: To be clear, this is a single-point range sensor, correct? It is possible to do Monte Carlo localization with such a sensor, but it will take a very long time to converge if it does so at all, and will be easily confused. Each additional point you can add when you're doing localization will improve performance, so if you can get a few more of these sensors, you'll do better.


问:
Continous rotation with cables
A motor needs to spin n*360 degrees. On top of the motor there are distance sensor which scan the room. I.e. lidar. What options do I have for implementing a continous rotation while having cables which are in the way?</p>

答:
This is a problem I've thought a lot about, but haven't yet come up with a good solution.  The only ideas I've had thus far are:

Custom turntable: if it's only a few wires, a custom turntable could have a brush/copper contact system.  This might have a problem with noise, however.

Create a separate control system for the head (include battery, microcontroller, etc.) and wirelessly connect to the main robot.  This is probably what I'd do if I were making a really big/expensive robot, but for small sizes or budgets it's just not feasible.

Avoid the issue: Don't spin more than +/-180 degrees at any time, and simply oscillate back and forth really fast.

Title: Continous rotation with cables


问:
What frequency does my quadcopter output-sense-calculate-output update loop need to stay stable?
With a 600 mm (2 foot) motor-to-motor quadcopter, what frequency does my output-sense-calculate-output update loop need to stay stable?

I'm estimating a total takeoff weight of very roughly 2 pounds ( 0.9 kg ),
which I expect to be mostly motors and batteries.

答:
To be able to a hard number you would need to have a mathematical model your craft and analyse it. There are two options to get a model of a system:

1)You come up with a mathematical representation of the quadcopter via free body diagrams;

2)You build a gig to test the quadcopter without any control system and use identification theory to find a model;

Then you'll have to linearize your model, a quadcopter is inherently non linear. Make a bode plot of the system, the frequency you need is about twice the highest frequency of your system.

This is the the "pro" way of doing it. If you don't want to go through all this, use a value like what user65 and yoos have suggested (read my comment on yoos answer) and iterate until you get what you want. You also don't want the sample time to be too high, because you'll start having problems when the control system responds to noise.


答:
There is also ready to use commercial solution from Adafruit, called "slip ring" http://www.adafruit.com/products/736

The only problem is the max speed, which is only 300rpm, but probably you won't get any better with a custom solution.

Title: Continous rotation with cables

Body: A motor needs to spin n*360 degrees. On top of the motor there are distance sensor which scan the room. I.e. lidar. What options do I have for implementing a continous rotation while having cables which are in the way?</p>


问:
Choosing DC motor: max needed torque vs nominal torque
I have just sized the DC motors I want to use (corresponding to my robot and its intended applications - my figures include a 50% uncertainty factor to account for friction in reducers and other losses). Now I need to actually choose the exact motors I want to buy from the manufacturer (I am targeting maxon motors as I am not an expert and want no problem). I have a few down to earth questions about linking the mechanical needs to the electrical characteristics, among them:

Question #2:

As far as I understand, the nominal torque corresponds to the maximum torque the motor can sustain continuously. So I guess, as a rule of thumb, I should find a motor with a nominal torque = my max needed torque (after reduction), or around. Right?

答:
No. The nominal (or rated) torque is a torque that motor delivers at nominal speed. The motor is the most efficient at that point. When you take a look at any DC motor characteristics, you will see that the more torque you get, the smaller is the speed (and bigger is the current). Maximum torque is when the motor is stopped (stalled).

You shouldn't stall the motor for too long (more than couple of seconds), because it can burn, as it receives maximum current then. However, as long as you don't stall the motor, it is completely safe to operate with loads bigger than nominal torque.


问:
Real time operating system for robotics vision
I have robot vision system which consists of conveyor with encoder, two cameras (gigabit eth and usb) and simple illuminator.

I need to trigger cameras and illuminator when encoder reaches position interval.

I'm considering using real time operating system for this task:
Encoder, illuminator and cameras connected to PC and vision system application runing on it.

Which real-time solution you can reccomend for this problem?

I'm considering using Beckhoff TwinCAT software which turns normal operating system into RT.

答:
EtherCAT as you have noticed is a actually a good option for real-time data transfer, but if by "normal operating system" you mean Windows, that's a bad choice.

You can get a Linux implementation of EtherCAT master from IgH (http://www.etherlab.org/en/ethercat/index.php) which needs a real-time operating system, such as Linux patched with RTAI, Xenomai or RT-preempt.

Once you are able to acquire your data periodically, you can use the many freely available software packages under most GNU/Linux distributions to process them.


问:
What happens when a brush-less motor stalls?
Ok apologies for those who think my questions are not direct enough as I got warned about this. I am really new to this and I will try to keep this one direct enough for the forum.

For obvious reasons I cannot test this out without damaging something so would prefer to learn from the experience of others.

I have a "Turnigy Trackstar 1/10 17.0T 2400KV Brushless" motor which I will be using for my weapon (spinning disk).

Relevant specs of the motor are:
Kv: 2400
Max Voltage: 21v
Max current:24amps
Watts: 550
Resistance: 0.0442Ohms
Max RPM: 50000

I will use this with an ESC with the following specs:

Constant Current: 30A
Burst Current: 40A
Battery: 2-4S Lipoly / 5-12s NiXX
BEC: 5v / 3A
Motor Type: Sensorless Brushless
Size: 54 x 26 11mm
Weight: 32g
Programming Functions:
Battery Type: Lipo /NiXX
Brake: On / Off
Voltage Protection: Low / Mid / High
Protection mode: Reduce power / Cut off power
Timing: Auto / High / Low
Startup: Fast / Normal / Soft
PWM Frequency: 8k / 16k
Helicopter mode: Off / 5sec / 15sec (Start up delay)

If the motor stalls, I know the current draw will increase drastically. So my questions are:

In the case that the motor stalls (my disk gets stuck in the opponent etc), then what gets damaged? The motor, the ESC, both? And how long before this happens?

Would I have time to turn the r/c switch off before irrevocable damage occurs (once I am obviously observing the action?). Notes. I will be using an on/off switch on the r/c to just turn the motor on and off (so no proportional speed increase etc), plus I will be using an 11.1 volt battery even though the motor is rated for a 21 volt maximum.

Thanks.

答: Your equipment will be fine as long as the stall periods aren't too big(like 5 minutes). I think the first thing to fail is the ESC as you're using half the voltage the motor is rated for. You also have to take into account that the battery can also heat up and fail, as if you would short circuit the battery. But as I said, if it's not for long periods of time you won't have a problem.</p>


问:
Controlling a 400W motor with 24V 16A batteries with an arduino board
I want to build a robotic vacuum. I have a 400W 24V vacuum motor that I want to switch on automatically at a set time every night. The batteries I will be using will be 2x12V 80aH deep cycle gel batteries connected in series. I want the Arduino to switch the motor on and off. So my first real question I guess is will the 5V supplied from the Arduino be able to switch on a motor that big? The second question is a mosfet the answer? My apologies I'm pretty new to all this but love it..

Can I control a 400W motor with 24V 16A batteries with an Arduino board and a mosfet? What type of mosfet would I use?

答:
Since you don't need to "control" the motor beyond simply turning it on and off (i.e., you don't need to adjust the speed and you don't need to run it in reverse), I think what you are describing is a solid state relay (SSR).

SSRs are usually made using MOSFETs, and given that you are "pretty new to all this", you should consider buying the SSR as a component instead of building your own.  Or, depending on price, just buy a mechanical relay.

You'll need to look for an SSR that's rated for "inductive loads" (i.e. your motor).

$\frac{400\text{ Watts}}{24 \text{Volts}} = 16.666 \text{ Amps}$

So you want something that has an input voltage of 5V (for the arduino to be able to control it), and it should be rated for a 24+ Volt and 17+ Amp inductive load.


答:
Motors stalling can take many amps as you have found out. In the electrical industry three types of overload cut out are available. fuse, trip, auto resetting trip.

A more suttle way is to monitor the motor amps and if an overload happens limit out the power to the motor. For example current limitors

If the motor windings have them (very rear) thermistors are incorperated into the motor windings. If the windings get hot the trip operates, but when the windings cool then the motor runs again. Nice if your saw jams and gets free. Try the motor and try again. When the windings cool down the saw can cut again. Thermistors can be fastened to the battery to give data feedback on temprature.

There may be a way to give a few second of power boost, a very large capacitor on the main power bus, say a full farad electrolitic. However the motor control transitors can fry/burn if the motor is jammed. Big power audio ampliphoiers in cars use these large caps.

Title: What happens when a brush-less motor stalls?

Body:
Ok apologies for those who think my questions are not direct enough as I got warned about this. I am really new to this and I will try to keep this one direct enough for the forum.

For obvious reasons I cannot test this out without damaging something so would prefer to learn from the experience of others.

I have a "Turnigy Trackstar 1/10 17.0T 2400KV Brushless" motor which I will be using for my weapon (spinning disk).

Relevant specs of the motor are:
Kv: 2400
Max Voltage: 21v
Max current:24amps
Watts: 550
Resistance: 0.0442Ohms
Max RPM: 50000

I will use this with an ESC with the following specs:

Constant Current: 30A
Burst Current: 40A
Battery: 2-4S Lipoly / 5-12s NiXX
BEC: 5v / 3A
Motor Type: Sensorless Brushless
Size: 54 x 26 11mm
Weight: 32g
Programming Functions:
Battery Type: Lipo /NiXX
Brake: On / Off
Voltage Protection: Low / Mid / High
Protection mode: Reduce power / Cut off power
Timing: Auto / High / Low
Startup: Fast / Normal / Soft
PWM Frequency: 8k / 16k
Helicopter mode: Off / 5sec / 15sec (Start up delay)

If the motor stalls, I know the current draw will increase drastically. So my questions are:

In the case that the motor stalls (my disk gets stuck in the opponent etc), then what gets damaged? The motor, the ESC, both? And how long before this happens?

Would I have time to turn the r/c switch off before irrevocable damage occurs (once I am obviously observing the action?). Notes. I will be using an on/off switch on the r/c to just turn the motor on and off (so no proportional speed increase etc), plus I will be using an 11.1 volt battery even though the motor is rated for a 21 volt maximum.

Thanks.


问:
Roll, Pitch Calculation Problem!
My problem is that when i hold my sensors (MPU9150) so that +y axis is downward, and y axis is on the horizontal plane, i expect that pitch = 90 degree,  and roll = 0 degree, but actually pitch = 90 degree, and roll = 160 degree. However, when roll = 90 degree and pitch = 0 degree (That is what i expect). Do you know what cause my problem?
Thanks</p>

答: For the most common definition of roll, pitch, yaw used in UAVs, when pitch=90deg you encounter what's called gimbal Lock. Basically, when pitch=90deg you have infinite combinations of roll and yaw that will give you the same physical result.</p>

Title: Roll, Pitch Calculation Problem!


问:
Jacobian method for inverse kinematics
I have big problem. I have to solve inverse kinematics for a manipulator with 6-DOF using jacobian method. From what I know to do that I need to have matrix of transformation and Denavit–Hartenberg parameters, which both I have. But I am not a mathematician, and descriptions I find on the web are not even a bit understandable to me. So I would love if you could give me an example of how to solve my problem.

The Denavit-Hartenberg parameters are:
$$
        \begin{matrix}
        \alpha & l & \lambda & \theta\\
        90 & 150 & 0 & var(-69) \\
        0 & 610 & 0 & var(85) \\
        90 & 110 & 0 & var(-52) \\
        -90 & 0 & 610 & var(62) \\
        90 & 0 & 113 & var(-60) \\
        0 & 0 & 78 & var(-108) \\
        \end{matrix}
$$

The values in theta are values to get the following matrix of transformation, and values I want to get with this jacobian method. And those values are in degrees.

Matrix of transformation:
$$
        \begin{matrix}
        0.7225 & 0.0533 & 0.6893 & 199.1777\\
        -0.2557 & -0.9057 & 0.3381 & -500.4789\\
        0.6423 & -0.4206 & -0.6408 & 51.6795\\
        0 & 0 & 0 & 1 \\
        \end{matrix}
$$

I would be most greatful, if someone could walk me through how to solve it in simple language.

答:
I agree with all of Tvaṣṭā's questions above.  It would be nice to have answers to these, but I will try to provide an answer regardless.

To calculate the (geometric) Jacobian, you don't really need all those D-H parameters.  See this question for an explanation how to calculate the Jacobian:
jacobian of Abb irb140 robot

Inverse-kinematics using the Jacobian doesn't sound right.  Remember that the Jacobian describes the mapping between joint velocities and end-effector velocities, and that this relationship is configuration dependant.  So you can use the Jacobian to determine joint velocities to move your end-effector along a given vector.  But not really to move the end-effector to some other point in the workspace, far from the current configuration.  Typically IK solvers will give you a number of solutions for a target pose.

That being said, you might want to check out this page by another user:
http://freespace.virgin.net/hugo.elias/models/m_ik2.htm on gradient based methods.

Finally, I would highly recommend using a kinematics library such as OpenRave, Orocos KDL, ROS MoveIt! among others.  These libraries will do the heavy math stuff for you, give you advanced controls, and get you up and running much quicker.

Title: Jacobian method for inverse kinematics


问:
How to know when a Li-Po battery is discharged?
I'm building a quadcopter and I've seen that a Li-Po battery must not be entirely discharged, otherwise it could damage it.

How do you know when you have to stop your quadcopter or robot in order to prevent damages, since the voltage doesn't drop? Which part should control the battery charge? ESCs? BEC? Flight controller?

答:
First of all if you want to do it yourself using an Arduino then I would recommend using the Arduino Nano to save on weight.

If you don't want to rely on noises (as used by some battery monitors) then you could program the Arduino to trigger something off, maybe a visible LED or some other physical thing on the quadcopter. Or it could simply gently reduce power to all motors so that the quad lands slowly and safely.

You could also consider the use of telemetry (i.e. sending back information from the quadcopter) if your r/c transmitter supports it. This will give you a real time reading of the battery voltage as well as temperature etc.

Many r/c transmitters also allow you to set a simple timer on the transmitter which you would set based on ground testing to know when approximately you should bring the quadcopter back to base.This is the least technical of the solutions but apparently works well if you allow a bit of safety leeway to compensate for variations due to varying flight conditions.


问:
Choosing motor and battery for a robot
I have a project which requires a robot to move around a room with a flat surface (concrete floor).

The robot must carry a laptop. I estimated that the total weight would be 6-7kg (including motors, battery, laptop, motor controller board and other mics items). I would like it to move at about the same speed as a Roomba moves. The robot will have two motors and a castor.

I have tried doing the calculation to determine the type of motor to use, but I'm very confused.

Can someone advise me on the type of motor and type of battery (Lipo/SLA) to use?

答:
Or you could just do what I have done and scavenge two DC motors plus gearboxes from used cordless drillers. Mine are from 14.4v drillers and I am operating them using 3S LIPOs (11.1v). The LIPOs are not that expensive if you buy them rated at say 2200mAh (more current capacity = more cost). You don't even need a very high "C" rating. 20 "C" would probably do fine. But of course since you have no weight limitation you could easily use the Nicd batteries that came with the cordless driller itself, plus you get a free charger too.

You will need to remove the chuck (unscrew the centre screw within the chuck by turning in the opposite direction as it is a reverse thread, and then put an allen key in the chuck, unscrew it all the way, and hit the key hard counter clockwise and the chuck will come off)  and then remove the little ball-bearings and insert (self-tap them) grub screws in the holes where the bearings were in order to block the clutch.

Then if you wish you can just put the chuck back on and attach any shaft and wheel! You can easily get controllers for the motors and connect them to an r/c receiver.

The point is that these motors and gearbox combos are made for a good torque and speed compromise and are quite hardy in use. They are of course brushed and in my experience won't draw much over maybe 10 Amps each and that only if stalled.

Title: Choosing motor and battery for a robot


问:
Choosing suitable simulator for a swarm of AUVs
Which of the following simulators is the best choice for simulating a swarm of AUVs working together to perform a mission? Please clarify your reason and if you know any better choice, I would greatly appreciate it if you kindly help me. Please consider the need for doing Hardware-In-The-Loop(HIL) simulation.

Webots

V-REP

AUV Workbench

Gazebo

UWSim

SwarmSimX

In addition, notice that capability to connect to the middle-wares like ROS is really important.

The other option is using a game engine like Blender but I think it needs a lot of developing effort and is time-consuming! Would you recommend this approach be used? If not, why not? And what would you recommend instead?

答:
We are using for the AUV-Avalon a simulation called Mars

http://rock-robotics.org/master/documentation/simulation/index.html

Unfortunately there is no ROS integration, but a Rock integration.
Rock supports HIL in general.

For AUVs there are multiple integrations available which are collected in the mars-core package https://github.com/rock-simulation/orogen-mars_core

Mars does not provide hydrodynamic calculation, but the mars-core package provide a fossen-based model for auv motion-simulation.

The documentation therefore is (unfortunately) not finished yet but you can take a look to: https://gitorious.org/rock-tutorials/orogen-auv_simulation

The main advantage is the same interface for simulated and real systems. Rock also provides a lot of (auv) tooling.

But in the end the question is what exactly do you want to simulation, mission-planning, sensors, motion estimation. I think you have to specify this to find a good answer.


问:
Stated power for a motor does not equal nominal voltage x current?
I have just sized the DC motors I want to use (corresponding to my robot and its intended applications - my figures include a 50% uncertainty factor to account for friction in reducers and other losses). Now I need to actually choose the exact motors I want to buy from the manufacturer (I am targeting maxon motors as I am not an expert and want no problem). I have a few down to earth questions about linking the mechanical needs to the electrical characteristics, among them:

Question #3:

I chose a motor reference (310005 maxon reference found here) which has a stated power of 60W, as the nominal voltage is 12V, I was expecting to have a nominal current of 5A, but it states 4A. Where am I wrong?

答:
Take a look at this sample characteristic: http://homepages.which.net/~paul.hills/Motors/ScottMotorCharacteristic.gif

Nominal current and voltage are given for the point of maximum efficiency (or close to) of the motor, but this is not the point of maximum power. Power of the motor is given by

P=I*V

It does not rise linearly, because the slower the motor rotates (because of greater load) and the greater is the current, the smaller is the voltage drop on the motor (caused by back EMF). As you can see on the characteristic, maximum of that function comes somewhere in the middle.


问:
Programming a G-code Interpreter
I want programme my very own G-code generator for my final year electrical engineering project. I know that there are many open source G-code generators out there, but I need a G-code generator which generates a G-codes for custom circuit designs drawn by the user and pass the G-code serially to my 2 axis CNC machine. So currently I'm working on a Qt based GUI where I draw .dxf format circuit diagrams and electrical components (like resistors, capacitors) and when I press a "Generate G-code" push button I should generate a text file with nice set of G-codes for my designed diagram.

So the problem here is, how do I generate the G-code? Is there any specific algorithm to follow or adapt? I tried googling for G-code generator algorithm but I couldn't find any helpful stuff.

答:
I assume you know (or can figure out) how to parse the line objects in the dxf file, and can convert them to straight line operations in g-code.  So the basic problem is how to order the operations to minimize time (which is the same as unnecessary travel).

This sounds like a variant of the Travelling Salesman Problem.  Except instead of visiting nodes, you traverse edges (the lines in your circuit).  So there is probably no efficient solution to the problem.

I assume that once you are tracing a line, you don't want to stop until the line ends.  This is to avoid unnecessary pen-up, pen-down operations.  I guess a greedy solution would probably be fine.  I envision the algorithm to be something like this:

```<code>given a list of lines with endpoints:

0. if list is empty: end
1. Pick a line and endpoint, go there, pen down.
   (you might want to use a heuristic here such as pick the closest point to where you are).
2. go to other endpoint, delete line from list
3. search through list of lines and find a new line with same endpoint.
   (you might want to use a heuristic here to continue going straight if you can).
  if you found one: goto 2
  else: pen up, goto 0
</code>```

Title: Programming a G-code Interpreter

Body:
I assume you know (or can figure out) how to parse the line objects in the dxf file, and can convert them to straight line operations in g-code.  So the basic problem is how to order the operations to minimize time (which is the same as unnecessary travel).

This sounds like a variant of the Travelling Salesman Problem.  Except instead of visiting nodes, you traverse edges (the lines in your circuit).  So there is probably no efficient solution to the problem.

I assume that once you are tracing a line, you don't want to stop until the line ends.  This is to avoid unnecessary pen-up, pen-down operations.  I guess a greedy solution would probably be fine.  I envision the algorithm to be something like this:

given a list of lines with endpoints:

0. if list is empty: end
1. Pick a line and endpoint, go there, pen down.
   (you might want to use a heuristic here such as pick the closest point to where you are).
2. go to other endpoint, delete line from list
3. search through list of lines and find a new line with same endpoint.
   (you might want to use a heuristic here to continue going straight if you can).
  if you found one: goto 2
  else: pen up, goto 0


问:
What is the most appropriate SLAM algorithm for quadrotors with RGB-D camera?
I have been researching on SLAM. I came across EKF SLAM which uses odometry to measure the robot's initial position in the map and as well as landmarks which helps the robot's position to be more accurate. Based on the SLAM for dummies, it has a problem of loop closure. In another journal, it was compared to fastSLAM and EKF has a big-O function of $O(K^2)$ where $K$ is the number of landmarks while fastSLAM has $O(M\log(K))$.

It was also said that the most promising SLAM algorithm from the journal "The vSLAM Algorithm for Navigation in Natural Environments"
 is FastSLAM
However, the vSLAM used by an experiment done by the University of Pennsylvania is the occupancy grid SLAM.

I want to ask what would be the most approriate SLAM algorithm for vSLAM given an unmanned aerial vehicle like the quadrotor and RGB-D camera + IMU? Also are there any algorithm that can be extended to support co-operation?

答:
There is no the most appropriate SLAM algorithm. You use based on what you have. Every approach has pros and cons. People use cameras because they are so cheap in comparison with Laser sensors. Laser sensors  are extremely expensive however they are so accurate and give more info about the map than cameras.  No matter what kind of sensors you use, the ultimate goal of SLAM is to build a map and estimate the robot in this map. Another problem arises when the sensors are used which is the noise. So to filter the measurements, you need a filter. The most common filter used in SLAM is Extended Kalman filter, hence the name EKF-SLAM. Another one is Particle Filter PF.

EKF SLAM which uses odometry to measure the robot's initial position
  in the map and as well as landmarks which helps the robot's position
  to be more accurate.

This is actually incorrect. EKF is an optimal estimator. It has nothing to do with odometry. Odometry works as a sensor based on accumulating previous data. As you can see, odometry is an error-prone because it accumulates the noise beside the robot's pose. GPS doesn't work in an indoor environment. This is why SLAM is needed. Given an accurate sensor, say laser, EKF-SLAM for example, the robot is able to estimate its pose in an unknown environment whether indoor or outdoor. Even though cameras are very cheap, the image manipulation is so heavy. Also, a single camera doesn't give the distance to a beacon or landmark.


答:
This is not a trivial problem to solve. Assuming your DXF file contains various primitives like tracks and pads drawn out, you need to create an algorithm which draws cuts around them, to end up with a PCB something like this:

This is known as PCB isolation routing, and is in itself is non-trivial because (I assume) the tracks and pads will overlap in places, and so the algorithm has to be sure not to cut all the way around every primitive, but to cut around them in so far as to avoid cutting through any of them.

There are two ways you can approach this problem:

Vector: The 'best' way is to solve it using vectors. Calculate the set of lines and arc segments around each primitive, calculate where they intersect neighboring lines or arcs, and trim them to length so that they form a continuous loop around the copper net. This is the 'best' because the lines and arcs naturally translate into a simple set of G-Codes. However, it can be a pain to program, and you'll be working out lots of linear algebra, and dealing with a ton of tricky edge cases.

Bitmap: This way produces more bloated G-Code, but is easier to program. Simply render the image of your PCB at high resolution. But for each primitive, draw it wider by the width of the cutting tool, Then write an algorithm which follows the edges around the copper nets, generating G-Code commands as it goes. If you're smart, you can reduce the number of G-Code lines produced by detecting movement in straight lines, and only generating a G-Code command when you turn a corner. If you're really smart, you might even be able to detect arcs too:

You might want to go the next step and cut out the dead copper to have a PCB like this:

This is only a little harder, and involves offsetting your cutting paths, trimming them against each other, offsetting again, etc. Then finally joining up all of the concentric loops into one continuous path. This example image is not from a PCB, but it's the same principle:

Having written several similar programs, I can tell you from experience that it's not trivial. But it's also not impossibly hard. You'll have to decide how much time you have to spare on this problem. If you have less than a week (though I suggest at least two weeks), then I suggest you try out one of the many source code repositories out there which do this.

Title: Programming a G-code Interpreter

Body:
I want programme my very own G-code generator for my final year electrical engineering project. I know that there are many open source G-code generators out there, but I need a G-code generator which generates a G-codes for custom circuit designs drawn by the user and pass the G-code serially to my 2 axis CNC machine. So currently I'm working on a Qt based GUI where I draw .dxf format circuit diagrams and electrical components (like resistors, capacitors) and when I press a "Generate G-code" push button I should generate a text file with nice set of G-codes for my designed diagram.

So the problem here is, how do I generate the G-code? Is there any specific algorithm to follow or adapt? I tried googling for G-code generator algorithm but I couldn't find any helpful stuff.


问:
Is it possible to use Matlab "system" function to call ROS commands?
Is it possible to use the Matlab's system function to call ROS commands?

For example, using system('rostopic pub /cmd_vel geometry.msgs.Twist {....}
or system('rospack find ipc_bridge).

I'm trying to send some commands to ROS without using something like IPC-Bridge.

PS: I know, however, that I need to use IPC-Bridge to subscribe to topics.

答:
This is possible. But it is very sloppy, in my humble opinion. It is useful for one-off commands, but how will you read back output, verify your command was executed, etc.

If you are dead-set against the IPC bridge, you may want to look at using the MATLAB-java interface. ROS also allows you to program in Java using ros-fuerte-client-rosjava (ubuntu), or just rosjava.


问:
Will AIs ever be as advanced as the human brain?
I'm reading a book about a hypothetical economy in which robots work for us because they eventually became able to do everything we do ("Our work here is done, visions of a robot economy" by Nesta).

I was wondering though: is it theoretically possible for a human brain (an extremely complex  artificial intelligence the way I and many others see it) to comprehend itself in its deepest details and produce an artifical intelligence which is exactly identical? It sounds unlikely. If not then, how close can we get?

This is not a philosophic question, the ideal answer would be a rigorous demonstration based on metrics simplifying the problem to be able to answer it, however objective answers with valid arguments are always interesting, too.

答:
Will AIs ever be as advanced as the human brain?

Unless the humans destroy themselves before that point, or lose interest in the subject whatsoever, then yes of course AI will be as advanced as the human brain. Even more advanced I would say.

Before you comment, let me point out two things out

Technologically speaking

The brain is a machine. It is complex, but it's still is a machine. Theoretically, you could build artificial neurons, look at someone's brain and position the your artificial neurons similarly. Then teach your baby robot like you would teach your child.

Whether that's practical or not is another question. Whether there is a better way to produce human-like intelligence is yet another question. Whether human-like intelligence is actually a good kind of intelligence is again, another question.

Predicting the future

Now here's the real answer to your question (and yes, your question is philosophical). Take the following question:

Will X ever happen?

The answer to such a question is:

Unless X is physically or mathematically impossible, then yes it will happen.

Why is that? Because it's a prediction that is not bounded by time. Any such prediction is utterly worthless, yet you cannot say it's wrong. Why? Let's say I make a prediction: "One day, humans will grow a third arm". Now let's say N years pass. Has my prediction happened?

Yes: I was right,

No: It will happen in the future.

(for arbitrary large N). That said, it is impossible for anyone to say my prediction is wrong no matter how many years pass and it still doesn't happen.

Your question is the same. Will AI become great? Sure why not.

(Incidentally, adding deadlines to predictions is what made people like Nostradamus a man everyone would laugh at now, and not adding deadlines to predictions is what makes many religious figures still not regarded as frauds by many)


答:
There are many things that humans can do that computers have never been able to do.
Every year people manage to get computers and robots to do something they have never done before.
Those builders and programmers are usually surprised at how much code and hardware it required to get it to work, and long it took to build and debug that code and hardware.

is it theoretically possible for a human brain ... to comprehend
  itself in its deepest details and produce an artificial intelligence
  which is exactly identical?

If you are asking if it's possible for a single human brain, simply through introspection, to figure out enough about what's going on inside to build an artificial intelligence that is exactly like that same single human brain (at some point in time), the answer is no.
We now know that human brains do a lot of work in the visual system and other areas that is completely inaccessible to conscious introspection.

However, the reason we know this is because there are other ways to learn something about what is going on in there.

If not then, how close can we get?

As of 2014, no one knows.

Many of the tasks that were once thought of as "higher-level" thinking can now be done by computers -- symbolic mathematics, chess, music composition, writing stories (a) (b), etc.

And yet -- many other tasks that were once thought of as "simple" still cannot be reliably done by computers -- distinguishing photos of cats from photos of dogs (c), much less remembering a human's name when seeing what that human's face looks like today (slightly older than any other time that human has ever been seen), etc.

I personally suspect that it is unlikely humans will build a machine that "thinks like a human", and even less likely that humans will build a machine that thinks like some particular human.

And yet I think it is very important for researchers to continue to try to do that, because -- whether they eventually discover some insurmountable barrier, or else (against my expectations) build a machine that actually does think like a human -- either way, I think we will find out some very interesting things about what it means to be human.

As a secondary benefit, it is a goal that is highly likely to, as a side effect, produce machines that will do other very useful things, long before the question is resolved one way or the other.

a small part of
"Navigating 50 years of philosophical debate -- Robert Horn's seven 'Can Computers Think?' debate maps"

Title: Will AIs ever be as advanced as the human brain?

Body:
I'm reading a book about a hypothetical economy in which robots work for us because they eventually became able to do everything we do ("Our work here is done, visions of a robot economy" by Nesta).

I was wondering though: is it theoretically possible for a human brain (an extremely complex  artificial intelligence the way I and many others see it) to comprehend itself in its deepest details and produce an artifical intelligence which is exactly identical? It sounds unlikely. If not then, how close can we get?

This is not a philosophic question, the ideal answer would be a rigorous demonstration based on metrics simplifying the problem to be able to answer it, however objective answers with valid arguments are always interesting, too.


问:
Are there surface texture sensors for integration in circuits?
I have a project in mind for a robot which is able to recognize surfaces, and thought about including the following sensors:

a temperature sensor

a colour sensor, or a complex of electronic components to determine a colour

and a texture sensor, or, as above, a complex of components to fulfill the purpose

Now, I did some research on finding a(preferably small) texture sensor for soldering into an electronic circuit, similar to those little temperature sensors one can buy.
I already thought that "small" would probably turn out to be not small at all before I searched.
But my research has been fruitless.
Not just fruitless like in "I can't find exactly what I want." but fruitless like in "I cannot find anything similar to what I want."...

Most things that turned up either were scientific papers about whole devices, or whole devices for purchase.
Some company even choose "Structure Sensor" as the name of their iPad-compatible 3D scanner, which made the search utterly depressing as every second article I found is about buying some pre-built iPad device.

All I need is the electronic component, nothing else.
So hope that any of you people can spare me some research time and recommend me a company/site/whatever which sells such texture sensors.

(Btw., I do know that surface sensors are probably a bit way more complex than temperature sensors, and my hope for getting what I want is low, but just because I cannot find something, ot does not mean that it doesn't exist.)

答:
Texture sensing is hard.  Can you be more specific on your requirements?  I think texture is typically inferred from dynamics.  For example, holding your finger still on a texture doesn't give you much information.  You have to move your finger around on the surface to start to feel what the texture is like.  You are probably feeling the friction from sheer forces, and vibrations in your finger.

You might want to check out this paper:
Microgeometry Capture using an Elastomeric Sensor.  They have a "portable" version which is is an 8 inch long, 3 inch diameter tube.

Some more robot tactile sensors: Takktile, SynTouch, OptoForce.  They each use different sensing modalities and will have different characteristics in terms of normal forces, sheer forces, and dynamic range.