问:
How to use scan command in Arduino WifiBee
We want to find available WiFi networks near.
So in tutorial there is command scan, which is send from CoolTerm program from PC.

Now we want to write program to Arduino which will do same operation, how it can be done?

答: To my knowledge, the WifiBee doesn't support network scanning.  You must specify the SSID of the Wifi network that it should connect to, the IP address it expects to be assigned, and the gateway address as part of its initial configuration.</p>


问:
What's a good pose estimation method for high precision (<5mm per-axis) solutions at short range (<50cm)?
I'm trying to get a 6DOF pose solution for an object that'll be between 10 and 50 cm from a fixed point. I want to avoid putting too much special hardware on the object, but extra hardware on the fixed side is fine.

I've been looking into two general methods:

fiducial markers There are several software packages with different types of markers, but I haven't been able to find any information about them regarding precision or accuracy in short-range pose sensing.

ultrasonics I've found some commercial systems that do 6DOF pose sensing (e.g. hexamite), but they're expensive and require you to put transmitters on the object.

答:
The accuracy of fiducial markers (i.e. glyphs) depends on your camera's resolution, noise ratio, focus, and field of view.  Essentially, you will need to ensure that there are enough pixels in the recorded image to represent the real-world precision that you want.

To make this easier, it would help if the glyphs are as large as possible and the camera is aimed as "tightly" as possible on the subject.  For a camera with a known resolution and field of view, you should be able to calculate the pixels-per-cm that the images represent (given 10cm and 50cm distances to the subject).  Assume ±2 pixels possible measurement error, and calculate the precision from that.

ContentLicense: CC BY-SA 3.0


问:
How to connect Arduino Uno3, L293D motor driver and 3 colour sensors together?
I am trying to build an autonomous multi coloured lines following robot.

The parts I have bought so far include:

Arduino Uno 3.

3 Colour Sensors (taos tcs 230).

L293DNE motor driver.

Robot chassis including 2 dc motors, 2 wheels and 1 caster wheel.

I am trying to figure on how to connect all these components together (for example: arduino to the colour sensor, l293d to motor).  How do I connect it in order for the motor to rotate in both directions?  Do I need to solder anything?

答:
Some of the arduino connections require no soldering.  The black strips with holes in them -- the headers -- allow you to connect and disconnect a wire without soldering it.  You may also find it useful to use a breadboard, which is a large grid of similar solderless connections.

However, whether you'll need to solder things together depends more on the needs of your projects than the components themselves.  Although solderless versions of many connectors exist (crimp, punch-down, etc), you probably won't be able to do anything interesting in robotics without being at least somewhat familiar with soldering.

In terms of how to connect those specific components, you'll need to consult the data sheets.  The easiest way to draw a component (i.e. what appears on the datasheet) is not the easiest way to manufacture a component (i.e. how things are laid out on the circuit board), so the datasheet is your guide to converting your schematic on paper to a set of solid electrical connections.


问:
Compliance control for a single link robot in matlab
What exactly is active compliance control in robotics joint?
Why Is it used ?
How can I write a program to simulate the compliance control in matlab for a single robotic link or single robotic joint ?
I have to develop an algorithm for torque control.
I have to sense the torque and give feedback to BLDC motor which is supposed to apply some controlled torque.
I also have some unclear understanding of few things: Lets say I have single joint two link systems, How would this system behave when I have applied the compliance control algorithm at the joint? How will I test it? I mean if I apply some external torque what should it do so that I understand that it is in compliance control mode.
Here is a related paper.
http://www.thehandembodied.eu/pdf/ICCAS.pdf</p>

答:
I was hoping you would elaborate your question because it is pretty vague.  There are two kinds of robot arm compliance: passive and active.

Passive compliance is a property of the physical system.  For example a soft end-effector, a spring in line with the motor (aka series elastic actuation), or a flexible link.  If you know all the parameters of the arm such as masses, moments of inertia, spring, and damper coefficients, you can determine various characteristics of the arm.  For example, how the arm will behave when given a step input.  This is a standard control problem.

Active compliance uses sensing in the arm and/or end-effector to sense external forces on the arm, then move the joints accordingly.  This is closely related to force control.  In the industrial world, this could be applying the right amount of force during some machining operation.  For arms in human environments, this could be moving out of the way when a user pushes the arm.


问:
What's the difference between CAN's Motor Max Velocity vs. Profile Max Velocity?
CAN301/402 provides Max Motor Speed (0x6080,0x00) and Max Profile Velocity (0x607F,0x00). In profiled motions, the maximum speed is limited to the lower of these two values. In non-profiled motions, the maximum speed is limited to Max Motor Speed.

What is the intended purpose of Max Profile Velocity, rather than only providing Max Motor Speed and using that everywhere instead?

答:
Max Motor Speed is used to protect the motor against being driven over it's maximum speed.  The units for this are RPM.

Max Profile Velocity is given in same units as the profile velocity and applies only to profile position mode.

(Source CiA DSP 402 V2.0)

While the standard doesn't expand on these, the way I see it is that the first number is something you set up based on the motor's data sheet to prevent damaging the motor.  The units are set up that way.

The second number is an application specific limit.  You want to protect yourself against moves that can be damaging in your application and you use the same units used for position profiles.

Having two parameters allows for running the motor in velocity mode in higher speeds than you allow during positioning modes.  While that may not seem important I've actually worked on an application where a plate was loaded on a drum and the drum then spun up to considerable speed.  In this application the loading portion used positioning mode and needed to be slower than the velocity mode used later so this separation of limits could have come in handy.  In general having those sorts of limits built-in reduces the chance of damaging the machine you're working on.


答:
Moderator Note: This answer has been posted by someone related to the
  product that they are recommending

Sketch Arduino and PIC firmware for Wifly RN-XV modem configuration without Wifly library and with front-end.

Type in browser address bar: 192.168.1.195/YT to toggle LED and open a HTML page.

The microcontroller can be, with this firmware and Wifly, a server (switching the LED signal through 192.168.1.195/YT in address bar)
or also client (the AD converter value is inserted in google databank).

Title: How to use scan command in Arduino WifiBee

Body:
We want to find available WiFi networks near.
So in tutorial there is command scan, which is send from CoolTerm program from PC.

Now we want to write program to Arduino which will do same operation, how it can be done?


问:
Localising a robot swarm non-optically
This question is further to Localizing a swarm of robots.

In summary: I want to create a swarm of robots which can each measure their own position in a 3x2m room with a 25cm high ceiling, to an accuracy of ±5mm.

There were some good answers, but most of them were optical methods. I would be interested to hear some non-optical localisation ideas, so I will impose the following further constraints:

Localisation method cannot use optical means, either visible or invisible.

Nothing can be added to the floor or ceiling.

There's no appreciable gap between the top of the robots and the ceiling.

There are no walls, and equipment can be added around the perimeter of the room.

I look forward to hearing some creative ideas.

答:
What about sonar?  I guess this would be made a bit more difficult with other robots in the room.  It might take a few minutes for an individual robot to create a clear picture of the room by eliminating the other robots that it detects, thus finding "walls".  You would get the added benefit of collision detection.

Do the robots communicate?

Title: Localising a robot swarm non-optically


答:
It seems that RF positioning is the only technology capable of giving you the precision that you need.  That said, I don't think it's ready for 5mm ranges just yet.

50 quadcopters, 20Hz, 5-15cm precision

Development of experimental TDOA system test-bed for indoor applications

Hybrid TDOA/AOA Indoor Positioning and Tracking Using Extended Kalman Filters

Title: Localising a robot swarm non-optically

Body:
This question is further to Localizing a swarm of robots.

In summary: I want to create a swarm of robots which can each measure their own position in a 3x2m room with a 25cm high ceiling, to an accuracy of ±5mm.

There were some good answers, but most of them were optical methods. I would be interested to hear some non-optical localisation ideas, so I will impose the following further constraints:

Localisation method cannot use optical means, either visible or invisible.

Nothing can be added to the floor or ceiling.

There's no appreciable gap between the top of the robots and the ceiling.

There are no walls, and equipment can be added around the perimeter of the room.

I look forward to hearing some creative ideas.

ContentLicense: CC BY-SA 4.0


问:
Do servo motor specifications take into account the gear ratio inside?
I am looking at buying a servo motor for a an application that must be able to lift 4-5 lb at a rotational speed of approximately 1rpm. The servo motor listed here http://www.robotshop.com/ca/en/hitec-hs755mg-servo.html states a stalling torque of 200 oz-in. Is this torque rating at the horn of the servo motor or the torque rating of the actual motor before any gear reduction is done?

Is this motor sufficiently strong for my application?

答:
Is this torque rating at the horn of the servo motor or the torque
  rating of the actual motor before any gear reduction is done

For reputable manufactures and vendors, the ratings will include all internal gear reduction, or external in the case of gear-head motors.

Is this motor sufficiently strong for my application?

That depends more on the details of your application. 200 oz-in of torque means the servo should be able to lift up to 200 oz within one inch of its center shaft. That means it can work on up to [ 200 oz / 16 oz/lb ] = 12.5 pounds within that inch.

To get 4 - 5 pounds out of it, your rotational radius must be within:

12.5 lb-in / 4.5 lb = 2.78 inches.

However, operating the motor continuously under a full load will most likely cause it to fail fairly quickly. It will also slow down the rotational speed.

Speaking of speed, the servo is given at 0.23 seconds / 60 degrees. That means it will rotate 60 degrees in 0.23 seconds. a Full circle is 360 degrees, so 4 * 0.23 = 0.92 seconds for a full rotation.

However, (and correct me if I am wrong) no where in the listing does it mention continuous rotation. A traditional RC servo motor cannot rotate all the way around unless it specifically states it can or is manually altered (voiding any warranties). It will typically only rotate a maximum of 140 to 180 degrees.


问:
What different sensing approaches are used in the current batch of indoor 3D cameras?
I'm aware of the PrimeSense camera powering the Kinect. Are more advanced sensor types available now in the < $500 range? For example, has there been any sort of game-changer in structured light techniques? Do decent flash lidar cameras exist now?</p>

答:
I guess that the approach in structured cameras is pretty much the same.

However, the world is trying to minify this kind of sensors.
In particular

http://structure.io/

https://www.google.com/atap/projecttango/

Some people speculate that the reason for kinect to be so big is the array of microphones that allows to localize source of noise.

I haven't heard of anything else, though if I find new info I will expand my answer.


问:
Preventing leaks in motor shafts for underwater bots
Whenever building an aquatic bot, we always have to take care to prevent leakages, for obvious reasons. Now, holes for wires can be made watertight easily--but what about motors? We can easily seal the casing in place (and fill in any holes in the casing), but the part where the axle meets the casing is still left unprotected.

