问:
How to determine the parameter of a Complementary Filter?
I know that the Complementary Filter has the functions of both LPF and HPF. But I think my understanding on the principal behind it is still unclear.

I am quite new on digital signal processing, and maybe some very fundamental explanations will help a lot.

Say I have a Complementary Filter as follows:

$$y =a\cdot y+(1-a)\cdot x$$

Then my parameter $a$ may be calculated by $$a=\frac{\text{time constant}}{\text{time constant}+\text{sample period}}$$
where the $\text{sample period}$ is simply the reciprocal of the $\text{sampling frequency}$.

The $\text{time constant}$ seems to be at my own choice.

My Questions:

What is the theory behind this calculation?

How do we choose the $\text{time constant}$ properly?

Note: I also posted this question on Stack Overflow, as the answers there are likely to be slightly different in emphasis.

答:
The complementary filter you mentioned comprises of both a low-pass filter (which filters out, or attenuates, short term accelerometer fluctuations), as well as a high pass filter (which tries to negate the effect of drift on the gyroscope).

A time constant $\tau$ with respect to first order filters describes at what point (the cut-off frequency $f_{c}$) information should start being rejected (LPF) or stop being rejected (HPF). With respect to a complementary filter the time-constant used is the same for both the LPF as well as the HPF. The time constant can be thought of as boundary between trusting the gyroscope, and trusting the accelerometer.

The value of $a$, or the time constant, should be a function of your gyroscope's drift and accelerometer noise. You can optimize to filter out gyroscopic drift (HPF with slow cut-off), but then your accelerometer will allow too much accelerometer noise (LPF with slow cut-off).

As with all filter design, calculate the filter coefficients, test it to confirm it doesn't work, and randomly tweak it till it does.

Refer to the following links for more in depth discussion:

Marion, C. The Segway: Theory (Jan 2011)

Colton, S. A Simple Solution for Integrating Accelerometer and
Gyroscope Measurements for a Balancing Platform (June 2007)


问:
What is the difference between a Robot and a Machine?
What is the difference between a Robot and a Machine? At what point does a machine begin to be called a robot?

Is it at a certain level of complexity? Is it when it has software etc?.

For instance: A desktop printer has mechanics, electronics and firmware but it is not considered a robot (or is it). A Roomba has the same stuff but we call it a robot. So what is the difference.

I have always believed that a robot is a robot when it takes input from it's environment and uses it to make decisions on how to affect it's environment; i.e. a robot has a feedback loop.

答:
There are quite some definitions (see other questions) and even robot ontologies. I am with Joseph Engelberger (inventor of the first industrial robot Unimate):

I can't define a robot, but I know one when I see one.

Works quite well.

ContentLicense: CC BY-SA 3.0


问:
Absolute positioning without GPS
Using an IMU a robot can estimate its current position relative to its starting position, but this incurs error over time. GPS is especially useful for providing position information not biased by local error accumulation. But GPS cannot be used indoors, and even outdoors it can be spotty.

So what are some methods or sensors that a robot can use to localize (relative to some frame of reference) without using GPS?

答:
Primarily, dead reckoning is used along with some other technique, generally SLAM-like. The robot builds a map, and then tries to localize within that map. For example, using laser range scanners, and based on dead reckoning, the robot has an idea of where it is. By comparing the laser range data to the map, it can improve its estimate.

Relevant resources are:

Indoor positioning system on Wikipedia.

H. Liu, H. Darabi, P. Banerjee and J. Liu. Survey of Wireless Indoor Positioning Techniques and Systems. IEEE TRANSACTIONS ON SYSTEMS, MAN, AND CYBERNETICS, page 1067.

Tracking Position Indoors: moving from Hype to Reality.

Methods include:

SLAM (or at least localization) with

laser

vision (cameras, stereo-vision)

structured environments

cellular signals

wifi signals

RF (radio frequency) beacons and triangulation (more information at http://www.wpi.edu/Images/CMS/PPL/ITT.pdf).

camera tracking systems (optical tracking of markers within a space)

Title: Absolute positioning without GPS


问:
Off-the-shelf micro fluid dispenser
Need a way to dispense micro liter amounts of water (lets say 1-10ul). Only thing I've found is piezoelectric dispensers and they are >$100. Any suggestions?

I can build, but preferably would be an off-the-shelf component.

答:
It may be practical to adapt some ink-jet printer heads to dispense water.

An ink-jet printer head projects a stream of droplets.  Droplet volume varies widely among printers; typically, it's smaller in newer printers.  Eg, a fairly-comprehensive 1998 inkjet tutorial at imaging.org says early HP 800-series ink-jets produced 6000 drops per second with 32 pL per drop, which works out to about 5.2 seconds to deliver 1 µL of ink.  (I don't know if the DPS is per nozzle or per head.) The later 890C with a 192-nozzle head produced 12000 drops per second with 10 pL per drop, or about 8.3 s to deliver 1 µL of ink.  As noted in a 2010 computerworld.com blog, the “Photosmart 8250 uses 3,900 nozzles to deliver 122 million drops per second onto the paper.”

(Note, with a drop-on-demand printhead, you could count drops – that is, control the number of pulses –  vs turning the head on for a timed interval.)

An article called Non-Contact Liquid Handling: Basics and Technologies at labautopedia.org gives a good introduction to several techniques now in use for delivering small amounts of liquid. [Edit, May 2015: Article is gone; instead see Small Volume Pipetting and perhaps Microfluidic Sample Transport.]   Among other topics it covers physics of
droplet formation and illustrates several valving techniques.

Another useful survey, “Dispensing systems for miniaturized diagnostics”, is at ivdtechnology.com. [Edit, May 2015: Website is gone; perhaps see a search for related articles at mddionline.com]

The wikipedia inkjet article referenced earlier and a wikipedia microdispensing article are helpful but seem superficial compared to the imaging.org and labautopedia.org articles.  Also see an nlm.nih.gov article about dispensing an enzyme-conjugated solution into an ELISA plate by adapting ink-jet printers, by Lonini et al.

Title: Off-the-shelf micro fluid dispenser


问:
How do SLAM algorithms handle a changing environment?
I'm doing some groundwork for a project, and I have a question about the current state of SLAM techniques.

When a SLAM-equipped device detects an object, that object's position is stored. If you look at the point cloud the device is generating, you'll see points for this object, and models generated from it will include geometry here.

If an object is placed in a previously-empty space, it is detected, and points are added. Subsequent models will feature geometry describing this new object.

How does the device react if that object is removed? As far as I've seen, SLAM systems will tend to leave the points in place, resulting in "ghost" geometry. There are algorithms that will disregard lone points caused by transient contacts, but objects that remained long enough to build up a solid model will remain in the device's memory. Are there any systems that are capable of detecting that previously-occupied space is now empty?

答:
That very much depends. Since SLAM is a problem (or at least a technique), not a solution, there is no definitive SLAM algorithm.  Semantically, you have to decide what goes on a "map" of the environment, and that determines how your algorithm should handle transient (aka moving) signals. But that's a digression.

Permanent maps:

Permanent maps should contain enough information to localize yourself with respect to known geometry. Typically used in buildings. Typically human-readable. See Willow-Garage's work. or anything by Thrun in his quite famous textbook. If you lose this map, you have to build it up over time again.

Removing objects. Yes, the object will appear in a static map for a time. If no measures are taken to remove previously-detected objects, then it will persist. A typical 2D grid-based representation will use each grid cell to represent the probability of an object, so after time the object will "fade".

Adding objects. Same as above.

Local maps:

In reality, SLAM is usually used to localize a robot as it moves, and the map is not kept permanently (or, it is kept permanently, but only the closest Y features are used). Local maps are whatever the robot needs to know to determine how it moved in the last X minutes, where X depends on the application. If you lose the map, you can still fly just fine by using whatever features are in sight right now.

Batch methods such as Bundle Adjustment using visual features is a very common technique in this direction. Features may be kept over time, and even revisited, but a moving feature is just an unreliable feature, and it will be ignored when trying to figure out where the robot is.

Visual SLAM is exactly this. It is a delta-P (change in pose) estimator, not a map-based localization algorithm.

In short, as long as most things are not currently moving, it doesn't matter if you remove an object when the robot isn't "looking" at it.

Example

So do this. When you read a SLAM paper, decide the following:

Are they really building a map?

Are they just keeping a list of features and locations?

If so, what "features" go in the map? Lines, points, visual features?

Are these features likely to move?

If so, how can they handle that?

Finally, sensor noise often "looks" like moving features. How do they handle sensor noise? Because this will often determine what happens to moving features.

You'll get a different answer for each paper / author / book / application. In short, they are typically omitted since they don't help the robot localize much, and can be avoided by simply having a few low-level path planner that only uses local information.

Good luck, slam is a huge topic.


答: Just how precise do you need to be? We build medical instruments and a $100 pump would be considered pretty damn cheap around here. The most common technology is a syringe pump controlled by a stepper motor, but for precise, very repeatable dispense, fluid dynamic effects have to be considered. e.g., wicking off the droplet at the probe tip can have a dramatic impact on accuracy.</p>

Title: Off-the-shelf micro fluid dispenser

Body:
Need a way to dispense micro liter amounts of water (lets say 1-10ul). Only thing I've found is piezoelectric dispensers and they are >$100. Any suggestions?

I can build, but preferably would be an off-the-shelf component.


问:
H-Bridge using atmega8 microcontroller
I want to use my atmega8 uC as a h-bridge.

Can anybody give me the source code using C, so that the microcontroller acts as an H-Bridge.

答:
I'm not really familiar with Atmel microcontrollers, but I'm assuming you're using some Arduino variant. Here's a pretty thorough tutorial about using an Arduino with a SN754410 h-bridge (found it via the SN754410 Sparkfun entry). It seems the only thing the tutorial lacks is controlling the motors via PWM, which of course means you will only be able to control the motors direction, and whether the motor is on or off. Just google Arduino PWM, I'm sure there's loads of code examples. [Update] See also Adafruit Arduino tutorials.

