问:
Introduction to Robotics Mechanics & Control, John J Craig., 3rd Ed., Forward transformation problem Examples 2.2 and 2.4
I am reading the book "Introduction to Robotics Mechanics & Control", John J Craig., 3rd Ed., Forward transformation problem Examples 2.2 and 2.4.

Ex. 2.2 (Page 29): Frame {B} is rotated relative to frame {A} about X axis by 60 degrees clockwise, translated 20 units along Y axis and 15 units along z axis. Find P in frame {A} where P in frame {b} = [0 8 7]

The book's answer is [0.18.062 3.572].
But my answer is [0 30.062 11.572].

Ex. 2.4 (Page 33): Vector P1 has to be rotated by 60 degrees clockwise, about X axis and translated 20 units along Y axis, and 15 units along Z axis. If P1 is given by [0 8 7], find P2.

Essentially Ex.2.2 and 2.4 are the same problem. However, the Transformation matrix for Ex 2.4, has [0 8 7] as translation vector (The 4th column of T) instead of [0 20 15]. And, the given answer is [0.18.062 3.572].

I am not sure if it is just typo, or I am missing some genuine operation. Please let me know your opinion.

Thanks.

答:
I think I would solve this as I believe you did, where I find a rotation matrix $E$, a translation vector $\overrightarrow {dr}$, and I locate point P in frame B by adding it to the origin of frame B; $\overrightarrow P_{B} = \overrightarrow P + F_B$. Recall that you are "unrotating" from frame B to frame A, so you need to transpose the rotation matrix. Assemble the $T$ matrix:
$$
E_{A\rightarrow B} = \begin{bmatrix}
1 & 0 & 0 \\
0 & cos(-60) & sin(-60) \\
0 & -sin(-60) & cos(-60)
\end{bmatrix} \\~\\~\\
\\
E_{B\rightarrow A} = E_{A\rightarrow B}^T\\~\\~\\
\overrightarrow {dr} = \begin{bmatrix}
0 \\
20 \\
15
\end{bmatrix} \\
T_{B\rightarrow A}=
\begin{bmatrix}
E_{B\rightarrow A} & \overrightarrow {dr} \\
0 & 1
\end{bmatrix}
$$
Now, multiply $T \overrightarrow {P_B}$ to get $\overrightarrow {P_A}$, which is the same answer you gave in your statement. I believe you did everything correct. I actually drew the problem on a piece of paper to verify the solution. You are also correct that the second problem (2.4) is the same problem, just reworded. Again, try drawing it on a sheet of paper.


问:
Matlab toolbox (Windows) for Sick lasers?
Does anybody know where I can get a matlab toolbox or functions to work with a SICK laser-scanner (Windows OS)? I'm using a SICK-LDRS2110 with ethernet cable, but SOPAS software does not allow me to program recording times and other specific tasks. Any tips are more than welcome!

Thanks!

答: I had a look at the protocol specification, which is very well documented and easy to implement. Instead of using the sicktoolbox, I suggest writing your own driver, which meets your recommendations. This gives you more control over the performance, because you can just ignore (for you) useless commands. </p>

ContentLicense: CC BY-SA 3.0


问:
Fingerprinting/ model matching algorithms for localization
This paper mentioned the fingerprinting/model matching case. But I could not find an image based algorithm. Any suggestion about image based localization</p>

答: For fingerprint matching model, try working with SVM (support vector machines) algorithm, it is a based supervised learning model. For localization purpose you need to match ridges and bifurcation found in fingerprints. </p>


问:
ROBOTIC arm for playing chess
I wish to build a chess playing robot with robot arm as shown on youtube, can anyone please tell me which robot arm would suit my purpose and whether it can be bought second hand or alternatively anybody willing to sell used chess arm robot? Please help out.</p>

答:
You can buy one here: RobotShop

But an arm can be fun to make!  If you want to build one, there are a lot of sources to read up on.

Here's a general overview

societyofrobots

The 3 general things you need are...

1) to learn forward kinematics -- this will give you a basis to learn the next step

2) to learn inverse kinematics -- this will give you an understanding of the math used in moving your robotic arm

3) to decide on a hardward platform -- stick with the big names, something like Arduino or Raspberry Pi.  You'll find tons of code & community resources online.

Title: ROBOTIC arm for playing chess


问:
Libusb and arduino communication not working
I am doing a line following robot based on opencv. I have my onboard computer(an old pandaboard) running opencv. It will calculate the offset from the required path and communicate it to the arduino via USB. Then it will do PID optimisation on the data, and adjust the speed of the left and right motors.

To my dismay the communication part is not working, and I've tried hard for a day to fix it with no result. Here is the relavent code running on the pandaboard:

```<code>while(1)
    {

        r = libusb_bulk_transfer(dev_handle, 131, recieve, 1, &actual, 0);
        cout<<"r="<<r<<endl;
        int a;
        cin>>a;
        imgvalue=krish.calc_offset();
        send[0]=imgvalue&0xff;
        send[1]=imgvalue>>8;

//make write

        cout<<"Data to send->"<<imgvalue<<"<-"<<endl; //just to see the data we want to write : abcd
        cout<<"Writing Data..."<<endl;
        r = libusb_bulk_transfer(dev_handle, (4 | LIBUSB_ENDPOINT_OUT), send, 2, &actual, 0); //my device's out endpoint was 2, found with trial- the device had 2 endpoints: 2 and 129
        if(r == 0 && actual == 2) //we wrote the 4 bytes successfully
            cout<<"Writing Successful!"<<endl;
        else
            cout<<"Write Error"<<endl;

    }
</code>```

where imgvalue is the data to be send. This is the code running on the Arduino:

```<code>void loop()
{
  Serial.write('s');
  if(Serial.available()>0)
    Input_tmp = Serial.read();
  if(Serial.available()>0)
    Input_tmp = Input_tmp | (Serial.read() << 8);
  Input=Input_tmp;
  myPID.Compute();

// adjust the motor speed

}
</code>```

What happens when I run is that it will pause at the libusb read operation as the timeout is zero(infinity). At this point I've tried resetting the arduino, but this doesn't help. So how do I make my program respond to this start byte send my the Arduino? Where did I go wrong?

答:
Did you initialize libusb?

From the Sourceforge documentation:

int libusb_init  (   libusb_context **   context )

 Initialize libusb.

This function must be called before calling any other libusb function.

Seems like a trivial thing to ask but I didn't see it in your code, but I also don't see anything blatantly wrong with your code.


问:
Selecting hardware: stereo camera for beginners
I'm looking for some cheap hardware that would offer me results decent enough to continue my experimentation.

I've been looking into how to obtain hardware for learning about stereo vision and 3D reconstruction, I found two basic ways: - buy 2 cheap webcams and DIY - buy a stereo camera

For what I understood little variations in distance and inclination can easily compromise the diff map and so the DIY version might end up requiring constant calibrations, however on the other end, so buying "professional" stereo camera range from 500 euro to infinite.

For the moment I trying something in between, like the minoru 3d, however the overall performance of the camera looks a bit poor also because it's a 2009 product, however I can't find any more recent product offering a similar solution.

Can you suggest me what would be the best way/product/guide to archive decent results without spending a fortune ?

Thank you very much :)

答: I am a huge fan of the ZED it is easy to use and comes with pre built modules to use with opencv and some great examples, but at 500$ it might be out of your price range. I have had plenty of success with two cheap webcams, thee best thing to do it mount them on somthing like a metal bar after removing any pivot mechanism, so they will always be aligned.</p>


问:
What is the cheapest way to detect and identify vehicles entering a gate in real time?
I want to detect and identify each of the vehicles passing through a gate.

I have the live video feed of the gate which I initially thought to process and detect the number plates with the help of OpenCV or any other graphics library freely available. The problem is, the size of number plates may vary very widely, and the language the number plates are written with(Bengali) does not have a good OCR performance at all.

The next idea was to put a QR code in the windshield of the vehicles. (Yes the vehicles supposed to enter the area are private and enlisted vehicles). But I am not confident that I will be able to detect and identify all the QR codes in real time with 100% accuracy, as the QR codes might get pixelated due to low resolution of video.

So can anyone suggest any other cheap way we can adopt to detect and identify the vehicles? Can NFC or any other cheap sensors be used for this purpose?

答:
I am assuming that it is a narrow gate so all the vehicles come through at around the same point, you could reposition the camera so that it is focused on where the license plate is normally when they come in, but having only done ocr on english I do not know if this will improve detection much, qr codes are much easier to detect, but I would suggest somthing simpler like a 1D qr code (depending on the amount of information to encode) just add some alignment bits to the front and back with data in the middle, you could detect that from further away more easily.

Edit:
As you stated you wanted a more robust sensor based approach, I did some digging and This site claims wih passive tags you can read out to aroud 40 feet with directional antennas, allowing you to simply put tags on the inside of the windsheild and read them with a directional antenna from above pherphas giving you around 10ft between the antenna and the trucks.


答: If you can run OCR okay with your cameras (you cite resolution as problematic for QR code reading), then I would suggest you make bumper stickers. As they are installed on bumpers and not windshields, you can make them (essentially) as large as you need, in whatever character set you need, in whatever contrasting colors you need, and bumpers are all generally the same height and orientation, where windshields can vary a lot more. </p>

Title: What is the cheapest way to detect and identify vehicles entering a gate in real time?

Body:
I want to detect and identify each of the vehicles passing through a gate.

I have the live video feed of the gate which I initially thought to process and detect the number plates with the help of OpenCV or any other graphics library freely available. The problem is, the size of number plates may vary very widely, and the language the number plates are written with(Bengali) does not have a good OCR performance at all.

The next idea was to put a QR code in the windshield of the vehicles. (Yes the vehicles supposed to enter the area are private and enlisted vehicles). But I am not confident that I will be able to detect and identify all the QR codes in real time with 100% accuracy, as the QR codes might get pixelated due to low resolution of video.

So can anyone suggest any other cheap way we can adopt to detect and identify the vehicles? Can NFC or any other cheap sensors be used for this purpose?


问:
Artificial Intelligence Software Packages: Professionals, University education is oft' a step behind. What's actually being used?
Currently using Windows 8, what software packages for artificial intelligence programming (robotics branch) are used in today's professional environment as standard. Lots of internet suggestions, but companies seem to keep this a closely guarded secret. And are the internet rumors true? Would switching to Ubuntu offer me more in terms of depth.