Water leaking into the motor is still quite bad. I doubt there's any way to seal up this area properly, since any solid seal will not let the axle move, and any liquid seal (or something like grease) will rub off eventually.

I was thinking of putting a second casing around the motor, maybe with a custom rubber orifice for the shaft. Something like (forgive the bad drawing, not used to GIMP):

This would probably stop leakage, but would reduce the torque/rpm significantly via friction.

So, how does one prevent water from leaking into a motor without significantly affecting the motor's performance?

(To clarify, I don't want to buy a special underwater motor, I'd prefer a way to make my own motors watertight)

答:
You may want to consider a Magnetically Coupled Drive. Use a standard motor with a magnetic coupling to transmit the torque to your prop.

This would allow your motor to be completely sealed inside your vehicle:

From Eric Stackpole's article mentioned above. Image used without permission, but with attribution.

This solution may or may not be suitable however, depending on the torque you need to transmit, but for open water use has the distinct advantage that it is torque limited. In other words, if your prop gets jammed and you have selected suitable motor and coupling torques then the coupling will slip before your motor burns out.

I particularly like Erics solution as it simultaneously transmits torque to the prop, centers the prop on the shaft and centers the prop along the shaft. An elegant piece of design which solves several problems simultaneously.


问:
Reading data from D+ and D- pins of a USB
So I have this optical mouse with me, which has a PAN3504DL-TJ optical sensor. It has a USB interface and when I looked up the internet, all I could find was tutorials using A2501 or sensors in those lines and it has pins like SCLK and SDI but I don't have them instead I have D+ and D-. I understand that these are the data pins so what I did was take two wires and plug them into my Analog Pins of my dsPIC30F4011 and read data from it. After setting up UART communication and transmitting data, all I get are numbers running continuously.

What I want to do is to read coordinates over the analog pins as the mouse aka the sensor moves on a surface. I would use this for position control for my robot.
So my question is how do I read coordinates from the Optical Sensor over the D+ and D- lines through my Analog Pins ?

答: Use different PAN, PAN3101 in praticular. How to do that? See this (chapter "5.3.6 PAN3101") https://robotics.stackexchange.com/a/2733/2663</p>


答:
As others pointed out, you'll need to implement the protocol for communication (most likely HID). I recommend you buy an optical mouse with PS/2 protocol because it will be much much easier to implement, there are even numerous solutions for it online (as in codes and libraries).

Regards

Title: Reading data from D+ and D- pins of a USB

Body:
So I have this optical mouse with me, which has a PAN3504DL-TJ optical sensor. It has a USB interface and when I looked up the internet, all I could find was tutorials using A2501 or sensors in those lines and it has pins like SCLK and SDI but I don't have them instead I have D+ and D-. I understand that these are the data pins so what I did was take two wires and plug them into my Analog Pins of my dsPIC30F4011 and read data from it. After setting up UART communication and transmitting data, all I get are numbers running continuously.

What I want to do is to read coordinates over the analog pins as the mouse aka the sensor moves on a surface. I would use this for position control for my robot.
So my question is how do I read coordinates from the Optical Sensor over the D+ and D- lines through my Analog Pins ?


问:
What is the Name of the part I'm describing
I'm looking for a part that will do a particular function.  It has to be able to move along one axis and tell me the force that is being exerted on it.

Kind of how like a piston moves inside an engine (one axis of movement) except that something will be pushing at the top of the piston and I need to know how hard its pushing.  Another difference is that the piston won't be constantly moving back in forth, but needs to be able to receive commands like.  move x centimeters forward and then remain stationary at its new position.

I know to make this it would involved a sensor and something that can exert force but what is the name of the described machine?

Edit #1 - Response to Matthew Gordon

The piston would have to move between 0-6 centimeters.  The form factor would be small, ideally smaller than the palm of your hand.  (Smaller=better) The forces it would have to deal with are comparable to the forces exerted on a bicycle by its chain.  I'm a math/cs person not engineering so I don't know technical terms for these kinds of things off the top of my head.  It would have to be real time sensor reading, but the volume of data could be processed by a phone.  Would have to working in conjunction with wireless communication, probably Bluetooth, but I'd have to look into the latency requirements to be sure.

答:
It sounds like you're describing a linear actuator with a pressure sensor (or strain gauge) attached to the end.

To bridge that system across bluetooth, you may want to check out one of several microcontrollers -- look for bluetooth modules, a motor (or servo) controller, and analog inputs (to read the strain gauge).


问:
What are the advantages of using the Denavit-Hartenberg representation?
When one wants to model a kinematic chain and in particular define the frames attached to each body, it is common to use the Denavit-Hartenberg parameters.

What are the advantages of this representation?

I can understand the interest of having a normalized representation but does it impact the algorithms performance?
The algorithm is not trivial to implement, what gain can we expect from this instead of, for instance, just fixing reference frames by hands (i.e. arbitrarily) like this is done in many robotics formats such as URDF.

答:
I believe this to be the key factor:

In this convention, coordinate frames are attached to the joints between two links such that one transformation is associated with the joint, [Z], and the second is associated with the link [X]. The coordinate transformations along a serial robot consisting of n links form the kinematics equations of the robot,

[T] = [Z1][X1][Z2][X2]...[X(n-1)][Zn]

where [T] is the transformation locating the end-link.

That is, to get a transformation from a serially attached links you can just multiply transformation matrices which is much easier to write and much easier to work with than calculating everything manually using basic geometry.

Regards


问:
Spatial tracking between two UAVs
I have two Unmanned Aerial Vehicles (planes) which work well. They can fly to various waypoints automatically using GPS.

Now I would like them to fly together in formation. I would like them to fly side-by-side fairly close. This is too close to reliably use GPS to guarantee that they keep the correct relative positions safely, and so I am looking for another way.

Somehow the UAVs need to be able to measure their position and orientation in space relative to the other one. How can I do this? Is there some kind of sensor which can do this? It would need to have the following properties:

6 axes (position and orientation)

