问:
Balancing Robot Control Model
I am trying to find a control model for the system of a balancing robot. The purpose of this project is control $\theta_2$ by the 2 motors in the wheels i.e. through the torque $τ$ I started with the dynamic equations and went to find the transfer function.

Then I will find the PID gains that will control the robot and keep it balanced with the most optimum response. For the time being I am only interested in finding the transfer function for the dynamic model only.

Here is an example: https://www.youtube.com/watch?v=FDSh_N2yJZk

However, I am not sure of my result.Here are the free body diagrams for the wheels and the inverted pendulum (robot body) and calculations below:

Dynamic Equations:

$$
\begin{array}{lcr}
m_1 \ddot{x}_1 = F_r - F_{12} & \rightarrow & (1)& \\
m_2 \ddot{x}_2 = F_{12} & \rightarrow &  (2) &\\
J_1 \ddot{\theta}_1 = F_r r - \tau & \rightarrow & (3) &\\
J_2 \ddot{\theta}_2 = \tau - mgl\theta & \rightarrow & (4) & \mbox{(linearized pendulum)}\\
\end{array}
$$

Kinematics:

$$
x_1 = r\theta_1 \\
x_2 = r\theta_1 + l\theta_2 \\
$$

Equating (1) and (3):
$$
m_1 \ddot{x}_1 + F_{12} = F_r \\
\frac{J_1 \ddot{\theta}_1}{r} + \frac{\tau}{r} = F_r
$$

Yields:

$$
\frac{J_1 \ddot{\theta}_1}{r} - m_1 \ddot{x}_1 + \frac{\tau}{r} = F_{12} \rightarrow (5)
$$

Equating (5) with (2):

$$
\frac{J_1 \ddot{\theta}_1}{r} - m_1 \ddot{x}_1 + \frac{\tau}{r} - m_2 \ddot{x}_2  = 0 \rightarrow (6) \\
$$

Using Kinematic equations on (6):

$$
(J_1 - m_1 r^2 - m_2 r^2) \ddot{\theta}_1 + m_2 l r \ddot{\theta}_2 = -\tau \rightarrow (7) \\
$$

Equating (7) with (4):

$$
\begin{array}{ccc}
\underbrace{(J_1 - m_1 r^2 - m_2 r^2) }\ddot{\theta}_1 &+& \underbrace{(m_2 l r + J_2 ) }\ddot{\theta}_2 &+& \underbrace{m_2 gl}\theta &= 0 \rightarrow (8) \\
A & &B & & C & \\
\end{array}
$$

Using Laplace transform and finding the transfer function:

$$
\frac{\theta_1}{\theta_2} = -\frac{Bs^2 + C}{As^2} \\
$$

Substituting transfer function into equation (7):

$$
(J_1 - m_1 r^2 - m_2 r^2) \frac{\theta_1}{\theta_2}\theta_2 s^2 + m_2 lr\theta_2 s^2 = -\tau \\
$$

Yields:
$$
\frac{θ_2}{τ} = \frac{-1}{(mlr-B) s^2+C}
$$

Simplifying:
$$
\frac{θ_2}{τ}=  \frac{1}{J_2 s^2-m_2 gl}
$$

Comments:

-This only expresses the pendulum without the wheel i.e. dependent only on the pendulums properties.

-Poles are real and does verify instability.

答:
At a glance, you haven't defined your x/y datums so when you have an equation it's hard to tell what you are referencing.

That said, you give an equation:

$$
m_2 \ddot{x}_2 = F_{12}
$$

But later, for kinematics, you state what I believe to be correct:

$$
x_2 = r \theta_1 +l \theta_2
$$

Which could also be stated, per your definition, as

$$
x_2 = x_1 + l \theta_2
$$

But, if you take two derivatives of the above, you do not get anything close to the first two dynamic equations.

Using the kinematic equation as an example, I would suggest that the acceleration $\ddot{x_2}$ is due to both the acceleration at the base and due to the rotational acceleration of the pendulum, but again you need to pick a datum and see for yourself. I would suggest:

$$
m_2 \ddot{x}_2 = F_{12} + l \ddot{\theta}_2
$$

Where again, per your definition, this could be rewritten as:

$$
m_2 \ddot{x}_2 = F_r - m_1 \ddot{x}_1 + l \ddot{\theta}_2
$$

See now the similarity between this and your kinematic definition? This also couples rotation to the wheel motion. I didn't read any further than the kinematic definitions, so there may be other issues, but try this first, see what you get, then ask more questions if you have them.

Title: Balancing Robot Control Model


问:
rotation matrix to euler angles with gimbal lock
How do i determine which angle i can negate when gimbal lock occurs.

As i've understood with gimbal lock that it remove one degree of freedom, but how do i determine which degree can be removed when a  value R[1][3]  of a rotation matrix (size 3x3) has the value 1.  Is it the Roll, Pitch or yaw which can be taken out from the equation?

答:
I think you may be misunderstanding the nature of gimbal lock. It sounds like you may be trying to remove an actual term in a rotation matrix calculation , but this is incorrect because each axis is still able to rotate. What happens with gimbal lock is that one of the rotational degrees of freedom of the object you are rotating is removed. This happens when two rotational axes become aligned.

In the image on the left, pins that allow the blue and orange rings to rotate are aligned. This means that the blue ring may rotate to allow pitch, the green ring may rotate to allow yaw, but the orange ring does not allow roll. The orange ring is aligned with the blue ring, meaning that it also can only allow pitch motion.

The way to achieve roll is to separate the blue and orange rings, as shown on the right image above. To pitch the orange ring moves, and then yaw and roll are movements of the blue and  green rings together.

Notice again that, even in gimbal lock, each ring (each axis) can still move - no term would be removed from a rotation matrix equation. Instead, the object is "locked" on the roll axis because the physical arrangement is such that there is no way to roll.

ContentLicense: CC BY-SA 3.0


问:
What is the difference between a CNC router versus a CNC mill?
People at the RepRap 3d-printing project often mention CNC routers or CNC mills.

Both kinds of machines almost always have a motorized spindle with stepper motors to move the spindle in the X, Y, and Z directions.

What is the difference between a CNC router versus a CNC mill?

(Is there a better place for this sort of question -- perhaps the Woodworking Stack Exchange?)

答:
TL;DR CNC routers move the tool while CNC mills move the workpiece, but this is a matter of common usage and not based on hard definitions.

A router (in the woodworking sense) is just a rotary tool with a cutting bit.  Woodworkers consider them a very universal tool, because they can be mounted into shop-made fixtures to create a wide range of other tools.

router table

router lathe

copy router

pantorouter

router mills

A "mill" typically defines a machine that can feed a workpiece to a rotary cutting bit along several axes.  There are many variations on this concept (e.g. vertical mills, horizontal mills, spiral mills, etc) depending on which axes are used.

Technically speaking, either the workpiece or the cutting tool can move in a milling machine.  But in common usage, when people say "milling machine" they mean "bridgeport-style milling machine" -- a vertical mill with its cutting tool in a fixed position and an X/Y/Z axis table that can move the workpiece.  (A mill made from a router is just a "gantry-style" milling machine.)

ContentLicense: CC BY-SA 4.0


问:
Quadcopter stability vs (PID error signal lag and sample time)
The question I am asking is that, what is the effect on stability of increasing or decreasing both the sample time and lagging of error signal to PID. Does it helps in stability or degrade it?</p>

答:
A PID can provide great control, but it's a very unsophisticated technique -- it only understands error and correction.  The longer you wait between measurements, the larger your error will be each time.  (No surprises here, right?  It's the difference between moving 60 miles every hour and moving 1 mile every minute.)

The best performance that you can get from a PID happens when it runs (1) as fast as your sensor can supply accurate measurements, or (2) as fast as your actuator can make accurate adjustments -- whichever is slower.  If your sensor measurements aren't updating between PID ticks, your PID will overcompensate.  If your actuators aren't updating between PID ticks, you will notice that your PID gains only work for a limited range of the output (e.g. it works fine at 75% thrust but goes crazy at 55% or 95%).

Regarding accuracy: it may be necessary to average out individual measurements from a noisy sensor, which sacrifices the sample rate.  If that's the case, there really isn't much you can do here except lower your maximum speed.  You can experiment a bit to see how much averaging is sufficient for your application, but you can't really get around the limitations of the hardware itself.


问:
Choosing motors for quadcopter frame
I bought this drone frame : q450 glass fiber quadcopter frame 450mm from http://hobbyking.com/hobbyking/store/__49725__Q450_V3_Glass_Fiber_Quadcopter_Frame_450mm_Integrated_PCB_Version.html

I'm considering buying 4 AX-4005-650kv Brushless Quadcopter Motor's from http://hobbyking.com/hobbyking/store/__17922__AX_4005_650kv_Brushless_Quadcopter_Motor.html

Will these motor's fit this frame ? How can I determine what motor's will fit the frame ?

答:
Those motors have three mounting holes while the frame expects four for the the motors. So you could use an adapter like this:

Just make sure all the spacings are correct for your motrs and your frame.

The URL for your frame lists mounting holes that are spaced at 16/19mm.

Or alternatively you could look for a motor with holes that are spaced correctly to your frame without having to use adapters. You're probably better off avoiding use of the adapters as they add unnecessary weight, unless you can't find better specced motors.

Title: Choosing motors for quadcopter frame


问:
Standalone (or capable of being) Robotics Simulator
I'm a software engineer who volunteers with a non-profit that introduces young girls to technology. We have recently been talking about methods of introducing these children to the world of robotics, and I am curious what types of low-cost options we have.

One very appealing idea would be to have an online simulator, or (more preferable) an off-line standalone-simulator that we can build and program simple robots with. Perhaps nothing more than dragging components together, and then programming the interactions between those components.

What solution(s) exist that I might be able to make use of in our outreach?

答:
Maybe not a full robotics simulator but we are using 3D CAD, Autodesk Inventor, quite a lot for simulations. Usually we make an interface to the CAD similar to what we want it to be for the hardware. That way we can use the CAD model as a virtual prototype to:

Catch design errors early. Collisions, not enough stroke etc.

It has also been useful for finding compensations to errors such as alignment errors. Using the CAD we can model different errors one by one and test our compensations. It is convenient to be able to introduce large errors with known sign.

The CAD also gives answers about things such moments of inertia.

We also use the CAD model to generate the program for the equipment.


问:
Balancing a plate with an IMU offset from the center
I recently bought a IMU . I am new at this.

My question: Does the positioning of the IMU matter? Are there any differences between placing it at the center of the plate or if it is offset from the center?

I am still learning about this topic. So any help would be greatly appreciated.

Thanks.

答:
Basically it does not matter.

But you have to be carefull if the plate is rotating fast, because the rotation of the plate around its center point, with the IMU placed out of center, will cause the accelerometer to measure centrifugal forces.