Context: Educational field: Computer Science and Artificial Intelligence, current focus (though obviously experience in others) in programming languages stands at c++, C and Python. Looking to build, program and develop a human-like bot (NOT aiming for singularity at this point ;))and am asking this question in order to build my toolbox a little.

答:
I am not sure which end of the AI work you intended, so this may not apply. If you are working disconnected from hardware one might be better off with straight MATLAB / Octave.

If you are planning to demonstrate on hardware, the widest robotics control architecture / middleware is ROS which was the DARPA funded Player/Stage / Gazebo. There are many middlewares based on CORBA as the main alternatives. It has interfaces for all your language preferences.  http://playerstage.sourceforge.net/

ROS has sort of won the OS wars in robotics.  People clung to ACE TAO/ MIRO/ OROCOS / CORBA middlewares until they - mostly - accepted that ORBs are flexible but bloated producing bloated cores. The telling feature of all this collected effort is ROS' widest device driver array for sensors and robot chassis you will find:

http://wiki.ros.org/Sensors

It might be better to dual boot that machine to Ubuntu and slowly acclimatize. ROS has native Ubuntu .apts.  I dual-booted my first machine in 2003 and have never looked back. Nor rebooted the Windows partition either... Best of luck!


答:
Most professionals would be researching in particular subfields.

When you say:

Bot, I'll assume robot and not a natural language processing and response system. (You posted in robotics after all.)

Human-Like:
Looks? Synthetic Skin

Motion?  mechanical engineering

Intelligence? Mind? neural networks, planning, machine learning, psychology

capabilities? data processing

You leave way too many open questions for an intelligent response.

All of these things are open enough that any tool could lead to an advance, while no particular tool gives you much advantage in all places.

Plus when you go for the singularity, you can program it in Basic, and then it will work its own way forward to reprogram itself fast enough that it wouldn't matter.

I hope this helps a tiny bit.

Title: Artificial Intelligence Software Packages: Professionals, University education is oft' a step behind. What's actually being used?

Body:
Currently using Windows 8, what software packages for artificial intelligence programming (robotics branch) are used in today's professional environment as standard. Lots of internet suggestions, but companies seem to keep this a closely guarded secret. And are the internet rumors true? Would switching to Ubuntu offer me more in terms of depth.

Context: Educational field: Computer Science and Artificial Intelligence, current focus (though obviously experience in others) in programming languages stands at c++, C and Python. Looking to build, program and develop a human-like bot (NOT aiming for singularity at this point ;))and am asking this question in order to build my toolbox a little.


问:
Simple wireless connection between two circuits
I'm relatively new to robotics, and I'm building a project for which I need a simple wireless connection between two circuits such that when the first circuit is switched on, the other circuit gets switched on too. I'm looking to preferably build something like this on my own, but I have no idea about wireless connections. I only know basic wired robotics. I also know C++ programming if that helps. Apologies if such a question has already been asked.

Regards,
Hanit Banga

答: First of all do it with IR transmiter and receiver to develop your skills on signal buffering and processing. Than try to do it with fm or am transceiver circuits. Also you can use toy remote control devices 25MHz or 433 MHz. </p>


问:
How do you determine EKF process noise for pre-recorded data sets?
I've seen this question, which asks about determining the process noise for an EKF.  I don't see anything there about pre-recorded data sets.

My thought on how to determine the noise parameters, assuming ground truth is available, would be to run the data several times with the EKF and minimize the mean square error, while varying the noise parameters.

Is this an acceptable way to determine noise for a pre recorded data set?  Are there better (or just other) ways from determining the optimal noise values based just on the data set?

答:
Yes, such a method can give you a reasonable estimates of noise. Note that it is susceptible to systematic error. For instance if you are flying a quadrotor in the presence of a fan. This would show up in your findings which is generally undesirable.

With that said you could improve your estimates by using the forward-backward algorithm. This algorithm is named from the fact that it consists of a forward pass and a backward pass. The forward pass is basically just an application of a Kalman-Filter, which as you may already realize, only includes data available up until the time step for which the state is being estimated. The backward pass then improves these estimates by including data available after the time in question.

I have only used the forward-backward algorithm with a KF (i.e. not an EKF). As such I don't know the precise implementation details when using an EKF. However there does appear to be some literature on the topic.

Edit: As I think about this further it occurs to me that you can use expectation maximization (EM) and coordinate descent (CD) to automatically determine the noise parameters. The process would treat the covariance matrices for the process model (call it P) and observation models (call it O) as EM parameters and proceeds as follows:

Start with your best guess for one of the matrices. Say P for the
sake of an example. Then use EM to identify O.

Use the O found in step 1 with EM to improve the estimate of P.

Repeat steps 1 and 2 until the log-likelihood of using O and P reaches some stopping criterion (e.g. stops varying, varies very little, or is minimized).

ContentLicense: CC BY-SA 4.0


答:
Different solution, so different answer.

If you're looking for sensor-based, you can do pretty much anything. Passive sensors (RFID tags) are, in my experience, only reliable over very short distances; 1 meter or less. Additionally, RFID tags work best when the reader is located normal to the face of the tag. That is, if you glued the tag to a windshield, a reader on the side of the car is the worst place you could put it. You want the tag "broadside" to the reader to get the best signal strength (again, range is a big issue), which would mean either put the reader 1m in front of the windshield or put the tag on the driver/passenger window.

You could do RF, over something like XBEE, or you could do infrared like a TV remote. Anything that's not passive, which again is essentially only RFID, requires power. This means batteries, which could (would) be drained quickly if they are constantly transmitting, or splicing into the vehicle power wiring, which could (would) be costly and time consuming.

What are your requirements? What's your intended range? How many vehicles are you servicing? Do you have a budget? Can you splice in to vehicle wiring? Do you need automation, and if so, what degree of automation?

Your question is very open-ended.

For a sensor-based system, the easiest solution would be a garage door opener or similar. This would require a small transmitter in every vehicle, where the driver pushes a button to send a signal to open the gate. You could also just put a keypad at the gate, where the driver has to enter a passcode.

Basically, any transmitter that could run on batteries should only run intermittently, requiring interaction from the driver. Any transmitter that emits constantly will need vehicle power. I believe that you will find that any passive transmitter is simply not feasible due to the range requirement. Also, RFID readers are expensive, much more so than the garage door openers, but probably less than interfacing with vehicle wiring.

If you're insistent on a totally passive system, I would look at simply upgrading the security camera. This would provide you the higher resolution you need to do OCR. At that point, see my solution above of bumper stickers if license plate reading is not feasible.