Range 0m - 5m, (from between plane centres, but planes won't actually ever touch wingtips)

Works in day or night and all weather conditions

Light weight (This is for 1.5m wingspan RC planes, so max extra weight of about 100g)

Probably need about 50Hz - 100Hz refresh rate, but might get away with less, using the IMU to fill in the gaps

答: How close together?  If they use the same make and model GPS unit, you MIGHT be able to use the relative positions calculated via GPS.  A lot of the sources of GPS error would be the same for both vehicles in that case (e.g., atmospherics, any built-in GPS filtering).  Each vehicle could broadcast it's state vector to the other one.  </p>

Title: Spatial tracking between two UAVs


问:
Is it possible to record only incoming data with realterm?
I am trying to test a sensor circuit I'm working on. Essentially, I am using RealTerm to send commands to the microcontroller and it is returning the value read by the sensor. </p>

<p>When logging to a file in RealTerm, I noticed the commands being sent were showing up as well as the data being returned. I was wondering if anyone knew a way to record only the incoming data using RealTerm, and not the outgoing commands. Any suggestions would be greatly appreciated. Unfortunately, there is no way around using RealTerm specifically because of a company policy. </p>

答: It sounds like RealTerm has local echo turned on.  Apparently that setting in RealTerm is (incorrectly) called "half-duplex", and should be disabled for your purposes.</p>


问:
Maximum Distance using Ultrasonic sensor Arduino
What is the maximum distance (of say , a car ) you could measure using an ultrasonic sensor that would be compatible with arduino? Is there any sensor(ultrasonic or not) that could measure the distance of a car , say upto 50 meters that can be used with arduino?</p>

答:
Your question is multiple questions inside of one. As answered in comments, your question should probably be limited to the sensor and/or technology for longer range detection of large (moving?) objects. The use of an arduino is mostly irrelevant.

As per comment by @Ian, ultrasonic sensors will probably not be useful at 50 meters, I think due to physics of sound. See the article below on choosing an ultrasonic sensor.

One option might be to use a laser rangefinder (such as you can find in hardware stores).  Another option might be to use radar, such as in old police radar guns. However, both of these options are limited in capability and highly dependent on environmental factors.

Perhaps the best option would be a LIDAR system. They tend to be expensive, but there is an upcoming product called "LIDAR-Lite" by PulseLight that is lower cost and might be of interest. They are advertising a 40 meter range capability.

Additional reading:

Low Cost LIDAR and Laser Range Finders: Where Are They?

LIDAR-Lite by PulseLight

SF02 Laser Rangefinder from Parallax

Choosing an Ultrasonic Sensor for Proximity or Distance Measurement

Beam patterns of various MaxBotix ultrasonic sensors

Radar Gun


答: You can use Cutecom on linux or Terminal on windows. Both of them log only incoming data.</p>

Title: Is it possible to record only incoming data with realterm?

Body:
I am trying to test a sensor circuit I'm working on. Essentially, I am using RealTerm to send commands to the microcontroller and it is returning the value read by the sensor. </p>

<p>When logging to a file in RealTerm, I noticed the commands being sent were showing up as well as the data being returned. I was wondering if anyone knew a way to record only the incoming data using RealTerm, and not the outgoing commands. Any suggestions would be greatly appreciated. Unfortunately, there is no way around using RealTerm specifically because of a company policy. </p>


问:
differential drive PID controller
I have a differential drive robot that works fine (good PD parameters) driving at say 1 m/s. Now, if it speeds up (to 1.2 m/s) it starts wobbling again. What would be a good strategy for a controller that is able to cope with the whole speed range of 0 - 4 m/s?

edit 14th of April:

The robot is a line follow robot but I do not see how this would be related to my question since a robot following a trajectory would have the same problem.

I recently talked to other developers of differential drive robots and they are facing similar issues e.g. they told me that they need to adjust PID parameters once the battery is not fully charged hence the robot drives at a different speed.

I do not know if you guys are into youtube, but if your are really interested in my robot this link would be helpful: https://www.youtube.com/watch?v=vMedNPhXlEo

PID parameters are: P 0.31, D 0.59, I 0.00

PID controller programmed using C:

```<code>  // note: the inner wheel turns backwards for narrow curves
  // cte is -128..128 depending on the robots position
  // relative to a trajectory / black line
  /** Execute the PID controller and update motor speeds */
  void PID()
  {
    int32_t steer;
    int32_t cte;
    cte = 128 - get_segment_center(0);
    // Compute PID equation
    steer = (int)(
      -P * (float)cte
      -D * (float)(cte - diff_cte) / (float)PERIOD_MS
      -I * (float)int_cte
    );
    if (steer < -5)
    {
      // turn left
      turn = -1;
      uXbot_move(MAX_SPEED + steer, MAX_SPEED);
    }
    else if (steer > 5)
    {
      // turn right
      turn = 1;
      uXbot_move(MAX_SPEED, MAX_SPEED - steer);
    }
    else
    {
      // go straight
      turn = 0;
      uXbot_move(MAX_SPEED, MAX_SPEED);
    }
    diff_cte = cte;
    int_cte += cte;
  }
</code>```

答:
Nice robot.

The +/- 5 threshold in your code is a red flag to me.  This introduces a non-linearity/discontinuity which shouldn't be needed.  What is the rationale for that?

If you have enough memory to capture some real-time data try logging your cte and steer and then review them as you tune.

Speed is going to have an impact because of the way you've set up your steering and the vehicle dynamics.  As the speed increases your steering command is going to cause a different turning radius.  Also as speed increases it becomes hard to steer the vehicle.  This isn't a trivial system.  When your battery voltage goes down and assuming that voltage is your motor power tail and that you're not actually closing a velocity loop the effect of the lower voltage would be lower speed and therefore the effect of your PID coefficients will be reduced linearly to that.  Note that going at a lower speed with a full battery and going at a low speed due to a low battery will behave differently (the impact of your steer command will be different).

Here's what I would suggest as a first go:

Get rid of that +5/-5 threshold.

Add some data logging in and review while tuning.

Start with I=0, D=0 and pick a fixed velocity.  Start on the slow end.

Ramp up P, keep doubling it until the system becomes unstable.  Back off (e.g. take half or 1/4 of the unstable P.)

Experiment with adding a little I or D and see if they improve performance.  If not leave at 0.

Repeat tuning at a few speeds and plot your tuned variables vs. speed.

Try fitting linear or 2nd order segments to that graph to determine the coefficients at different speeds if needed.

Title: differential drive PID controller


答:
You aren't properly mapping your steering value to the wheel speeds.  In fact, I don't think you're applying the PID correctly at all.

From your code, my guess is that you're using get_segment_center to determine the adjustment that you need to make.  My assumption is that this describes a distance measurement of how far the line sensor is off of the center of the line.  If that's the case, you are lacking the necessary calculations.

The output of a PID takes an error and gives you a correction, so if your error is in inches then your correction will be in inches; if the error is in degrees, your correction will be in degrees, and so on.  You need to pick either of those and stick with it.  As written, you're taking a distance error and plugging it directly into a speed correction – no wonder it only works at one speed!

My recommendation would be to calculate the steering error as an angle, which you can get by measuring (1) the distance over which your sensor can pick up the line and (2) the distance between the axle and the sensor.  With the tangent function, you can map sensor readings to angle error.  Then, you can implement the function I wrote about in this post to convert the steering angle to wheel velocities.

Title: differential drive PID controller

Body:
I have a differential drive robot that works fine (good PD parameters) driving at say 1 m/s. Now, if it speeds up (to 1.2 m/s) it starts wobbling again. What would be a good strategy for a controller that is able to cope with the whole speed range of 0 - 4 m/s?

edit 14th of April:

The robot is a line follow robot but I do not see how this would be related to my question since a robot following a trajectory would have the same problem.

I recently talked to other developers of differential drive robots and they are facing similar issues e.g. they told me that they need to adjust PID parameters once the battery is not fully charged hence the robot drives at a different speed.

I do not know if you guys are into youtube, but if your are really interested in my robot this link would be helpful: https://www.youtube.com/watch?v=vMedNPhXlEo

PID parameters are: P 0.31, D 0.59, I 0.00

PID controller programmed using C:

```<code>  // note: the inner wheel turns backwards for narrow curves
  // cte is -128..128 depending on the robots position
  // relative to a trajectory / black line
  /** Execute the PID controller and update motor speeds */
  void PID()
  {
    int32_t steer;
    int32_t cte;
    cte = 128 - get_segment_center(0);
    // Compute PID equation
    steer = (int)(
      -P * (float)cte
      -D * (float)(cte - diff_cte) / (float)PERIOD_MS
      -I * (float)int_cte
    );
    if (steer < -5)
    {
      // turn left
      turn = -1;
      uXbot_move(MAX_SPEED + steer, MAX_SPEED);
    }
    else if (steer > 5)
    {
      // turn right
      turn = 1;
      uXbot_move(MAX_SPEED, MAX_SPEED - steer);
    }
    else
    {
      // go straight
      turn = 0;
      uXbot_move(MAX_SPEED, MAX_SPEED);
    }
    diff_cte = cte;
    int_cte += cte;
  }
</code>```


问:
How to turn a rover 90 degrees using wheel encoders?
I have a four wheel DC rover with two optical wheel encoders.  I'm executing rover turns by controlling the direction of wheel motion on either side of the rover.  To turn left, all wheels on the left rotate backwards while all right wheels rotate forward.  This allows to rover to remain relatively in the same position while turning.  The directions are reversed to do a right turn.

How can I use these two sensors to execute as close to a 90 degree turn as possible without fusing additional sensor data?

答:
You want the wheel odometry to add up to 1/4 of the circumference of the circle whose radius is the distance between the wheels (call it $R$).

In other words, if you only drove one wheel and the wheels were $R$ units apart, then you'd leave a circular tire track whose circumference would be $2\pi R$.  If the left wheel moved $\frac{2\pi R}{4} = \frac{\pi R}{2}$ then effectively you've drawn a quarter circle and are now facing 90 degrees ($\pi/2$ radians) to your right.

This also works if you rotate both wheels in opposite directions.  Instead of rotating one wheel $\frac{\pi R}{2}$, rotate each wheel $\frac{\pi R}{4}$ in opposite directions.  This will trace a circle of diameter $R$ (half the size of before), whose circumference is $\pi R$.  Both wheels are tracing $\frac{\pi R}{4}$ or one quarter of the same circle.

My back-of-the-envelope says that this will work for any combination of left and right wheel distances.  So, if your left and right wheel odometry values are $D_l$ and $D_r$, you've made a 90 degree turn to the right when $D_l - D_r = \frac{\pi R}{2}$

You should be able to calculate $D_l$ and $D_r$ from your wheel encoders since you know the wheel radius.  At that point, the value of $\pi$ should be factored out of the equation.

This won't be accurate over time, but it's about the best you can do without factoring in any other sensor data.


问:
NXT Segway problem. Need advice/help
I'm attempting to build a segway robot using a gyrosensor and accelerometer.

I'm having trouble getting the robot to remain standing, for some reason, and I can't identify the problem.
Here's what I know:

The gyroscope API for the lejos NXT platform is here:

http://www.lejos.org/nxt/nxj/api/

By using timestamps and angular velocity, the project attempts to infer the angle of the robot.  The API suggests that in order to be accurate, it must be polled 100 times per second (or every 10ms on average).

The problem is that simply polling the gyrosensor takes 4ms.
Polling the accelerometer takes 10ms.

The dimensions of the robot:
Height: 28cm
wheel circumference : 13.25cm
Radius of a wheel, given the circumference:  2.1cm

The accelerometer is mounted on the top of the robot (at approximately 28cm from the ground, 26cm from axis of rotation)

In order to keep the correction amount linear (as opposed to trying to correct an arbitrary angle) , I translate the angle of the robot to a distance to travel along the ground to "right" the robot.  This might be a bit naive, and I'm open to suggestion here.  Basically it's just the horizontal distance calculated using a right-angle triangle with the angle of the robot at the top and hypotenuse of 28cm.

If that's not clear, it's essentially the horizontal distance from the top of the robot and the bottom of the robot.

Right now my main concern is the amount of drift the gyroscope seems to be experiencing.  Given the fact that with the NXT java software package, it's nearly impossible to poll 100 times per second, the amount of error accumulated by the gyroscope is fairly large.

Finally, I've implemented a PID control system.  The thing I'm not clear about with respect to this system is the integral and derivative of error must be calculated given a set of values.  Say, the last 20 error measurements recorded.

If the amount of past errors recorded is a variable, and the PID constants are variable, and the speed of the wheels is a variable, it seems this problem begs for some kind of automated optimization.  But how to do it?  If I set the speed to 120 RPM (roughly the max of the NXT servos) and take the past 20 errors for calculating the integral and derivative of the error, will it be possible to optimize the PID constants successfully?  Or must all 5 variables be tuned together?

Thanks ahead for any insight on the problem.

答: You're essentially designing an "inverted pendulum" PID controller.  If you search for that, you should find a lot of good information on the calculations you need to make.</p>

Title: NXT Segway problem. Need advice/help


问:
Datasheet for Taos TCS3200 GY-31
Can someone please post the datasheet for the colour sensor mentioned above. All i can find is for TCS3200</p>

答:
Are you looking for the TCS230 or the TCS3200?
If its the TCS3200 GY-31 (which is the upgraded module from the TCS230), you can try this.

Its not the most informative, but it does cover the basics for the GY-31.

Title: Datasheet for Taos TCS3200 GY-31


问:
Computing inverse kinematic with jacobian matrices for 6 dof manipulator
I'm trying to calculate the inverse kinematic for an 6 dof manipulator.

Task:

A target point $p_{target} = (x,y,z)^T$ and the orientation $o_{target} = (a, b, c)^T$ are given and I want to get the angle configuration $q = (q_1, q_2, q_3, q_4, q_5, q_6)^T$ for my robot.

Method:

For that I try to implement the Jacobian method (with the transposed jacobian matrix) with this guide and followed the pseudocode at slide 26. But instead using the pseudoinverse of the Jacobian matrix I used the transposed one.

I'll try to compute the Jacobian matrix numerically and analytically, but didn't get a solution (endless loop) for any of them. Here's how I retrieve the Jacobian:

Numerically:

```<code>private void calculateMatrixNumerically()
{
    var deltaTheta = 0.01;
    var newAxisConfiguration = new AxisConfiguration(
        this.currentAxisConfiguration.joints[0] + deltaTheta,
        this.currentAxisConfiguration.joints[1] + deltaTheta,
        this.currentAxisConfiguration.joints[2] + deltaTheta,
        this.currentAxisConfiguration.joints[3] + deltaTheta,
        this.currentAxisConfiguration.joints[4] + deltaTheta,
        this.currentAxisConfiguration.joints[5] + deltaTheta
        );

    var ePos = this.kinematic.CalculateDirectKinematic(newAxisConfiguration);

    for (var column = 0; column < this.Columns; column++)
    {
        this.M[0, column] = (this.currentPos.Point.X - ePos.Point.X) / deltaTheta;
        this.M[1, column] = (this.currentPos.Point.Y - ePos.Point.Y) / deltaTheta;
        this.M[2, column] = (this.currentPos.Point.Z - ePos.Point.Z) / deltaTheta;
        this.M[3, column] = (this.currentPos.Orientations[0].A - ePos.Orientations[0].A) / deltaTheta;
        this.M[4, column] = (this.currentPos.Orientations[0].B - ePos.Orientations[0].B) / deltaTheta;
        this.M[5, column] = (this.currentPos.Orientations[0].C - ePos.Orientations[0].C) / deltaTheta;
    }
}
</code>```

Analytically:

```<code>private void calculateMatrixAnalytically()
{
    var peMatrix = calculateJointPositions();
    var zMatrix = calculateZ();

    for (var column = 0; column < this.Columns; column++)
    {
        double[] p_p = new double[3];
        for(var row = 0; row < zMatrix.Rows; row++)
        {
            p_p[row] = peMatrix.M[row, this.Columns-1] - peMatrix.M[row, column];
        }

        this.M[0, column] = zMatrix.M[1, column] * p_p[2] - zMatrix.M[2, column] * p_p[1];
        this.M[1, column] = zMatrix.M[2, column] * p_p[0] - zMatrix.M[0, column] * p_p[2];
        this.M[2, column] = zMatrix.M[0, column] * p_p[1] - zMatrix.M[1, column] * p_p[0];
        this.M[3, column] = zMatrix.M[0, column];
        this.M[4, column] = zMatrix.M[1, column];
        this.M[5, column] = zMatrix.M[2, column];
    }
}

/// <summary>
/// Calculate the positions of every joint.
/// </summary>
/// <returns>The Matrix with the joint coordinate for each joint.</returns>
private Matrix calculateJointPositions()
{
    Matrix jointPositions = new Matrix(3,6);
    Position pos;

    for (var joint= 0; joint< this.currentAxisConfiguration.joints.Count(); joint++)
    {
        pos = this.kinematic.CalculateDirectKinematic(this.currentAxisConfiguration, joint);
        jointPositions.M[0, joint] = pos.Point.X;
        jointPositions.M[1, joint] = pos.Point.Y;
        jointPositions.M[2, joint] = pos.Point.Z;
    }

    return jointPositions;
}

private Matrix calculateZ()
{
    // (z0^T-z1^T-z2^T-...-z6^T)
    var ksEnd = Kinematics.TranslateRobotToWorld();
    var zMatrix = new Matrix(3, 6);

    for (var column = 0; column < this.currentAxisConfiguration.joints.Count(); column++)
    {
        for (var row = 0; row < zMatrix.Rows; row++)
            zMatrix.M[row, column] = Math.Round(ksEnd.M[row, 2], 7);

        ksEnd = ksEnd.Multiply(
            Kinematics.TranslateCoordinateSystem(
            Robo.theta[column] + this.currentAxisConfiguration.joints[column],
            Robo.d[column],
            Robo.alpha[column],
            Robo.a[column])
            );
    }
    return zMatrix;
}
</code>```

Here is the implementation of the Pseudocode:

```<code>        do
        {
            jacob = JacobiMatrix.GetJacobi(currentPosition, currentAxisConfiguration);
            jacobiTranspose = jacob.getTransposeMatrix();

            // deltaE = (x2-x1, y2-y1, z2-z1, a2-a1, b2-b1, c2-c1)
            deltaE = Position
                .GetDistanceVector(currentPosition, targetPosition);

            deltaThetas = jacobiTranspose.Multiply(deltaE).
                                    Scale(beta);

            for (var axis = 0; axis < deltaThetas.Rows; axis++ )
                currentAxisConfiguration.joints[axis] += deltaThetas.M[axis, 0];

            currentPosition = this.CalculateDirectKinematic(currentAxisConfiguration);
        } while (Math.Abs(Position.Distance(currentPosition, targetPosition)) > epsilon);
</code>```

where $beta = 0.5$ and $epsilon = 0.0001$

Problems:

The transformation matrice should be fine, because it behaves good for the forward kinematic.
In my opinion the Jacobian matrix must be somehow wrong. I'm not sure if it is correct how I put the orientation data in the numerical calculation. For the analytical computation I didn't have any clue what could be wrong.
I would be thankful for any advice. An explicit example for calculating the Jacobian would also be very helpful.

答:
Disclaimer!

I will try to solve your problem but it may or may not solve the problem with your code!

TL;DR: Two possible mistake in your code. In your pseudo-code, you are using transpose of jacobian instead of pseudo-inverse of jacobian (as suggested in your referenced slide). The other possible mistake is in the calculation of cross product in your analytical jacobian code.

Long answer for future readers:

First: In gradient based jacobian approach, if the target point is out of workspace of the robot, your algorithm traps in an infinite loop, trying to reach the error threshold. In inverse methods, jacobian looses rank and program crashes!

Second: Note that under some conditions a 6dof for manipulator there is always a closed form solution that gives you 6 answers for a IK problem of position and orientation. These conditions are as follow:

Three consecutive rotational joint axes are incident (e.g., spherical wrist)

Three consecutive rotational joint axes are parallel

To give you an idea, consider an anthropomorphic arm. First joint brings the end-effector to a plane that answer lies within and next two joints solve the position problem. The rest of three degrees of freedom cat tackle the orientation part. There is a brief explanation in 7th page of this file.

Three: Regarding your code, I'm not sure if the following is correct (to be very honest, I'm not sure what is happening!).