One thing to keep in mind is to never enable both directional signals at the same time (which obviously causes a straight short across your motor rail). One way of ensuring this never happens is by using only one micro-controller output (eg MOTOR_DIR_FORWARD), and then feeding that into a not-gate, and then into your other directional signal (in other words, instead of having a motor enable ouput, and two directional outputs, you'll only have a motor enable output, and a single directional output).

Also remember that if your motors and micro are running off the same supply that insufficient decoupling may cause your micro to reset.

Title: H-Bridge using atmega8 microcontroller


问:
What are good strategies for tuning PID loops?
Tuning controller gains can be difficult, what general strategies work well to get a stable system that converges to the right solution?

答:
For small, low torque motors with little or no gearing, one procedure you can use to get a good baseline tune is to probe it's response to a disturbance.

To tune a PID use the following steps:

Set all gains to zero.

Increase the P gain until the response to a disturbance is steady oscillation.

Increase the D gain until the the oscillations go away (i.e. it's critically damped).

Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations.

Set P and D to the last stable values.

Increase the I gain until it brings you to the setpoint with the number of oscillations desired (normally zero but a quicker response can be had if you don't mind a couple oscillations of overshoot)

What disturbance you use depends on the mechanism the controller is attached to. Normally moving the mechanism by hand away from the setpoint and letting go is enough. If the oscillations grow bigger and bigger then you need to reduce the P gain.

If you set the D gain too high the system will begin to chatter (vibrate at a higher frequency than the P gain oscillations). If this happens, reduce the D gain until it stops.

I believe this technique has a name. I'll put it here when I find it.


答:
If your goal is to dispense a single reagent (water), then you are best off using a microdispensing valve based solution. I do not know that you will find something for less than $100, but if you went that route, you would be looking for parts like this.

There are other technologies out there (syringe based, capillary action based, pipette based), but none are suited as well as a microdispensing valve for bulk reagent dispensing in the 1-10uL volume range. You can find more technical information about microdispensing here.

Title: Off-the-shelf micro fluid dispenser


答:
It is not possible to use the micro-controller directly as an H-Bridge. A micro-controller is a micro-controller and an H-bridge is an H-bridge. You need both of them to control a motor (or something equivalent).

I will suppose that you are using motors and not servo. Let's say you want to use your micro-controller as an H-bridge. You have two cables from the motor. One for the ground and the other one for the current. When both of them are plugged, how are you going to wired it to the micro-controller to control the motor ? Or are you going to wire directly the current supply wire to the micro-controller ?

The thing is you will not be able to input enough current to move the motor with just the pin of a micro-controller. You will need another source of current and thus, something to control it, if you want to control the direction and speed of your motor. That's where the H-bridge is used.

You should read some documentation about H-Bridge, it's not that complicated to understand.

And if you really want not to use H-Bridge, you can create one with transistors on the bread-board. That tutorial is pretty good for that.

If in the end you want to use H-Bridge, the tutorial that EDDY74 gave you is perfect for that. Really simple and easy to understand. To, then, control the motor via a PWM is fairly easy since you just have to modulate the enable pin or the motor logic pins (I guess it depend on the H-bridge you are using).
There a discussion about speed control on the Arduino forum.

Title: H-Bridge using atmega8 microcontroller

Body:
I want to use my atmega8 uC as a h-bridge.

Can anybody give me the source code using C, so that the microcontroller acts as an H-Bridge.


问:
AT command in SIM900A GSM/GPRS module to find out originating address of an SMS
I am using SIM900A for some purpose and want to know the number of the sender from where a message comes. I am unable to find the specific AT command related to receiving message which give me number from where latest message comes.

I had used AT+CNMI (it corresponds to notification regarding latest received message), but am unable to find sender number.

I had seen AT+CMGL=<stat>[,<mode>] will give you a string which will have oa i.e. originating address and once that is stored in a string I can easily parse it out, but when I had data format of that string. Need help or any suggestion if somebody can help me out with any other possible solution.

答:
Text mode vs PDU mode

The SIM900 module supports both text and PDU mode. Please note that some AT commands have different syntax depending on which mode is currently active.

To check which mode is currently active (0: PDU mode, 1: Text mode):

```<code> AT+CMGF?
</code>```

Retrieving SMS's

You can use the CMGL command to retrieve unread, read, stored unsent, stored sent, or all messages.

If text mode is currently selected:

```<code> AT+CMGL=STAT,MODE
</code>```

Parameters:

```<code>STAT:
   "REC UNREAD"  Received unread messages
   "REC READ"    Received read messages
   "STO UNSENT"  Stored unsent messages
   "STO SENT"    Stored sent messages
   "ALL"         All messages
MODE: (OPTIONAL)
   0 Normal
   1 Not change status of the specified SMS record

In other words, the following command should print all SMS messages:

   AT+CMGL="ALL"
</code>```

If PDU mode is currently selected:

```<code> AT+CMGL=STAT,MODE
</code>```

Parameters:

```<code>STAT:
   0  Received unread messages
   1  Received read messages
   2  Stored unsent messages
   3  Stored sent messages
   4  All messages
MODE: (OPTIONAL)
   0 Normal
   1 Not change status of the specified SMS record

In other words, the following command should print all SMS messages:

   AT+CMGL=4
</code>```

Example

If text mode is currently selected, and a CMGL command is issued, the following is an example of what could be expected (note there's a line break before the actual message starts).

```<code>AT+CMGL="ALL"
+CMGL: 1,"REC READ","+85291234567",,"07/05/01,08:00:15+32",145,37
It is easy to list SMS text messages.

     1                      : Message index
     "REC READ"             : Message status (it's been read before)
     "+85291234567"         : Source number (ie the person that sent you the sms)
     "07/05/01,08:00:15+32" : Service center timestamp
     145                    : Character set
     37                     : Length of message

Refer to Section 4.2.3, page 99, of the SIM900 AT command set for more information.
</code>```

External links

SIM900A AT Command set (V1.05: 2011-10-24)

Developers home — Tutorials regarding AT commands (I'd strongly recommend you take some time and go through the tutorials — especially sections 18 to 26)

Body:
Text mode vs PDU mode

The SIM900 module supports both text and PDU mode. Please note that some AT commands have different syntax depending on which mode is currently active.

To check which mode is currently active (0: PDU mode, 1: Text mode):

 AT+CMGF?

Retrieving SMS's

You can use the CMGL command to retrieve unread, read, stored unsent, stored sent, or all messages.

If text mode is currently selected:

 AT+CMGL=STAT,MODE

Parameters:

STAT:
   "REC UNREAD"  Received unread messages
   "REC READ"    Received read messages
   "STO UNSENT"  Stored unsent messages
   "STO SENT"    Stored sent messages
   "ALL"         All messages
MODE: (OPTIONAL)
   0 Normal
   1 Not change status of the specified SMS record

In other words, the following command should print all SMS messages:

   AT+CMGL="ALL"

If PDU mode is currently selected:

 AT+CMGL=STAT,MODE

Parameters:

STAT:
   0  Received unread messages
   1  Received read messages
   2  Stored unsent messages
   3  Stored sent messages
   4  All messages
MODE: (OPTIONAL)
   0 Normal
   1 Not change status of the specified SMS record

In other words, the following command should print all SMS messages:

   AT+CMGL=4

Example

If text mode is currently selected, and a CMGL command is issued, the following is an example of what could be expected (note there's a line break before the actual message starts).

AT+CMGL="ALL"
+CMGL: 1,"REC READ","+85291234567",,"07/05/01,08:00:15+32",145,37
It is easy to list SMS text messages.

     1                      : Message index
     "REC READ"             : Message status (it's been read before)
     "+85291234567"         : Source number (ie the person that sent you the sms)
     "07/05/01,08:00:15+32" : Service center timestamp
     145                    : Character set
     37                     : Length of message

Refer to Section 4.2.3, page 99, of the SIM900 AT command set for more information.

External links

SIM900A AT Command set (V1.05: 2011-10-24)

Developers home — Tutorials regarding AT commands (I'd strongly recommend you take some time and go through the tutorials — especially sections 18 to 26)


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

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

答:
I think a more compact and reliable solution would be to use a third shaft that is perpendicular to the other two (on the Z-axis)

Given the shaft moving up/down is moving on the Y-axis and the shaft moving left/right is moving on the X-axis.

This crude diagram should explain things better.

As the motor turns Shaft A upwards it then turns Shaft C. Shaft C then moves Shaft B left and right

The addition of Shaft C would make this vertical to horizontal conversion precise and compact.

Note that the only rotating parts are Shafts A and C. Shaft B would only move left and right.

And unlike Kurts answer there's no need for messy joints at the end of each shaft.

ContentLicense: CC BY-SA 4.0


问:
What modelling tools are available to design a robot
I am planning to build a robot.

1) What free or low cost robot modelling tools exist.

答:
Here are some that I know of:

Solidworks student edition:
http://www.solidworks.com/sw/education/cad-faq-students.htm
(Free for students who use a school's privately assigned password, otherwise $149)

AutoCAD Student version: http://students.autodesk.com/ (Free for students)

Google Sketchup: http://www.sketchup.com/products/sketchup-make (Free)

FreeCAD: http://www.freecadweb.org/ (Free)


问:
Reducing motor speed without jamming up
So I built three little bots so far.

One with a raspberry-pi, (6V motors), one with an arduino (12V motors), and another with an arduino but a hacked remote car (7ish, volt motors):

The problem I have with all these is that the motors spin so fast the car just bumps into something in a few seconds. (I have a small house)

I tried to use PWM to control the speed, but at a little less than full throttle (255) they jam up and they can't take the weight I put on them.

Should I buy one of these chassis that slow the motor down and give it torque with a gearbox, or is there anything else I can do?

答:
You need to use a PID algorithm to control the speed of the motors, that way you'll be able to make them spin as slow as you need while still getting torque. The PID algorithm needs to measure the speed of your motor somehow, the typical way is to place some optical encoders in the wheels, this is a must for any rover and besides giving you the speed will give you a very good estimate of the position, which helps navigate and make turns.

You can steal the optical encodes from an old mouse, those with a ball.

Title: Reducing motor speed without jamming up


问:
Moldable rubber for "feet"
I’m trying to inject some kind of rubber around an aluminum strut to form “feet” for a robot. I’ve already milled the mold, but I’m having trouble finding an inexpensive and readily available rubber compound that will cure without exposure to air. Ideally it should cure to about the consistency of a silicone O-ring. I’ve tried silicone gasket-maker (the automotive stuff), however a week later it hasn’t cured in the mold, as there is no exposure to the air.  Is there anything out there with a similar consistency to silicone, but doesn’t require air to cure?  Or is there a way to get what I’m currently using to set up without waiting a millennium?  There aren’t any real mechanical requirements, I’m just trying to clean up the look of the robot and prevent its legs from scratching my table. </p>

答: Sugru is great for this kind of thing, but it can be a little pricey. An alternative is Oogoo, a DIY mixture of silicone caulk, cornstarch, and (optional) pigment.</p>

Title: Moldable rubber for "feet"


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

答: All seals leak. If you are able to enclose the motor so that the shaft is the only exit point, fill the motor with a low viscosity non conductive oil such as mineral oil. This greatly reduces the pressure difference across the seal.</p>


问:
Approach to using PID to get a differential robot driving straight
Consider a differential drive robot that has two motorized wheels with an encoder attached to each for feedback. Supposed there is a function for each DC motor that takes a float from -1 to 1 and sets the PWM signals to provide a proportional amount of power to that motor. Unfortunately, not all motors are created equal, so sending each motor the same PWM signal makes the robot veer left or right. I'm trying to think about how to drive the robot straight using the encoders attached to each motor as input to a PID loop.

Here's how I would do it: I would take the difference between the left and right encoders, bound the error between some range, normalize it to be from [-1, 1], and then map it to the motor powers 0 to 1. So if I and D were zero, and we get an error of 1 (so the left motor has turned much more than the right motor), then left motor would be set to 0, and the right motor set to 1 (causing a hard left).

Are there any issues with this? What is a better approach?

答:
I have a bot with 2 independently driven wheels.

I chose to use a gyro to keep it heading in the desired direction, bumps slippage and even picking it up and turning it around are of little consequence to it as it will just correct it's heading.

I use a single PID, which adds/subtracts a correction to the desired current speed for each of the 2 motors in accordance with the error in the current heading (direction) as determined by the gyro.

For example I set the speed to 50% and the heading to 20degrees. this would normally drive both motors at 50% power. but as the heading wanders off, the PID will make adjustments adding some power to one motor and removing some power from the other, so you might end up with a 45%/55% power split between the motors as the pid corrects the heading.

Gyros have their problems though, even with some time spent calibrating I'm still finding my gryo has about 1 degree per minute drift. It might be because the earth rotates 15 degrees per hour, this should also be considered in the long run.

As previously stated encoders on the wheels are a great idea for actually knowing how far you have traveled.


问:
Design Calculations & Mathematical Modeling of Tricopters
I have been studying about building a tricopter.  But I couldn't find the design calculations or mathematical modeling of the tricopter any where over the internet.

What are the mathematical relationships or equations of motion and forces in tricopter?  How do I calculate the requirements of the structural design and the energy requirements of the motors?

答: I found the following paper, Model Predictive Control of a Tricopter (Barsk, J. 2012) quite helpful.</p>


问:
Assigning Serial number and GUID to a microcontroller
This might be a out of league question and may seems to be very odd.I am using multiple Arduino UNO boards over network and want to assign a GUID and Serial number to each board so that when ever they send any data to a central server, server is able to find which Device it is if we have assign name for each device.

first way to do this is to assign GUID and serial number of device before each message that is send to central server manually while programming and then burn that hex to arduino.

Now is there any way out that we can burn a program that always give a output as a string (GUID+Serial number of device) like we program EEPROM for this and then burn our main code in Arduino which pick the GUID+Serial ID combo from EEPROM and write it before every message which arduino is pushing to central server.

Or my another way of asking is can we program EEPROM with a different program and our Arduino separately like 2 files running in parallel or is it not possible?

Is there any other way of doing this?

答:
The answer to this question depends entirely on the type of connection you are using to build your network.

Assuming that when you say you have arduinos "on a network" you are using ethernet shields or similar to put them on an ethernet network, one way to accomplish your goal would be to take advantage of the MAC address on the ethernet shield as this is a pre-existing globally-unique identifier. The MAC address is appended to every ethernet frame. Now, you only have access to that data at Level 2 (the "link layer") of ethernet and you are not going through a switch / hub which will modify the frames which you almost certainly are.

So instead, you could have your hub or switch assign IP addresses through DHCP based on the MAC address of the ethernet shield. This is sometimes referred to as "link layer filtering." Then when you get packets with data from the Arduino, you know which one it comes from by the source IP address on the packet.

You suggested you might be using cellular data, IP addresses are probably dynamic and the problem becomes more difficult. You would need to talk to your provider and see if you can get static IP addresses.

If you are using SMS, then simply identify by phone number.


答:
I have used small solenoid valves with a fixed displacement to dispense small droplets. For example, the valve I used consistently pumped 0.5 uL from one orifice to the other every time it was switched. That particular valve was not intended to be used as a pump, but there was no reason it couldn't be. There are other solenoids which are intended to be used that way.

The valve I used costs less than $100. Unfortunately I can't share the specific part number, but you should be able to find some help from The Lee Company, or SMC, who sell these types of valves. Lee will definitely sell small quantities. I don't know about SMC. Either one should be able to provide you with samples.

Title: Off-the-shelf micro fluid dispenser


问:
Polling or Timer interrupt?
We hope to build a simple line follower robot and we got a problem when we were discussing about PIC programming.

We planed to write a endless loop, check the sensor panel reading and do the relevant stuff for that reading.

But one of our friends told us to use a timer interrupt to generate interrupts in definite time periods and in each interrupt check the sensor panel reading and do the relevant stuff for that reading.

But we can't figure out which is best: the endless loop in main method OR timer interrupt method.

What is the best way, and why?

答:
The processor has to execute something.  You will always have an "endless" loop even if you're doing some work in an interrupt handler.

The best solution depends on exactly what you're trying to do.

The main advantage of using interrupts is they allow you to service events in real-time while your main program is doing something else.  Timer interrupts specifically allow you to perform some periodic activity on a fairly accurate time-base while doing some other processing.

For most control algorithms it is useful to have some sort of a time-base (or fixed frequency).  If that's all your CPU is doing you can easily do that without interrupts by either controlling the number of cycles/instructions in your control loop or polling the timer.  Both methods would be simpler and more efficient than using interrupts.  Interrupts are more useful in more complex systems doing many things concurrently (I/O, time keeping, scheduling etc.).

If you go with the endless loop without polling the timer or calibrating the time it takes to run one iteration of the loop you will have to be careful of situations where adding more code in your loop changes the timing and the behavior of your control system.

If you implement your control algorithm in a timer interrupt you will have to be careful you're not trying to perform more work than the CPU can handle in one time "slot" or that will again impact the behavior of your control system.

Title: Polling or Timer interrupt?


答: If your goal is to have a georeferenced localization, you will have to use GPS at some point. The other techniques (dead reckoning, SLAM, ...) will only be useful to "bridge" spotty GPS/indoor absolute positioning reception.

Title: Absolute positioning without GPS

Body:
Using an IMU a robot can estimate its current position relative to its starting position, but this incurs error over time. GPS is especially useful for providing position information not biased by local error accumulation. But GPS cannot be used indoors, and even outdoors it can be spotty.

So what are some methods or sensors that a robot can use to localize (relative to some frame of reference) without using GPS?


问:
Any globally unique signature in Ardupilot hardware, or Arduino in general?
I have several APM 2.5 boards and need to identify them based on some globally unique hardware signature that does not change with programming.

Arduinos and atmel AVR chips in general do not have (also this thread) an accessible serial number.

However, it seems that the Ardupilot has so many integrated sensors and other ICs that one of them must have something unique I can use ( see schematic )!

I will be checking datasheets for MPU-6000, HMC5883L-TR and MS5611, but in the meantime, if someone has already figured this one out, please answer.

答:
Well, I'll be darned. A serial number shows up in dmesg when you plug the thing in. I checked two boards that the number was different, so hopefully these are globally unique.</p>

```<code>me@mycompy:~/arducopter/MissionPlanner$ dmesg|tail
[26581.627967] iwlwifi 0000:03:00.0: fail to flush all tx fifo queues
[26583.020822] usb 1-1.2: new full-speed USB device number 27 using ehci-pci
[26583.115672] usb 1-1.2: New USB device found, idVendor=2341, idProduct=0010
[26583.115682] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[26583.115689] usb 1-1.2: Product: Arduino Mega 2560
[26583.115696] usb 1-1.2: Manufacturer: Arduino (www.arduino.cc)
[26583.115702] usb 1-1.2: SerialNumber: 64033353830351A0B122
[26583.116485] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device
</code>```

Body:
Well, I'll be darned. A serial number shows up in dmesg when you plug the thing in. I checked two boards that the number was different, so hopefully these are globally unique.

me@mycompy:~/arducopter/MissionPlanner$ dmesg|tail
[26581.627967] iwlwifi 0000:03:00.0: fail to flush all tx fifo queues
[26583.020822] usb 1-1.2: new full-speed USB device number 27 using ehci-pci
[26583.115672] usb 1-1.2: New USB device found, idVendor=2341, idProduct=0010
[26583.115682] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[26583.115689] usb 1-1.2: Product: Arduino Mega 2560
[26583.115696] usb 1-1.2: Manufacturer: Arduino (www.arduino.cc)
[26583.115702] usb 1-1.2: SerialNumber: 64033353830351A0B122
[26583.116485] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device


答:
Further to Guy's answer, using a timer interrupt to generate accurate intervals adds determinacy.

For example, at any given time, you know exactly what the processor is doing, and all activities are performed at specified rates.

You also should schedule at determined rates as otherwise you have no basis for time constants and such like, which will be essential in your filtering.

And finally, this means that if you add additional tasks, then the existing tasks are not slowed down.

Simple polling is OK if that is all your system has to do - but while time slot scheduling is a minor overhead in a trivial system, adding it from the start allows growth and expansion without having to restructure everything later.

Title: Polling or Timer interrupt?

Body:
We hope to build a simple line follower robot and we got a problem when we were discussing about PIC programming.

We planed to write a endless loop, check the sensor panel reading and do the relevant stuff for that reading.

But one of our friends told us to use a timer interrupt to generate interrupts in definite time periods and in each interrupt check the sensor panel reading and do the relevant stuff for that reading.

But we can't figure out which is best: the endless loop in main method OR timer interrupt method.

What is the best way, and why?


问:
What is an effective distribution of grayscale sensors on robot
I'm working on a robotics project, and I am using grayscale sensors to automatically follow a black line: turning 90 degrees, going round in a circle, and passing through gaps in the lines etc.  I was wondering what is an effective way to detect the colours and move it through the lines, with five or six grayscale sensors.

Thank you very much.

答: Use dynamic threshold to counter variation of ambient light condition, though the color green may still be hard to distinguish from white and black (dependent on the reflective index of the green material, which you might have to experiment with). This is a serious problem if you are using photo reflectors as grayscale sensors. The distribution of grayscale sensors depends on the size of your robot and your expected speed. If your robot aims at 1.0m/s, I would say six sensors are enough, placed at the front of your robot with a distance of roughly 1cm or 2cm. If you want to achieve higher speed (i.e., 3.0m/s) you might need as many as twelve to sixteen sensors. But these numbers are very inconclusive since you are giving out too limited information about your project. As someone who has done this before, I would recommend using the TSL1401 linear sensor array, which is equivalent to 128 grayscale sensors, yet is still quite cheap. </p>


答:
I would just like to add few points to other posts. My personal opinion is that endless while loop has no sense in systems which read from snsors or write to actuators as both has some physical constrains, eg. There is no point in reading from sensors at 1Mhz if the sensor has stability cycle before meassurent is accurate at 100Hz. Same goes to motor drivers. You can send 1mil instructiins to move motor but it can only witstand its physical limitations in respect of inertia.

What i do in my designs is following. I create timer interrupt which triggers every 1ms or so, and then i decrement some global variables in that interrupt routine. In main while loop i check if variable is 0 and execute command that is defined by that variable. In that case i can drive motor at 125Hz, read sensor at 20Hz, and output leds at 0.5Hz.

I hope you got the point.

Title: Polling or Timer interrupt?


答:
I'd also like to stress that the comparison between polling (i.e. checking if a interrupt flag has been set) and interrupt vectors (i.e. an ISR, or function that's loaded when a interrupt has occurred) should be more than just evaluating the efficiency/simplicity of executing a block of reactionary code. The interrupt controllers of most modern micros are capable of so much more, especially when considering inter-peripheral signalling (ie, DMA).

For example, a Texas Instruments TMS320F28335 microcontroller allows you to trigger your ADC's start of conversion pulse directly from a PWM's rising or falling edge. In addition to this, the micro also has a six channel DMA controller, which for instance can also be programmed to trigger off the same PWM signal (this could allow you to start a memory read via the devices' parallel bus, that's for instance connected to a high speed delta sigma converter). The same DMA controller can then be used to buffer the values read from the ADC and external delta sigma to internal RAM. The DMA controller can then be configured to only trigger a normal interrupt service routine after sampling a total of lets say 128 ADC and delta sigma readings. All this would happen without any CPU intervention (freeing you up to do other things).

This type of behind-the-scenes triggering allows you to get a lot more work done compared to when you would have had an ISR controlling all the enable flags or memory reads (due to the overhead associated with interrupt latency). The vector chained approach would allow you to sample at (let's say) 50 KHz, where an ISR driven approach would only allow you to sample at (let's say) 5 KHz.

Also as Andrew stated, using interrupt vectors are much more deterministic, or repeatable, than polling a status register.

I'd also highly recommend subscribing to Phil Koopman's blog, or at least reading the following posts:

Rules for using interrupts

Why Short Interrupt Service Routines Matter

Making Main Loop Scheduling Timing More Deterministic

Software Timing Loops (and why you should rather use a hardware timer)

Title: Polling or Timer interrupt?


问:
How mature is real-time programming in robotics?
Edit: I don't know why, but this question seems to be confusing many people. I am aware of when/where/why/how to use real-time. I am interested in knowing whether people who have a real-time task would actually care enough to implement it in real-time or not.

There's no need to mention why real-time operations are important for a robot. My question is however, how much is it actually used in robotics?

Take this question for example. Only one answer mentions any platform with real-time capabilities, and it is far from the top too. ROS apparently, being a very popular platform which is not real-time.

In the real-time world however, RTAI1 seems to be the only workable free real-time platform of use. It is however, limited to Linux (no problem), badly documented and slowly developed.

So, how much is real-time behavior sought after among robotics developers? The question is, how much are developers inclined to write real-time applications when real-time behavior is actually needed? If not much, why?

For example, reflexive behavior based on tactile data, cannot go through ROS because it would lose its real-time property. But do people really come up with a real-time solution or use ROS anyway, ignoring the real-time property?

1 or similarly Xenomai

答:
If you actually need real-time, then you use a real-time operating system. Safety monitoring, data acquisition, and constant sample rate control loops are common subsystems that use real-time scheduling.

The real-time portion of the programming is usually as small as possible, because it's more difficult to debug and less code is easier to check for correctness. Documentation on real-time OS's is usually pretty good (including RTAI/Xenomai).

I've used QNX and RTAI->Xenomai in different real robotics projects. I preferred QNX but Xenomai was just as effective.


问:
What to do when the control input of the Kalman filter is unknown?
I am implementing a simple Kalman Filter that estimates the heading direction of a robot. The robot is equipped with a compass and a gyroscope.

Say at time $t-dt$, the compass reports a reading $\theta_{t-dt}$, and the gyroscope reports a reading $\omega_{t-dt}$. Then I assume from time $t-dt$ to $t$, the rotation rate can be regarded as a constant. Thus, my current heading direction is $$\theta_{t}=\theta_{t-dt}+\omega_{t-dt}\cdot dt$$
As can be seen, the $\theta$ can be easily time-updated.

But what about my $\omega$? The robot is not at my control. So its rotation rate at next moment is unpredictable.

How should I do the time update in this case?

答:
For both states, you are using sensors to give you the required information.

One way to make this work properly: Use the gyroscope reading for your ω and your previous state estimate for your θ (or initial state estimate if its the first iteration). This is the predict step of the filter.

Then for the update step you can use your compass measurement (this will correct the gyro drift).

For both states, you are relying on sensors to provide information about heading, not the control inputs of the robot itself.

This method is common in attitude heading and reference systems.

For your application a complementary filter may be better suited since its easily implemented and is easy to tune and can have comparable performance to a Kalman filter in many situations.


问:
How to model unpredictable noise in Kalman Filter?
Background:

I am implementing a simple Kalman Filter that estimates the heading direction of a robot. The robot is equipped with a compass and a gyroscope.

My Understanding:

I am thinking about representing my state as a 2D vector $(x, \dot{x})$, where $x$ is the current heading direction and  $\dot{x}$ is the rotation rate reported by the gyroscope.

Questions:

If my understanding is correct, there will be no control term, $u$ in my filter. Is it true? What if I take the state as a 1D vector $(x)$? Then does my $\dot{x}$becomes the control term $u$? Will these two methods yield different results?

As we know, the main noise source comes from the compass when the compass is in a distorted magnetic field. Here, I suppose the Gaussian noise is less significant. But the magnetic distortion is totally unpredictable. How do we model it in the Kalman Filter?

In Kalman Filter, is the assumption that "all the noises are white" necessary? Say, if my noise distribution is actually a Laplacian distribution, can I still use a Kalman Filter? Or I have to switch to another filter, like Extended Kalman Filter?

答:
There will be no control input term. You should take (x, xdot) as your state vector to formulate the Kalman filter properly.

The primary sources of noise are the compass and the gyroscope. The gyroscope noise and drift are significant. It is pretty challenging to overcome magnetic distortion in general but there are compensation techniques.

The assumption of zero mean multivariate normal
distribution noise is necessary however white noise is only a special case of this. For the extended Kalman filter, this assumption still needs to be true. You can look into other types of filters (particle filter, unscented Kalman filter).

Kalman Filter Design/Implementation Paper:

Implementing a Sensor Fusion Algorithm for 3D Orientation Detection with Inertial/Magnetic Sensors


答:
I would model this as a one-state system (x), with the gyro as the control input.  The gyro noise becomes state input noise, the compass noise becomes measurement noise.  So your system model becomes $$\hat{\dot \theta} = \omega_{gyro} + w$$ $$\hat y = \hat x$$ where $\hat y$ is the filter's estimate of direction, which you compare to the compass direction to get your Kalman update.

The magnetic distortion is going to be difficult, because if you sit in any one place it will appear as a constant offset term -- the Kalman filter won't deal with this well.  I'm pretty sure you'll either need to map the distortion, get some second absolute direction reference, or just accept the distortion.

You are confusing spectral content with probability distribution.  If the noise is white, then each sample in perfectly independent of any other sample.  If the noise is Laplacian, each sample obeys the Laplace distribution.  Kalman filters don't like colored noise (but you can deal with that by adding states).  A Kalman filter is only the overall optimal filter when the noise is of Gaussian distribution and the cost function is sum-of-squares.  For any other noise and cost function, the optimal filter is probably nonlinear.  But for any zero-mean, white noise and sum-of-squares cost function, the Kalman filter is the best linear filter to be found.

(Note that the system model I gave ends up with a pretty trivial Kalman filter -- you may be better off, if you can't find some other means of estimating compass offset, using a complimentary filter to combine these two sensor inputs.  Doing all the Kalman computations will just end up coughing up a complimentary filter anyway, and chances are that you'll have enough guesses for your constants that you may as well just guess at the crossover point in a complimentary filter and be done with it).

(Note, too, that if you have some absolute position reference, and some means estimating speed, and a vehicle that always goes in the direction you point it, that you can use an extended Kalman filter very profitably to correct the compass distortion by using the direction it actually moves to correct for the compass direction).

Optimal State Estimation by Dan Simon, Wiley 2006, is -- in my opinion -- a very rich and clear treatment of the subject of Kalman filtering and its more sophisticated brethren (H-infinity, extended Kalman, unscented Kalman, and even a bit on Baysian and particle filtering).  It won't tell you how to apply that to navigation problems like this, but where would be the fun in life if all the problems were solved?.  If you can't follow the math in Simon's book, then you should probably be asking yourself if you're going to be able to apply a Kalman filter in any sort of intelligent way.

Title: How to model unpredictable noise in Kalman Filter?

Body:
Background:

I am implementing a simple Kalman Filter that estimates the heading direction of a robot. The robot is equipped with a compass and a gyroscope.

My Understanding:

I am thinking about representing my state as a 2D vector $(x, \dot{x})$, where $x$ is the current heading direction and  $\dot{x}$ is the rotation rate reported by the gyroscope.

Questions:

If my understanding is correct, there will be no control term, $u$ in my filter. Is it true? What if I take the state as a 1D vector $(x)$? Then does my $\dot{x}$becomes the control term $u$? Will these two methods yield different results?

As we know, the main noise source comes from the compass when the compass is in a distorted magnetic field. Here, I suppose the Gaussian noise is less significant. But the magnetic distortion is totally unpredictable. How do we model it in the Kalman Filter?

In Kalman Filter, is the assumption that "all the noises are white" necessary? Say, if my noise distribution is actually a Laplacian distribution, can I still use a Kalman Filter? Or I have to switch to another filter, like Extended Kalman Filter?


问:
Tracking with accelerometer and gyro versus multiple accelerometers
I'm building quadcopter and most of the control systems use one accelerometer and gyro. I've read few papers and usually accelerometer is used as reference to the ground because gyro slowly drifts away in time. But if quadcopter does some crazy maneuvering when force direction from accelerometer does not have to point to the ground than accelerometer data is useless. As well there is problem with centripetal force if the accelerometer is not directly in the centor of mass.

I was thinking about using multiple accelerometers. To fully determine position and motion of quadcopter one would need three accelerometers(If I have done the math right). This would kind of solve the problem with centripetal force

So I would like to know if anyone tried to use multiple accelerometers for better orientation estimation.

答: You definitely mean the orientation and not position. Any yes, people have used multiple accelerometers to determine the orientation, for example Wii's "nunchuck" is an attachment to the Wiimote that has an additional accelerometer, so that the orientation of the stick can be calculated</p>


问:
How to control the position of a pneumatic piston?
How can I control the position of a pneumatic piston?

The only way I know about is using a magnetic reed switch (magnetic sensor) with a matching piston and use some type of control algorithm, like PID for instance, to keep the piston where the sensor is.

The problem with that is that it gives you only limited control of the position, it just adds another "state" (open, closed, sensor position) and not full control. for example I want it to be 43% once and 70% the other time, but without using a sensor for each position because I would like all the "options" to be available (I mean that the percentages aren't pre-defined)

This is an example of the pistons I use:

This is a good example of what I want: http://www.youtube.com/watch?v=A8LZ15uiuXU

答:
You probably could attach an optical encoder strip to the piston, maybe even paint the piston rod with some reflecting / non reflecting paint.
Or you could attach a modified digital caliper to it, using something similar to this: http://hackaday.com/2013/06/20/giving-digital-calipers-bluetooth/ .

I have never done anything like this, so I don't really know if it would work in reality :-)


答:
You won't be able to determine the position of the quadcopter with accelerometers or gyros or a combination of both.

You can use either accelerometers or a combination of accelerometers and gyros to determine the orientation (eg. roll, pitch, yaw) of the quadcopter. The gyro will allow for a more nimble quadcopter because it provides additional information at a faster rate.

You can think of it like this: The accelerometers are useful for determining your orientation when moving slow (stable response, no drift, low bandwidth). The gyros are useful for determining your orientation when your moving fast (provide high bandwidth updates but have significant drift over longer time periods). The combination of the two using something like a complementary filter will provide the best of both worlds however you will need 6 axes of measurement (3-axis gyro, 3-axis accelerometer). Also, since gravity is symmetric about the vertical axis you would need a magnetometer or compass sensor to zero the gyro drift about that axis and provide reliable heading control. There are several off-shelf Intertial Measurement Units (IMU) that can be purchased and interfaced to your main controller.

If you use only accelerometers your quadcopter won't be as agile as if you used a combination of gyros and accelerometers since the bandwidth of accelerometers are generally lower than that of gyros. Most ready-to-fly quads use accelerometers, gyros, and magnetometers.

Title: Tracking with accelerometer and gyro versus multiple accelerometers

Body:
I'm building quadcopter and most of the control systems use one accelerometer and gyro. I've read few papers and usually accelerometer is used as reference to the ground because gyro slowly drifts away in time. But if quadcopter does some crazy maneuvering when force direction from accelerometer does not have to point to the ground than accelerometer data is useless. As well there is problem with centripetal force if the accelerometer is not directly in the centor of mass.

I was thinking about using multiple accelerometers. To fully determine position and motion of quadcopter one would need three accelerometers(If I have done the math right). This would kind of solve the problem with centripetal force

So I would like to know if anyone tried to use multiple accelerometers for better orientation estimation.


问:
Visualizing and debugging an EKF
I am currently debugging and tuning an EKF (Extended Kalman Filter). The task is classical mobile robot pose tracking where landmarks are AR markers.

Sometimes I am surprised how some measurement affects the estimate. When I look at and calculate the numbers and matrices involved, I can work out how the update step got executed, what and why exactly happened, but this is very tedious.

So I wonder if anyone is using some technique, trick or clever visualization to get a better feel of what is happening in the EKF update step?

UPDATE #1 (will be more specific and show first approximation of what I have in mind)

What I am looking for, is some way to visualize one update step in a way that gives me a feel of how each component of the measurement affects each component of the state.

My very first idea is to plot the measurement and it's prediction together with some vectors taken from the K matrix. The vectors from K represent how the innovation vector (measurement - measurement prediction, not plotted) will affect each component of the state.

Currently I am working with an EKF where the state is 2D pose (x,y,angle) and the measurements are also 2D poses.

In the attached image(open it in new page/tab to see in full resolution), the (scaled) vector K(1,1:2) (MATLAB syntax to take a submatrix from 3x3 matrix) should give an idea how the first component of the EKF state will change with the current innovation vector, K(2,1:2) how the second component of EKF will change, etc. In this example, the innovation vector has a relatively large x component and it is aligned with vector K(2,1:2) - the second component of the state (y coordinate) will change the most.

One problem in this plot is that it does not give a feel of how the third component(angle) of the innovation vector affects the state. The first component of the state increases a bit, contrary to what K(1:1:2) indicates - the third component of the innovation causes this, but currently I can not visualize this.

First improvement would be to visualize how the third component of the innovation affects the state. Then it would be nice to add covariance data to get a feel how the K matrix is created.

UPDATE #2 Now the plot has vectors in state-space that show how each component of measurement changes the position. From this plot, I can see that the third component of the measurement changes the state most.

答:
A very informative way to visualize the effect of measurements (for me) is to plot the state of the robot (mean, with covariance ellipse) before and after each measurement. Then, take the individual components of the measurement (bearing, range for AR markers), and apply them separately to get a feel for it.

To do this:

I use one or more of these functions to plot the ellipse. To find the constants $a,b$, note that they are the square roots of the eigenvalues of the covariance matrix.  Then sample the angle $\theta$ over $[0, 2\pi]$ and find the range from the hypothesis. using the linked equation. I especially recommend using this equation:

$$
r(\theta) = \frac{ab}{\sqrt{b\cos^2\theta + a\sin^2\theta} }
$$

Tracking the covariance of the prior hypothesis, measured state, and posterior hypothesis is usually sufficient to find if the equations of an EKF are being applied correctly.

Good luck, and don't update your question too frequently. Instead, come back with new questions.

Title: Visualizing and debugging an EKF


问:
Actuator design. plausible?
So i got this idea waay back when i was in highschool as a kind of electromagnetic analogue to a biological muscle. it is basically a long stack of thin electromagnets connected in parallel.
.
when current is applied gaps between electromagnets shrink thus providing contraction of the whole chain.

I am pretty sure it can work. It can't offer great contraction range (up to 50% i would guess) but it has potential to provide good speed and be compact so that multiple chains can be combined to form stong and fast linear actuators. The thing is, i never heard of this type of actuator being used. so what is the catch? is there a better alternative? is there a design flaw? too much heat generated making them unpractical?

答:
This design is definitely plausible, but there are some problems I can see.

The maximum length is defined by the force the magnets can lift, since the ones lowest in the stack won't push the other ones up after some amount of them.

The magnets will want to get as far from the force as possible, so they will most definitely not go straight up. This calls for a use of something like a flexible tube. This may mean the design won't be as space-efficient as it seems (if it is even possible).

The stack won't keep it's shape if the magnets are not energized all the time, so the current consumption may be bigger than readily-available parts.

It is an interesting concept, but I can't see using it to lift any significant load to a reasonable distance.

Title: Actuator design. plausible?


答:
To control the position of a piston, you need -- at the very least -- a position sensor and an actuated valve.

In reality, you will encounter a few other effects that will complicate the simple PID algorithm you're attempting.

Depending on how many pistons you're driving, or how much airflow your piston takes, you may find that the available air pressure fluctuates.  If your valve can achieve a range of positions (not just open or closed), this changes the relationship between valve position and the resulting pneumatic force.

The system may exhibit negative damping for a variety of reasons.  For a good explanation, see this page about a robot experiencing negative damping, and how to fix it.  (This might also be a solution to your problem of the actuator moving too fast.)

There is no simple answer; these systems are complicated and require testing every step of the way.

Title: How to control the position of a pneumatic piston?

Body:
How can I control the position of a pneumatic piston?

The only way I know about is using a magnetic reed switch (magnetic sensor) with a matching piston and use some type of control algorithm, like PID for instance, to keep the piston where the sensor is.

The problem with that is that it gives you only limited control of the position, it just adds another "state" (open, closed, sensor position) and not full control. for example I want it to be 43% once and 70% the other time, but without using a sensor for each position because I would like all the "options" to be available (I mean that the percentages aren't pre-defined)

This is an example of the pistons I use:

This is a good example of what I want: http://www.youtube.com/watch?v=A8LZ15uiuXU


问:
setting custom variables on catkin workspace environment
I am developing a package for the ROS, in fact, it is a package of resources/models for the Gazebo, and I need with the presence of this package in the Workspace of Catkin to automatically set the variable GAZEBO_MODEL_PATH for this package.

I could intervene in the file ~/catkin_mygazebo_ws/devel/setup.sh, adding the path to a variable, but first I would like to know if there is any way to do it by another more specialized route to Catkin.

答:
After some tests and following suggestions in the reference links at the end of this answer, I came up with the following solution:

Let's assume you need to add the path to new gazebo templates when developing your packages, so create a directory called env_hooks in your template package folder.

Enter the directory and create a configuration file with the extension specified for each shell (.bash, .zsh, tcsh). This file can have any name, in the case I will use models_env. , change <shell_string> to the extension representing the shell, each file must be the required variables configuration according to the shell.

Now edit the CMakeLists.txt file and add the following directive to the end:

```<code>catkin_add_env_hooks (models_env SHELLS bash tcsh zsh DIRECTORY $ {CMAKE_CURRENT_SOURCE_DIR} / env-hooks)
</code>```

For example, for the Bash shell, I edited my models_env.bash file and put:

```<code>#! /bin/bash
echo "*******"
echo "Preparing specific variables for the gazebo_model package"
echo "*******"

_CATKIN_ENV_HOOKS_PATH = <span class="math-container">$ (catkin locate arr_gazebo_models)
export GAZEBO_MODEL_PATH = "$</span> {_ CATKIN_ENV_HOOKS_PATH} / models: $ {GAZEBO_MODEL_PATH}"
</code>```

References:

https://docs.ros.org/api/catkin/html/user_guide/environment.html
https://docs.ros.org/api/catkin/html/dev_guide/generated_cmake_api.html#catkin_add_env_hooks

Body:
After some tests and following suggestions in the reference links at the end of this answer, I came up with the following solution:

Let's assume you need to add the path to new gazebo templates when developing your packages, so create a directory called env_hooks in your template package folder.

Enter the directory and create a configuration file with the extension specified for each shell (.bash, .zsh, tcsh). This file can have any name, in the case I will use models_env. , change <shell_string> to the extension representing the shell, each file must be the required variables configuration according to the shell.

Now edit the CMakeLists.txt file and add the following directive to the end:

catkin_add_env_hooks (models_env SHELLS bash tcsh zsh DIRECTORY $ {CMAKE_CURRENT_SOURCE_DIR} / env-hooks)

For example, for the Bash shell, I edited my models_env.bash file and put:

#! /bin/bash
echo "*******"
echo "Preparing specific variables for the gazebo_model package"
echo "*******"

_CATKIN_ENV_HOOKS_PATH = $ (catkin locate arr_gazebo_models)
export GAZEBO_MODEL_PATH = "$ {_ CATKIN_ENV_HOOKS_PATH} / models: $ {GAZEBO_MODEL_PATH}"

References:

https://docs.ros.org/api/catkin/html/user_guide/environment.html
https://docs.ros.org/api/catkin/html/dev_guide/generated_cmake_api.html#catkin_add_env_hooks


问:
Relationship between the velocity twist Jacobian and the spatial velocity Jacobian
While reading Kevin Lynch's "Modern Robotics" [1], I came across a fundamental question concerning the manipulator Jacobian.
Upon better reading and further cross-checking with Peter Corke's "Robotics, Vision and Control" [2], I have managed to only confuse myself even more...

Kevin Lynch approaches kinematic representation of open chains with the product of exponentials (PoE) formula. In such representation, the space Jacobian $J_s(\theta) \in \mathbb{R}^{6 \times n}$ relates the joint rate vector $\dot{\theta} \in \mathbb{R}^{n}$ to the end-effector's twist expressed in fixed-frame coordinates $\mathcal{V}_s$ via
$$
\mathcal{V}_s = J_s(\theta)\dot{\theta}.
$$

A similar concept, the body Jacobian, relates the joint rate vector to the end-effector's twist in the end-effector frame coordinates via
$$
\mathcal{V}_b = J_b(\theta)\dot{\theta}.
$$

Finally, the relationship between both of the above is given by:
$$
J_b(\theta) = [Ad_{T_{bs}}]J_s(\theta);
$$
$$
J_s(\theta) = [Ad_{T_{sb}}]J_b(\theta).
$$

Given the above, my question is:

Provided $J_b(\theta)$, how can I obtain the geometric Jacobian?

I tried looking into Peter Corke's book and I found the following subsection.

Screenshot taken from Peter Corke's book:

So, apparently, what I am looking for is that final equation. (?)

It seems that $\sideset{^0}{^\mathcal{V}}{J}$ in Corke's book refers to the same as what $J_b(\theta)$ refers to in Lynch's book.

But what does Corke mean exactly with "velocity transformation"?

Specifically, what exactly is the top-right 3x3 block of that 6x6 matrix pre-multiplication?

[1] Kevin M. Lynch and Frank C. Park, "Modern Robotics: Mechanics, Planning, and Control," Cambridge University Press, 2017. (http://modernrobotics.org)

[2] Peter Corke, "Robotics, Vision and Control: Fundamental Algorithms," Completely Revised. Vol. 118. Springer, 2017. (http://petercorke.com/wordpress/rvc/)

答:
According to the notation in Corke's book, it looks like that top-right 3x3 block that you're looking for is the translation from end effector frame E to base frame 0 represented in so(3).

It looks like the trouble here comes from viewing the velocity in different frames. Lynch's spatial twist (defined on page 99) differs from Corke's spatial velocity (defined in section 8.1).


问:
How to add a magnetometer in an Extended Kalman filter for innovation update?
I can't find out the response so I am posting here.

My post kind of follow this one : Adding magnetic field vector to a Kalman filter
but I already know that I don't have to put the magnetometer in a state vector.

I am working on a implementation of an Extended Kalman filter. So far I have integrated a gyroscope, an accelerometer and encoders wheels.

But I don't know what are the equation for the update state to integrate a magnetometer.

So far :

I have seen some kind of work where magnetometer are fuse with accelerometer.
But I don't have any formulas and I am kind of stuck...

I have seen some kind of work where there is no quaternion but I can't afford this modelisation cause of gimbal lock and I have all my work already in quaternion...

Thanks in advance for help. Don't hesitate if you need complementary details.

答:
First, you need a model of the magnetic field you are measuring. Have a look at the IGRF model, which is usually used in space applications. There are ready to go implementations for most programming languages.

With this model, you are able to calculate a theoretical magnetic field vector in the inertial coordinate frame, depending on your estimated position. With your estimated quaternion you transform this vector in your body coordinate frame.

Second, now you have a theoretical vector in the body frame and a measured vector in the body frame, provided by the sensor.

The rest is straight forward EKF formulation.

References:
Three-axis attitude determination via Kalman filtering of magnetometer data, MARK L. PSIAKI

Fundamentals of Spacecraft Attitude Determination and Control, Markley, F. Landis


问:
Struggling to understand Jacobian Inverse Kinematics
I'm trying to find a method to control a moveo 5dof arm. My goal is to calculate the right angle to turn for each stepper motor to reach a desired point in real environment. I've spent time looking at the jacobian inverse kinematics, but it really got me confused. According to some articles I've read, Jacobian is useful to calculate joints' velocity, but as far as I know, stepper motors operate at a fixed speed. So my question is can I use this method to just calculate the necessary angles for the steppers, or should I use another method? In both cases, can you please introduce to me some helpful articles to refer to?
Many thanks</p>

答:
Without using the Jacobian, inverse kinematics provide joint angles to put the robot at a desired pose.  But using inverse kinematics to move from one pose to another does not say anything about the path the robot will take between poses.  Therefore, you can choose target poses that are pretty close together to have a robot follow a desired path.   When those poses are infinitesimally close to one another, you enter the subject of Jacobians.   These matrices map differential joint velocities to differential Cartesian velocities for a given pose.   So if you are at pose A, the inverse Jacobian will provide a joint velocity vector in the direction of pose B.   These have to be updated rapidly, though, because the Jacobian is only accurate in a small neighborhood of where it is computed.  </p>

<p>Incidentally, stepper motors are not necessarily constant-velocity motors.   They move one step for every pulse they receive.   You can change the rate of the pulses to change the motor’s velocity.  </p>

Body:
Without using the Jacobian, inverse kinematics provide joint angles to put the robot at a desired pose.  But using inverse kinematics to move from one pose to another does not say anything about the path the robot will take between poses.  Therefore, you can choose target poses that are pretty close together to have a robot follow a desired path.   When those poses are infinitesimally close to one another, you enter the subject of Jacobians.   These matrices map differential joint velocities to differential Cartesian velocities for a given pose.   So if you are at pose A, the inverse Jacobian will provide a joint velocity vector in the direction of pose B.   These have to be updated rapidly, though, because the Jacobian is only accurate in a small neighborhood of where it is computed.

Incidentally, stepper motors are not necessarily constant-velocity motors.   They move one step for every pulse they receive.   You can change the rate of the pulses to change the motor’s velocity.


答:
You will find it helpful to keep the physical robot and the math separate.

The kinematics equations map joint parameters (which are often grouped as a vector $q$) to Cartesian coordinates ($x$,$y$,$z$).

If you take the first-order partial derivative of the kinematics equations, you get a set of equations that map a change in the joint parameters to a change in the Cartesian coordinates. The Jacobian is another name for this first-order partial derivative.

It's true that if you consider a change over a fixed amount of time, you can call it a velocity, and you can use the Jacobian to map joint velocities to Cartesian velocities. But you have to be careful because these are instantaneous velocities and as soon as the position changes, the mapping between velocities changes as well.

To calculate inverse kinematics using the jacobian you will need solve or approximate inverse equations that map Cartesian changes to joint parameter changes, and then use an iterative algorithm to find the solution.

If you are not interested in learning the mathematics and numerical methods required to implement inverse kinematics, there are software libraries available that already solve the problem.

If you use an existing library, you should keep in mind that solving the inverse kinematics is a hard problem that often has no solutions or more than one solution.

Title: Struggling to understand Jacobian Inverse Kinematics

Body:
I'm trying to find a method to control a moveo 5dof arm. My goal is to calculate the right angle to turn for each stepper motor to reach a desired point in real environment. I've spent time looking at the jacobian inverse kinematics, but it really got me confused. According to some articles I've read, Jacobian is useful to calculate joints' velocity, but as far as I know, stepper motors operate at a fixed speed. So my question is can I use this method to just calculate the necessary angles for the steppers, or should I use another method? In both cases, can you please introduce to me some helpful articles to refer to?
Many thanks</p>


问:
Kalman-Filter: how to solve angles near +/-pi?
I'm trying to get into Kalman filters. I've noticed an issue with Euler angles near -180°/180° (or -pi/pi) and wonder how to correctly resolve this. Its often said you need to normalize the angles into this range. However, this isn't as easy as it seems at first sight. Especially, when using a Kalman filter class from a library (e.g. OpenCV).

Let's take a very simple examle. We have only a compass sensor, which will give us a heading in the XY-plane. And our state keeps track of the current heading and its first derivative (speed of change).

Matrix Algebra

First, I'll give all information in the typical matrix form to show how this actually relates to the Kalman filter. Later I'll reduce this to simple formulas for better reasoning.

We define our state space vector as:

$x_{k} = \begin{bmatrix} \alpha \\ \dot{\alpha} \end{bmatrix}$

Where $\alpha$ is the current heading in degrees (for simplicity) and $\dot{\alpha}$ is the current change of the heading in degrees per second.

The new a priori state estimate (prediction) is calculated by:

$\hat{x}_{k|k+1} = F_k x_k$
where $F_k = \begin{bmatrix} 1 & \Delta t \\ 0 & 1\end{bmatrix}$

Our observations look like this:

$z_k = \begin{bmatrix} \alpha_{new} \end{bmatrix}$

And the correction / update step looks like this:

$\tilde{y}_k = z_k - H_k \hat{x}_{k|k+1}$ where $H_k = \begin{bmatrix} 1 & 0\end{bmatrix}$

Later the Kalman gain $K_k$ is calculated and influences the state estimate like this:

$\hat{x}_{k+1} = \hat{x}_{k|k+1} + K_k \tilde{y}_k$

Simplifications

$\hat{x}_{k|k+1} = \begin{bmatrix} \alpha + \Delta t \dot{\alpha} \\ \dot{\alpha}\end{bmatrix}$

$\tilde{y}_k = \alpha_{new} - (\alpha + \Delta t \dot{\alpha})$

$\hat{x}_{k+1} = \hat{x}_{k|k+1} + K_k \tilde{y}_k$

Now lets only focus only on the estimation of $\alpha$:

$\alpha_{k|k+1} = \alpha_k + \Delta t \dot{\alpha}_k$

$\alpha_{k+1} = \alpha_{k|k+1} + K_k^1 (a_{new} - \alpha_{k|k+1})$

The Issue and Semi-Solution

For simplicity I'll use angles in degrees. Let's assume, we've got the following situation:

$\alpha_k = 160°$, $\dot{\alpha}_k = 100°/s$, $\Delta t = 0.1 s$, $a_{new} = -170°$ ($\equiv$ 190°) and $K_k^1 = 0.1$.

Hence, $\alpha_{k|k+1} = 160° + 0.1 * 100° = 170°$ and therefore $a_{new} - \alpha_{k|k+1} = -170° - 170° = -340° \equiv 20°$.

The updated estimate would therefore (incorrect estimate) be:

$\alpha_{k+1} = 170° + 0.1 * (-340°) = 170° - 34° = 136°$

If we normalize $\alpha_{k|k+1}$ to [-180°, 180°] we get the equivalent 20° and the result is (correctly estimated):

$\alpha_{k+1} = 170° + 0.1 * 20° = 170° + 2° = 172°$

The normalization would fix the issue. However, if I use a normal Kalman filter class, I usually cannot influence how the innovation $\tilde{z}_k$ is calculated and the filter class cannot know that this is an Euler angle that needs special handling. Thus, I would need to write it my own... Or is there any way around this?
A quick solution might be to use a unit vector $\begin{bmatrix} cos(\alpha) \\ sin(\alpha) \end{bmatrix}$ instead of the euler angle $\alpha$, which I would have to renormalize every now and then.
I know that one could maybe use quaternions for this, but I currently can't grasp the math behind it to use it. Also I saw someone argue that it would be a bad idea to use quaternions in the state space of a Kalman filter (e.g. see comments to this question). This could also apply to my unit vector approach. Hence, I would like you to discuss the issue and give me some clues on how this is usually resolved.

答:
In my case, I generally write my own Kalman Filter stuff. My very first solution for this problem would be straight forward. I would put the angles at the desired interval before/after any angle update operation. In the case this not perform accordingly to the specifications I would recur to some mathmagic, like unit vector as you did. In this case it is up to you to establish the frequency of reorthogonalization. With 3D-roation matrices I use 1000 iterations for a 64bit computer.

Another solution would be in code. Can't you simply inherit the kalman filter class and alter only the method performing the update/inovation step?

And also, there is Lie Algebra and the Twist coordinates. Very helpful when comes to specifying 3D movement.


问:
how to find space in point cloud larger than given l*b
Is their any method by using which I can find a space or gap in given point cloud which has size greater than given rectangle of size $l*b$ or a circle of radius $r$? This way my robot can make a path to that space and move towards it. Is this possible by first finding the key points than applying triangular to given key points?

I am developing a navigation algorithm for my robot, and wondering if this kind of method already exists.

答:
Why don't you try to look it au contraire? Given you know the robot's "radius" (a contact free sphere actually with your desired r value) you can enlarge obstacles you find, although this would require the used of some sort of discretaziation of the world in a grid. For 3D this can be done using OctoMap (https://octomap.github.io/).

With obstacles enlarged by half of the robot radius, the robot becomes a dot. The planning now can be performed using A* in the discrete grid. The A* will give a sequence of points that can be used as waypoints or can be interpolated using spline curves to impose linear and angular velocity to the robot. Dubin's path is also an option.


问:
Pwm settings of a Sg90 servo motor
I use a TowerPro sg90.

1.5 ms for the centre position 0 degree, and 2 ms pulse for +90 degree and -90 degree with a 1ms pulse.

But it's definitely not looking like it goes for 90 degree or -90 degree.

I did read, some said "I tested two of them for about 130.000 cycles, without load, at one cyle per second, and 70 degrees travel." .

What does that mean "130.000 cycles at one cycle per second"?

答:
They use "cycle" to mean moved left then right.

They moved it left then right 130,000 times. They did it at a rate of once per second. They moved it 70 degrees, without any load attached.

Title: Pwm settings of a Sg90 servo motor


问:
How to get data from ArduPilot through Serial Port
I'm doing a project related to telemetry, and I want to make ArduPilot (programmed with ArduPlane 2.73) send through a serial port the sensors informations such as height, GPS position, etc.. I have tried to use ArduStation, but I could not change its firmware to do what I want.

The idea would be to read the Ardupilot's serial port using an Arduino Uno, and then saving it in a SD card in real-time. So ArduPilot needs to send data without any user input or something like that. I've already tried to manipulate ArduPlane source code to do that, but I couldn't either.

Has someone here did something like that before? I need some advice!

答:
If you just want to write data to the UART, you can use

```<code>cliSerial->printf("my output");
</code>```

cliSerial is an alias for hal.console .

There is a good example here.

UART 2 is unused on the APM so I think you can examine how hal.console is set up and set up your own equivalent that uses UART 2. Looks like you would start with

```<code>hal.uartB->begin(115200);
</code>```

Using the mavlink protocol is also an option but you probably want your own simpler protocol. If you want to use mavlink you can use the gcs_send_text_fmt() function. For example, it is used inside verify_nav_wp() of commands_logic.pde .

Body:
If you just want to write data to the UART, you can use

cliSerial->printf("my output");

cliSerial is an alias for hal.console .

There is a good example here.

UART 2 is unused on the APM so I think you can examine how hal.console is set up and set up your own equivalent that uses UART 2. Looks like you would start with

hal.uartB->begin(115200);

Using the mavlink protocol is also an option but you probably want your own simpler protocol. If you want to use mavlink you can use the gcs_send_text_fmt() function. For example, it is used inside verify_nav_wp() of commands_logic.pde .


问:
How to implement a novel control algorithm for a drone
I and my research team are working on a novel drone design based on trirotor. The difference between this design and a trirotor is that it has an extra propeller to generate additional thrust, therefore we can not use the open-source autopilot ArduPilot anymore. I have prototyped a control algorithm on MATLAB/Simulink but I don't know how to implement this algorithm on the drone. I have encountered this on so many papers but I still don't know how they did it.

What type of hardware and coding should I need to prepare and learn in order to realize the algorithm? Should we continue to learn and modify the source code of open-source Autopilot like Ardupilot or it would be easier for us to start from scratch with a hardware?

答: Assuming you know how to model a regular quadrotor as $\dot{x} = Ax + Bu$, the only difference with the addition of the extra propeller will be in your control matrix and control vector (one more dimension and different control derivatives).


问:
How to keep track of (x,y) co-ordinates of a line-following bot?
I am working on a bot that follows a certain line path based on some pre-determined algorithm. I would like to know what the (x,y) co-ordinates of my bot are as it traverses with respect to some pre-defined origin and scale.

I am very new to robotics, so I am not sure of the hardware requirements such a task would entail. I would be glad to provide any further information.

答: Keeping tracking of (x,y) location would fall under state estimation. One fundamental method of state estimation is odometry.


问:
How do I send text to a Torobot USB device?
I'm trying to get the "Torobot" USB servo controller to work with Angstrom Linux on a Beagle Board XM.

The servo controller registers as a USB device. The device just takes simple text commands, but there is no TTY associated with it. So I'm not sure how to send commands to it.

Can I just send data like this (assuming that 002/005 is the device):

```<code>$ cat file.txt >> /dev/bus/usb/002/005
</code>```

Or do I need to associate it with the generic USB device? If so, how do I do that?

答:
you can pyusb for send data http://pyusb.sourceforge.net/docs/1.0/tutorial.html
and your data information is here http://www.torobot.com/down/usc_en.pdf
i think you python code like this</p>

```<code>    import usb.core
import usb.util

# find our device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()

# get an endpoint instance
cfg = dev.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_settting = usb.control.get_interface(interface_number)
intf = usb.util.find_descriptor(
    cfg, bInterfaceNumber = interface_number,
    bAlternateSetting = alternate_setting
)

ep = usb.util.find_descriptor(
    intf,
    # match the first OUT endpoint
    custom_match = \
    lambda e: \
        usb.util.endpoint_direction(e.bEndpointAddress) == \
        usb.util.ENDPOINT_OUT
)

assert ep is not None

# write the data
ep.write('#1P1500T100\r\n')
</code>```

Body:
you can pyusb for send data http://pyusb.sourceforge.net/docs/1.0/tutorial.html
and your data information is here http://www.torobot.com/down/usc_en.pdf
i think you python code like this

    import usb.core
import usb.util

# find our device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()

# get an endpoint instance
cfg = dev.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_settting = usb.control.get_interface(interface_number)
intf = usb.util.find_descriptor(
    cfg, bInterfaceNumber = interface_number,
    bAlternateSetting = alternate_setting
)

ep = usb.util.find_descriptor(
    intf,
    # match the first OUT endpoint
    custom_match = \
    lambda e: \
        usb.util.endpoint_direction(e.bEndpointAddress) == \
        usb.util.ENDPOINT_OUT
)

assert ep is not None

# write the data
ep.write('#1P1500T100\r\n')


答:
There are a lot of definitional problems and inconsistencies in this area.

Geometric Jacobian.  I'm not sure this has a precise and agreed upon meaning.  But across the more classical robotics books (Siciliano etal., Spong etal., Corke) it relates joint velocities to end-effector velocity (translational and rotational) expressed in either the world or end-effector frame.  I call this 6-vector a "spatial velocity" but this is a term that Feathersone also uses for a "velocity twist" (as per Park & Lynch).  The Jacobian of Park & Lynch relates joint velocities to a velocity twist.

The geometric Jacobian is distinct from the analytic Jacobian.  The latter represents the rotational velocity of the end-effector in terms of the rate of change of some 3-angle parameterisation (eg. RPY or Euler angles).

Translational and rotational velocity.  This can be the translational and rotational components stacked into a 6-vector (Siciliano etal., Spong etal., Corke) or a velocity twist.  The former is easy to understand in terms of how the end-effector is actually moving. The latter has very nice mathematical properties and is natural when coming at the problem from the Lie group/algebra perspective.  The principle difference is that the translational velocity component of the velocity twist is the velocity of an imaginary point at the origin that is rigidly attached to the moving object.  This means that the Park&Lynch Jacobian will be different to the Corke Jacobian, and the velocity transformations will also be different.  The difference will in the sub matrices concerned with translational velocity.

As an author, the problem I confronted was trying to morph the first edition (very classical, based on the books I grew up with) into the second edition with what I hoped was an easy path to the mathematical tools that Park&Lynch have popularised.  I am clearly not there yet...

Title: Relationship between the velocity twist Jacobian and the spatial velocity Jacobian

Body:
While reading Kevin Lynch's "Modern Robotics" [1], I came across a fundamental question concerning the manipulator Jacobian.
Upon better reading and further cross-checking with Peter Corke's "Robotics, Vision and Control" [2], I have managed to only confuse myself even more...

Kevin Lynch approaches kinematic representation of open chains with the product of exponentials (PoE) formula. In such representation, the space Jacobian $J_s(\theta) \in \mathbb{R}^{6 \times n}$ relates the joint rate vector $\dot{\theta} \in \mathbb{R}^{n}$ to the end-effector's twist expressed in fixed-frame coordinates $\mathcal{V}_s$ via
$$
\mathcal{V}_s = J_s(\theta)\dot{\theta}.
$$

A similar concept, the body Jacobian, relates the joint rate vector to the end-effector's twist in the end-effector frame coordinates via
$$
\mathcal{V}_b = J_b(\theta)\dot{\theta}.
$$

Finally, the relationship between both of the above is given by:
$$
J_b(\theta) = [Ad_{T_{bs}}]J_s(\theta);
$$
$$
J_s(\theta) = [Ad_{T_{sb}}]J_b(\theta).
$$

Given the above, my question is:

Provided $J_b(\theta)$, how can I obtain the geometric Jacobian?

I tried looking into Peter Corke's book and I found the following subsection.

Screenshot taken from Peter Corke's book:

So, apparently, what I am looking for is that final equation. (?)

It seems that $\sideset{^0}{^\mathcal{V}}{J}$ in Corke's book refers to the same as what $J_b(\theta)$ refers to in Lynch's book.

But what does Corke mean exactly with "velocity transformation"?

Specifically, what exactly is the top-right 3x3 block of that 6x6 matrix pre-multiplication?

[1] Kevin M. Lynch and Frank C. Park, "Modern Robotics: Mechanics, Planning, and Control," Cambridge University Press, 2017. (http://modernrobotics.org)

[2] Peter Corke, "Robotics, Vision and Control: Fundamental Algorithms," Completely Revised. Vol. 118. Springer, 2017. (http://petercorke.com/wordpress/rvc/)


问:
inverse kinematics matlab RVC for 3 joint RRR
Hi im having problem with Inverse kinematic using RVC toolbox in matlab for RRR manipulator.

```<code> L_1 = 20;
 L_2 = 50;
 L_3 = 40;
 L(1) = Link([0 L_1 0 pi/2]);
 L(2) = Link([0 0 L_2 0]);
 L(3) = Link([0 0 L_3 0]);
 Robot = SerialLink(L);
 Robot.name = 'RRR_Robot';
 T = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
 J = Robot.ikine(T, [0,0,0], [1 1 1 0 0 0]) *180/pi;
</code>```

Error using SerialLink/ikine (line 164) Number of robot DOF must be >= the same number of 1s in the mask matrix

Can somone explain me why my code is not working? / how to fix it ?

答:
I'm not sure what version of RTB you are using but you are missing the 'mask' keyword.

```<code>>> J = Robot.ikine(T, [0,0,0], 'mask', [1 1 1 0 0 0]) *180/pi
J =
    0.0000  -40.5416 -157.6684
</code>```

or more concisely:

```<code>>> J = Robot.ikine(T, [0,0,0], 'mask', [1 1 1 0 0 0], 'deg')
J =
    0.0000   -0.7076   -2.7518
</code>```

You'll get a quicker response by taking questions like this to http://tiny.cc/rvcforum

Body:
I'm not sure what version of RTB you are using but you are missing the 'mask' keyword.

>> J = Robot.ikine(T, [0,0,0], 'mask', [1 1 1 0 0 0]) *180/pi
J =
    0.0000  -40.5416 -157.6684

or more concisely:

>> J = Robot.ikine(T, [0,0,0], 'mask', [1 1 1 0 0 0], 'deg')
J =
    0.0000   -0.7076   -2.7518

You'll get a quicker response by taking questions like this to http://tiny.cc/rvcforum


问:
Does simulink accepts robotics toolbox in matlab?
I'm trying to make a model for a robotic arm on simulink and then excute it on arduino controller but i want also to use robotics toolbox to calculate forward and inverse kinematics so i need to add matlab function in my simulink model i tried it but it keeps giving errors but when i try it away from simulink it gives rsults ! is that because robotics toolbox works only with matlab but not with simulink?

the code in matlab function

```<code> function [theta1, theta2, theta3, theta4] = fcn(x, z, y)

L(1)=Link([0,0.03,0,pi/2,0]);
L(2)=Link([0,0,0.12,0,0]);
L(3)=Link([0,0,0.1,-pi/2,0]);
L(4)=Link([0,0,0,0,0]);
robot = SerialLink(L,'name','robot');

robot.tool=transl(0,0,.08);
robot.base=transl(0,0,.07);

    T=transl(x,y,z);
    q=robot.ikine(T,[0,0,0,0], [1 1 1 0 0 1]);
    q(1)=fix(q(1)*(180/pi));
   q(2)=fix(q(2)*(180/pi));
    q(3)=fix(q(3)*(180/pi));
    q(4)=fix(q(4)*(180/pi));

          theta1=q(1)
    theta2=q(2)
    theta3=q(3)
    theta4=q(4)
</code>```

but when i try it in command window away from simulink it gives results for x=1 y=1 z=1 and higher values

```<code>   Warning: solution diverging at step 245, try reducing alpha
 > In SerialLink/ikine (line 260)
  Warning: solution diverging at step 459, try reducing alpha
 > In SerialLink/ikine (line 260)
 Warning: solution diverging at step 533, try reducing alpha
 > In SerialLink/ikine (line 260)
 Warning: ikine: iteration limit 1000 exceeded (row 1), final err 1.790820
 > In SerialLink/ikine (line 179)

 theta1 =

  -21996

theta2 =

-1050694

theta3 =

 2711696

theta4 =

 2848957
</code>```

but for x=0.2  y=0.2 z=0.2 it gives that error

```<code>      .
      .
      .
      .
> In SerialLink/ikine (line 260)
Warning: solution diverging at step 567, try reducing alpha
> In SerialLink/ikine (line 260)
Warning: solution diverging at step 570, try reducing alpha
> In SerialLink/ikine (line 260)
Warning: solution diverging at step 574, try reducing alpha
> In SerialLink/ikine (line 260)
Warning: solution diverging at step 578, try reducing alpha
> In SerialLink/ikine (line 260)
Error using tr2angvec (line 97)
matrix not orthonormal rotation matrix

Error in SerialLink/ikine (line 191)
        [th,n] = tr2angvec(Rq'*t2r(T));
</code>```

答:
The MATLAB function block in Simulink has some limitations.  The fact that Link.m is referred to as a function not a class is a worry.  I recreated your Simulink model and get similar error messages, basically Simulink can't convert these classes into C code which it needs to do in order to run the simulation.  You could try putting all your code into a standalone m-file and then calling that from an "Interpreted MATLAB Fcn" block or writing an S-function.

It looks like you are using a very old version of the Robotics Toolbox which is clearly not converging on an IK solution.  The one in RTB10.x is much better.


问:
About official robotics system toolbox Matlab and Peter Corke Robotics toolbox matlab
I came to know that matlab released robotics system toolbox in 2016 version but I'm using Matlab 2014b. At that time I installed Peter Corke Robotics toolbox matlab and start working on it. I develop few GUI and wrote others code too using the same Peter Corke Robotics toolbox. But now I want to install new official version of robotics toolbox. But my doubt is if I install new version then what happen to older one. Will I  able to run my old codes (which used old toolbox) on matlab after installing new official version or it may vanish older one. Will matlab shows error in my codes or GUI after installing new version. I want to work with both toolbox.

Thanks.

答:
There are very few problems having both toolboxes installed.  The biggest gotcha is the function angdiff() which is provided by both toolboxes but defined differently.

If you want to stick with MATLAB 2014b you should use RTB9.10.


问:
Robotics Toolbox: Display all DH link frames in Seriallink.plot()
I am using the Robotics Toolbox by Peter Corke to create a plot of a simple four-link robot. For an assignment, I want a figure of the robot with all frames according to the DH-convention. Though even after reading through the documentation and googling for an hour, I couldn't find an option.

Seriallink.plot(...) offers the options 'jaxis' and 'jvec', though they only display the joint axes, not the complete xyz-frame per link.

How can I get a plot of a robot with all DH frames included?

If this is not possible, is there any other way to quickly render such a plot from a DH table? I am almost tempted to do it on paper after already wasting so much time on such an easy task.

答:
And the forward kinematics function has a second output argument which is an array of the transforms for each frame.  The following code will do what you want:</p>

```<code>p560.plot(qz)
[T,A] = p560.fkine(qz);
hold on
for i=1:6
  trplot(A(i), 'frame', num2str(i))
end
</code>```

Body:
And the forward kinematics function has a second output argument which is an array of the transforms for each frame.  The following code will do what you want:

p560.plot(qz)
[T,A] = p560.fkine(qz);
hold on
for i=1:6
  trplot(A(i), 'frame', num2str(i))
end