Know that, whatever the system, there will be failures, and you will always need a gate operator on standby to handle the failures (guests, bad transmitter, battery died, dirty sticker, OCR didn't register, etc. etc.)


答:
How much work are you looking to put into this?

sparkfun offers these lovely transmitters for just \$4/ea and recievers for just \$5 each, paired with an ATTiny you can do just about anything :O

Transmitter

Receiver

ATTiny84

My suggested implementation would be the following:

Near the gate of your complex you would have a receiver paired with an ATTiny, this will be your detector, and you will be getting your data from this node.

In each vehicle, a voltage regulator will step the 12v of the vehicle down to a usable 3.3v, which will power the ATTiny. Once every second or so, power on the transmitter via a transistor, and broadcast a vehicle specific identification for a split second.

This circuit could run at all times (would draw verry little current relatie the the capacity of the vehicle battery), or could be triggered off of the ignition, and will only be broadcasting when the vehicle is running, or maybe even a switch in the cabin - up to you.


答:
If you are looking for an implementation that would use a microcontroller, you can opt for RF which allows a much broader range of communication then IR can offer.

Sparfun offers some transmitters and recievers for use $4/5/ea.

Transmitter

Receiver

Title: Simple wireless connection between two circuits

Body:
I'm relatively new to robotics, and I'm building a project for which I need a simple wireless connection between two circuits such that when the first circuit is switched on, the other circuit gets switched on too. I'm looking to preferably build something like this on my own, but I have no idea about wireless connections. I only know basic wired robotics. I also know C++ programming if that helps. Apologies if such a question has already been asked.

Regards,
Hanit Banga


问:
How do I Program the Create 2?
I just un-boxed and set the Create 2 to charge overnight.

How do I program it? Where is the software?

答:
You can use a Computer, Arduino, Raspberry Pi or other device that can communicate via serial (using a Create 2 USB cable or build your own) or Bluetooth (if you have a something like the Rootooth or build your own) and program that device to connect and interact with the Create 2.
Please checkout the Create 2 Site at iRobot

On the Create 2 site you will also find the Getting Started page that will link you to the Create 2 Open Interface Specification and several example projects.

As Andy mentioned a direct link to the Open Interface Specification is here as well.

Title: How do I Program the Create 2?


答:
Looking through the links posted by Andy, here are some simple commands I extracted from iRobot's python script:

```<code>if k == 'P':   # Passive
    self.sendCommandASCII('128')

elif k == 'S': # Safe
    self.sendCommandASCII('131')

elif k == 'F': # Full
    self.sendCommandASCII('132')

elif k == 'C': # Clean
    self.sendCommandASCII('135')

elif k == 'D': # Dock
    self.sendCommandASCII('143')

elif k == 'SPACE': # Beep
    self.sendCommandASCII('140 3 1 64 16 141 3')

elif k == 'R': # Reset
    self.sendCommandASCII('7')
</code>```

They will more then likely have a full command set either provided with the system, or available online - but here are some basic commands.

The connection to the system is made via serial, and it would appear from this script as if ASCII commands are all it takes to get it up and running.

Plug, open a serial terminal, and play.

Title: How do I Program the Create 2?

Body:
I just un-boxed and set the Create 2 to charge overnight.

How do I program it? Where is the software?

Body:
Looking through the links posted by Andy, here are some simple commands I extracted from iRobot's python script:

if k == 'P':   # Passive
    self.sendCommandASCII('128')

elif k == 'S': # Safe
    self.sendCommandASCII('131')

elif k == 'F': # Full
    self.sendCommandASCII('132')

elif k == 'C': # Clean
    self.sendCommandASCII('135')

elif k == 'D': # Dock
    self.sendCommandASCII('143')

elif k == 'SPACE': # Beep
    self.sendCommandASCII('140 3 1 64 16 141 3')

elif k == 'R': # Reset
    self.sendCommandASCII('7')

They will more then likely have a full command set either provided with the system, or available online - but here are some basic commands.

The connection to the system is made via serial, and it would appear from this script as if ASCII commands are all it takes to get it up and running.

Plug, open a serial terminal, and play.


问:
How can I send a jpeg image to a microcontroller via USART?
How can I send a jpeg image to a microcontroller via USART?</p>

答:
the UART protocol it not really intended for images, each data packet is 11 bits, and can only contain 8 bits of data. This will take a really long time, even for the smallest of images.

I am sure there are libraries out these, or you could do it your own.

On the side with the jpg file, you should be able to iterate through the memory map of the image, transmitting 8 bits at a time. On the receiving end, you will then need to take and rebuild the raw file.

You have not specified an architecture of any kind, so I can not provide further information - but you should really look into compression before you transmit it.


问:
What is the reduced form of this block diagram?
What is the reduced form of this block diagram? I can't see any solution way :(

答:
Starting with your system and some guidelines for block diagram reduction (PDF):

Move the pickoff point between G2 and G3 to before G2

Combine G2 and G3 into one block (G2G3)

Combine G4 with the G2G3 block (G4 + G2G3)

Combine G2 and H1 (G2H1)

Redraw the rats nest after G1

Duplicate the H2 line to give a feedback loop around (G4 + G2G3) and
a feedback line towards (G2H1)

Collapse the (G4 + G2G3) and H2 loop

Make room for more work!

Move the summing junction located just before G1 to just after G1

Move the pickoff point just before the big transfer function to
 just after it (what was the G4 + G2G3 stuff)

At this point everything should be easy

Collapse summing junctions into summed blocks

Collapse feedback loops

Collapse feedback loops

Collapse feedback loops

Done! (see the pic below for details) Please check my work; I did everything in paint, but this is the route you should take. Moving summing junctions and pickoff points is key to solving this, as it is in nearly every instance.


问:
Quadcopter PID output and duty cycle conversion
I'm trying to design two PD controllers to control the roll and pitch angle of my quadcopter and a P controller to control the yaw rate. I give to the system the reference roll, pitch and yaw rate from a smartphone controller (with WiFi).In the case of roll and pitch the feedback for the outer 'P' loop is given by my attitude estimation algorithm, while in the inner 'D' loop there is no reference angle rate, and the feedback is provived by a filtered version of the gyroscope data.
As far the yaw rate is concerned, is only a P controller, the reference yaw rate is given by the smartphone, and the feedback of the only loop is provived by the smartphone. This is to illustrate the situation. My sampling frequency is 100hz (imposed by the attitude estimation algorithm, that is a Kalman Filter, that I'm using). I have tuned my controller gains with matlab, imposing a rise time of 0.1 seconds and a maximum percent overshoot of 2% with root locus. Matlab is able to found me a solution, but with very large gains (like 8000 for P and 100 for D). I was doing the tuning, using a quadcopter model (for each euler angle) based on the linearized model for quadcopter or instance : $$\ddot \tau_\Phi = I_x\ddot \Phi    ->  G_\Phi(s) = \frac{I_x }{ s^2} $$ only in order to have a 'reasoned' starting point for my gains, and then re-tune it in the reality. (The transfer function above is continous, in my model I have obliviously used the discrete version at 100hz of sampling rate).
This is to do a premise of my following questions.
Now, I have to map my controller outputs to duty cycle. Since I'm using a PWM at 25Khz frequency, my period (in the TIM channel configuration) is of 2879.
I have checked the activation threshold (after which the motor starts move) and the threshold after which it stops increasing its speeds, and the first is 202
and the second is 2389.
I was following the very good answer of Quadcopter PID output but I still have some questions.

1) As far the throttle mapping is concerned, I have to map it in such a way that the values coming from my smartphone controller (in the interval [0, 100]) are not
mapped in the whole [202, 2389] interval, but I have to 'reserve' some speed in order to allow the quadcopter to have an angular movement exploiting differences in the 4 motor speeds even with 100% throttle?

2) Coming back to the fact that matlab propose me huge gains for my controllers, this leads to the fact that I cannot directly sum the controller output to the duty cycle as stated in the metioned answer (because I will certainly go out of the [202, 2389] bound of my TIM pulse). Doing a proportion will result in altering the gains of the systems, so placing somewhere else the poles of my systems and the procedure done with matlab will became useless, right? So, what I'm doing wrong? I have tried to enforce matlab to bound the gainsm for instance in the [0,100] interval, but in this case it cannot find gains such that my constraints are verified.
Thank you

答:
I'm posting this as an answer because it is a bit lengthy for the comments section, and I hope it will point you in the right direction.

First, you mention an "outer P loop" and an "inner D loop", which, to me,  would imply that you are performing those two tasks at different rates. This is incorrect for any form of a PID controller (P, PI, PD, etc.)

All of your gains, proportional, integral, derivative, should act on the respective error measurement. If you are commanding a speed, proportional error is the difference between command and actual speed. Integral error is the difference between desired and actual position, and derivative error is the difference between reference and actual acceleration.

You have the option of either calculation the integral/derivative of your reference speed, the actual speed, and subtracting to get the error, OR you can calculate the integral/derivative of the speed error and use that directly.

Once you have all the error terms, you multiply each by its respective gain and add all the terms to get the control signal. I emphasize add the terms to reinforce that you need all the terms to get the control signal - you shouldn't be calculating one at a faster rate than the other.

What I believe you are missing is what you had asked about in your other question - it seems like your Matlab model is missing the transfer function that converts from PWM to speed, and maybe from speed to torque or lift.

I would imagine the relationship between PWM and speed is linear - lowest PWM signal gives some minimum speed (y-intercept), up to full speed at 100%. Then, as the paper you linked in your other question suggests, try a constant k1/k2 to get from speed to lift/torque.

This paper (PDF) seems to  give the answer you're looking for (on page 8), and this page gives a really good derivation of equations of motion.

So, back to your specific questions, regarding point 1, you can either operate up to "full throttle" with no modifications, or you can leave a "reserve" (overhead) for maneuvering, or you can have sliding gains to account for a lack of headroom. If you want to rotate, you speed two props up and slow two down. At full throttle, two will slow, but the other two can't go any faster. Maneuvering is cut (for all intents and purposes) in half. You can leave headroom to allow two to speed up, but this restricts your top speed. You could modify gains to (hand waving) slow the two props twice as fast. This makes up for the other two not speeding up at all because you have the same differential.

The choice here is up to you, but because the controller is "watching" craft performance as compared to your commands it shouldn't matter too much. The controller isn't going to slow a pair and speed a pair by a fixed amount, it's going to slow/speed until the desired command inputs have been met. It won't respond quite as quickly as you would expect, though, because...

Point 2 - actuator saturation. This refers to passing a reference that is of such a magnitude that the actuator cannot comply. The output of your controller is the output of your controller. If you have modeled the system well, then the output should be what you supply as an input to your system. If the actuator saturates, it saturates. This would be something like requesting a speed of 1800rpm from a 1200rpm motor, or a force of 150lb from a 100lb hydraulic cylinder - you are asking the actuator to do something it physically cannot do.

In your case the gains may cause the system to saturate - your PWM signal "should be" (per the controller), at 150%, but you can only command 100%. So you truncate to whatever the max is (100%), and send that. When the controller "sees" that the system is responding and approaches the reference command, it will back off on its own. This is the great thing about a controller. The output signal doesn't matter too much because it's looking for a response as compared to your command, not any kind of absolute.

That is, if you command a yaw rate of 30 deg/second, but you can only accelerate 1 deg/s^2, your controller may saturate your input asking "full throttle". Once you finally accelerate to the desired yaw rate, the controller will back off on its own to hold the desired command. Note that the controller will always try to meet the performance goals you specified when choosing the gains; it is up to you to spec the actuators to meet those performance specs.

Mostly this is to say that, if your gains look like they're too high, you may have either asked for more performance than your craft is capable of delivering or you have not modeled your system correctly. If you're close it will generally work, but if your gains are too far off (your model is too incorrect), then you will wind up with either no response or you will wind up railing the controller, where the controller says, "I'm too slow - Full throttle!" and then a moment later, "I'm too fast, turn it off!". This is caused by gains that are too high.

You can always tune the gains manually to achieve desired performance (section 4 of this PDF - Zeigler Nichols tuning), but I think you'll find that PID control of a MIMO system is nigh impossible due to coupling between input/output channels. I think you would be happiest with a state feedback controller, but that's not what you asked about so I'll just post the link and leave it at that.

Good luck!


问:
Inter-processor communication for robotic arm
I'm building a hobby 6-DOF robotic arm and am wondering what the best way is to communicate between the processors (3-4 AVRs, 18 inches max separation). I'd like to have the control loop run on the computer, which sends commands to the microprocessors via an Atmega32u4 USB-to-??? bridge.

Some ideas I'm considering:

RS485

Pros: all processors on same wire, differential signal more robust

Cons: requires additional chips, need to write (or find?) protocol to prevent processors from transmitting at the same time

UART loop (ie, TX of one processor is connected to RX of next)

Pros: simple firmware, processors have UART built in

Cons: last connection has to travel length of robot, each processor has to spend cycles retransmitting messages

CANbus (I know very little about this)