```<code>this.M[0, column] = zMatrix.M[1, column] * p_p[2] - zMatrix.M[2, column] * p_p[1];
this.M[1, column] = zMatrix.M[2, column] * p_p[0] - zMatrix.M[0, column] * p_p[2];
this.M[2, column] = zMatrix.M[0, column] * p_p[1] - zMatrix.M[1, column] * p_p[0];
</code>```

To calculate the contribution of $i^{th}$ revolute joint motion to end-effector velocity, the correct way to go is:

$$J_{Li}(q) = z_{i-1}\times (p_{ee}-p_{i-1})$$
$$J_{Ai}(q) = z_{i-1}$$

where

$J_{Li}$ and $J_{Ai}$ are linear and angular velocity of end-effector

$q$ is a vector of the current configuration of the robot and

$z_{i}$ is the a vector expressing the orientation of the joint in space. If you are using Denavit Hartenberg convention, this will be the first three elements of the third column of DH matrix related to the joint.

$p_{i}$ and $p_{ee}$ are position of $i^{th}$ joint and end-effector respectively (First three elements of fourth column of DH).

At last but not least, $\times$ is the cross product of two vectors (I think this is one of the places that your code might have gone wrong).

This, is the proper way of calculating the geometric jacobian. Once you have this, there are several ways to solve IK problem numerically. Apart from transpose, newton method, gradient method and etc.

To have a deep study of these methods, have a look at these very nice set of slides.

Bonus!

I strongly suggest, if you are doing to do serious robot programming, consider using some linear algebra libraries such as boost::numeric::ublas or Eigen. They are fast, comprehensive and common. To give you an insight, here is how you can do a simple jacobian in Eigen for a 7dof robot:

```<code>    //Hint:
    // A0i = A01*A12*A23...Ai
    // Aij = DH matrix related to transformation for ith to jth joint.
    Eigen::Vector3d z0, p0, pe;
        z0  << 0, 0, 1;
        p0  << 0, 0, 0;
        pe = A07.block<3,1>(0,3);

    // Ji linear velocity
    Jacobian.block<3,1>(0,0) = z0.cross(pe-p0);
    Jacobian.block<3,1>(0,1) = A01.block<3,1>(0,2).cross(pe-A01.block<3,1>(0,3));
    Jacobian.block<3,1>(0,2) = A02.block<3,1>(0,2).cross(pe-A02.block<3,1>(0,3));
    Jacobian.block<3,1>(0,3) = A03.block<3,1>(0,2).cross(pe-A03.block<3,1>(0,3));
    Jacobian.block<3,1>(0,4) = A04.block<3,1>(0,2).cross(pe-A04.block<3,1>(0,3));
    Jacobian.block<3,1>(0,5) = A05.block<3,1>(0,2).cross(pe-A05.block<3,1>(0,3));
    Jacobian.block<3,1>(0,6) = A06.block<3,1>(0,2).cross(pe-A06.block<3,1>(0,3));

    // Ji angular velocity
    Jacobian.block<3,1>(3,0) = z0;
    Jacobian.block<3,1>(3,1) = A01.block<3,1>(0,2);
    Jacobian.block<3,1>(3,2) = A02.block<3,1>(0,2);
    Jacobian.block<3,1>(3,3) = A03.block<3,1>(0,2);
    Jacobian.block<3,1>(3,4) = A04.block<3,1>(0,2);
    Jacobian.block<3,1>(3,5) = A05.block<3,1>(0,2);
    Jacobian.block<3,1>(3,6) = A06.block<3,1>(0,2);
</code>```

And if you are sure your jacobian is not rank deficient, calculating right pseudo inverse is as easy as:

```<code>inline Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> pInv(const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> &a) {
    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> aT= a.transpose();
    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> aaT = a*aT;
    return aT*(aaT.inverse());
}
</code>```

Body:
Disclaimer!

I will try to solve your problem but it may or may not solve the problem with your code!

TL;DR: Two possible mistake in your code. In your pseudo-code, you are using transpose of jacobian instead of pseudo-inverse of jacobian (as suggested in your referenced slide). The other possible mistake is in the calculation of cross product in your analytical jacobian code.

Long answer for future readers:

First: In gradient based jacobian approach, if the target point is out of workspace of the robot, your algorithm traps in an infinite loop, trying to reach the error threshold. In inverse methods, jacobian looses rank and program crashes!

Second: Note that under some conditions a 6dof for manipulator there is always a closed form solution that gives you 6 answers for a IK problem of position and orientation. These conditions are as follow:

Three consecutive rotational joint axes are incident (e.g., spherical wrist)

Three consecutive rotational joint axes are parallel

To give you an idea, consider an anthropomorphic arm. First joint brings the end-effector to a plane that answer lies within and next two joints solve the position problem. The rest of three degrees of freedom cat tackle the orientation part. There is a brief explanation in 7th page of this file.

Three: Regarding your code, I'm not sure if the following is correct (to be very honest, I'm not sure what is happening!).

this.M[0, column] = zMatrix.M[1, column] * p_p[2] - zMatrix.M[2, column] * p_p[1];
this.M[1, column] = zMatrix.M[2, column] * p_p[0] - zMatrix.M[0, column] * p_p[2];
this.M[2, column] = zMatrix.M[0, column] * p_p[1] - zMatrix.M[1, column] * p_p[0];