If your task is to stabalize the platform, this won't be an issue for you.


问:
How would I replicate a tank/zero-turn steering system in a small robotic vehicle?
I'm working on a project that requires me to build a small vehicle (footprint of ~ 14 x 14 inches, less than 6.5 pounds) that can traverse sand. For the steering system, I was thinking of replicating the way tanks and lawn mowers navigate (ability to do zero-point turns), but I want to do this with four wheels instead of tracks like a tank.

I need help with implementing this idea. My preliminary thoughts are to have two motors where each motor power the wheels on one side of the vehicle (I think this would require a gearing system) or to have a motor to power each individual wheel which I'd rather avoid.

答:
You should just need to reverse the inside wheels.  The problem you might get on sand is the wheels have too much grip, or rather bite the sand too much.

Track systems need torque.  I suspect you might have the same issue with your design, you have to overcome the forces when you try and drag the wheels through the sand.


问:
How do I model a robot?
The answers I received to the question on training a line following robot using reinforcement learning techniques, got me to think on how to train a robot. I believe there are essentially two ways -

Train the physical robot.

Model the robot and simulate the training.

Did I miss something?

Approach 2 is definitely the better approach. However, a priori knowledge of the motion (response), a certain PWM signal (stimulus) would cause when the robot is in a given state is required. The motion caused by a PWM signal may depend on the (1) current battery voltage, (2) the mass of the robot and the (3) current velocity (did I miss something?).

How do I model such a robot? And how do I model it quick? If I change the battery or add a few boards and other peripherals and change the mass of the robot, I would have to remodel and retrain the robot. Can I do this by providing some random stimulus PWMs and measuring the response?

added: My related question in dsp.SE

Update: A suggested edit to the title by Ian worth mentioning - "How do I model train a robot so that if its dynamics change, it does not need complete re-training?" I think this is a good question too but different from the one I am asking here. I am okay with re-training for now.

答:
For modeling the kinematics Denavit–Hartenberg parameters are commonly used.
the course Introduction to Robotics provided by Stanford University is available on YouTube

Title: How do I model a robot?


问:
my quadcopter settling time is very large
my quadcopter's settling time is very large, that is it sets its setpoint in very large amount of time, during which it has covered a large distance. But at settle point, when i gives it a jerk or push its returns to settle in normal duration. doesnt over shoots(little). The problem is with the settling time that is when i move the stick front or back it takes huge amount of time. what could be wrong. i have tried giving more P value and I value to PID but then it overshoots and get unstable. This is my PID program. the PID values are given. I read 6 channels from remote using the command pulsein(). which i guess is taking upto 20ms per command.

```<code>kp = 1.32;
ki= 0.025;
kd= 0.307;
void PID() {
  error = atan2(lx,ly);
  error *= 1260/22;
  error = setpoint1 - error;
  now = millis();
  dt = now - ptime;
  ptime = now;
  dt /= 1000;
  integ = integ + (error * dt);
  der = (error - prerror) / dt;
  pidy = (kp * error);
  pidy += (ki * integ);
  pidy += (kd * der);
  //Serial.println(error);
  prerror = error;
}
</code>```

pidy is added and subtracted to esc speeds respectively.

答:
Typically when someone refers to settling time, it's time to achieve the desired target within some limit, and is usually in reference to oscillations about the desired target.

If you have a long time to reach a set position with little or no overshoot, it sounds to me like you have a long rise time and that maybe your controller is more damped than you would like.  I would try increasing the proportional gain and/or the integral gain until you get a response that is closer to what you want.


问:
Quad Copter flight module can replace with smart phone?
I want to replace the flight module with smart phone because it has all sensors that are required, like gyroscope, magnetometer, etc. Is that possible?

I am using an Google Nexus 4 Android (OS model 5.1). I will control using another mobile, I am able write an app, with an Arduino acting as a bridge between smartphone and copter. I am using flight controller OpenPilot CC3D CopterControl.

答:
You need to be a lot more specific in your question so you can get a meaningful answer:

What smart phone are you connecting? Make, model, OS

What flight module are you replacing?

How will you be controlling the smart phone?

Are you able to write an app for the smart phone?

What will happen when the smart phone looses its signal?

How will you connect the phone to the copter?

Why have you tagged this with Arduino?

If you can provide more info then I can provide a more specific answer than: Maybe.


问:
EKF-SLAM: Shrink covariance matrix on one direction
I have implemented an EKF on a mobile robot (x,y,theta coordinates), but now I've a problem.
When I detect a landmark, I would like to correct my estimate only on a defined direction. As an example, if my robot is travelling on the plane, and meets a landmark with orientation 0 degrees, I want to correct the position estimate only on a direction perpendicular to the landmark itself (i.e. 90 degrees).

This is how I'm doing it for the position estimate:

I update the x_posterior as in the normal case, and store it in x_temp.

I calculate the error x_temp - x_prior.

I project this error vector on the direction perpendicular to the landmark.

I add this projected quantity to x_prior.

This is working quite well, but how can I do the same for the covariance matrix? Basically, I want to shrink the covariance only on the direction perpendicular to the landmark.

Thank you for your help.

答:
Here is my solution, that is just an approximation but it is working quite well.

Essentially this is what I do:

I store the a priori covariance matrix in $P_{old}$.

I execute the normal (uncorrected) update step, and store the covariance matrix in $P_{new}$.

Given the direction of the landmark $d$, I compute the parallel component (to this direction $d$) of the axis of the ellipse represented by $P_{old}$. Then, I select the component with maximum length and store it in $a_{par}$.

I compute the perpendicular component (to the same direction $d$) of the axis of the ellipse represented by $P_{new}$. Then, I select the component with maximum length and store it in $a_{perp}$.

Finally I generate the corrected ellipse from the 2 axis $a_{par}$ and $a_{perp}$ and store the covariance matrix in $P$.

This is represented in the following example (direction of the landmark $d$ = 0°) figure, where the red ellipse is represented by $P_{old}$, the green ellipse by $P_{new}$, and the blue ellipse is the corrected one represented by $P$, where only the component perpendicular to $d$ has been shrunk.


答:
Check out the video I linked in my answer to a similar question at the Engineering SE. In that answer I said that the problem with trying to use differential steering in a wheeled vehicle is that you have to accept a tremendous amount of slip in order to perform turns.

In a wheeled vehicle on a hard surface, like pavement, this means burning tires to make common turns. Tanks don't have this issue because they aren't designed to and typically don't operate on roads, they operate on soil. In that scenario the ground gets torn up instead of the "wheels"(tracks). However, with a tank, there isn't as much damage to the ground because the tracks distribute the weight of the vehicle over a much larger surface area, reducing the ground pressure it exerts.

The problem you'll have with a differentially steered wheeled vehicle operating in sand is that you get small points of contact between the tire and terrain due to the circular nature of the tire (point of tangent plus some tire/terrain deformation), and that small point of contact boosts ground pressure. Then, on top of that, you're going to spin tires - you're asking for the vehicle to dig itself in.

Your vehicle is light, so if you manage to get some large/oversized tires and run them under-inflated you might be able to get by, but this for me is one of the great joys of engineering: the best, fastest way to get a satisfying answer is to try it. Try what you want to do in the environment you expect to operate. If building a prototype is too costly/time consuming I would choose a different method of locomotion for fear of digging into the sand, but if your actual terrain is "sandy" instead of "sand", as in by a river, or if the sand is wet or compacted, you might be able to get by.

Finally, that said, if you really want to go this route and weight is an issue, I would use belts or chains to attach the wheels to the motors. Using a gearbox would be expensive weight-wise and would also probably limit the wheel base you could use.

Title: How would I replicate a tank/zero-turn steering system in a small robotic vehicle?

Body:
I'm working on a project that requires me to build a small vehicle (footprint of ~ 14 x 14 inches, less than 6.5 pounds) that can traverse sand. For the steering system, I was thinking of replicating the way tanks and lawn mowers navigate (ability to do zero-point turns), but I want to do this with four wheels instead of tracks like a tank.

I need help with implementing this idea. My preliminary thoughts are to have two motors where each motor power the wheels on one side of the vehicle (I think this would require a gearing system) or to have a motor to power each individual wheel which I'd rather avoid.


问:
Determining pose from ar_track_alvar message in ROS
I am using the ar_track_alvar package in Indigo to detect AR Tags and determine their respective poses. I am able to run the tracker successfully as I can visualize the markers in RViz. I give the following command to print the pose values

rostopic echo /ar_pose_marker

and I get the following output indicating that the poses are determined.

```<code>header:
  seq: 0
  stamp:
    secs: 1444430928
    nsecs: 28760322
  frame_id: /head_camera
id: 3
confidence: 0
pose:
  header:
    seq: 0
    stamp:
      secs: 0
      nsecs: 0
    frame_id: ''
  pose:
    position:
      x: 0.196624979223
      y: -0.238047436646
      z: 1.16247606451
    orientation:
      x: 0.970435431848
      y: 0.00196992162831
      z: -0.126455066154
      w: -0.205573121457
</code>```