My main considerations are hardware and firmware complexity, performance, and price (I can't buy an expensive out-of-box system).

答:
I can highly recommend CAN for inter processor communications. We use it in our robots, with up to 22 processors on the same bus. With good protocol design, you can use up about 90% of the available bandwidth (about 640kbps when you take into account all of the error checking and inter frame spacing). We're able to servo 10 motors at 1000Hz on one CAN bus. This is approaching the limit. You could probably squeeze it to 20 motors if you pack the data very carefully.

Generally CAN needs to have one transceiver chip for each processor (it's just a little 8-pin device). The transceiver gives you the nice differential signal which emits very little interference, and also makes it immune to interference if you're working in an electrically noisy environment (motors, solenoids, and radio transmitters).

However, in limited circumstances, it's actually possible to use CAN with no transceivers.

If you ever feel like implementing a bus with serious bandwidth, I suggest you try EtherCAT. It's a 100Mb bus, which can be connected to your PC's Ethernet port. There are two important parts to the bus:

The Bridge. This converts the Ethernet physical layer to a simpler, lower cost LVDS physical layer, which doesn't require the large connectors, Phy chip, and many components that Ethernet itself does.

The nodes. Each node just needs one ET1200 chip and a microcontroller.

The PC can transmit and receive large chunks of data to and from the nodes at 1kHz or faster. You can control quite a lot of stuff on a single EtherCAT bus.

Added:

Shadow Robot Company now sell a useful EtherCAT Bus system called Ronex. It lets you add quite a lot of I/O, and they're going to be introducing lots of other types of board soon, like motor controllers, and high quality ADCs.


问:
What is the technology used for no-resistance robot arms?
I saw a high end robot arm once that I could move and bend it to any form I wanted with no resistance, as if the robot arm didn't have any weight. I'd like to know more about them. What is this class of robot arm design called? Where can I get some more information about its design and applications?</p>

答:
Besides gravity compensation, some impedance/admittance control can be used to make a robot compliant and regulate the stiffness of the motion. What you actually do is that by using a specific control law you can make the robot to behave as a mass-damper-spring system.

Using control theory and measurements from the robots sensors (torque sensors etc) the controller (implemented on a computer) calculates the new torques for the joints and send them to the actuators. These new torques are the result of the control law (a mathematical equation). You can specify a desired value for the inertia (how difficult is to accelerate the robot), the damping coefficient (how difficult is to move the robot with a high velocity) and the spring constant (how "fast" the robot will return to the initial position). If you want just a compliant robot, you may not need the spring constant.


问:
How to implement PID control for robotic arm?
I'm wondering that, PID control is a linear control technique and the robot manipulator is a nonlinear system, so how it is possible to apply PID control, in this case. I found a paper named: PID control dynamics of a robotic arm manipulator with two
degrees of freedom. on slide share page, is this how we use PID control for robotic arm, is there any name for this approach? and how to remove the ambiguity that PID is linear control technique and the robot is nonlinear system. Any suggestions?</p>

答:
As @acs said, PID control is used for individual joint control.  And you ignore all non-linearities.  And typically this is good enough.  Sure each joint's control isn't completely optimal, but they should be stable.  You can have each joint doing position or velocity control.  Then you can do trajectory control at a higher level.

For whole arm control where you want to take into account non-linearities, you do non-linear control.  Drake is one such toolbox that does this.


答:
From my experience, it is often easier to stop thinking in terms of "block diagrams" and start to think in terms of equations that these block diagrams represent.

I introduce a few new nodes E, A and B:

Now let's write the equations for each of them
$$
\begin{align}
E &= R-C\\
A &= H_2C+G_1(E+H_1B)\\
B &= G_2A\\
C &= G_3B + G_4A\\
\end{align}
$$

Insert B in A and C gives
\begin{align}
E &= R-C\\
A &= H_2C+G_1(E+H_1G_2A)\\
C &= (G_3G_2 + G_4)A\\
\end{align}

Insert E in A gives
\begin{align}
A &= H_2C+G_1(R-C+H_1G_2A) = H_2C+G_1R-G_1C+H_1G_1G_2A \\
  &= (H_2-G_1)C +G_1R +H_1G_1G_2A  \\
  &=\frac{(H_2-G_1)C +G_1R}{1-H_1G_1G_2}\\
C &= (G_3G_2 + G_4)A\\
\end{align}

Insert A in C gives
\begin{align}
C &= (G_3G_2 + G_4)\frac{(H_2-G_1)C +G_1R}{1-H_1G_1G_2}\\
(1-H_1G_1G_2)C  &= (G_3G_2 + G_4)(H_2-G_1)C +(G_3G_2 + G_4)G_1R\\
[(1-H_1G_1G_2)-(G_3G_2 + G_4)(H_2-G_1)]C  &= (G_3G_2 + G_4)G_1R\\
\end{align}

And finally

\begin{align}
\frac{C}{R} &=\frac{(G_3G_2 + G_4)G_1}{(1-H_1G_1G_2)-(G_3G_2 + G_4)(H_2-G_1)}\\
&\\
 &= \frac{G_1G_2G_3 + G_1G_4}{1-G_1G_2H_1-G_2G_3H_2 - G_4H_2 + G_1G_2G_3 + G_1G_4}\\
\end{align}

Body: What is the reduced form of this block diagram? I can't see any solution way :(


问:
Is ROS hard real time safe?
I know that is a question that has been asked too many times, but still its not clear to me. I read online that it isn't but some people say that they control their robots under ROS in applications with hard real time constraints. So, because I need some technical arguments (rather than a plain "ros is not real time") I will be more specific (suppose we have ROS under a RTOS):

I read that ROS uses a TCP/IP-based communication for ROS topics and I know that TCP/IP is not reliable. That means I cannot use topics in a real time loop? For instance send a control signal to my system publishing it to a topic, and the system sending me some feedback via a topic?

If I have a RTOS (eg Linux+Xenomai) can I build a real time control loop for a robot using ROS, or ROS will be a bottleneck?

Maybe the above are naive or I lack some knowledge, so please enlighten me!

Note: I define as a hard real time system (eg in 1KHz), the system that can guarantee that we will not miss a thing (if the control loop fails to run every 1ms the system fails).

答:
ROS is not a real-time operating system.  The purpose of ROS was not to be like VXWorx (which is what the Mars Curiosity rover uses).  ROS was developed to be a simple, generic, reusable platform for everyone to contribute to and use.  Developers would be able to add their own abstracted modules, building a rich community of reusable code.  The key here is that ROS is meant to save development time, not to ensure real-time operations.  This addresses your point #6.

Simplest reason ROS is not real-time: the version of Linux it sits on is not real-time.

To point 1, the unreliability of TCP/IP is a good point, but in itself, that doesn't mean that a system with TCP/IP cannot be a real-time system.  "Real-time" simply means that 2 guarantees are always made:

1) a task is guaranteed to have a completion time - an absolute deadline,
and
2) if that deadline cannot be achieved, a warning about this failure will be made.

That should also explain points 2 & 3.

Not sure about point 4.

For point 5: Yes, there is a benefit, but for some architectures to be able to accomplish this, we would need a real-time OS slice (also called a base operating layer), and this may be too burdensome for some projects.

I hope that helps,
Ryan

Title: Is ROS hard real time safe?


问:
How to make a directed graph?
I'm working on an robot that would be able to navigate through a maze, avoid obstacles and identify some of the objects in it. I have a monochromatic bitmap of the maze, that is supposed to be used in the robot navigation.

Up till now, I have converted/read the bitmap image of the maze into a 2D array of bits. However, now I need guidance on how to use that array to plan the path for the robot. I would appreciate if you could share any links as well, because I am new to all this stuff (I am just a 1st year BS electrical engineering student) and would be happy to have a more detailed explanation.

If you need me to elaborate on anything kindly say so.

I would be grateful!

Here's the image of the maze.

This is just a sample image; the robot should be able to work with any maze (image) with similar dimensions. And you are welcome!

Thank you Chuck!

UPDATE
Heres the code for sub2ind in c++. Kindly see if the output is correct:-

```<code>ofstream subtoind;
subtoind.open("sub2ind.txt");

int sub2ind[96][64] = { 0 };
int ind2subROW[6144] = { 0 };
int ind2subCOL[6144] = { 0 };
int linearIndex=0;
j = 0;
z = 0;

for (j = 1; j <= 64; j++)
    {
        for (z = 1; z <= 96; z++)
            {
                    linearIndex = z + (j - 1) * 96;
                    sub2ind[z-1][j-1] = linearIndex-1;
                    //ind2subROW[linearIndex-1] = j-1;
                    //ind2subCOL[linearIndex-1] = z-1;
            }
    }
for (j = 0; j < 96; j++)
{
    subtoind << endl; //correction
    cout << endl;

    for (z = 0; z < 64; z++)
    {
        subtoind << sub2ind[j][z] << " ";
    }
}
subtoind.close();
</code>```

Heres the Link to the output file.
https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing

答:
Use the bits in your array to create a connectivity map, assign distances between points (but it sounds like the map is uniformly sampled), then implement some version of Dykstra's algoritm.

The map you have can be parsed to see which non-wall tiles have neighbors. Use this, with a regular numbering scheme, to establish the connectivity graph. Each location on your map will have a distance associated with each neighbor. Dykstra uses the map and distances to find the shortest path from one point to another. One output is total distance, another output is a list of way points to get from A to B. The way points will be a list of every neighbor along the path, then all you have to do is get the car to move from one point to another.

:EDIT:

I started this as a comment, but it's too long and this is really more information on the answer, so I put it here.

Matlab has a neat trick where you can access values of a matrix with only one number (called linear indexing) instead of the usual row/col argument. Your map will be an arbitrary size, like the 64x96 you mention. In it you have a 1 if the craft is allowed there (is a path) and a 0 of the craft is not allowed there (is a wall).

So you should be able to display your map matrix, which again is of arbitrary size, and see all of the paths and walls.

Now to create to connectivity map (the directed graph, or digraph), you want to cycle through all of the points in your map and see which neighbors are adjacent. Note that the linear indexing I linked to shows that Matlab indexes increasing from the top of col1 to the bottom of col1, then top of col2, etc. Linear indexing is great because it gives each location on your map one number with which to refer to that position.

Let's assume your map has N locations, where N is the length x width of your map (N = 64x96 = 6144 in your example). Now your digraph matrix should be NxN, because you're looking for a relationship between any one location on your map and any other location. Let's name your digraph "Digraph" for simplicity.

This setup means that you should be able to call digraph(a,b) and get a value of 1 if $a$ and $b$ are connected and 0 if they are not, where again $a$ and $b$ are linear indices that refer to one location on your arbitrary map.

So, for some implementable Matlab code (writing this on the fly on my phone, so please forgive any errors):

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

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

A couple things to note here -
1. This populates the digraph with zeros for every entry of Digraph(a,a). This is a matter of preference, but if you prefer you can set all of those entries to 1 (showing that $a$ is connected to itself) with the command
Digraph = Digraph + eye(N);