To calculate the contribution of $i^{th}$ revolute joint motion to end-effector velocity, the correct way to go is:

$$J_{Li}(q) = z_{i-1}\times (p_{ee}-p_{i-1})$$
$$J_{Ai}(q) = z_{i-1}$$

where

$J_{Li}$ and $J_{Ai}$ are linear and angular velocity of end-effector

$q$ is a vector of the current configuration of the robot and

$z_{i}$ is the a vector expressing the orientation of the joint in space. If you are using Denavit Hartenberg convention, this will be the first three elements of the third column of DH matrix related to the joint.

$p_{i}$ and $p_{ee}$ are position of $i^{th}$ joint and end-effector respectively (First three elements of fourth column of DH).

At last but not least, $\times$ is the cross product of two vectors (I think this is one of the places that your code might have gone wrong).

This, is the proper way of calculating the geometric jacobian. Once you have this, there are several ways to solve IK problem numerically. Apart from transpose, newton method, gradient method and etc.

To have a deep study of these methods, have a look at these very nice set of slides.

Bonus!

I strongly suggest, if you are doing to do serious robot programming, consider using some linear algebra libraries such as boost::numeric::ublas or Eigen. They are fast, comprehensive and common. To give you an insight, here is how you can do a simple jacobian in Eigen for a 7dof robot:

    //Hint:
    // A0i = A01*A12*A23...Ai
    // Aij = DH matrix related to transformation for ith to jth joint.
    Eigen::Vector3d z0, p0, pe;
        z0  << 0, 0, 1;
        p0  << 0, 0, 0;
        pe = A07.block<3,1>(0,3);

    // Ji linear velocity
    Jacobian.block<3,1>(0,0) = z0.cross(pe-p0);
    Jacobian.block<3,1>(0,1) = A01.block<3,1>(0,2).cross(pe-A01.block<3,1>(0,3));
    Jacobian.block<3,1>(0,2) = A02.block<3,1>(0,2).cross(pe-A02.block<3,1>(0,3));
    Jacobian.block<3,1>(0,3) = A03.block<3,1>(0,2).cross(pe-A03.block<3,1>(0,3));
    Jacobian.block<3,1>(0,4) = A04.block<3,1>(0,2).cross(pe-A04.block<3,1>(0,3));
    Jacobian.block<3,1>(0,5) = A05.block<3,1>(0,2).cross(pe-A05.block<3,1>(0,3));
    Jacobian.block<3,1>(0,6) = A06.block<3,1>(0,2).cross(pe-A06.block<3,1>(0,3));

    // Ji angular velocity
    Jacobian.block<3,1>(3,0) = z0;
    Jacobian.block<3,1>(3,1) = A01.block<3,1>(0,2);
    Jacobian.block<3,1>(3,2) = A02.block<3,1>(0,2);
    Jacobian.block<3,1>(3,3) = A03.block<3,1>(0,2);
    Jacobian.block<3,1>(3,4) = A04.block<3,1>(0,2);
    Jacobian.block<3,1>(3,5) = A05.block<3,1>(0,2);
    Jacobian.block<3,1>(3,6) = A06.block<3,1>(0,2);

And if you are sure your jacobian is not rank deficient, calculating right pseudo inverse is as easy as:

inline Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> pInv(const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> &a) {
    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> aT= a.transpose();
    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> aaT = a*aT;
    return aT*(aaT.inverse());
}


问:
Why do I need a Kalman filter?
I am designing an unmanned aerial vehicle, which will include several types of sensors:

3-axis accelerometer

3-axis gyroscope

3-axis magnetometer

horizon sensor

GPS

downward facing ultrasound.

A friend of mine told me that I will need to put all of this sensor data through a Kalman filter, but I don't understand why. Why can't I just put this straight into my micro controller. How does the Kalman filter help me about my sensor data?

答:
Sensor data is noisy. If you do not filter it, then your vehicle would at least act erratically if it were even stable enough to fly. Filtering, via a Kalman filter or otherwise, can reduce the noise when done correctly, improving stability in turn.

A Kalman filter is a particularly powerful filter. It takes a model of the system and noise models for both the system and your sensors. It then estimates the state of the vehicle based on a provided state estimate and the controls applied at any moment in time. This estimated state will be more accurate than what the sensors report.

Title: Why do I need a Kalman filter?


答:
All theory aside, circumferences and actual distances travelled will vary with your wheel geometry since your wheels aren't perfectly tangential to their direction of travel while turning.  While Ian gives some good math I think I would run tests and assign a pseudo-circumference.

I think I would just measure what the odometers read for a full 360 turn-about and then divide that up as necessary.

Also, I'd bet that different floors would give different performance from your off-tangent wheels and your pseudo circumference is probably dependent on that.

Title: How to turn a rover 90 degrees using wheel encoders?

Body:
I have a four wheel DC rover with two optical wheel encoders.  I'm executing rover turns by controlling the direction of wheel motion on either side of the rover.  To turn left, all wheels on the left rotate backwards while all right wheels rotate forward.  This allows to rover to remain relatively in the same position while turning.  The directions are reversed to do a right turn.

How can I use these two sensors to execute as close to a 90 degree turn as possible without fusing additional sensor data?


问:
Wire gauge for hobby robot question
So, i'm making my second ever hobby robot(I'm 15) and am planning on soldering my own connectors for the battery, sensors, Arduino, etc. It will be a small mobile robot. Anyways, I was wondering what a good gauge of stranded hookup wire would be good for that purpose. Thanks!!</p>

答:
For power/ground/analog signals the only limitation on how small you can go on wire gauge is power loss.
You can look up voltage drop calculators online but generally speaking if it's short runs with low current you shouldn't run into problems with wire gauge being too small.
One place where you do need to be careful is when using ratiometric sensor such as rotary potentiometers or resistive temperature sensors as the resistance of the connecting wires could have a measurable effect.
In the applications I work on I use a rule of thumb of 28AWG for signals, 26AWG for low current devices (up to 0.2A) 24AWG for up to 1A and 22 AWG up to 3A (assuming the lengths aren't more than 1-2m)

As much of a consideration as wire gauge is the wire material and protection.
Plated wire (normally tin) is much easier to solder, I've occasionally had batched of unplated wire which refused to solder unless attacked with flux and steer clear of wire with thick PVC coating. Not only is it bulkier but the PVC melts when you solder the wire.

Title: Wire gauge for hobby robot question


答:
You may want to check this table to see what a given AWG size can handle in terms of current as well as AC frequency.

Remember that getting enough surface area on your connections is as important as using the correct wire size.

Title: Wire gauge for hobby robot question

Body: So, i'm making my second ever hobby robot(I'm 15) and am planning on soldering my own connectors for the battery, sensors, Arduino, etc. It will be a small mobile robot. Anyways, I was wondering what a good gauge of stranded hookup wire would be good for that purpose. Thanks!!</p>


答: If you wanted accurate turns, you should throw a gyrometer onto the rover. They're relatively inexpensive and easy to use. Here's one as an example: https://www.sparkfun.com/products/11977</p>


答:
No need for factors of pi. (I think in Ian's answer, the circumference would be pi*R since he defines R as the separation between the wheels which I read as the width of the robot?) You just need the width of the robot and the diameter of the wheels. The amount the robot turns is:

Ang = enc_value/enc_range * D/W * 360

Where Ang is the angle, env_value is your encoder reading, enc_range is the encoder reading for one full revolution, D is the diameter of a wheel and W is the width of the robot.

For 90 degrees you get:

enc_value= enc_range/4 * (W/D)

Calibration as another poster said, is recommended. This kind of dead reckoning without any reference points will accumulate errors pretty fast. After a few turns you'll have order unity errors.

Note that if you only drive the wheels on one side to turn, how the wheels drag on the other side is very dependent on the surface. For example on a softer surface, the wheel that has to push across the surface will dig in more than the one that is dragged and you'll rotate about the wheel not moving.


问:
Position and Object Data Tracking
For a class project, I'm working with a weight stack:

I'm trying to simultaneously measure:

the position of a moving weight stack

the value of the weight based on a calibrated/preloaded position in the stack, not via load sensor. (e.g. think a stack of plate weights where the sensor knows in advance that 1 plate = 10lbs, 2 plates = 20lbs, etc.)

The weight stack and the base camp chip/sensor/laser would be within two feet of the weight stack, so I don't need anything overly strong. My requirement is that it is small/unobtrusive and cost effective. I've looked into a few options, but I'm not an engineer so I'm not sure if I am on the right track.

How would you do this? Is there any research that I could check out?

答:
You can use a kinect or a similar depth sensor.

If you know the weight of a plate, if you can setup the environment as you wish (namely the stack is always on the floor or on a plane) you can, with pcl extract the volume of the stack (removing the plane what rest is only the stack and you get its track for free), estimate the number of plates with the height of the stack and consequently get the weight.

Title: Position and Object Data Tracking


问:
Point tracking from a mobile robot
How can I track a fixed point $P=(x_P, y_P)$  from a moving robot?

Coordinates of $P$ are relative to the state/pose of the robot (x axis looks forward the robot and y axis is positive on the right of the robot).
Suppose that the initial robot state/pose is at $S_{R}=(x_R, y_R, \theta_R)$.
The next frame (namely after $\Delta t$) with the applied control $(v, \omega)$ the robot is at state $S_{R'}=(x_{R'}, y_{R'}, \theta_{R'})$.

Where (I set the axes as OpenCV):