Now I want to use these poses in another ROS node and hence I need to subscribe to the appropriate ROS message('ar_pose_marker"). But I am unable to get enough information on the web on the header files and functions to use in order to extract data from the published message. It would be great if somebody can point to a reference implementation or documentation on handling these messages. It might be useful to note that ar_track_alvar is just a ROS wrapper and hence people who have used ALVAR outside of ROSmay also give their inputs.

UPDATE:

I tried to write code for the above task as suggested by @Ben in the comments but I get an error. The code is as follows

```<code>#include <ros/ros.h>
#include <ar_track_alvar_msgs/AlvarMarker.h>
#include <tf/tf.h>
#include <tf/transform_datatypes.h>

void printPose(const ar_track_alvar_msgs::AlvarMarker::ConstPtr& msg)
{
    tf::Pose marker_pose_in_camera_;

    marker_pose_in_camera_.setOrigin(tf::Vector3(msg.pose.pose.position.x,
                             msg.pose.pose.position.y,
                             msg.pose.pose.position.z));

}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "pose_subscriber");

    ros::NodeHandle nh;

    ros::Subscriber pose_sub = nh.subscribe("ar_pose_marker", 1000, printPose);

    ros::spin();

    return 0;

}
</code>```

And I get the following error

```<code>/home/karthik/ws_ros/src/auto_land/src/pose_subscriber.cpp: In function ‘void printPose(const ConstPtr&)’:
/home/karthik/ws_ros/src/auto_land/src/pose_subscriber.cpp:17:53: error: ‘const ConstPtr’ has no member named ‘pose’
    marker_pose_in_camera_.setOrigin(tf::Vector3(msg.pose.pose));
                                                     ^
make[2]: *** [auto_land/CMakeFiles/pose_subscriber.dir/src/pose_subscriber.cpp.o] Error 1
make[1]: *** [auto_land/CMakeFiles/pose_subscriber.dir/all] Error 2
make: *** [all] Error 2
</code>```

Any suggestions?

答:
If you do a rostopic type /ar_pose_marker you should see something like:

```<code>ar_track_alvar_msgs/AlvarMarker
</code>```

Then if you do a rosmsg show ar_track_alvar_msgs/AlvarMarker you should see something like:

```<code>std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
uint32 id
uint32 confidence
geometry_msgs/PoseStamped pose
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  geometry_msgs/Pose pose
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w
</code>```

So now you can subscribe to the /ar_pose_marker topic which is of type ar_track_alvar_msgs/AlvarMarker.  (Follow the cpp or python tutorials for the syntax).  Then in your callback, you can get the pose out of the message by simply doing msg.pose.pose.

Keep in mind that this is the pose in message format.  It doesn't support the normal mathematical operations that you would expect.  For that, you must convert it to another type such as an Eigen matrix, Numpy matrix, or KDL Frame.  tf_conversions has some code for that.  Or you can use some external library like tfx.  Or just do it yourself.

Body:
If you do a rostopic type /ar_pose_marker you should see something like:

ar_track_alvar_msgs/AlvarMarker

Then if you do a rosmsg show ar_track_alvar_msgs/AlvarMarker you should see something like:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
uint32 id
uint32 confidence
geometry_msgs/PoseStamped pose
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  geometry_msgs/Pose pose
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w

So now you can subscribe to the /ar_pose_marker topic which is of type ar_track_alvar_msgs/AlvarMarker.  (Follow the cpp or python tutorials for the syntax).  Then in your callback, you can get the pose out of the message by simply doing msg.pose.pose.

Keep in mind that this is the pose in message format.  It doesn't support the normal mathematical operations that you would expect.  For that, you must convert it to another type such as an Eigen matrix, Numpy matrix, or KDL Frame.  tf_conversions has some code for that.  Or you can use some external library like tfx.  Or just do it yourself.


问:
In HRI, how is the "uncanny valley" experienced by people on the autism spectrum?
I'm familiar with the idea of the uncanny valley theory in human-robot interaction, where robots with almost human appearance are perceived as creepy. I also know that there have been research studies done to support this theory using MRI scans.

The effect is an important consideration when designing robotic systems that can successfully interact with people. In order to avoid the uncanny valley, designers often create robots that are very far from humanlike. For example, many therapeutic robots (Paro, Keepon) are designed to look like animals or be "cute" and non-threatening.

Other therapeutic robots, like Kaspar, look very humanlike. Kaspar is an excellent example of the uncanny valley, since when I look at Kaspar it creeps me out. However, people on the autism spectrum may not experience Kaspar the same way that I do. And according to Shahbaz's comment, children with autism have responded well to Kaspar.

In the application of therapeutic robots for people on the autism spectrum, some of the basic principles of human-robot interaction (like the uncanny valley) may not be valid. I can find some anecdotal evidence (with Google) that people on the autism spectrum don't experience the uncanny valley, but so far I haven't seen any real studies in that area.

Does anyone know of active research in human-robot interaction for people on the autism spectrum?  In particular, how does the uncanny valley apply (or doesn't it apply) when people on the autism spectrum interact with a humanlike robot?

答:
One of the primary facets of ADD/ADHD/Spectrum is awareness, that is, not missing small details. The phenomenon of the Uncanny Valley is probably more prevalent for these people. However, as also noted, many people sufficiently afflicted with ASD may not consciously recognize the signals they're getting.

I would advise making a conscious effort to stay on the non-human-cute side of the Uncanny Valley, because this is some of the most shaky ground.


问:
Linear actuators in a cartesian robots
I would like to make a Cartesian robot with maximum speed of up to $1ms^{-1}$ in x/y plane, acceleration $2ms^{-2}$ and accuracy at least 0.1mm. Expected loads: 3kg on Y axis, 4kg on X axis. Expected reliability: 5000 work hours. From what I have seen in 3D printers, belt drive seems not precise enough (too much backlash), while screw drive is rather too slow.

What other types of linear actuators are available? What is used in commercial grade robots, i.e. http://www.janomeie.com/products/desktop_robot/jr-v2000_series/index.html

答:
I have worked on a cartesian robot with similar requirements† as your own, and we selected direct drive synchronous linear motors for our x/y stages. In our case, both axes were around 2m in length, but magnet the tracks have the potential to be as long as you need to build them.

† Less than an order of magnitude higher at $2/5ms^{-1}$ velocity & $10/20ms^{-2}$ acceleration for x & y stages respectively.

In our case, we used an exposed magnet track linear motor from aerotech, but for most applications a u-shaped track is more convenient as it contains the high magnetic fields within a more enclosed space. Our cartesain robot had large exposed magnet track surfaces which meant that we had to post warnings regarding letting pacemakers and metal tools getting too close (a screwdriver could be attracted to the magnet track with sufficient force to damage both and anything which got in between, such as your fingers).

There are a number of manufacturers making direct drive linear motors (as a google search will show), and in addition to flat and U-shaped tracks, manufacturers such as Nippon Pulse and LinMot do cylindrical shaft motors, which might be easier to retrofit to a robot which currently uses a lead-screw linear actuator.

The accuracy of these direct drive systems can be very much dependent on tuning. They often suffer from significant cogging effects, though some manufacturers claim to include patented zero and anti-cogging techniques and often maximum and minimum speeds can be related to how smooth you want the movement to be at those speeds.

As an aside, we also used air-bearings on our X track, which is how we managed high speed and acceleration with a relatively small motor. They were really difficult to tune however and this was complicated by the fact that we had 6 X-carriages on each Y beam (of which there were two, so 14 x/y axes and 16 motors in total).

Title: Linear actuators in a cartesian robots


问:
How to connect ethernet based Hokuyo scanner?
This is a very basic beginner question, I know, but I am having trouble connecting to the Hokuyo UST-10LX sensor and haven't really found much in terms of helpful documentation online.

I tried connecting the Hokuyo UST-10LX directly to the ethernet port of a Lubuntu 15.04 machine. The default settings of the Hokuyo UST-10LX are apparently:
ip addr: 192.168.0.10
netmask: 255.255.255.0
gateway: 192.168.0.1

So, I tried going to the network manager and setting IPv4 settings manually, to have the ip addr be 192.168.0.9, netmask of 255.255.255.0, and gateway to 192.168.0.1. I also have a route set up to the settings of the scanner.

I then go into the terminal and run:

```<code>rosrun urg_node urg_node _ip_address:=192.168.0.10
</code>```

and get this output:

```<code>[ERROR] [1444754011.353035050]: [setParam] Failed to contact master at [localhost:11311].  Retrying...
</code>```

How might I fix this? I figure it's just a simple misunderstanding on my end, but through all my searching I couldn't find anything to get me up and running :(

Thank you for the help! :)

EDIT:

HighVoltage pointed out to me that I wasn't running roscore which was indeed the case. I was actually running into problems before that when I still had roscore up, and when I tried it again, this was the output of the rosrun command:

```<code>[ERROR] [1444828808.364581810]: Error connecting to Hokuyo: Could not open network Hokuyo:
192.168.0.10:10940
could not open ethernet port.
</code>```

Thanks again!

答:
Are you sure roscore is running? "Failed to contact master" is usually an issue with roscore not initializing.

If roscore indeed is running but you are still getting the message, check if ROS_MASTER_URI is set to something other than the default. Or run "rosnode list" and paste the output here.


问:
Nano Quadcopters Microcontroller and battery
I am looking into building a nano quadcopter, But as i watch more resources and videos i get more confused, regarding some of the things that i hope would be answered here. I am in very basic level of expertise here, i haven't built any robots or quadcopters to be exact.

What i want to know is, when i program a quadcopter say using intel edison chip, how do i power the quadcpter? i could not find that small size battery to move the propellers and start the chip.

Further more what is the procedure i should follow while developing a nano or small quadcopter, i saw a link on instructable that uses python on raspberry pi and then that raspberry pi control the arduino to control the robot. Can it be done only by using raspberry pi itself?

I am getting confused and i would like to know if i have to make small or nano quadcopter what should i be doing to get started?

Most of the latest chip support linux and high level programming language like python, so i hope i can go about programming the entire quadcopter using python or similar high level language and i don't suppose i have to stick with c langauge now. If i am wrong please help me understand the matter, there is high chance that i could be wrong.

答:
If you use a Linux based microprocessor you run the risk of tasks being switched at inopportune moments that's why they used an Arduino in the example, you could also try a ESP3266.

I think you would be making a mistake to build a Nano for your first project.  Larger parts are more readily available.

To build any project you need to work out the components and get them working, otherwise you are going to overwhelm yourself:

Learn how to program and use Arduino\ESP8266.

Learn how to control a motor

Learn how to read all the sensors you need

Learn how to communicate from the controller to the quadcopter.

Learn how to work out how much lift you need.

Buy the different motors and batteries you knew you should have brought in the first place.

Put it all together.

Pray it doesn't crash to badly on its maiden flight.

Hope that helps :)


答:
There is no angle that should be removed. At a gimbal lock, you are able to express an orientation in an infinite amount of ways if you use a three-angle representation. At a gimbal lock, axes of two angular rotations are aligned. As such, their rotations are no unique solution to a given orientation. It depends on the representation which axes are considered here.

I'll try to find time later to add a can-in-series example to further clarify this.

I suggest you never ever look back at three-angle representations, such as pitch-yaw-roll, Euler angles or Tait-Bryan angles. The theory is flawed as it does not make any sense mathematically. It's like trying to flatten a piece of paper over a globe.

Title: rotation matrix to euler angles with gimbal lock

Body:
How do i determine which angle i can negate when gimbal lock occurs.

As i've understood with gimbal lock that it remove one degree of freedom, but how do i determine which degree can be removed when a  value R[1][3]  of a rotation matrix (size 3x3) has the value 1.  Is it the Roll, Pitch or yaw which can be taken out from the equation?


问:
Do "toy" robots move technology forwards?
Over the last month, I saw many robots that don't have any real purpose, which made me ask myself: "Does this have any value?" I saw dancing robot on CES, advanced lego based robots and also robots combined for very limited purpose. I saw ten year old children playing with robots, and competitions for them. Someone has told me that this is just for education and logic spreading.

In other cases, there were arguments like, "this is for informing people that everything is going forwards". I know that people will buy robotic vacuum cleaners because they think that they'll save some time, but these robotic cleaners are not very reliable and I see it only as marketing.

Do these things (children's education, dancing robots, and other instances of selling a pig in a poke) have any value in terms of robotics, and are really advancing the field as manufacturers say?

答:
In general, toy robots probably face fewer challenges, except in human safety. I'd imagine that they don't usually advance the knowledge base themselves.

HOWEVER, I think it's beyond question that our crop of engineers and scientists will be larger and more competent if they're exposed early and often to technologies and sciences such as, in this example, robotics. The tinkering culture is known to facilitate and produce innovators more than who has memorized the most mathematical formulae or protein folding shortcuts.

The FIRST Robotics Competition also doesn't "move technology forwards", but I dare people to claim that it isn't important for our overall success of our technology sector. There's little technological advancement in playing with Lego, but the creativity and persistence in problem solving that gets reinforced by playing with Lego is absolutely essential.

So to answer your question: his statement is mostly true, in that things like what they're selling are sparks for the engine, but that particular company isn't directly pushing technology forward.


问:
Gyro measurement to absolute angles
Let us assume we have a gyro that is perfectly aligned to a global frame ($X,Y,Z$).

From what I know the gyro data give me the angular rate with respect to the gyro axis ($x,y,z$). So let's say I got $\omega_x,\omega_y,\omega_z$. Since I know that the 2 frames are perfectly aligned I perform the following operations:

$\theta_X = dt * \omega_x$

$\theta_Y = dt * \omega_y$

$\theta_Z = dt * \omega_z$

where $\theta_X$ is the rotation angle around $X$ and so on.

My question is: what is this update like in the following steps? Because this time the measurement that I get are no more directly related to the global frame (rotated with respect to the gyro frame).

Thank you!

答:
Your first step works because it is implied that your frames are "aligned", meaning that:

$$
\theta_{X_0} = 0 \\
\theta_{Y_0} = 0 \\
\theta_{Z_0} = 0 \\
$$

In general (as with any integration!), you have some starting angles(initial condition), $\theta_{(X,Y,Z)_0}$, and you proceed to update from there, such that:

$$
\theta_{X_N} = \theta_{X_{N-1}} + \omega_{X_N} dT \\
\theta_{Y_N} = \theta_{Y_{N-1}} + \omega_{Y_N} dT \\
\theta_{Z_N} = \theta_{Z_{N-1}} + \omega_{Z_N} dT \\
$$

Note that when your initial conditions are as you use in your example, the $\theta_{N-1}$ terms vanish leaving you with the equations you originally stated.

Title: Gyro measurement to absolute angles


问:
Angular velocities and rotation matrices
Let us assume I have an object O with axis $x_{O}$, $y_{O}$, $z_{O}$, with different orientation from the global frame S with $x_{S}$, $y_{S}$, $z_{S}$ (I don't care about the position).
Now I know the 3 instantaneous angular velocities of the object O with respect to the same O frame, that is $\omega_O^O = [\omega_{Ox}^O \omega_{Oy}^O \omega_{Oz}^O]$.
How can I obtain this angular velocity with respect to the global frame (that is $\omega_O^S$)?

Thank you!

答:
If your object $O$ has a different orientation from your global frame $S$, and you know what that difference in orientation is, you can create a 4x4 transform matrix between the two:

$$
T = \left[ \begin{array}{cc}
 R & s \\
0 & 1 \end{array} \right]
$$

where $R$ is the 3x3 rotation matrix, $s$ is the 3x1 translation vector, $0$ is a 1x3 row of zeros, and $1$ is just 1. You can transform your (points, angular velocities, etc.) from one frame to another with:

$$
\left[ \begin{array}{c}
x' \\
y' \\
z' \\
1 \end{array}
\right] = \left[ \begin{array}{cc}
R & s \\
0 & 1 \end{array} \right] \left[ \begin{array}{c}
x \\
y \\
z \\
1 \end{array} \right]
$$

If you don't care about translation you can just set
$s = \left[ \begin{array}
00 \\
0 \\
0 \\ \end{array} \right]$


问:
UWSim Pressure Sensor Units
I am attempting to use the data Underwater Simulator (UWSim) provides through the ROS interface to simulate a number of sensors that will be running on a physical aquatic robot. One of the sensors detects the current depth of the robot so, I want to simulate this with the data provided by the UWSim simulated pressure sensor. The Problem is that nowhere in the UWSim wiki or source code can I find any reference to what units UWSim uses to measure pressure.

That being said, what units does UWSim use to measure pressure? Additionally, I would appreciate general information about what units UWSim uses for the data provided by it's virtual sensors.

答:
I haven't used ROS before, but you could try to determine the pressure units with an experiment!

Put your sensor in water and take a pressure measurement.

Lower the sensor 10.3 meters, or about 34 feet, and take another pressure measurement.

Subtract (1) from (2), and look for the correct "ballpark":

~1 = bar

~14.7 = psi

~101 = kPa

~1,000 = mbar

~101,000 = Pa

This test checks the change in pressure when changing depth to a pressure difference of 1 atmosphere.

Title: UWSim Pressure Sensor Units


问:
Overcorrecting Kalman Filter
I'm trying to get an extended Kalman Filter to work. My System Model is:

$ x = \begin{bmatrix}
 lat \\
 long \\
 \theta
\end{bmatrix}$

where lat and long are latitude and longitude (in degree) and $\theta$ is the current orientation of my vehicle (also in degree).
In my Prediction Step I get a reading for current speed v, yaw rate $\omega$ and inclination angle $\alpha$:

$z = \begin{bmatrix}
 v \\
 \alpha\\
 \omega
 \end{bmatrix}$

I use the standard prediction for the EKF with $f()$ being:

$
\vec{f}(\vec{x}_{u,t}, \vec{z}_t) = \vec{x}_{u,t} +
 \begin{bmatrix}
  \frac{v}{f} * \cos(\theta) * \cos(\alpha) * \frac{180 °}{\pi * R_0} \\
  \frac{v}{f} * \sin(\theta) * \cos(\alpha) * \frac{180 °}{\pi * R_0} * \frac{1}{\cos(lat)} \\
  \frac{\omega}{f}
 \end{bmatrix}
$

$f$ being the prediction frequency, $R_0$ being the radius of the earth (modelling the earth as a sphere)

My Jacobian Matrix looks like this:

$
C = v \cdot \Delta t \cdot cos(\alpha) \cdot \frac{180}{\pi R_0}
$

$
F_J =
\begin{pmatrix}
  1 & 0 & -C \cdot sin(\phi) \cdot \frac{1}{cos(lat)} \\
  -C \cdot sin(\phi) \cdot \frac{sin(lat)}{{cos(lat)}^2} & 1 & C \cdot cos(\phi) \cdot \frac{1}{cos(lat)}\\
  0 & 0 & 1
\end{pmatrix}
$

As I have a far higher frequency on my sensors for the prediction step, I have about 10 predictions followed by one update.

In the update step I get a reading for the current GPS position and calculate an orientation from the current GPS position and the previous one. Thus my update step is just the standard EKF Update with $h(x) = x$ and thus the Jacobian Matrix to $h()$, $H$ being the Identity.

Trying my implementation with testdata where the GPS Track is in constant northern direction and the yaw rate constantly turns west, I expect the filter to correct my position close to the track and the orientation to 355 degrees or so. What actually happens can be seen in the image attached (Red: GPS Position Measurements, Green/blue: predicted positions):

I have no Idea what to do about this. I'm not very experienced with the Kalman filter, so it might just be me misunderstanding something, but nothing I tried seemed to work…

What I think:

I poked around a bit: If I set the Jacobian Matrix in the prediction to be the identity, it works really good. The Problem seems to be that $P$ (the covariance Matrix of the system model) is not zero in $P(3,1)$ and $P(3,2)$. My interpretation would be that in the prediction step the Orientation depends on the Position, which does not seem to make sense. This is due to $F_J(2,1)$ not being zero, which in turn makes sense.

Can anyone give me a hint where the overcorrection may come from, or what I should look at / google for?

答:
There is an error in your posted equation for the Jacobian $F_J$, so that could be the source of the problem. It should look like this:

$F_J = \begin{bmatrix}
1 & 0 & -C \sin \theta \\
C \frac{\sin \theta \sin \lambda}{\cos^2 \lambda} & 1 & C \frac{\cos \theta}{\cos \lambda} \\
0 & 0 & 1 \\
\end{bmatrix}$

With that new Jacobian I get results that look like:

Title: Overcorrecting Kalman Filter


问:
Aligning datasets with drift
I have a dataset that contains position information from tracking a robot in the environment. The position data comes both from a very accurate optical tracking system (Vicon or similar) and an IMU. I need to compare both position data (either integrating the IMU or differentiating the optical tracking data).

The main problem is that both systems have different reference frames, so in order to compare I first need to align both reference frames. I have found several solutions; the general problem of aligning two datasets seems to be called "the absolute orientation problem".

My concern is that if I use any of these methods I will get the rotation and translation that aligns both datasets minimizing the error over the whole dataset, which means that it will also compensate up to some extent for the IMU's drift. But I am especially interested in getting a feeling of how much the IMU drifts, so that solution does not seem to be applicable.

Anyone has any pointer on how to solve the absolute orientation problem when you do not want to correct for the drift?

Thanks

答: Use a method to solve the absolute orientation problem so that you have a result for the IMU data that does compensate for drift. Separately, use a dead reckoning method (i.e., integration) to compute the result without compensating for drift. Then you can subtract the first result from the second result and the difference should be the drift you are looking for.</p>

Title: Aligning datasets with drift


问:
3D Angular velocity to 3D velocity to predict next state
I have a sensor that gives R, Theta, Phi (Range, Azimuth and Elevation) As such:
http://imgur.com/HpSQc50
I need to predict the next state of the object given the roll, pitch yaw angular velocities given the above information. But the math is really confusing me.
So far all I've gotten is this:

```<code>Xvel = (R * AngularYVel * cos(Theta))
YVel = (R * AngularXVel * cos(Phi))
ZVel = (R * AngularYVel * -sin(Theta)) + (R * AngularXVel * -sin(Phi))
</code>```

i worked this out by trigonometry, so far this seems to predict the pitching about the x axis and yawing about my y axis (sorry i have to use camera axis)
But i dont know how to involve the roll (AngularZVel)

答:
Assuming that you mean to say your frame of reference is rotating with those roll-pitch-yaw rates and you are tracking a stationary object with position defined by $R$, $\theta$, and $\phi$ in the rotating frame, then you need to do this:

Compute the new roll, pitch, and yaw angles given the previous values and the measured rates.

Compute the rotation matrix, $A$, for the new reference frame.

Compute the previous position vector, $p$, for the object, where $p = (R \cos \theta \cos \psi, R \sin \theta \cos \psi, R \sin \psi)$

Compute the new predicted position vector by rotating the previous one into the new frame (i.e., $p_{new} = A^{-1} p$)

Compute the new predicted $R$, $\theta$, and $\psi$ from the elements of the new predicted position vector ($R_{new} = \sqrt{p_{new,1}^2 + p_{new,2}^2 + p_{new,3}^2}$, etc.)

Note that I am not paying attention to your axes and sign conventions, so you will have to take that into account for your own solution.


问:
Accurate Wheeled Robot Odometry
I'm looking for a "good" algorithm/model for wheeled odometry estimation. We have encoders on the two back wheels of the tricycle robot, and IMU on the controller board. Currently we use MEMS gyro for angular velocity estimation and encoders for linear velocity, then we integrate them to get the pose. But it's hard to calibrate gyro properly and it drifts (due to temperature or just imperfect initial calibration). How can we improve the pose estimation? Should we consider model that incorporates both encoders and gyro for heading estimation? Model slippage, sensor noise? Is there some nice standard model? Or should we just use more/better gyro? Not considering the visual odometry.

答:
First, you can try adding encoders - you don't need to buy anything to do this. Only remember to perform UMBmark procedure first. It will allow you to get much more reliable odometry from encoders alone.

If adding encoders is not enough, try to add magnetometer. It will get you absolute heading relative to magnetic north. Unfortunately, these devices are very sensitive to interference from running motors, so try to keep them away.

As a last step I would go for a better gyro.

Title: Accurate Wheeled Robot Odometry


答:
You can also try Snark:
https://github.com/acfr/snark
which requires
https://github.com/acfr/comma.

The name of the application is called hokuyo-to-csv. See --help -v for details.

Title: How to connect ethernet based Hokuyo scanner?

Body:
This is a very basic beginner question, I know, but I am having trouble connecting to the Hokuyo UST-10LX sensor and haven't really found much in terms of helpful documentation online.

I tried connecting the Hokuyo UST-10LX directly to the ethernet port of a Lubuntu 15.04 machine. The default settings of the Hokuyo UST-10LX are apparently:
ip addr: 192.168.0.10
netmask: 255.255.255.0
gateway: 192.168.0.1

So, I tried going to the network manager and setting IPv4 settings manually, to have the ip addr be 192.168.0.9, netmask of 255.255.255.0, and gateway to 192.168.0.1. I also have a route set up to the settings of the scanner.

I then go into the terminal and run:

```<code>rosrun urg_node urg_node _ip_address:=192.168.0.10
</code>```

and get this output:

```<code>[ERROR] [1444754011.353035050]: [setParam] Failed to contact master at [localhost:11311].  Retrying...
</code>```

How might I fix this? I figure it's just a simple misunderstanding on my end, but through all my searching I couldn't find anything to get me up and running :(

Thank you for the help! :)

EDIT:

HighVoltage pointed out to me that I wasn't running roscore which was indeed the case. I was actually running into problems before that when I still had roscore up, and when I tried it again, this was the output of the rosrun command:

```<code>[ERROR] [1444828808.364581810]: Error connecting to Hokuyo: Could not open network Hokuyo:
192.168.0.10:10940
could not open ethernet port.
</code>```

Thanks again!


问:
Robotic arm ["FAiL"] error display. - Festo / Mitsubishi Melfa RV-2AJ (Controller CR1-571)
To avoid wasting your time on this question, you might only want to react on this if you have knowledge of industrial robotic arms specific.
Common troubleshooting is unlikely to fix this problem or could take too much time.

We've started a project with the Mitsubishi Melfa RV-2AJ robotic arm.
Everything went fine until the moment we replaced the batteries.

The controller displays: "FAiL" and does not respond to any buttons or commands sent through serial connection.

We did replace the batteries of both the robot and the controller. As it took some time to get the batteries delivered, we've left the robot (and controller) withouth power for the weekend. (Which might have caused this problem)

Is there anyone with knowledge of Mitsubishi Robotic arms around here?
I'm kinda hoping it would be a common problem/mistake and anyone with experience on this subject would know about it?

答:
After some googling I found that there is an explanation & fix guide, only in German, for this.

It'll be of use for others having the same problem.

I'll try my very best to translate it a bit, please note that German, not English, is my main language:

Concerning "FAIL" in the display of the robotcontroller after voltage drop from back-up batteries (general). - KS00527

When the battery voltage is unsufficient to keep the buffer (which
  holds the settings of the powered-off robot), the display will show
  the message: "FAIL".

To reset this message/state, a RAM data reset is needed. After this
  reset, all programs and position data in the robotcontroller will be
  erased and the parameters will be reverted.

The procedure (RAM data reset) is as following:

Press STOP and RESET at the same time, while the controller is being activated.

The robot controller display would show "|----|".

Releave the STOP and RESET buttons.

Press RESET untill the display will show "EnG".

Press START once.

Press RESET until the display shows your Robot type

Press Start once.

The robot controller display would show "rAMc9".

After ~15-25 sec. (depending on the contents of the RAM?) you'll see a countdown from "100-0".

The message "ok" will appear on the dispaly.

Finally the robot will automatically reboot. (Didn't happen for us though)

I believe the procedure might differ a little per controller, but this would get you going.

The original text:

Anzeige FAIL im Display der Robotersteuerung nach Spannungsverlust der
  Pufferbatterien (General) - KS00527 Wenn die Batteriespannung die
  Einstellungen der ausgeschalteten Robotersteuerung nicht mehr puffern
  kann, zeigt das Display nach dem Einschalten die Anzeige FAIL an. Um
  diese zu beseitigen hilft nur ein RAM Daten Reset. Nach diesem Reset
  sind alle Programme, Positionsdaten in der Robotersteuerung gelöscht
  und die Parameter auf Werkseinstellung zurückgesetzt. Die Prozedur ist
  wie folgt : - Drücken Sie die STOP und RESET Taste gleichzeitig,
  während der Controller eingeschaltet wird. - Im Display wird ”I- - -
  -I” angezeigt. - STOP und RESET Taste loslassen - Die Taste RESET so oft drücken bis ”EnG” im Display angezeigt wird. - Drücken Sie einmal
  die START Taste. - Drücken Sie die Taste RESET oder STOP so oft bis im
  Display angezeigt wird. - Drücken Sie einmal die START Taste. - Im
  Display wird nun ”rAMc9” angezeigt. - Nach ca. 15-25 sec (abhängig vom
  Inhalt des RAM Speichers) sieht man im Display einen Countdown von
  ”100-0”. - Es erscheint kurz die Meldung ”ok” im Display. -
  Abschließend bootet der Controller selbsttätig neu.

Source: https://eu3a.mitsubishielectric.com/fa/en/service/knowledgebase?m_culture=de&ks=527

KS00527 of the GERMAN knowledgebase on Mitsubishi (Somehow German people may know things the English aren't allowed to? :D (You can't find it in English))


答:
You gave two methods of comparison - "either integrating the IMU or differentiating the optical tracking data". I'm talking about one basic transform to convert from the vision frame to the global frame and vice-versa.

One transform, that you calculate in advance, that relates one origin to another origin. You seem to be talking about methods of best-fit to get good correspondence, but I'm saying to use one fixed, somewhat generic transform.

All you need to do is shift from one frame to another. This will preserve drift.

:EDIT:

I may have misunderstood the question, or your particular scenario. I thought that you could just go out and measure the location and orientation of the camera, measure the location and orientation of the robot, and make your own transform.

In the event that you can't or don't want to (too time consuming, lots of trials, etc.), then you could "cheat" by exploiting the fact that drift is a slow event, where a very small error is added over a very large number of samples.

What you might be able to try is to use the method you already found and apply that to only the first few samples of your data set.

If your robot is in motion from the start of the set, then the first sample should be enough to fix a position and the second sample should fix a heading/rotation. Use the resulting transform you get from only these two samples and apply that transform to all the others. Noise may be an issue, but that seems to be the point of what you're trying to do.

If you think it's too noisy or there's too much error, then you could try the algorithm with the first 3 samples, or first 4, or 5, etc. As you've noted, the more samples you include the more this will account for drift, but if you can't physically measure the transform you don't really have any other option.

Title: Aligning datasets with drift

Body:
I have a dataset that contains position information from tracking a robot in the environment. The position data comes both from a very accurate optical tracking system (Vicon or similar) and an IMU. I need to compare both position data (either integrating the IMU or differentiating the optical tracking data).

The main problem is that both systems have different reference frames, so in order to compare I first need to align both reference frames. I have found several solutions; the general problem of aligning two datasets seems to be called "the absolute orientation problem".

My concern is that if I use any of these methods I will get the rotation and translation that aligns both datasets minimizing the error over the whole dataset, which means that it will also compensate up to some extent for the IMU's drift. But I am especially interested in getting a feeling of how much the IMU drifts, so that solution does not seem to be applicable.

Anyone has any pointer on how to solve the absolute orientation problem when you do not want to correct for the drift?

Thanks


问:
Real-time video processing on video feed from a drone's camera
I am working on a project where I want to run some computer vision algorithms (e.g. face recognition) on the live video stream coming from a flying drone.

There are many commercial drones out there that offer video streams, like

http://www.flyzano.com/mens/

https://www.lily.camera/

etc..

But none of them seem to give access to the video feed for real-time processing.

Another idea is to have the drone carry a smartphone, and do the processing on the phone through the phone's camera. Or just use a digital camera and an arduino that are attached to the drone.

Although these ideas are feasible, I would rather access the video-feed of the drone itself. So my question is that are there any drones out there that offer this feature? or can be hacked somehow to achieve this?

答: This  AR.Drone provides SDK, therefore, you can access the images on real-time. It is fully compatible with Linux. They have examples also for smartphones. I believe android and iPhone. It has two cameras. I've bought it and its price is reasonable. At that time, the price was roughly 272 CAD. Of course, the price is now more expensive than before but I believe it is affordable. You need to know c programming and Makefiles. </p>


问:
what's confidence level? and how can we use it for vehicle detection using OpenCV?
I'm working on project for the Autonomous vehicle, and i want to know what's confidence level means and how can we use confidence level for vehicle detection in OpenCV ?</p>

答:
Statistical confidence is most often defined in terms of a score that is the number of standard deviations away from the mean.

Now let's say you have a set of states (a state vector) used to define an object recognized using image processing in OpenCV (for example, RGB data, HSV data, filter responses, etc.). Given a series of training images for vehicles, you can compute the mean and covariance of their state vectors. If you then consider some new object being tested, you can compute what is known as the Mahalanobis distance between the new object's state vector and the vehicle state vector. This distance will essentially be the statistical confidence that the new object is a vehicle.

In fact, OpenCV has functions available to compute things like the covariance matrix and the Mahalanobis distance.


问:
Quad Copter flight module can replace with smart phone?
I want to replace the flight module with smart phone because it has all sensors that are required, like gyroscope, magnetometer, etc. Is that possible?

I am using an Google Nexus 4 Android (OS model 5.1). I will control using another mobile, I am able write an app, with an Arduino acting as a bridge between smartphone and copter. I am using flight controller OpenPilot CC3D CopterControl.

答:
A project like this was already thought and working.

It was proposed from Vijay Kumar, one of the gurus of quarotor helicopers (that is the name he thinks it is the most appropriate for these objects).

I hope you will find the following link interesting:

Vijay Kumar: a smartphone as brain for a quadrotor

This is the video


问:
Standalone (or capable of being) Robotics Simulator
I'm a software engineer who volunteers with a non-profit that introduces young girls to technology. We have recently been talking about methods of introducing these children to the world of robotics, and I am curious what types of low-cost options we have.

One very appealing idea would be to have an online simulator, or (more preferable) an off-line standalone-simulator that we can build and program simple robots with. Perhaps nothing more than dragging components together, and then programming the interactions between those components.

What solution(s) exist that I might be able to make use of in our outreach?

答:
You might want to check out "MindRover".  It's old and harder to find now since the original website is defunct, but can still be found on Ebay or Amazon.  Although game/mission oriented, it involved picking from a palette of robot components, putting them on a chassis, and then wiring them together.  It was really well done for a game and could be used to explore simple to semi-advanced concepts. Some screenshots here: http://images.google.com/images?q=mindrover.

If you are looking for something a bit more serious with real world capabilities, you might want to check out FlowStone for Education. I have not used it, but I believe it is a visual programming environment ideally suited for robotics type work.

Last, although not software or simulation, I recently came across a comment on reddit by phblj regarding a technique for introducing programming, and I thought it was really good (and especially adaptable to robotics programming). Quote:

Great example of computers I did with kids: One kid got to be the
  "program" and gave instructions on how to make a peanut-butter and
  jelly sandwich, but they couldn't watch my actions. I was the
  computer, and followed the instructions exactly. Hilarity resulted.
  (Not taking lid off peanut bar, not getting bread out of box I had it
  in). After a minute, another kid came up and tried. They got a little
  further, but still floundered. "Put the peanut butter on the bread"
  resulted in the jar sitting on the loaf, etc. It took several kids,
  but eventually we got it. If you've got an assistant, have them write
  the instructions as they're said, creating the "program."

You can get into explanations, then, but the thing that really stuck
  was that the kids were each "smarter than a computer." But that
  computers were really, really fast at following instructions. So they
  needed to use their smarts and the computers speed, and...
  programming!


问:
How much should I expect a Kalman filter to converge?
I am learning about Kalman filters, and implementing the examples from the paper Kalman Filter Applications - Cornell University.

I have implemented example 2, which models a simple water tank, filling at a constant rate. We only measure the tank level, and the Kalman filter is supposed to infer the fill rate.

According to the model, the fill rate is a constant, so I assumed that over time, the Kalman filter would converge more and more accurately (and with less and less noise) on the correct fill rate. However, the amount of noise in the fill rate never seems to reduce after the first few iterations:

This graph shows how the fill rate part of the state vector changes over the course of 1000 iterations of the simulation.

Adjusting the Measurement Variance Matrix seems to have very little effect on the fill rate noise.

Also, the Kalman gain vector and State Variance matrix seem to be constant throughout the simulation. I assumed that the State Variance would reduce as the filter became more and more confident in its state estimate.

Questions:
- Is this graph what I should expect to see?
- Should the Kalman Gain vector and State Variance matrix change over time in this situation?

答:
Let's assume a constant Kalman filter $x_n = Gx_{n-1}+\omega$ with $\omega \sim \mathrm{N}(0, W)$ and $y_n = Fx_n+ \nu$ with $ \nu \sim \mathrm{N}(0,V)$, and initial state $x_0 \sim \mathrm{N}(m_0, C_0)$, where $C_0$ is the initial state variance. Then, the sequence of state covariance matrices $C_0, C_1, \dots, C_n$ converges to a constant covariance matrix $C > 0$ when $n \to \infty$ if the system is observable, and $C$ is a function of the system and measurement covariance matrices $W$ and $V$, respectively (i.e., depends only on the signal-to-noise ratio). The Kalman gain also converges to a constant matrix. This convergence process occurs in just a few steps.

In summary, the state covariance matrix $C_n$ does not reduces indefinitely with time, it reduces until achieve a limiting constant covariance matrix $C>0$. In fact, it is not even sure that $C_n$ will decrease! If $C_0 < C$, the sequence $C_0, C_1, C_2 \dots$ increases until $C$.

See the second chapter of the following reference for a proof: Bayesian forecasting and dynamic models, by West and Harrison


问:
Where should I put the angle sensor on my cart-pole robot?
I'm using an accelerometer and gyroscope to detect the angle and tilt rate on my two-wheeled cart-pole robot.  Is there an optimal height to place the sensors?  Should I place them closer to the bottom (near the wheels), the middle (near the center of mass), or the top?  Justification for the optimal choice would be appreciated.</p>

答:
The gyroscope placement shouldn't make any difference since the rotation rate will be the same everywhere (assuming your robot is rigid enough).

The accelerometer will pick up the rigid body acceleration of the robot as well as virtual accelerations from centripetal and coriolis effects, plus gravity of course. If you are intending on using the accelerometer to track the gravity vector then you will want to minimize those virtual accelerations by placing the accelerometer closer to the centre of mass. You could potentially take advantage of the centripetal and coriolis effects to help determine the rotation rate, but I would suggest trying the simpler approach first.

Note that if you place the sensors on a pole that is flexible then you will pick up elastic deformation as well, with the effect getting worse as you place them further up high. (A long-winded way of saying watch out for vibration!)


问:
DC Motors for a ROV?
I am planning to build a homemade ROV, and I wanted to know a couple of things about the motors.  First is: Will it be Ok, if I use a brushed DC motor,  instead of a brushless motor, and is there any major disadvantages ? Second : What RPM DC motor should I aim for ? High RPM or low RPM ? Will 600rpm be enough ? The specific motor that I am talking about is    http://www.ebay.ca/itm/37mm-12V-DC-600RPM-Replacement-Torque-Gear-Box-Motor-New-/320984491847?hash=item4abc2aa747:m:mEBEQXXpqmNg4-vxmFaZP5w

Will this be a good motor for the propellers of the ROV.  I am planning to have 4 motors / propellers. Two for upward and downward thrusting,  and 2 for forward and side thrusting. The propellers that I plan to use, are basic plastic 3 blade propellers,  with diameter,  between 40mm and 50mm.

My main question is, what RPM and torque should I aim for when choosing the DC motor ?

答:
The main differences between brushed and brushless DC motors are cost, efficiency, and complexity. Brushless motors don't have brushes (surprise!) so they don't wear down as fast as brushed motors and are more efficient. However, brushless motors are more complex both in terms of construction, but also in terms of operation. That makes them more expensive and means more sophisticated electronics and software if you want precise position and torque control. (See this page for more information).

For an ROV thruster you can probably get away with brushed motors but if you have the funding then you might want brushless instead.

As for the motor specifications, you are really talking about the initial sizing for the ROV itself. From an engineering perspective you will want to figure out what torque, power, and RPM requirements you are expecting based on the propeller design and expected thrust and in-flow, then choose a motor that meets those requirements (maximizing efficiency at the expected operating condition).

If you can get access to this article, I have included most of the equations you would need in section III-C (page 7).

I suggest taking a look at this forum, you can probably find good suggestions for particular motors, propellers, or complete off-the-shelf thrusters.

Title: DC Motors for a ROV?


问:
Should the therotical parameters match the physical setup constraints when modeling a robot?
I'm working on modeling and simulation of robotic arm, after I obtained the mathematical model of the robot, I used that to implement some control techniques, to control the motion of the robot. The dimensions and masses of each links are taken from available kit, basically, it's RA02 robot with servo at each joint. After the modeling, different parameters, can be plotted: like the joint angles\speeds\torques ... etc. The point now is that, the value obtained for the joint toque is much more higher that the torque limit of the servo, does it mean my design\modeling is not realizable? Is it necessarily to get close (torque)  value for servo's torque?

Any suggestion?

答:
If your computed torques are out of the range for your robot, then you are no longer modelling your robot but a different one. You can ignore the torque limits as good as the joint angle limits of your robot (i.e. not at all).
If the required torque is to high, your robot will either be much slower (if you are lucky) or won't be able to reach its goal positions (e.g. if it's just not able to overcome gravity). </p>


问:
Ways to estimate the drift rate of the gyrometer
I found not so much literature to the topic, this is why I ask here.
Does someone know some ways to estimate the drift rate of the gyrometer.
I was thinking about basically two approaches.
One would be to use a low pass filter with a low cut-off frequency to estimate the drift of the angular velocity.
Second would be to use the accelerometer, calculate the attitude dcm and by this also the angular velocity. The difference between the acc angular velocity and gyrometer would be maybe also a drift rate.
Nevertheless, I am not so sure whether this is a good way to get reliable drift rates :D</p>

答:
If your drift is expected to be a constant bias then you should be able to measure it while the gyroscope is static. Many systems employ a feature that measures the bias for a couple of seconds when the device is powered on so that it can be subtracted from future gyroscope measurements.

However, if the drift is more of a random walk that wobbles up and down, then you will need something a bit more sophisticated. Your suggestion of using the accelerometer is good but you will need a magnetometer as well if you want to determine the attitude -- the accelerometer won't pick up any rotation if the angular velocity is aligned with the gravity vector. But overall, a sensor fusion approach is almost always better since all of your sensors will have some inherent uncertainty.


答:
I'm not sure which way you're trying to model this; forward or inverse kinematics, but the term you should look for is "saturation". Saturation means basically that the system can't continue to respond despite a signal being present. For example, a 0-10V sensor being supplied with 11V is saturated because it will only show you 10V. Likewise, your actuators saturate at $\tau_{\mbox{max}}$ despite the fact that you are asking/signalling for more torque.

I don't know how you're simulating this system (Matlab/Simulink or ROS, etc.), but Simulink has a saturation block you can use on your actuators. If you're using other software you can implement saturation yourself:

```<code>torqueMax = <max torque>;
torque = <control loop output>;
if abs(torque) > torqueMax
  torque = sign(torque) * torqueMax;
end
</code>```

You can of course have two different saturation values, one for a maximum limit and one for minimum, you'd just use two if statements to do the check.

Saturation adds nonlinear elements to your model, which may or may not be acceptable to you. If you don't want to deal with the nonlinearities this introduces, then you should lower your control gains such that your response slows down to the point that you never enter saturation.

I won't go into any more detail than to just say that "saturation is a thing" with a brief overview as your question seemed to be more in the scope of asking how to handle control/simulation outputs that exceed physical capability - I gave a code snippet above for that. If you want to read more on the subject there are a ton of articles on Google Scholar.

Title: Should the therotical parameters match the physical setup constraints when modeling a robot?

Body:
I'm working on modeling and simulation of robotic arm, after I obtained the mathematical model of the robot, I used that to implement some control techniques, to control the motion of the robot. The dimensions and masses of each links are taken from available kit, basically, it's RA02 robot with servo at each joint. After the modeling, different parameters, can be plotted: like the joint angles\speeds\torques ... etc. The point now is that, the value obtained for the joint toque is much more higher that the torque limit of the servo, does it mean my design\modeling is not realizable? Is it necessarily to get close (torque)  value for servo's torque?

Any suggestion?

Body:
I'm not sure which way you're trying to model this; forward or inverse kinematics, but the term you should look for is "saturation". Saturation means basically that the system can't continue to respond despite a signal being present. For example, a 0-10V sensor being supplied with 11V is saturated because it will only show you 10V. Likewise, your actuators saturate at $\tau_{\mbox{max}}$ despite the fact that you are asking/signalling for more torque.

I don't know how you're simulating this system (Matlab/Simulink or ROS, etc.), but Simulink has a saturation block you can use on your actuators. If you're using other software you can implement saturation yourself:

torqueMax = <max torque>;
torque = <control loop output>;
if abs(torque) > torqueMax
  torque = sign(torque) * torqueMax;
end

You can of course have two different saturation values, one for a maximum limit and one for minimum, you'd just use two if statements to do the check.

Saturation adds nonlinear elements to your model, which may or may not be acceptable to you. If you don't want to deal with the nonlinearities this introduces, then you should lower your control gains such that your response slows down to the point that you never enter saturation.

I won't go into any more detail than to just say that "saturation is a thing" with a brief overview as your question seemed to be more in the scope of asking how to handle control/simulation outputs that exceed physical capability - I gave a code snippet above for that. If you want to read more on the subject there are a ton of articles on Google Scholar.


问:
What is torque bandwidth in actuated joints and how does it affect the control systems?
The rest of my student team and I are in the process of redesigning an exoskeleton and building it based on an existing one. From the papers that we have been reading there are some references to low, high and zero impedance torque bandwith.

What is that? Does it have to do with the control system?

It is measured in Hz. Here is a table from one of the papers:

答:
The torque bandwidth is typically referring to the maximum frequency of motion at which the actuator can provide that torque. So your actuator can provide a peak torque of 100 Nm, as in it can hold up a weight of 100 N held at a torque arm of 1 m. If you want to swing that weight back and forth you could do it at up to 4 Hz, but no faster without damaging or overheating the actuator. However, if you reduce the weight to 2 Nm then you can swing it at 20 Hz.

Keep in mind that this is an oversimplification since if you were swinging a weight back and force the torque will not be constant the entire time. Still, it provides you with an idea of how fast the actuator can respond with different levels of applied torque (the torque is a resistance against the actuator, or rather an "impedance").

Note the "zero impedance" bandwidth is the same thing except with no payload weight being held at the end of the actuator torque arm -- the weight of the arm itself is the payload.


问:
MCU architecture design
Are there any standards regarding single vs multiple MCU in a robotic system? More specifically, if a single MCU can handle all of the sensor data and actuator controls, is it better to use a single MCU or multiple MCUs in a hierarchical manner? Are there any references/papers regarding this topic? What are the arguments towards one or the other? I am looking for facts, not personal opinions, so pros, cons, standards and such.</p>

答:
Although you have asked for facts and not opinions, that's a difficult thing to do. As of now, there are no current standards for much of anything in robotics. The field as a whole is so scattered with many avenues of research. In the end, it all comes down to what makes the most sense for the robot being designed. With that said, I do recall some information regarding this subject in this robotics handbook: https://www.cs.cmu.edu/~mmv/planning/readings/handbook.pdf but I'm unaware of any specific papers on this topic - most focus on some specific aspect of robotics or AI, and the controller architecture is just a means to that end.

Single Controller Architecture

For small applications or one-offs, this is a perfectly viable choice. If you know that a single MCU can handle all of the data input and actuator output, then there is nothing wrong with just using one MCU.

Pros

Fewer Components

Fewer (or none) board-board connections

Lower Cost

Less Power Use (potentially)

Less Firmware to maintain/update

Cons

Not easily expandable (limited I/O / space for code)

All components are coupled - removing 1 thing might break other things

Not modular - must redesign/reprogram similar systems in the future

No redundancy - MCU failure is catastrophic

No Fail-safe - Any blocking code stalls all systems

Multi-Controller Architecture

For larger, complex systems or those which will likely be expanded upon or used for research purposes, a multi-controller architecture is the better option. It should also be noted that robot controllers are not only MCUs, but are commonly controller using microprocessors (MPU) as well, as they are capable of processing more data at higher speeds.

Pros

Modularity - simple systems can be reused (motor drivers, sensor interfaces)

Easy to swap to different sensors using documented interfaces

Decoupled components - Switching to a different sensor or motor does not affect other systems

Multiple controllers could be less expensive than one powerful one

Timing - different systems can run at different clock speeds

Simple firmware - specific code is less cluttered

Well known and easy to implement serial interfaces (SPI, I2C, USB, etc)

Able to split control into layers of abstraction

Cons

More components to manage

More power usage

Complicated hardware infrastructure

More cables to run

Wrapping Up

It's obvious that the pros of one architecture are the cons of the other, and vice versa. This is to be expected. For complex robotic systems, it is common (not necessarily standard, but typical) to break the problem down into smaller chunks - using small MCU circuits that do very specific things. These can then be grouped together, whatever makes sense to you.

For example, there could be one central controller for all motor drivers or distance sensors. Similarly, all of the drivers for one section of a robot could be grouped together, such as a single arm in a humanoid robot. All of these mid-level-controllers are then commanded by a single high-level controller which decides when and why to do things, but doesn't really care how it gets done.

On the other hand, for a simple robot using a vary unique structure that is unlikely to be reused, a single central controller is often used.

Title: MCU architecture design


问:
Is it possible to do SLAM with few IR sensors like Buddy?
I saw Buddy's page and want to purchase for my SLAM research. However, I wonder is it possible to program Buddy for SLAM?

According to Buddy's spec, they're only few IR's, sonars and a camera. As I know, most SLAM algorithms are implemented with powerful sensors such as RGBD/stereo camera, or even laser range finder.

Are there any pepers mention about IR-based SLAM?

答:
SLAM can be done Using many different way, in this case,
Yes Buddy can map around him using its sensors :
RGB camera, IR sensor, Ultra sound Sensor, Encoder.
The result depend of the algorithme you are using.

We are also working on a 3D camera to allow buddy to have a better input of the world.


问:
How to connect an Arduino Uno to an Android phone via USB cable?
Is it possible to set up communication between an Arduino Uno and an Android phone using a wire that directly connects the Android phone and the Arduino?</p>

答:
Whilst your question would be better suited to the Arduino StackExchange site, I shall attempt to answer it nevertheless. Below is the method that I have used in the past, however, there are, obviously, more than one way to skin a cat... For example the same question was asked a few years ago on EE.SE, Connect Android device to Arduino Uno via USB.

The answer to your question may be found here, Android USB host + Arduino: How to communicate without rooting our Android tablet or phone. However there are some pre-requisites for the Android device that you are intending to use:

You will require an Android device that supports USB host mode as well
  as the USB host API. Most Android 3.1+ tablets will suffice (some may
  require an USB OTG adapter). Also, the Galaxy Nexus has host mode
  enabled and matches the requirements (you will need an USB OTG adapter
  however).

I shall quote the information from the above page, in the case of link death.

This example consists of two parts:

The Android application that makes use of the USB API

A simple Android
  app that let’s you regulate the brightness of an LED on the Arduino
  using a slider. It also features a button to “enumerate” the USB
  device.

Firmware for the Arduino that does some serial I/O with the
  Android app

Very basic firmware for the Arduino. An interrupt is
  generated when a new byte is received. The received data controls the
  brightness of the Arduino’s on-board LED. (implemented via
  usleep-style software pwm in the main loop).

The Arduino Code:

```<code>int main(void) {
    //initialization
    initIO();
    uart_init();
    sei();

    uint8_t i = 0;
    volatile uint8_t pause;

    for(;;){//this is the main loop
        pause = data;
        PORTB |= (1 << LED);
        for(i = 0; i < pause; i++)
            _delay_us(10);
        PORTB &= ~(1 << LED);
        for(i = 0; i < 255-pause; i++)
            _delay_us(10);
    }
}
</code>```

The Arduino Interrupt routine:

```<code>ISR(USART_RX_vect) {//attention to the name and argument here, won't work otherwise
    data = UDR0;//UDR0 needs to be read
}
</code>```

The Android  source code is available here: UsbController.tar.gz*.

You may need to change the PID value in UsbControllerActivity.java on line 38, if you have an Arduino Uno Rev3 or higher. You can check the VID/PID value with ‘lsusb’ after connecting the Arduino to your computer.

Most of the code is pretty standard, however, it is worth paying attention to the following UsbRunnable class:

```<code>private class UsbRunnable implements Runnable {
    private final UsbDevice mDevice;

    UsbRunnable(UsbDevice dev) {
        mDevice = dev;
    }

    @Override
    public void run() {//here the main USB functionality is implemented
        UsbDeviceConnection conn = mUsbManager.openDevice(mDevice);
        if (!conn.claimInterface(mDevice.getInterface(1), true)) {
            return;
        }
        // Arduino USB serial converter setup
        conn.controlTransfer(0x21, 34, 0, 0, null, 0, 0);
        conn.controlTransfer(0x21, 32, 0, 0, new byte[] { (byte) 0x80,
                0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }, 7, 0);

        UsbEndpoint epIN = null;
        UsbEndpoint epOUT = null;

        UsbInterface usbIf = mDevice.getInterface(1);
        for (int i = 0; i < usbIf.getEndpointCount(); i++) {
            if (usbIf.getEndpoint(i).getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
                if (usbIf.getEndpoint(i).getDirection() == UsbConstants.USB_DIR_IN)
                    epIN = usbIf.getEndpoint(i);
                else
                    epOUT = usbIf.getEndpoint(i);
            }
        }

        for (;;) {// this is the main loop for transferring
            synchronized (sSendLock) {//ok there should be a OUT queue, no guarantee that the byte is sent actually
                try {
                    sSendLock.wait();
                } catch (InterruptedException e) {
                    if (mStop) {
                        mConnectionHandler.onUsbStopped();
                        return;
                    }
                    e.printStackTrace();
                }
            }
            conn.bulkTransfer(epOUT, new byte[] { mData }, 1, 0);

            if (mStop) {
                mConnectionHandler.onUsbStopped();
                return;
            }
        }
    }
}
</code>```

After the USB interface has been claimed the Arduino USB serial
  converter is initialized by issuing the following control transfers:

```<code>conn.controlTransfer(0x21, 34, 0, 0, null, 0, 0);
conn.controlTransfer(0x21, 32, 0, 0, new byte[] { (byte) 0x80,
                0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }, 7, 0);
</code>```

The first call sets the control line state, the second call sets the
  line encoding (9600, 8N1). For communication, an additional thread is
  used to send data without blocking the Activity’s main UI thread. By
  notifying sSendLock of the UsbController the data will be transferred.
  After submission, the thread will go into “wait” again. This way, even
  if submission takes more time than expected, the Activity’s main
  thread will not be blocked and hence the app will not become
  unresponsive.

Body:
Whilst your question would be better suited to the Arduino StackExchange site, I shall attempt to answer it nevertheless. Below is the method that I have used in the past, however, there are, obviously, more than one way to skin a cat... For example the same question was asked a few years ago on EE.SE, Connect Android device to Arduino Uno via USB.

The answer to your question may be found here, Android USB host + Arduino: How to communicate without rooting our Android tablet or phone. However there are some pre-requisites for the Android device that you are intending to use:

You will require an Android device that supports USB host mode as well
  as the USB host API. Most Android 3.1+ tablets will suffice (some may
  require an USB OTG adapter). Also, the Galaxy Nexus has host mode
  enabled and matches the requirements (you will need an USB OTG adapter
  however).

I shall quote the information from the above page, in the case of link death.

This example consists of two parts:

The Android application that makes use of the USB API

A simple Android
  app that let’s you regulate the brightness of an LED on the Arduino
  using a slider. It also features a button to “enumerate” the USB
  device.

Firmware for the Arduino that does some serial I/O with the
  Android app

Very basic firmware for the Arduino. An interrupt is
  generated when a new byte is received. The received data controls the
  brightness of the Arduino’s on-board LED. (implemented via
  usleep-style software pwm in the main loop).

The Arduino Code:

int main(void) {
    //initialization
    initIO();
    uart_init();
    sei();

    uint8_t i = 0;
    volatile uint8_t pause;

    for(;;){//this is the main loop
        pause = data;
        PORTB |= (1 << LED);
        for(i = 0; i < pause; i++)
            _delay_us(10);
        PORTB &= ~(1 << LED);
        for(i = 0; i < 255-pause; i++)
            _delay_us(10);
    }
}

The Arduino Interrupt routine:

ISR(USART_RX_vect) {//attention to the name and argument here, won't work otherwise
    data = UDR0;//UDR0 needs to be read
}

The Android  source code is available here: UsbController.tar.gz*.

You may need to change the PID value in UsbControllerActivity.java on line 38, if you have an Arduino Uno Rev3 or higher. You can check the VID/PID value with ‘lsusb’ after connecting the Arduino to your computer.

Most of the code is pretty standard, however, it is worth paying attention to the following UsbRunnable class:

private class UsbRunnable implements Runnable {
    private final UsbDevice mDevice;

    UsbRunnable(UsbDevice dev) {
        mDevice = dev;
    }

    @Override
    public void run() {//here the main USB functionality is implemented
        UsbDeviceConnection conn = mUsbManager.openDevice(mDevice);
        if (!conn.claimInterface(mDevice.getInterface(1), true)) {
            return;
        }
        // Arduino USB serial converter setup
        conn.controlTransfer(0x21, 34, 0, 0, null, 0, 0);
        conn.controlTransfer(0x21, 32, 0, 0, new byte[] { (byte) 0x80,
                0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }, 7, 0);

        UsbEndpoint epIN = null;
        UsbEndpoint epOUT = null;

        UsbInterface usbIf = mDevice.getInterface(1);
        for (int i = 0; i < usbIf.getEndpointCount(); i++) {
            if (usbIf.getEndpoint(i).getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
                if (usbIf.getEndpoint(i).getDirection() == UsbConstants.USB_DIR_IN)
                    epIN = usbIf.getEndpoint(i);
                else
                    epOUT = usbIf.getEndpoint(i);
            }
        }

        for (;;) {// this is the main loop for transferring
            synchronized (sSendLock) {//ok there should be a OUT queue, no guarantee that the byte is sent actually
                try {
                    sSendLock.wait();
                } catch (InterruptedException e) {
                    if (mStop) {
                        mConnectionHandler.onUsbStopped();
                        return;
                    }
                    e.printStackTrace();
                }
            }
            conn.bulkTransfer(epOUT, new byte[] { mData }, 1, 0);

            if (mStop) {
                mConnectionHandler.onUsbStopped();
                return;
            }
        }
    }
}

After the USB interface has been claimed the Arduino USB serial
  converter is initialized by issuing the following control transfers:

conn.controlTransfer(0x21, 34, 0, 0, null, 0, 0);
conn.controlTransfer(0x21, 32, 0, 0, new byte[] { (byte) 0x80,
                0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }, 7, 0);

The first call sets the control line state, the second call sets the
  line encoding (9600, 8N1). For communication, an additional thread is
  used to send data without blocking the Activity’s main UI thread. By
  notifying sSendLock of the UsbController the data will be transferred.
  After submission, the thread will go into “wait” again. This way, even
  if submission takes more time than expected, the Activity’s main
  thread will not be blocked and hence the app will not become
  unresponsive.


问:
Sourcing motors by physical dimensions
I have a 1inch square tube that I would like to place a motor into.

The motor I have takes up approximately 1/2 of the available space (roughly 3/4 inch I.D.) I would like to find the largest motor that will fit in the space without having to cobble too much of a housing.

Where/how can i find motors by physical dimensions?

答: Digikey has the ability to sort by physical size (body diameter). I would have thought other sites would offer this as well, but Mouser and Tower Hobbies don't appear to. </p>

Title: Sourcing motors by physical dimensions


问:
Are there any aerodynamics modeling/simulation software that is capable to consume a SolidWorks model and to interface with MATLAB/Simulink?
Currently I am developing a control system for an aircraft of a unique design (something in between a helicopter and a dirigible). At this moment I can model only the dynamics of this vehicle without any aerodynamic effects taken into account. For this I use the following work-flow:

Mechanical model in SolidWorks -> MSC ADAMS (Dynamics) <--> MATLAB/Simulink (Control algorithms)

Thus, the dynamics of the vehicle is modeled in ADAMS and all control algorithms are in MATLAB/Simulink. Unfortunately, ADAMS can not simulate any aerodynamic effects. As a result, I can not design a control system that is capable to fight even small wind disturbances.

答:
Matlab has a package called Simscape that you can use for modeling physical systems in general. I would just caution you up front that Simscape is almost more like a plugin manager in that it enables other modules and doesn't offer a terrific amount of content on its own. This means you get to buy Simscape, then buy whatever other toolboxes you want that require Simscape. That said, if you're using Solidworks, you/your company is probably no stranger to paying good money for (great) software tools.

Once you have Simscape, you can purchase/install a package called SimMechanics. This package has the capability to interface with Solidworks; see the videos here and here (the second video is embedded in this page in case you have trouble accessing it).

Lastly, there's an Aerospace Blockset for Simulink that helps you model wind, but I'm not an aero guy and haven't used this set, so I can't comment on how useful it may be.


问:
Advanced Line Following Robot of Maze Solving
I know how to make a line follower. But in this video what have they done exactly? They are giving the source and destination in the map but how the robot moves based on the instruction given in map?

What is the procedure to do it? They have mapped the path. Please do watch the video.

答:
See this similar question and my answer to it. The question I linked asks for how to handle an unknown starting position, but it seems similar in that you and the other OP are both asking "how do I go from Dijkstra's algorithm to implementation?"

Essentially, Dijkstra's algorithm only requires to you give a digraph with a set of distances or "costs" between the two points. Dijkstra's algorithm gives you the series of waypoints that will get you/your vehicle from any one arbitrary point to another arbitrary point at the lowest cost, based on the cost information you provided. If you don't give it correct cost information it won't give you the optimal route; this is akin (actually) a map routing program that might send you on a back road because it only looked at distance and not distance at a given speed limit, or through a downtown area in rush hour because it doesn't account for traffic.

So it is up to you to calculate the distances between points and to know the physical relationship between two points. (read:heading)

So, for example, if you store all of the coordinates for the points in addition to the digraph and distances, you could try:

```<code>currentWaypoint = [x0,y0];
nextWaypoint = [x1,y1];
currentHeading = theta0;

nextHeadingAbsolute = atan2( (y1-y0) , (x1-x0) );
nextHeadingRelative = nextHeadingAbsolute - currentHeading;

driveDistance = sqrt( (x1-x0)^2 + (y1-y0)^2 );

turnRobot(nextHeadingRelative);
driveRobot(drivieDistance);
</code>```

This snippet/example assumes that you measure heading as 0 radians as the +x-axis, with angle increasing in a counter-clockwise direction. You can make any other axis be the zero by adding an offset, and can convert to degrees if you desire.

Basically you just find the angle between the coordinates relative to the global x/y axes, then subtract your current heading from that. Drive distance would then be along the hypotenuse, which you can calculate using the Pythagorean Theorem.

Body:
See this similar question and my answer to it. The question I linked asks for how to handle an unknown starting position, but it seems similar in that you and the other OP are both asking "how do I go from Dijkstra's algorithm to implementation?"

Essentially, Dijkstra's algorithm only requires to you give a digraph with a set of distances or "costs" between the two points. Dijkstra's algorithm gives you the series of waypoints that will get you/your vehicle from any one arbitrary point to another arbitrary point at the lowest cost, based on the cost information you provided. If you don't give it correct cost information it won't give you the optimal route; this is akin (actually) a map routing program that might send you on a back road because it only looked at distance and not distance at a given speed limit, or through a downtown area in rush hour because it doesn't account for traffic.

So it is up to you to calculate the distances between points and to know the physical relationship between two points. (read:heading)

So, for example, if you store all of the coordinates for the points in addition to the digraph and distances, you could try:

currentWaypoint = [x0,y0];
nextWaypoint = [x1,y1];
currentHeading = theta0;

nextHeadingAbsolute = atan2( (y1-y0) , (x1-x0) );
nextHeadingRelative = nextHeadingAbsolute - currentHeading;

driveDistance = sqrt( (x1-x0)^2 + (y1-y0)^2 );

turnRobot(nextHeadingRelative);
driveRobot(drivieDistance);

This snippet/example assumes that you measure heading as 0 radians as the +x-axis, with angle increasing in a counter-clockwise direction. You can make any other axis be the zero by adding an offset, and can convert to degrees if you desire.

Basically you just find the angle between the coordinates relative to the global x/y axes, then subtract your current heading from that. Drive distance would then be along the hypotenuse, which you can calculate using the Pythagorean Theorem.