If you use 1's and 0's in your map, then Map (currentPos)*Map (destPos) is either 1 if both entries are 1 or 0 if either entry is a 0. That is, it doesn't matter which is the wall, you equally can't move from wall to path or path to wall.

If you just use a regular map you should get a symmetric matrix. The nice thing about a Digraph is that it doesn't need to be symmetric. That is, you could have wormholes/tunnels/portals/chutes and ladders where one point on the map is connected to some remote point on the map.

Further, these tunnels can be bi-directional (two way), or they can be uni-durectional. That is, Digraph(a,b) could be 1 (path exists) where Digraph(b,a) is zero (path does not exist).

If there are such tunnels, you need to add them by hand after the script above runs.

Just like sub2ind gives you the linear index given conventional subscripts, ind2sub gives you subscripts given the linear index.

Finally, as a note, the Dykstra algorithm should give you a series of way points, but these will all be in linear index form. This is why I point out the ind2sub function above.

Hope this helps. Please feel free to comment if you have any more questions.

:EDIT EDIT:
Linear indexing is just a way to refer to a matrix location with one value. You can brew your own as follows (again in Matlab form not c++, though they are similar):

```<code>nRows = size(matrixToBeIndexed,1);
nCols = size(matrixToBeIndexed,2);
N = numel(matrixToBeIndexed);
sub2ind = zeros(nRows,nCols);
ind2subROW = zeros(1,N);
ind2subCOL = zeros(1,N);

for i = 1:nCols
  for j = 1:nRows
    linearIndex = j + (i-1)*nRows;
    sub2ind(j,i) = linearIndex;
    ind2subROW(linearIndex) = j;
    ind2subCOL(linearIndex) = i;
  end
end
</code>```

In this way you can pass subscripts to sub2ind, now a matrix instead of a function, and get the linear index, and you can pass a linear index to the pair of ind2sub functions to get subscripts. How you want to implement ind2sub is up to you; I would personally use an Nx2 matrix but I wrote it as two separate vectors for clarity.

Hope this helps!

Title: How to make a directed graph?

Body:
Use the bits in your array to create a connectivity map, assign distances between points (but it sounds like the map is uniformly sampled), then implement some version of Dykstra's algoritm.

The map you have can be parsed to see which non-wall tiles have neighbors. Use this, with a regular numbering scheme, to establish the connectivity graph. Each location on your map will have a distance associated with each neighbor. Dykstra uses the map and distances to find the shortest path from one point to another. One output is total distance, another output is a list of way points to get from A to B. The way points will be a list of every neighbor along the path, then all you have to do is get the car to move from one point to another.

:EDIT:

I started this as a comment, but it's too long and this is really more information on the answer, so I put it here.

Matlab has a neat trick where you can access values of a matrix with only one number (called linear indexing) instead of the usual row/col argument. Your map will be an arbitrary size, like the 64x96 you mention. In it you have a 1 if the craft is allowed there (is a path) and a 0 of the craft is not allowed there (is a wall).

So you should be able to display your map matrix, which again is of arbitrary size, and see all of the paths and walls.

Now to create to connectivity map (the directed graph, or digraph), you want to cycle through all of the points in your map and see which neighbors are adjacent. Note that the linear indexing I linked to shows that Matlab indexes increasing from the top of col1 to the bottom of col1, then top of col2, etc. Linear indexing is great because it gives each location on your map one number with which to refer to that position.

Let's assume your map has N locations, where N is the length x width of your map (N = 64x96 = 6144 in your example). Now your digraph matrix should be NxN, because you're looking for a relationship between any one location on your map and any other location. Let's name your digraph "Digraph" for simplicity.

This setup means that you should be able to call digraph(a,b) and get a value of 1 if $a$ and $b$ are connected and 0 if they are not, where again $a$ and $b$ are linear indices that refer to one location on your arbitrary map.

So, for some implementable Matlab code (writing this on the fly on my phone, so please forgive any errors):

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

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

A couple things to note here -
1. This populates the digraph with zeros for every entry of Digraph(a,a). This is a matter of preference, but if you prefer you can set all of those entries to 1 (showing that $a$ is connected to itself) with the command
Digraph = Digraph + eye(N);

If you use 1's and 0's in your map, then Map (currentPos)*Map (destPos) is either 1 if both entries are 1 or 0 if either entry is a 0. That is, it doesn't matter which is the wall, you equally can't move from wall to path or path to wall.

If you just use a regular map you should get a symmetric matrix. The nice thing about a Digraph is that it doesn't need to be symmetric. That is, you could have wormholes/tunnels/portals/chutes and ladders where one point on the map is connected to some remote point on the map.

Further, these tunnels can be bi-directional (two way), or they can be uni-durectional. That is, Digraph(a,b) could be 1 (path exists) where Digraph(b,a) is zero (path does not exist).

If there are such tunnels, you need to add them by hand after the script above runs.

Just like sub2ind gives you the linear index given conventional subscripts, ind2sub gives you subscripts given the linear index.

Finally, as a note, the Dykstra algorithm should give you a series of way points, but these will all be in linear index form. This is why I point out the ind2sub function above.

Hope this helps. Please feel free to comment if you have any more questions.

:EDIT EDIT:
Linear indexing is just a way to refer to a matrix location with one value. You can brew your own as follows (again in Matlab form not c++, though they are similar):

nRows = size(matrixToBeIndexed,1);
nCols = size(matrixToBeIndexed,2);
N = numel(matrixToBeIndexed);
sub2ind = zeros(nRows,nCols);
ind2subROW = zeros(1,N);
ind2subCOL = zeros(1,N);

for i = 1:nCols
  for j = 1:nRows
    linearIndex = j + (i-1)*nRows;
    sub2ind(j,i) = linearIndex;
    ind2subROW(linearIndex) = j;
    ind2subCOL(linearIndex) = i;
  end
end

In this way you can pass subscripts to sub2ind, now a matrix instead of a function, and get the linear index, and you can pass a linear index to the pair of ind2sub functions to get subscripts. How you want to implement ind2sub is up to you; I would personally use an Nx2 matrix but I wrote it as two separate vectors for clarity.

Hope this helps!


问:
iRobot Create 2 and Open Interface 2 Spec not syncing up with incoming data
I have the create 2 and have it hooked up to an arduino. Almost all the commands work fine except when retrieving sensor information. If i send a request for packet 18 I get back values that while consistent don't match up, unless I am missing something. So if I press the clean button I get 127 or 11111110 and if i then press spot I get something like 11111010. I might be messing up my endianness but regardless the data isnt formatted how I expected it to be according to the spec sheet. I have 3 create 2s and they all do the same thing. Any ideas? I am using a 2n7000 along with the tutorial from the site but i dont think that has anything to do with the formatting of the byte.

this is the library I am using: https://github.com/DomAmato/Create2

Sorry to take so long to get back on this, anyways the data we get is always formatted this way. It is not a baud rate issue since it understands the commands properly.

```<code>        day     hour    minute  schedule    clock   dock    spot    clean
day     3       x       x       x           x       x       x       x
hour    6       7       x       x           x       x       x       x
minute  13      14      15      x           x       x       x       x
schedule    x   x       x       x           x       x       x       x
clock   x       x       x       x           x       x       x       x
dock    27      29      30      x           x       31      x       x
spot    55      59      61      x           x       62      63      x
clean   111     119     123     x           x       125     126     127
</code>```

Note that the schedule and clock buttons return nothing

答:
The problem was the part we were using. Make sure you use the right transistor. The schedule and clock button still dont produce any output but everything else behaves as it should.

Error = 2n7000 transistor

Answer = 2n4403

Thanks to Steve for pointing it out though it doesn't just invert the signal it mutates it into the table I posted in my question.


问:
Matlab Control Toolbox root locus
I'm using the control system toolbox provided by matlab to estimate the gains of my controller: using root locus design I get a graph like this one .

My question is: what is the x on the x-axis? maybe a pole position at a previous iteration of the optimization procedure that I have run to find a gain value that satisfies my requirements? It shouldn't be the open loop pole position, because my system is formed by two integrators multiplied by a constant (1/inertia). Thanks

Edit: I add the requested details: I start from the following simulink diagram:

my trasfer function is $$G_\Theta(s) = \frac{Y(s)}{U(s)} = \frac{\Theta(s)}{\tau_\Theta} =  \frac{1}{I_y s^2}$$ with
Iy = 0.0054 (another little question, the point in which I'm taking out the torque is correct?)
and then I select analysis , control design, compensator design. I select Kp and Kd as the gains to be tuned, and I use the root locus for specifying the constraints. Then I click in SISO Design Task, automated tuning, optimize compensator, which automatically tries to find gain values to satisfy my constraints. The white are is the area that satisfies the constraints, and I think that the pink squares are my poles position after having been completed the optimization procedure. This is correct? But in this case, what is the x(pole) shown? Thanks

答:
I can add more detail to this answer later if you can provide your transfer function or block diagram you used to make that plot.

Regarding your question, an X is a pole, so that is what the X on your X-axis is.

Recall that, if you have a plant $G(s)$ ($ G(s)=1/s^2$ in your case), and you have a feedback loop, your transfer function becomes $G(s)/(1 +/- G(s))$, so you do in fact wind up with poles.

If you believe you are viewing outdated information on your plot, then be sure to call 'clf;' between plot commands, with a 'figure(N)' command prior to focus plot N if you have multiple plots open. 'clf' clears a figure window.

Finally, as a reminder, double check that what you are plotting is in fact the open loop system if that is that you would like to evaluate. If you are still having trouble, again, post the commands you are using to plot and I'll update this answer.

Hope this helps!

Title: Matlab Control Toolbox root locus


问:
Many to One Bluetooth Communication Link
I have an application that requires data to be streamed from multiple Bluetooth modules to one host controller. Somewhat like multiple Clients and one Server.

The throughput i am looking at is around 1920-bits per second per module.
The SPBT2632C2A.AT2 module only supports SPP profile in which i can have a single link (One Client One Server). My application needs multiple modules ( Max 5) to send information to one server.

Is there a way to have One Receiving Station and have multiple transmitting module using SPP? (All modules being the SPBT2632C2A), or i need a Different higher end module on the server side which supports multiple SPP Links?

It advisable to look into a module like the BCM2070 and have a driver run system?

答: Bluetooth protocol allows 3 bit addressing that means you can connect 8 devices. When i did it with neurosky mindwave head sets to computer data streaming was not enough to get raw data. İ can just get one healty data per second from each headset</p>


问:
Why PD controllers for quadcopter angles control?
my question is: in a lot of cases it is possible to find in Internet PD (instead PID) to control the euler angles of quadcopter? Why the integral part is often neglected in this kind of applications? thanks</p>

答:
Because the P term calculates a proportional response to the error, for example if the quad is tilted a little bit then you only correct a little bit o you do not overshoot your target value, the I controller will ramp up the response if it has not lowered fast enough, which in some cases can be good for example if there is wind and the proportional term is not correcting enough, but that too can cause problems with overshooting the error (requiring a negative error for the same time as there was a positive error), the D controller will dampen the P and I controllers as you get closer to the set point by measuring the rate of change of the system and slowing it as it approaches the set point. </p>

<p>Using only the P and D controllers can sometimes give better results especially in less demanding environments and can be easier to tune, In my experience this approach works great for multicopters expected to make less aggressive maneuvers where a well tuned PID controller can perform better with very aggressive environments. </p>

Body:
Because the P term calculates a proportional response to the error, for example if the quad is tilted a little bit then you only correct a little bit o you do not overshoot your target value, the I controller will ramp up the response if it has not lowered fast enough, which in some cases can be good for example if there is wind and the proportional term is not correcting enough, but that too can cause problems with overshooting the error (requiring a negative error for the same time as there was a positive error), the D controller will dampen the P and I controllers as you get closer to the set point by measuring the rate of change of the system and slowing it as it approaches the set point.

Using only the P and D controllers can sometimes give better results especially in less demanding environments and can be easier to tune, In my experience this approach works great for multicopters expected to make less aggressive maneuvers where a well tuned PID controller can perform better with very aggressive environments.


答: BCM2070 with Microsoft Bluetooth Enumerator!</p>

Title: Many to One Bluetooth Communication Link

Body:
I have an application that requires data to be streamed from multiple Bluetooth modules to one host controller. Somewhat like multiple Clients and one Server.

The throughput i am looking at is around 1920-bits per second per module.
The SPBT2632C2A.AT2 module only supports SPP profile in which i can have a single link (One Client One Server). My application needs multiple modules ( Max 5) to send information to one server.

Is there a way to have One Receiving Station and have multiple transmitting module using SPP? (All modules being the SPBT2632C2A), or i need a Different higher end module on the server side which supports multiple SPP Links?

It advisable to look into a module like the BCM2070 and have a driver run system?


问:
Changing behaviour Roomba 880
I've seen that it is possible to use some micro controller to send commands to the Roomba through the SCI but I was more interested in changing the behavior of the roomba operation (e.g: change the priority of the behaviours)

Is there some IDE for roomba?

答:
There is no way to alter behavior priorities or an IDE to alter the software on Roombas. You can use the OI to control and interact with it though using a computer, Arduino, Raspberry Pi, or other serial communication capable device.

See this answer for resources on using OI.

Title: Changing behaviour Roomba 880


问:
Which math course will be most beneficial?
Let me know if this should be on Academia instead, but I posted it here to get responses specifically from people active in robotics development.

I'm currently an undergraduate student completing majors in both mechanical engineering and computer science. I'm still fairly new to the field, but my interest is firmly in electronic and mechanical systems. Next year I can take one of the courses below:

```<code>1. Multivariable Calc.
2. Linear Algebra
3. Differential Equations
</code>```

I want to take all three and likely will eventually, but for the time being my schedule only allows for one. Therefore, I was wondering if you could explain a little bit about how each is applied to the robotics field and which you believe will be most helpful for me to learn now.Thanks in advance!

答: I went through the Virginia Community College System (VCCS) (not saying which one specifically for myself). In Virginia, if you graduate with >= 3.0 GPA from a Virginia Community College, you are guaranteed admission to any public (Virginia) university. Community colleges here are top notch; I got the most knowledge out of community college courses and grad school courses. Undergraduate classes are pretty terrible. Find a lab at your university that does what you want to do, then work your way to an assistanceship. If you work hard and do good work grad school can be free. </p>


问:
How to use an IMU to hover at a fixed location in a quadcopter in the presence of gravity?
There's an accelerometer in the IMU. The output can then be integrated to estimate the position, at least in theory.

But in practice, there's a huge acceleration from gravity, which varies rather randomly across locations. Vibrations etc can be filtered out with low-pass filters, but how do you filter out gravity? Is it simply the case that the vertical vector is ignored when doing any calculations?

My application is, I want to build a quadcopter that could hover in one place even in the presence of (reasonable) winds: the quadcopter ideally would tilt towards random gusts to maintain a certain position. Every single tutorial I could find on the Internet only uses the accelerometer to estimate where down is when stationary, and simply assumes that using the gyroscope to hold the quadcopter level is enough.

I also want to use the IMU to estimate altitude if possible, of course as an input to something like a Kalman filter in conjunction with a sonar system.

Obviously, for my application GPS is far too slow.

答:
Most flight controllers that I am aware of do not use the IMU for absolute positioning they are only used for attitude estimation and in some cases to try to dampen the effects of external forces (i.e. wind) but it can only be effective at damping these external forces if they are above a certain reasonably detectable level so over the long run you will drift quite a bit but in the short run you can somewhat compensate for the effects of wind.

If you need more robust position holding you might be better off using another system in conjunction with the imu like an optical flow sensor and a target dot or good old gps.

What is your target application?


答: To expand on Jonathan's answer:  While you cannot change code or low-level behavior priorities on the Roomba, the OI Spec does give you access to some high-level behaviors such as: "Clean", "Max Clean", "Spot Clean", "Dock", etc.  And it gives you full control of the motors and access to all the sensor data including button presses, schedule, and IR commands received.  So you could write your own new-and-improved Roomba behaviors if you'd like.

Title: Changing behaviour Roomba 880

Body:
I've seen that it is possible to use some micro controller to send commands to the Roomba through the SCI but I was more interested in changing the behavior of the roomba operation (e.g: change the priority of the behaviours)

Is there some IDE for roomba?


问:
What was the earliest concept of a robot?
I'm a highschool student studying electronics and for an assessment task on the history of electronics I have decided to focus on the history of robotics. I want to begin with the earliest possible concept of a robot and progress through major developments in robotics to the current day. Where should I begin my research?</p>

答:
When you start talking about the first robots, you quickly run into the question: "What is a robot?".

Before we can say whether or not some machine is the first robot, we need to define what exactly we mean by the word 'robot'. The problem is, that there's really no single definition, and it depends who you ask. For example, I had a massive argument with someone on the Wikipedia robots talk page about the definition of robot. And you can forget about looking up the word in a dictionary, all of the dictionary definitions I have seen are hopelessly naive. The best definition I have seen is on the Wikipedia page:

A robot is a mechanical or virtual artificial agent.

The most important word here is 'agent'. A machine which seems to have a sense of agency is more likely to be called a robot. I can imagine that if Leonardo had built his 'robot' then people would really have thought it has real agency of its own, and been practically alive, and would therefore have qualified to be included in that definition of robot. Today, however, roboticists have stricter definitions, and require robots to be more than just clockwork, and have some degree of autonomy and interaction with the environment.


问:
How to calculate quadcopter lift capabilities?
I'm looking for an equation (or set of equations) that would allow me to predict (with fair accuracy) how heavy a payload a quadcopter is capable of lifting.

I assume the main variables would be the weight of the copter as well as the size + power of the 4 rotors. What general approach can one use to make such a determination?

答:
Similar answer to this post:
Choosing motor for a tricopter

This depends on what you want to do with your copter.

Hovering: 100-150 Watt/kg

ScaleFlight: 200-300 Watt/kg

Some chilling acrobatic flight: 350-400 Watt/kg

3D acrobatics 500+ Watt/kg

Hardcore 3D 1000 Watt/kg

Just take your motors and your flight style and you got some values for the max weight of your copter

I also have a source for this but i know only a German one: http://www.heli-planet.de/index.php?section=auslegung_von_e_motoren

This values are pretty accurate. There are mathmatical ways to calculate the lift of your quadrotor but they are a very theoretical approach. You have to think about the enviorment, the wind, air pressure, reaction speed, controlability.


问:
How do safety cages around quadcopter rotors/blades affect lift capabilities?
I am interested in building a quadcopter from scratch.

Because I like to err on the side of caution, I'm considering adding "safety cages" around each propeller/rotor, to hopefully prevent (at least minimize) the chance of the spinning rotor blades coming into contact with someone. Without knowing much about the physics behind how "lift" works, I would have to imagine that cages present two main problems for rotors:

They add weight to the copter making it harder to lift the same payload; and

They're sheer presence/surface area makes it harder for the spinning rotor to generate lift and push down away from the ground

The former problem should be obvious and self-evident. For the latter problem, what I mean by "surface area" is that I imagine that the more caging around a spinning rotor, the more difficult it will be to lift effectively. For instance, a spinning rotor might have the ability to generate enough power to lift, say, 2kg. But if we were to construct an entire box (not cage) around the entire rotors, with 6 sides and no openings, I would imagine its lift capability would drop to 0kg.

So obviously, what I'm interested in is a cage design that provides adequate safety but doesn't "box in" the rotor so much that it causes the rotor to be ineffective or incapable of providing lift. So I'm looking for that optimal tradeoff of safety (boxing/caging around the spinning rotor) and lift performance.

I would imagine calculating and designing this is a pretty huge undertaking with a lot of math behind it. I'm just wondering if anyone has already figured all this stuff out, or if anyone knows of a way to model this safety-vs-lift-performance trade off in some way.

答:
To what degree are you looking to cage the fans? IP code gives some grades for fan protection, which may help you decide or even find some stock guards. Level 'A' protects against striking by the back of the hand, 'B' protects against striking a finger.

You are correct that the math is complicated; it's more than simply a reduction in diameter - flow around the grating will have a huge impact, especially at the flow rates for the fans.

I would suggest you decide what level of protection you want, purchase the guard for one fan, then setup a test rig where you can weight a fan assembly. Add weights until you can just keep the rig grounded. Add the guard, then remove weight until again, the rig is just grounded. This will give you a percentage reduction in thrust capacity.

I think you will find this method of empirical testing will be faster, easier, and more accurate than mathematical calculations, because you will find it difficult to get the model of the fan guard correct. Even if you could, assuming the guard is close to the blades, there will be an interaction between the fan blades and guard that is dependent on the blade shape.

This answer assumes you don't have access to ANSYS, LS-DYNA, or any other high power CFD tools, but even still empirical testing will be faster unless you already have experience with those tools and a library of blade and guard parts.

Finally, regarding the performance-safety tradeoff - safety is up to you to quantify. Performance impacts of adding guards can be quantified as I've described above. Once you have quantified how much safety matters to you (this is usually done with a failure mode analysis), then the tradeoff should become clear. Quantifying safety is usually one of the hardest problems for every engineering project.


问:
Implementing a position control for UAV through a flight controller. Plant model is unknown
We are using Naza-M-Lite for our flight controller without GPS. The localization is obtained through our RGB-D camera sensor. We are able to teleoperate and even implement PID controllers for Roll, Pitch, Yaw and Throttle channels for our quadrotor. However, we do not know the plant model because what we are inputting from Arduino to the Naza-M-Lite are servo PWM ranging from 1000 to 2000.

For throttle:   1500 altitude hold, 2000 maximum throttle, 1000
  minimum throttle

For Pitch, Roll, Yaw: 1500 maintain 0 angle, 2000 and 1000 moves the
  quadrotor towards its respective axes.

However, even at 1500 on every channel, the quadrotor drifts, maybe due to flying indoors and the wind pushes the quadrotor. Once it gains momentum, it drifts. We are having trouble tuning this because we do not know the relationship of the output is to the position. If the output were velocity, it would have been easier. But as in our case, it is not. Is there a way to find the plant model of the Naza-M-Lite and how can we tune this?

答:
What is your final desired result? You will certainly want to switch to a different Flight controller like the Pixhawk it will allow you mutch finer control and allow you to reprogam it at will to implment whatver it is that you are trying to do.

Normally a quadrocopter will drift a certain amount, you would want some kind of external position input depending on the accuracy of the hold you require, GPS for a couple meters, optical flow with a target dot for a couple inches


问:
Stewart platform as robotic wrist joint
I'm planning the design of a wrist for a humanoid robot. I would like to choose a design that is sturdy while allowing for dexterity comparable to a human wrist.

One option that was presented to me was to use a Stewart platform. This setup appears to correctly recreate all possible movements of the human hand. My immediate concern is that this platform will use a total of six actuators which will require additional power and computational requirements. I don't want to commit to this design until I am certain that there isn't a better alternative.

Is a Stewart platform a good choice for replicating the dexterousness of the human wrist? If not, what is a better solution?

答:
Bear in mind a Stewart platform has six degrees of freedom - yes it does reproduce the main motions of the human wrist, but it adds extra ones such as the ability to change its overall length.  There is (I would guess) additional complexity in building one - finding suitable compact actuators and linkages, additional work to control its path, perhaps robustness.

If your objective is just to get a simple arm working, I would look for a more conventional three axis design.  However the Stewart platform idea does add extra features - those extra degrees of freedom - and might be seen as a more novel concept.

Title: Stewart platform as robotic wrist joint


答:
I would go further than TobiasK, even if the order of magnitude is correct.

The main characteristic for a drone dynamic is its Thrust/Weight Ratio (TWR). To be able to fly, your TWR shall at least equal 1. To be able to take off, you need TWR>1. In my opinion, TWR=2 gives a fairly dynamic quadcopter.

For a given propeller, you can get its thrust vs rpm (round per minute) ratio, so you can get the target rpm (if you have 4 motors and want TWR=2, each motor should achieve a thrust equal to half the drone weight). You can also get its torque vs rpm characteristic, and get the mechanic torque you'll get at the target RPM.

Then you can choose your motor. The target RPM gives you the Kv of your motor. The Kv indicates the amplitude of the back EMF of your motor, according to its rotation speed. If you use a 3S LiPo battery, your battery may drop done to 9.6V, so, if you want to keep your dynamic during the whole flight, you shall choose a motor that may reach the rpm target at 9.6V. Let's say you need 10k rpm to get your TWR=2, your motor's Kv shall be at least 1040 rpm/V. You should choose your Kv a bit higher, as Kv is given with no load, and the actual speed under load is a bit slower.

The output torque of your motor is proportional to the current you feed in. I looked for "quadcopter motor" on google, and quickly found a motor with 1300Kv and 19A max (I don't know this motor and can't say if it's good quality or not). 10k rpm divided by 1300 rpm/V gives 7.7V. 7.7V will be the average voltage at the output of your ESC when driving the motor at 10k rpm. The max current is 19A, this means the maximum power at 10k rpm is 7.7*19=146W. This kind of motor has a typical efficiency around 0.7 when on load (if you take a motor with a much higher Kv, you usually decrease its efficiency on load). Therefore, I expect the output mechanical power to be 100W. Mechanical power is speed times torque (checks the units you uses). The max torque has to be higher than your propeller torque at TWR=2.

"Hardcore 3D" was mentioned. In my opinion, doing intensive 3D flight with a 5kg drone is insane. I think you should target a total weight under 1kg (400g is good for 3D acrobatics). 3D flight faces an other drawback: propellers are usually optimized to run in one way, and you usually want to use it in both, so you'll either have a much poorer TWR in reverse, or have a poorer efficiency in both way (symmetrical and better than a classical propeller in reverse, nonetheless).

Title: How to calculate quadcopter lift capabilities?

Body:
I'm looking for an equation (or set of equations) that would allow me to predict (with fair accuracy) how heavy a payload a quadcopter is capable of lifting.

I assume the main variables would be the weight of the copter as well as the size + power of the 4 rotors. What general approach can one use to make such a determination?


答:
The "best" robot wrist in terms of human analog is probably the omni-wrist by Mark Rosheim.  It has a large range of motion, and does not have singularities or gimbal lock that plague other more conventional wrists.  However, it is fairly complicated mechanically, and thoroughly patented i believe.

The book Robot Evolution: The Development of Anthrobotics by the same author has a good discussion of human analog robotics design.

Title: Stewart platform as robotic wrist joint

Body:
I'm planning the design of a wrist for a humanoid robot. I would like to choose a design that is sturdy while allowing for dexterity comparable to a human wrist.

One option that was presented to me was to use a Stewart platform. This setup appears to correctly recreate all possible movements of the human hand. My immediate concern is that this platform will use a total of six actuators which will require additional power and computational requirements. I don't want to commit to this design until I am certain that there isn't a better alternative.

Is a Stewart platform a good choice for replicating the dexterousness of the human wrist? If not, what is a better solution?


问:
Micro Quadcopter PID problem
I designed a mini quadcopter which is about 4.5x4.5cm(Main Body). The main body is the PCB.

![enter image description here][1]

It weighs about ~20 grams with the battery. I'm using the MPU6050 with the DMP using the i2cDevLib. I am using raw radians for pitch, roll, and yaw these measures are read from the MPU6050's DMP. The motors are attached to the body using electrical tape(Black thing  around motors). The motors are 8.5mm in diameter and are driven by a n-channel mosfet. The mode of control right now is bluetooth(HC-05 module). The code being used is my own.
I have a control loop on all axes, the pitch and roll have the same values since the quadcopter is symmetrical. The problem I have is that PID tuning is next to impossible, the best I got was a ~2 second flight ([Video in slow-motion][2]).

At first I was using my own code for the control loop, but it wasn't as effective as the Arduino PID library.

The output of the PID loops are mapped to -90 to 90 on all axes. This can be seen in the code

```<code>myPID.SetOutputLimits(-90, 90); //Y angle
myPID1.SetOutputLimits(-90, 90); // X angle
myPID2.SetOutputLimits(-90, 90); // Yaw angle
myPID.SetMode(AUTOMATIC);
myPID1.SetMode(AUTOMATIC);
myPID2.SetMode(AUTOMATIC);
</code>```

My full code is below, but what do you think the problem is?

Code

http://pastebin.com/cnG6VXr8

答:
Your derivative term is incorrect. You have:

dTerm = Kd * (error - last_error);

Note that this is not a derivative of the error, this is simply the difference between the previous error and the current error. To get the derivative of the error you need to divide by the sample time. I am not familiar with your platform so I cannot tell you how to get the sample time (loop time, sweep time, etc.), but you need a timer to start and stop every loop.

Anyways, assuming that $t_{elapsed} = dT$, and you can get this from a timer set to count and reset every time your PID code executes, then your sample time is $dT$ and your dTerm needs to become:

dTerm = Kd * (error - last_error)/dT;

If this isn't the root cause of your control issues it's a major contributing factor. It looks like your PID sections are commented out (not sure why), but I noticed this error everywhere I saw a "dTerm" defined.

Hope this helps!

Title: Micro Quadcopter PID problem


问:
Wiring & driving TowerPro SG90 servos
I got my hands on a few Tower Pro SG90 9G servos but cannot find their schematics or datasheet anywhere (besides that link).

I have the following concerns:

Looks like they're rated for 4.8V, but will they tolerate a 5V supply?

How do I determine the current they require, in amps, mA, etc.?

There's 3 wires: brown, red & yellow-orange, what do each of these guys do?

If I had to guess I'd say that red is power, another one is direction, and another one is the position to rotate to

答:
Regarding the voltage, the Amazon listing for this servo gives the operating voltage range to be 3.0 to 7.2V, so it should accept 5V no problem.

Regarding the current draw, on the user questions section of the same page, one user stated that these servos drew between 750 - 1000mA when fully loaded.

Regarding the wiring, PCB has a great article on servos that says the wiring would go generally how you would think - red is (+), black or brown is (-), and the other wire is signal. It says that Tower servos use red, black, and white wires.

Hope this helps!

Title: Wiring & driving TowerPro SG90 servos


问:
Can I control more than 18 servo motor with a Raspberry Pi
I'm trying to make an hexapod with 18 servo motors and i'm asking how to control them with a Raspberry Pi. (Never used it). I saw lot's of stuff to control 1, but 18, 20...

Currently I'm working on an Arduino Mega, and a SSC-32 board, but I found the result to slow and jerky.

At this end, I want to add a camera and processing the image, I know an Arduino can't handle that process but a Raspberry Pi can ?

Thank for all information about that subject :)

答:
Raspberry Pi has only one hardware PWM channel and Linux distribution it runs is not a real time system, so software PWM may be very unstable. You are not guaranteed, that your program will be executed at exact frequency you want, so you will have trouble getting precise timing required to drive servos.

If you already have Arduino Mega and SSC-32, I would suggest to make all the computations on the RPi, and just send the results to the servo controller via serial. I imagine your system like this: you have a central controller (RPi) that processes images from camera, detects obstacles, calculates positions for robot's legs and sends them to servo controller. These tasks can be done in various intervals - even if you have 100ms delay, nothing bad happens, because real-time part (requiring exact timing like driving servos) is handled by servo controller, which has hardware features that make it much more suitable for such a task.

Alternatively, to make system more compact, you could use dedicated RPi servo shield, or make your own basing on chips like PCA9685, which is PWM driver controlled via I2C. You can chain these chips to control more channels than 16.


问:
How do I accurately calculate the speed of a rotary encoder at a high sample rate?
I'm aiming to control a motorized joint at a specific speed. To do this, I'm planning on attaching a rotary encoder to do this.

I'll be controlling the motor with a PID controller. With this PID controller, I need to control the joints based on their velocity.

Since:

```<code>speed = distance / time
</code>```

It would make sense to do something like this:

```<code>double getCurrentSpeed() {
    return (currentAngle - lastAngle) / samplingRate;
}
</code>```

However, there's an issue; the encoder doesn't provide a high enough resolution to accurately calculate the speed (the sample rate is too high). I want to have updated data every 5-15 ms (somewhere in that range as my current motors seem to be able to respond to a change in that range)

Some more information:

14 bit precision (roughly 0.0219726562 degrees per "step" of encoder

I'd like to be able to calculate as small of speed differences as possible

As the motors will be going fairly fast (120+ degrees/second at highly variable speeds and directions), so the feedback has to be accurate and not delayed at all

So, a couple of ideas:

I can find encoders that I can sample at a very high rate. I was thinking about sampling the time between the changes of the encoder's value. However, this seems finicky and likely to be noise-prone

I could do some sort of rolling average, but that would cause the data values to "lag" because the previous values would "hold back" the output of the calculations somewhat and this would play with my PID loop some

Noise filter of some sort, although I don't know if that would work given the rapidly changing values of this application

However, none of these seem ideal. Is my only option to get a 16 bit (or higher!) encoder? Or is there another method/combination of methods that I could use to get the data I need?

答:
I think you're getting a little confused - you mention a 14b encoder that you have, then ask if you should get a 16b encoder to sample faster. While resolution and the time it takes to query a device can be somewhat related, the electronic interface has a lot more to do with how quickly you can sample than the sensor resolution. For instance, an I2C protocol requires the master to call the sensor by "name" (address), so the time you spend transmitting that information means you can't sample as quickly as you could with SPI, where you use a chip select and start getting data immediately. Both methods transmit data one bit at a time,  so both take longer than would a sensor with a parallel interface, where you read each bit simultaneously.

:EDIT: on my phone, pushed enter on accident.

Regarding sampling speed, 120deg/s is 0.6deg/5ms, which means your encoder should increment nearly 30 times (0.02 to 0.6) in that interval. You should always consider filtering the signal, because resolution isn't just some number that's exact. It's better to think of it as wedges. Anywhere in a particular wedge will give you the same reading. This means that, if you were perfectly centered on a bit (wedge), you are likely to get 30 increments per sample, but if you start a little to one side you might get 29 or the other side may give 31.

You can generally watch this behavior on a per sample basis - you may get increments of 29 29 29 30 30 31 29 29... You can watch the measurements change slowly because you are essentially strobing a rotating shaft and if you don't hit a multiple of speed exactly you'll get a phase roll. If you don't filter this signal then your robot will think you're actually going those speeds.

Every filter is going to, uh, filter your signal, so then it's up to you how to handle that alteration to your signal. I would suggest a simple lag filter as they are effective, exceedingly simple to implement, and there are really straightforward design guidelines to help you maintain whatever level of responsiveness you would like.


答:
You need a controller like this that can address them individually over I2C.  These can be chained together to control more than you'll likely ever need:

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685
https://www.adafruit.com/products/815

How to use them with a Raspberry Pi:
https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi

Title: Can I control more than 18 servo motor with a Raspberry Pi

Body:
I'm trying to make an hexapod with 18 servo motors and i'm asking how to control them with a Raspberry Pi. (Never used it). I saw lot's of stuff to control 1, but 18, 20...

Currently I'm working on an Arduino Mega, and a SSC-32 board, but I found the result to slow and jerky.

At this end, I want to add a camera and processing the image, I know an Arduino can't handle that process but a Raspberry Pi can ?

Thank for all information about that subject :)


问:
Hand Eye Calibration
I'm trying to use a dual quaternion Hand Eye Calibration Algorithm Header and Implementation, and I'm getting values that are way off. I'm using a robot arm and an optical tracker, aka camera, plus a fiducial attached to the end effector. In my case the camera is not on the hand, but instead sitting off to the side looking at the arm.

The transforms I have are:

Robot Base -> End Effector

Optical Tracker Base -> Fiducial

The transform I need is:

Fiducial -> End Effector

I'm moving the arm to a series of 36 points on a path (blue line), and near each point I'm taking a position (xyz) and orientation (angle axis with theta magnitude) of Camera->Fiducial and Base->EndEffector, and putting them in the vectors required by the HandEyeCalibration Algorithm. I also make sure to vary the orientation by about +-30 degrees or so in roll pitch yaw.

I then run estimateHandEyeScrew, and I get the following results, and as you can see the position is off by an order of magnitude.

[-0.0583, 0.0387, -0.0373] Real
[-0.185, -0.404, -0.59] Estimated with HandEyeCalib

Here is the full transforms and debug output:

```<code># INFO: Before refinement: H_12 =
-0.443021 -0.223478  -0.86821  0.321341
 0.856051 -0.393099 -0.335633  0.470857
-0.266286 -0.891925   0.36546   2.07762
        0         0         0         1
Ceres Solver Report: Iterations: 140, Initial cost: 2.128370e+03, Final cost: 6.715033e+00, Termination: FUNCTION_TOLERANCE.
# INFO: After refinement: H_12 =
  0.896005   0.154992  -0.416117  -0.185496
 -0.436281    0.13281  -0.889955  -0.404254
-0.0826716   0.978948   0.186618  -0.590227
         0          0          0          1

expected RobotTipToFiducial (simulation only):   0.168   -0.861    0.481  -0.0583
expected RobotTipToFiducial (simulation only):   0.461   -0.362    -0.81   0.0387
expected RobotTipToFiducial (simulation only):   0.871    0.358    0.336  -0.0373
expected RobotTipToFiducial (simulation only):       0        0        0        1

estimated RobotTipToFiducial:   0.896    0.155   -0.416   -0.185
estimated RobotTipToFiducial:  -0.436    0.133    -0.89   -0.404
estimated RobotTipToFiducial: -0.0827    0.979    0.187    -0.59
estimated RobotTipToFiducial:       0        0        0        1
</code>```

Am I perhaps using it in the wrong way? Is there any advice you can give?

答:
After solving the problem, I created a keynote presentation explaining many details about hand eye calibration for those that are interested. Practical code and instructions to calibrate your robot can be found at handeye-calib-camodocal.

I've directly reproduced some key aspects answering the question here.

Camodocal

Camodocal is the library I'm using to solve the problem. It is a well written C++ library that includes hand eye calibration, though documentation is extremely sparse.

Camodocal includes implementations of:

K. Daniilidis 1999 Hand-Eye Calibration Using Dual Quaternions (Tested and working)

Chessboard camera calibration

Stereo Camera Calibration

SLAM with multiple non-overlapping cameras and odometry
designed for a mobile vehicle

Relevant Papers

CamOdoCal: Automatic Intrinsic and Extrinsic Calibration of a Rig with Multiple Generic Cameras and Odometry, In Proc. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), 2013.