$x_{R'} = x_R + v cos(\theta_R) \Delta t $

$y_{R'} = y_R + v sin(\theta_R) \Delta t $

$\theta_{R'} = \theta_{R} + \omega\Delta t$

The question is: which are the coordinates $(x_P', y_P')$ of the same point $P$ relative to $S_{R'}$?

As visible in the picture, I know the transformation from the initial state to the next state of the robot and the coordinate of P in reference to the initial state

$$
t = \begin{pmatrix}
cos(\theta_{R'}) & -sin(\theta_{R'}) & x_{R'}\\
sin(\theta_{R'}) & cos(\theta_{R'}) & y_{R'}\\
0 & 0 & 1\\
\end{pmatrix}
$$

Please correct me if I made some mistakes!

Thank you, any help is appreciated.

答:
Let's assume that you know the position of P=(xp,yp) in the initial state.
Let's also assume that you know the transformation matrix t which transforms the initial state of the robot to the next state. Due to the relative nature of positions, you can say that robot is standing still and that the point P is moving. This is exactly what you need as you wish to view everything from robot's own coordinate system. It is not moving relative to itself, but the point P is.

By that we can say:
P'=inverse(T)*P

Regards

Edit: I'm not completely sure that the transformation matrix you wrote is perfectly correct, please check it and edit the post if it's incorrect for future reference (it should hold the difference between the values, not ending values).
Also, keep in mind that the rotation and translation are not commutative so don't let that give you headaches.

Title: Point tracking from a mobile robot


答:
The short, snide answer is "try it without one."  The better answer is an example: When your accellerometers say you are 10 degrees from vertical, but your gyro says you haven't rotated away from vertical, and your magnetometers are reporting a 30 deg offset from north but your gyro says 32 degree ... what is the current heading and tilt?

You'll probably come up with a million ad-hoc ways which seem to work in one example, but fail in others. The Kalman Filter (Extended Kalman Filter (EKF) for this task!) will provide for you a rigorous way to answer these questions. The quality of the answers is still being researched--though the EKF's track record is very good--but at least everyone will agree what the answers are.

Title: Why do I need a Kalman filter?

Body:
I am designing an unmanned aerial vehicle, which will include several types of sensors:

3-axis accelerometer

3-axis gyroscope

3-axis magnetometer

horizon sensor

GPS

downward facing ultrasound.

A friend of mine told me that I will need to put all of this sensor data through a Kalman filter, but I don't understand why. Why can't I just put this straight into my micro controller. How does the Kalman filter help me about my sensor data?


答:
Here is a useful thesis that might help:
http://dspace.mit.edu/bitstream/handle/1721.1/69500/775672333.pdf
And this paper discusses some of the control problems, including the drift compensation problem that you're having:

http://www.raysforexcellence.se/wp-content/uploads/2013/01/Dennis-Jin-Development-of-a-stable-control-system-for-a-segway.pdf

As a kind of side comment, you are better off to have the gyro mounted closer the wheels rather than up at the top as the linear accelerations measured are proportional to their distance from the wheel axis, and this may be making your drift worse.

Title: NXT Segway problem. Need advice/help

Body:
I'm attempting to build a segway robot using a gyrosensor and accelerometer.

I'm having trouble getting the robot to remain standing, for some reason, and I can't identify the problem.
Here's what I know:

The gyroscope API for the lejos NXT platform is here:

http://www.lejos.org/nxt/nxj/api/

By using timestamps and angular velocity, the project attempts to infer the angle of the robot.  The API suggests that in order to be accurate, it must be polled 100 times per second (or every 10ms on average).

The problem is that simply polling the gyrosensor takes 4ms.
Polling the accelerometer takes 10ms.

The dimensions of the robot:
Height: 28cm
wheel circumference : 13.25cm
Radius of a wheel, given the circumference:  2.1cm

The accelerometer is mounted on the top of the robot (at approximately 28cm from the ground, 26cm from axis of rotation)

In order to keep the correction amount linear (as opposed to trying to correct an arbitrary angle) , I translate the angle of the robot to a distance to travel along the ground to "right" the robot.  This might be a bit naive, and I'm open to suggestion here.  Basically it's just the horizontal distance calculated using a right-angle triangle with the angle of the robot at the top and hypotenuse of 28cm.

If that's not clear, it's essentially the horizontal distance from the top of the robot and the bottom of the robot.

Right now my main concern is the amount of drift the gyroscope seems to be experiencing.  Given the fact that with the NXT java software package, it's nearly impossible to poll 100 times per second, the amount of error accumulated by the gyroscope is fairly large.

Finally, I've implemented a PID control system.  The thing I'm not clear about with respect to this system is the integral and derivative of error must be calculated given a set of values.  Say, the last 20 error measurements recorded.

If the amount of past errors recorded is a variable, and the PID constants are variable, and the speed of the wheels is a variable, it seems this problem begs for some kind of automated optimization.  But how to do it?  If I set the speed to 120 RPM (roughly the max of the NXT servos) and take the past 20 errors for calculating the integral and derivative of the error, will it be possible to optimize the PID constants successfully?  Or must all 5 variables be tuned together?

Thanks ahead for any insight on the problem.


问:
SCARA Arm Lead Screw Choices
I'm thinking about building a SCARA Arm to lift moderate loads(5lbs) with a high degree of accuracy. I want a relatively quick and inexpensive Z axis gantry, and I was thinking about using a lead screw with dual linear rail. Trouble is I'm not certain the linear velocity will be fast enough.

What's the best method of choosing the lead screws and the associated nut, given a desired linear velocity of 10inches/second and a NEMA stepper motor driving it?

答:
The 'speed' of a lead-screw is the product of the lead-screw's pitch and the rotational speed of the motor. For example, if you have a screw with 10 threads-per-inch pitch, and you rotate it at 60 r.p.m. you will get an advance speed of 0.1 inches per second. At 600 r.p.m. you would get 1 inch per second. You would need 6000 r.p.m. to drive a 10 threads-per-inch lead-screw.(3/4" hardware store all-thread has this pitch)
If you get a coarser thread, to increase translational speed, the torque requirements go up, and you'll need a bigger motor.
Lead-screws are great for slow, precise motion - the homemade 3d printer industry was practically built on them. High speed movement is another kettle of fish. As Mark Booth pointed out, belt drives are better if you need the speed.
As per accuracy, this page has a good practical discussion:
http://www.protoparadigm.com/blog/2013/10/accuracy-vs-precision-and-threaded-rod-vs-leadscrews-in-3d-printers/</p>

Title: SCARA Arm Lead Screw Choices


问:
Atlas Robot Reference
Boston Dynamics keeps making great robots, however, I dont see any papers that they publish.  Although now I can find papers on people using the ATLAS robot, I can not find an original paper detailing the robot or its mechanics designs.  Is there a reference for the robot, should I use youtube videos?</p>

答:
What kind of "reference" do you want?  Some bibtex to reference in your paper?  Or detailed schematics?

If it is a paper reference, i'd probably just point to either BD's website above or this: http://www.theroboticschallenge.org or this: http://www.theroboticschallenge.org/files/ATLAS-Datasheet_v15_DARPA.PDF.

If you want to look at their mechanics, take a look at the ROS URDF and gazebo models.  They can be downloaded from OSRF's bitbucket site: https://bitbucket.org/osrf/drcsim.

Title: Atlas Robot Reference


答:
If the moving stack follows a regular path, you could use a stack of bump switches to determine their arrival at that point, and also to measure the number of plates in the stack by using one switch for each plate.
This would only work if the plates were thick enough, and the path regular. By extension, a array of photocell/LED pairs could provide a contactless method of doing the same thing.</p>

Title: Position and Object Data Tracking

Body:
For a class project, I'm working with a weight stack:

I'm trying to simultaneously measure:

the position of a moving weight stack

the value of the weight based on a calibrated/preloaded position in the stack, not via load sensor. (e.g. think a stack of plate weights where the sensor knows in advance that 1 plate = 10lbs, 2 plates = 20lbs, etc.)

The weight stack and the base camp chip/sensor/laser would be within two feet of the weight stack, so I don't need anything overly strong. My requirement is that it is small/unobtrusive and cost effective. I've looked into a few options, but I'm not an engineer so I'm not sure if I am on the right track.

How would you do this? Is there any research that I could check out?


问:
Crimp or Solder to LiPo Battery?
So, I'm planning out my second hobby robot(I'm 15). I am planning on using a 7.4V LiPo battery and my idea is to solder on a 3-pin header to connect to the electronics. Anyways, should I solder to crimp terminals and then attach it to the pack? Or should I solder directly to the battery leads Keep in mind I have a decent background in hobby electronics and am just starting with robotics. My soldering skills are also decent!

Thanks!!

答:
I find it's always cleaner to use connectors rather than soldering directly to leads, no matter what component you're trying to attach to your robot. You have to think about things in terms of maintenance. If a battery goes kaput (technical term :D) and you soldered directly to the leads, you'll have to desolder and solder again. If you used a connector, you simply pop out the battery and replace it with a new one.

If you want to take your designs to the next level, you should start planning where your wires will be routed through the chassis, covering them with wire loom, spiral wraps, cable carrier, cable ducts or even just cable ties w/ cable tie holders (google wire management products and you'll find even more options). The ideal situation is when the wiring throughout your chassis is static and never replaced or moved (except when a wire is the point of failure). To replace any part or to work/modify it, all you should have to do is unplug connectors.

As a final note, ALWAYS color code your wires: Red = +12V, Black = Gnd, Orange = +5V, Yellow = +3.3V, Green = Sensor Signals, Blue = Communication lines...you get the picture. You can define them any way you'd like (although I'd recommend to stick w/ red = power, black = gnd) as long as you're consistent. On the other hand, NEVER assume someone else has color coded their wiring. This has bitten me in the rear because I had assumed red would be power and black would be ground, but I was mistaken. The extra time you take in the beginning to do things cleanly will save you hours if not days later on in the project.

Title: Crimp or Solder to LiPo Battery?


答:
I must agree with Andrew Capodieci in that you should use a connectors and 1 mm headers (or whatever the balance lead is). There is a good chance that at some point you will want to remove the battery to replace it/inspect it for damage or whatnot.

If I had to do one of the two, then I would crimp for low current applications, and solder for high current. Crimping is probably fine for small robots, but I wouldn't dream of it for anything that wouldn't fit in a 20 cm cube or especial anything aerial. However, using a connector would be the best option in both situations.

Title: Crimp or Solder to LiPo Battery?

Body:
So, I'm planning out my second hobby robot(I'm 15). I am planning on using a 7.4V LiPo battery and my idea is to solder on a 3-pin header to connect to the electronics. Anyways, should I solder to crimp terminals and then attach it to the pack? Or should I solder directly to the battery leads Keep in mind I have a decent background in hobby electronics and am just starting with robotics. My soldering skills are also decent!

Thanks!!


答:
Really, the decision of whether to crimp or to solder comes from the thickness of the wire.  Thin wire is too brittle to be crimped, and must be soldered.  However, iff the wire is too thick then a soldering iron can't apply heat faster than the wire dissipates it (and the jacket will melt long before your solder does). At that point, your options are to use a torch (like in pipe soldering) or to crimp the connections.

For our batteries, we spot-welded nickel plates to the tops and bottoms of Li-ion 18650 cells to make battery packs, and then added crimp terminals to the connections between packs.

Crimp connections done properly are very reliable -- most residential wiring uses some form of a crimp connector.

Title: Crimp or Solder to LiPo Battery?


问:
How to know what motor/ESC/propeller combination will work for a quadcopter?
I am preparing for my first quadcopter build and need to know how to tell what motors/ESC's/propellers will work with each other. I also would like to know how to tell what the motors would be capable of carrying/how much thrust they have. I would like to put a camera on this copter. I cannot find anywhere a straight answer to this question.

The ones I currently think are the ones I want are:

ESC:
https://www.hobbyking.com/hobbyking/store/__25365__Turnigy_Multistar_30_Amp_Multi_rotor_Brushless_ESC_2_4S.html

Motor: https://www.hobbyking.com/hobbyking/store/__28112__Turnigy_D3530_14_1100KV_Brushless_Outrunner_Motor_US_Warehouse_.html

Propeller: 11inch

This copter needs to be able to carry a camera (~go pro)

TLDR: How does one match ESC's/Motors/Propellers, and how to tell if they can get the job done?

(ESC - Electronic Speed Control)

答:
First step to decide electronics is roughly estimate your all up weight (AUW) which is total flying weight including payload. Now your target total maximum thrust(T) provided by system should be just double your AUW which will ensure good maneuverability and control. This will given you amount of thrust to be provided by each motor (in your case it will be T/4 as you are using 4 rotors).
Now you have got a criteria to choose a motor.
For multirotor purpose, people generally use low rpm brushless motors (< 1200KV). You should also refer to this link for more criteria for motor selection. Once motor is selected, propeller can be selected based on manufacturer data for wattage and thrust for compatible propellers.
ESC can be chosen which is rated higher than maximum current rating of motor.

In your case, motor looks good as maximum thrust is around 1Kg. However no propeller data is given. I would personally suggest you to bench test motor with range of propeller to find optimum performance. However user comments in discussion section on webiste suggest 10x4.5 prop. Current rating for motor is 22A so ESC you are considering (30) should do fine.


问:
Keyboard control map for scalar based movement?
I'm working with a Wild Thumper 6 wheel chasis that is designed for use with an RC controller. However I'd like to have a mapping to a keyboard for control as well. Can you suggest a set of keys and behaviors that you've used to deal with the continuous value control normally offered by a joystick or pair of joysticks? The standard wasd keys + an accelerate/decelerate pair? I'd also take a pointer to a videogame that you think does this well.</p>

答:
Assuming you don't have other functionality that would take precedence, I would use WASD for movement and Left/Right arrows or mouse buttons for accelerating. Having the controls be divided that way mimics the conventional movement/action interface seen in many video games, while letting the user control the speed in parallel to motion.

However, ultimately, the right answer is whatever is most comfortable/intuitive. The above is what I'd try first, but the real best answer is getting user feedback.


问:
Spatial tracking between two UAVs
I have two Unmanned Aerial Vehicles (planes) which work well. They can fly to various waypoints automatically using GPS.

Now I would like them to fly together in formation. I would like them to fly side-by-side fairly close. This is too close to reliably use GPS to guarantee that they keep the correct relative positions safely, and so I am looking for another way.

Somehow the UAVs need to be able to measure their position and orientation in space relative to the other one. How can I do this? Is there some kind of sensor which can do this? It would need to have the following properties:

6 axes (position and orientation)

Range 0m - 5m, (from between plane centres, but planes won't actually ever touch wingtips)

Works in day or night and all weather conditions

Light weight (This is for 1.5m wingspan RC planes, so max extra weight of about 100g)

Probably need about 50Hz - 100Hz refresh rate, but might get away with less, using the IMU to fill in the gaps

答:
It is possible that two independent GPS units might be accurate enough (as ViennaMike suggests) if both are sufficiently similar, get a lock from the same location, follow roughly the same paths (so the accumulated differential GPS errors are roughly the same) and are re-synchronised at regular intervals.

This might be significantly assisted though if you also had some sort of proximity measure between the two devices.

Start them off a fixed distance from each other, sync both their differential GPS locks & calibrate the proximity thresholds (starting distance, too close threshold and too far threshold). You can then use the proximity sensor distance to say if the gps locks are drifting too much (they are getting closer than they should be or further apart).

One option which I believe could provide both rough proximity information and data communication between the two UAVs would be Bluetooth. Once the two devices are paired, you may be able to get both intra-device communication and rough proximity information from one pair of radios.

Searching on Bluetooth Proximity led me to see the use of RSSI (Received Signal Strength Indicator) as a measure of proximity and thus onto Bluetooth Indoor Positioning using RSSI and Least Square Estimation # which may be able to give you some interesting ideas for this.

# Stack Exchange thinks that the original link http://202.175.25.24/papers/2010/fcc2010yapeng.pdf is invalid, so won't let me use it as a link, so I have used the google wrapped link.

Title: Spatial tracking between two UAVs


问:
Radio-control over dozens of kilometers and mountains
I am wondering what technology should I use to transmit data (enough for controlling the robot and receiving video) over dozens of kilometers and mountains ?</p>

答:
How far is it in kilometers? What radio frequency you can use? Do you need security (code the data)?

It strongly depends on your application, it seems you need a real-time connection (to control a robot).

In practice you can use an infrastructure such as telephony systems, GPRS or if you have enough resources you can use satellite solutions.

Another solution is to make a network or repeater of ZigBee modules.


答: You can use high power(1W) radio modems such as digi XTend or RFD900 for controlling your robot. For video transmission you can use high power analog video modules. Using proper directional antennas such as patch antennas or helical antennas, you can easily go up to 20+ km in line of site. </p>

Title: Radio-control over dozens of kilometers and mountains

Body: I am wondering what technology should I use to transmit data (enough for controlling the robot and receiving video) over dozens of kilometers and mountains ?</p>


问:
PID output does not reach setpoint precisely enough
I'm developing/tuning a software PID for a quadcopter. For now I'm only trying to stabilise the pitch angle using the front and back motors, and I'm only looking at Kp. The motors have a control resolution: input variations need to reach a threeshold to have any effect at all.

The process output does reach the setpoint, but not precisely enough for my requirements. There is no steady-state error (aka droop), the hunting range is centered on the setpoint, just too wide for my requirements. Also the instability is not an oscillation, but more of a random drift which needs to be large enough before the PID attempts to correct it.

With a lower Kp the output needs to diverge from the setpoint significantly before the error is big enough for the PID to attempt to correct it.

With a higher Kp the PID oscillates.

I could not find a reasonable compromise.

I'm thinking about applying the cuberoot function (or similar) to the error before feeding it to the PID: that way small errors should be significant enough for the PID to attempt to correct them, and large errors would be reduced and might not trigger oscillations. I suppose someone must have been through this before: is this a good solution? Are there any better alternatives?

This is not a steady-state error (aka droop) or oscillation issue as far as I can tell: please don't suggest using Ki or Kd

EDIT: I have clarified the problem description and suggested using cuberoot rather than logarithm which was a bad idea indeed.

Thanks,
Marc.

答:
I am unsure of why you said "please don't suggest using Ki or Kd" and will suggest them anyway.
From the comments from the original post I understood that it is not the problem that you settle near the setpoint but that you oscillate around it.

If that is the case then you need to add Kd to dampen the oscillations.

If your problem is in fact that you settle near the setpoint then you need to add Ki to compensate that error.

This is the reason why there are all three terms in the PID regulator and not just one. Such behavior from using proportional term only is expected. Introducing nonlinearity such that you suggested is not something you should generally do.

Regards


答:
I'm going to suggest it anyways. Add an integrator.

What you've described is a textbook description of how a proportional only controller would work. If your output is stable, you will never reach your setpoint. From Wikipedia:

Because a non-zero error is required to drive it, a proportional
  controller generally operates with a steady-state error, referred to
  as droop. Droop is proportional to the process gain and inversely
  proportional to proportional gain. Droop may be mitigated by adding a
  compensating bias term to the setpoint or output, or corrected
  dynamically by adding an integral term.

Biasing is typically a static value added to the output based on some known quantity. If the droop is a know stable constant, you can do this. But my personal feeling is that it is usually a hack that requires constant adjustment.

You're attempting to achieve dynamic biasing by using the logarithm of the error. Don't mess with the input to the controller. It will only cause you headaches down the line. You will achieve much better results if you use an integrator.

The alternative is to use a lead-lag filter:

A lead compensator can increase the stability or speed of reponse[sic] of a
  system; a lag compensator can reduce (but not eliminate) the
  steady-state error.

But you will achieve the same thing with a lot less math if you manually tune using an integrator.

Title: PID output does not reach setpoint precisely enough

Body:
I'm developing/tuning a software PID for a quadcopter. For now I'm only trying to stabilise the pitch angle using the front and back motors, and I'm only looking at Kp. The motors have a control resolution: input variations need to reach a threeshold to have any effect at all.

The process output does reach the setpoint, but not precisely enough for my requirements. There is no steady-state error (aka droop), the hunting range is centered on the setpoint, just too wide for my requirements. Also the instability is not an oscillation, but more of a random drift which needs to be large enough before the PID attempts to correct it.

With a lower Kp the output needs to diverge from the setpoint significantly before the error is big enough for the PID to attempt to correct it.

With a higher Kp the PID oscillates.

I could not find a reasonable compromise.

I'm thinking about applying the cuberoot function (or similar) to the error before feeding it to the PID: that way small errors should be significant enough for the PID to attempt to correct them, and large errors would be reduced and might not trigger oscillations. I suppose someone must have been through this before: is this a good solution? Are there any better alternatives?

This is not a steady-state error (aka droop) or oscillation issue as far as I can tell: please don't suggest using Ki or Kd

EDIT: I have clarified the problem description and suggested using cuberoot rather than logarithm which was a bad idea indeed.

Thanks,
Marc.


问:
What are the advantages of optimal control as opposed to control theory?
For a robot, say path planning in particular, what are the pros and cons of choosing classical control theory or optimal control (LQR for example) ?</p>

答: Classical control theory requires Linear Time Invariant systems. Most robots of interest actually have non-linear dynamics. Of course many optimal control techniques also require linear systems. LQR for instance stands for Linear Quadratic Regulator meaning it takes a quadratic cost function and gives the optimal control for a system with linear dynamics. This is handled in both cases by linearizing the dynamics. In the case of classical control techniques linearizing the dynamics invalidates all the guarantees and the tools for analyzing stability and tuning gains generally don't work. In the case of optimal control methods then generated control will often still be good so long as the approximation error is low. Often it helps to simply try the different methods. Alternatively you may consider non-linear control methods.


问:
What is the minimum number of RC channels required to control a Quad Copter?
Most of the blogs/website say we need a minimum of four channels for a quadcopter (pitch, roll, throttle, yaw):

One channel for throttle

A second channel for turning right and left.

A third channel for pitching forward and backward.

A fourth one for rolling left and right.

But looking at the RC transmitter, I see that at a time you can change a maximum of two sets data (left and right joy stick). Even if you want to send Rudder and Throttle information at the same, can it not be sent in the same packet?

My understanding is two channels should be sufficient to control a quad copter. Please provide more clarity on this.

答: You have two channels on each stick. Commonly throttle and yaw on the left stick and pitch and roll on the right.</p>


问:
What do the commutation waveforms look like for a brushless motor?
I have seen waveforms for driving a brushless motor.

I guess this is the waveform used for the simpler block commutation. But if I want to do sinusoidal waveforms, what does the PWM signal look like now? Is there a need to carefully synchronise the edges on the three phases?

答:
The diagram you show looks like it would produce a pretty rough trapezoidal Back-EMF. I'm assuming that the gates that are at 100% are the lower legs of the motor drive bridge. I can't think of a reason you would want to do this. In general you want the gate voltage of the return leg to be the complement of the gate voltage of the supply leg.

In six-step trapezoidal commutation, you typically ramp the PWM up to 100%, leave it there for a while (~30 electrical degrees of rotation), and then ramp it back down again.

In sinusoidal commutation, the PWM duty cycle is continuously varied in sinusoidal values. Here is a good diagram showing the difference between sinusoidal drive and trapezoidal drive PWM and phase signals:

This Fairchild app note shows the PWM though a full 360° rotation:

It's useful to look at what's going on in the signal up close. What you're really doing is gradually varying the current in a triangular wave so that it slowly builds up in the stator of the motor. You have more control over this buildup if you drive the supply and return gates in a complementary fashion rather than holding the lower leg open.

Computing a sine wave is more computationally intensive (unless you use a lookup table) than a simple ramp up, hold, ramp down. But it produces a much smoother drive.

Space-vector commutation is even more computationally intensive. And while it has more torque ripple than a sinusoidal drive, it makes higher utilization of the bus voltage and is therefore more efficient in terms of power.

The phase voltage in space vector drive ends up looking like this:

This is done by varying the PWM duty cycle in all three phases at the same time. This is opposed to having just a single phase driven as in two-quadrant drive or having two phases driven in complementary pairs as in four-quadrant drive.


问:
Datasheet for Taos TCS3200 GY-31
Can someone please post the datasheet for the colour sensor mentioned above. All i can find is for TCS3200</p>

答: One thing I find helpful for minimal or missing datasheets is to look for Arduino/PIC or other code examples and discussions on the module. The basic datasheet has wiring - but no actual usage help, where as forum discussions and code examples will get you some actual results from it. This one looks promising.</p>

Title: Datasheet for Taos TCS3200 GY-31


问:
Why does iRobot not sell the Create in Europe?
I'm trying to find a good beginners platform to use ROS with, and I came across the iRobot Create. To my surprise, they do not sell in Europe. Why is that?</p>

答:
I believe the Create was not sold in Europe because it is not RoHS compliant.

However, every Roomba can be hacked.  You can communicate with the robot with the "Open Interface" or sometimes called the "Serial Control Interface".  There is lots of information about this on the web.  See here for example: http://www.irobot.com/filelibrary/pdfs/hrd/create/Create%20Open%20Interface_v2.pdf

Note that you will need to either make or buy a cable to connect to the 7 pin mini-DIN port on the robot.  Every Roomba has this.  Sometimes it is under the faceplate though.

Most libraries you can find online communicate with the Roomba outlined above and do not use the "Command Module" that was unique to the Create.


答:
In this case, you can think of a "channel" as a "linear control" -- a single-dimensional value.  For example, throttle can go from 0%-100% (or -100% to 100% if you're doing some really crazy things); roll, pitch, and yaw are expressed as a range of degrees.

The RC transmitter you refer to has 2 joysticks, each with 2 dimensions, for a total of 4 channels that can be controlled -- this covers all the channels you mentioned.

However, since a quadcopter can move freely in any cardinal direction, you need only transmit 3 channels: throttle, roll, and pitch.  This prevents you from controlling what direction the quadcopter is facing at any one time, but does not limit its mobility.

Title: What is the minimum number of RC channels required to control a Quad Copter?

Body:
Most of the blogs/website say we need a minimum of four channels for a quadcopter (pitch, roll, throttle, yaw):

One channel for throttle

A second channel for turning right and left.

A third channel for pitching forward and backward.

A fourth one for rolling left and right.

But looking at the RC transmitter, I see that at a time you can change a maximum of two sets data (left and right joy stick). Even if you want to send Rudder and Throttle information at the same, can it not be sent in the same packet?

My understanding is two channels should be sufficient to control a quad copter. Please provide more clarity on this.


答:
It sounds like the problem stems from your motors.  The motors are fine, but they have a threshold that prevents you from setting their speed to exactly the value you want.  This is a problem because you are attempting to map your PID directly to their output, which has a minimum value.

You need to alter your motor control code so that if the desired thrust is below the motor's threshold, you pulse the motor so that its average over time is the thrust you need.  There are several ways of accomplishing this, depending on how your control loop works.


答:
You're posting somewhat of a contradiction.  If you want a radio signal with enough bandwidth to transmit video, then you'll have to use line-of-sight communications.

To do what you're asking, you'd need more of a network solution, or a very high vantage point (i.e. somewhere in the atmosphere) for your control antenna.


问:
Battery system with and without mains voltage attached
I'm working on a project where mains voltage will sometimes be disconnected, and the system will have to run on battery for as long as possible before doing a (safe) shutdown.  The desired behavior is exactly like a laptop battery system:

When mains voltage is connected, charge the battery and power the system from mains

When mains voltage is disconnected, power the system from the battery

Prevent the battery system from supplying current when the batteries are discharged below a certain voltage (to prevent damage).

Is there a name for this type of system, or a name for the feature(s) that I should be looking for when I look at chargers?  (If it matters, this system will be 12V, so I'm looking at 14.8V Lithium battery options.)

答:
I found the name of the component: PMIC, or Power Management IC.

To quote from this example:

PMICs seamlessly manage power flow from various power sources (wall adapters, USB and batteries) to power loads (device systems and the charging battery), while maintaining current limits where required (such as that specified for USB). To this end, PMICs typically feature built-in PowerPath control, DC/DC conversion and battery charging functions.


答:
Since posting the question I tried to tune the 3 PID parameters a lot but I never reached any acceptable result. I didn't try to modify the error curve as I suggested in the question, but I found an alternative solution which works reasonably well. There might be other good solutions.

I was using a PID as follows:

process setpoint: angle

process output: difference between motors speed (used in motor mix equation)

While in theory this might very well work, I could not find good values for Kp, Ki, and Kd to obtain satisfying results. I changed my program to use 2 cascaded PIDs as follows:

Outer PID:

process setpoint: angle

process output: angular rate

Inner PID:

process setpoint: angular rate

process output: difference between motors speed (used in motor mix equation)

I first tuned the inner PID so as to get no oscillation but a slight resistance against angular change when the target angular rate is zero. I then tuned the outer PID so as to get no oscillation but a reasonably responsive attitude matching the stick inputs. Even with a very basic tuning the results are acceptable.

Thanks again to all the participants, your input encouraged me to learn more about PIDs and avoided me some errors.


问:
Single camera vision and mapping system
Some time ago I saw a demo of a small 'toy tank' with a single camera mounted on it. This tank was able to drive around the floor and detect objects and then move/steer to avoid them.
The interesting part was that it used a single camera vision system and as far as I remember was taking advantage of the floor being flat. and then using the rate a feature was moving in the scene relative to the motors and directions of travel to evaluate and hence map the scene.

Can anyone send me pointers what to search for to get some more information on this, or some pointers to codebases that can do this.

The reason I ask is that this was a single camera system from a number of years ago (5+) and therefore (from what I remember) was a relatively low compute load.
I was intending to try this out on a Raspberry PI to build a car/tank that maps a room or set of rooms.

答:
In the general you can't extract metric distance measurements from a single image, unless  you have extra information about the world. For example, if you know the world is planar (or you can detect the floor, which is a planar region), then you can estimate a homography.

A homography is a projective transformation between planes (3x3 matrix). Given the camera intrinsic calibration, you can decompose this plane-induced homography into a rotation and translation. The translation is up to scale. You can resolve this scale ambiguity by knowing the distance from the camera to the floor (plane).

Once you have the homography, you can detect objects that are not on the plane. The homography allows you warp the first image onto the second. Objects on the plane will align and will have a small error. Objects not on the plane will not align. This is called parallax.

One way to implement this could be

Extract features from both images.

Match the features, or track them.

Estimate the homography using RANSAC.

Decompose the homography into a rotation and translation using the calibration.

Warp the first image onto the

second. Pixels with large errors are not on the floor and could be

obstacles.

Most of the building blocks are implemented in opencv (see http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html).

Good luck.

P.S. the homography decomposition will also give you the normal of the plane. But, since you are assuming this is the ground plane, we have the normal pointing in the up direction. A more precise solution can be accomplished in your calibration procedure. You can use a checkerboard target and estimate its pose. The pose will have a plane normal and distance to the camera.

Title: Single camera vision and mapping system


答:
Ironic answer: you do not need any channel, but your quadcopter will just hover stationary :)

Practical answer:

The throttle controls translation on the vertical axis. This allows you to gain or loose altitude. Depending on how the quadcopter is programmed you may control the vertical acceleration or the vertical speed (aka autolevel mode).

The rudder controls the rotation around the vertical axis. This allows you to face North, East, South, and West.

The ailerons and elevator (2 channels) control the roll and pitch. This allows you to get the quadcopter at an angle compared to the horizontal plane, and move forward, backward, left, or right. Depending on how the quadcopter is programmed you may control the angular rate (aka manual mode) or the angle (aka attitude mode).

In addition you may have any number of spare channels to control the flight mode, trigger a camera, control a gimbal, retract the landing gear, etc.

As commented in the ironic answer none of this is required, but more channels will make your quadcopter experience more fun. You don't say what your goal is, but if you want to build a quadcopter for fun I would recommend at least 6 channels, and advise against using a 4-channels transmitter. For instance the mainstream DJI Naza controller requires 6 channels to use all the features.

Extra information: Each joystick counts for 2 channels, because they can move on 2 different axes. The number of channels does not mean anything on a hardware/packet level on modern controllers (2.4GHz), as all the channels are multiplexed into digital packets and demultiplexed at the receiver. Multiplexing 4 channels into 2 on the transmitter and demultiplexing them on the receiver is possible but it would require a significant amount of DIY and is not practical or sensible for any actual application.