Lionel Heng, Mathias Bürki, Gim Hee Lee, Paul Furgale, Roland Siegwart, and Marc Pollefeys, Infrastructure-Based Calibration of a Multi-Camera Rig, Submitted to IEEE International Conference on Robotics and Automation, 2014.

Feeding data into CamOdoCal

Each measurement taken at a different time, position, and orientation narrows down the possible transforms that can represent the unknown X

Record a list of many transforms A and B taken between different time steps, or relative to the first time step

Rotations are in AxisAngle = UnitAxisAngle format, or [x_axis,y_axis,z_axis]_angle

||UnitAxis||=1

|| AxisAngle || = _angle

Translations are in the normal [x,y,z] format

Pass both vectors into EstimateHandEyeScrew()

Returns X in the form of a 4x4 transform estimate

ROS Integration

There is a package that implements a solver for this using camodocal + ROS called handeye_calib_camodocal. It also includes detailed troubleshooting instructions.

References

Strobl, K., & Hirzinger, G. (2006) . Optimal hand-eye calibration. In 2006 IEEE/RSJ international conference on intelligent robots and systems (pp. 4647–4653), October 2006.

Technical University of Munich (TUM) CAMP lab wiki

K. Daniilidis, “Hand–Eye Calibration Using Dual Quaternions,” Int. Journal of Robs. Research, vol. 18, no. 3, pp. 286–298, June 1999.

E. Bayro–Corrochano, K. Daniilidis, and G. Sommer, “Motor–Algebra for 3D Kinematics: The Case of Hand–Eye Calibration,” Journal for Mathem. Imaging and Vision, vol. 13, no. 2, pp. 79–100, Oct. 2000.

F. Dornaika and R. Horaud, “Simultaneous Robot–World and Hand– Eye Calibration,” IEEE Trans. on Robs. and Aut., vol. 14, no. 4, pp. 617–622, August 1998.

Note: figures and text are from mixed sources including the presentation author, the various papers referenced, and the TUM wiki.

Title: Hand Eye Calibration