问:
rospack Error: package 'script' not found
I am trying to run rosrun script forward.py but it gives me an error saying [rospack] Error: package 'script' not found

In my bashrc I've added these lines:

```<code>source /opt/ros/indigo/setup.bash
source /home/hassan/catkin_ws/devel/setup.bash
export ROS_PACKAGE_PATH=/home/home/catkin_ws:/opt/ros/indigo/share:/opt/ros/indigo/stacks
export ROS_WORKSPACE=/home/hassan/catkin_ws
</code>```

What could be the reason?
I am following this video: https://www.youtube.com/watch?v=zwTnY-ZqNcM&t=102s

答:
There may be several reasons:

You haven't compiled all your projects in the workspace, to fix it go to your workspace cd ~/catkin_ws then execute catkin_make. If it works and you don't have compilation errors, source your workspace source ~/catkin_ws/devel/setup.bash, then re-try.

When you are typing rosrun script forward.py, you expect to launch the script forward.py from the package script. Check if your folder ~/catkin_ws/src/script exists, if not this cannot work!


问:
Quaternion error in one degree of freedom
I would like to control a system which orientation I measure with as quaternion based EKF in one degree of freedom. Obviously the simplest thing would be to convert the quaternion estimate to euler angles and take one of these. Unfortunately these euler angles are not stable. The other option I was thinking about was to use the so called quaternion error, where I specify another quaternion which I want my system to be controlled towards. Then I would have to specify all four values of this quaternion. </p>

<p>I'm wondering if there is a way to generate a quaternion error only for one of my angles? </p>

答: If your system has a fixed rotation about some axis, then you should be able to design your KF about a single angle of rotation. You should be able to tailor your equations of motion and measurements to be a function of that angle. </p>

ContentLicense: CC BY-SA 4.0


问:
Computing the Jacobian matrix for Inverse Kinematics
When computing the Jacobian matrix for solving an Inverse Kinematic analytically, I read from many places that I could use this formula to create each of the columns of a joint in the Jacobian matrix:

$$\mathbf{J}_{i}=\frac{\partial \mathbf{e}}{\partial \phi_{i}}=\left[\begin{array}{c}{\left[\mathbf{a}_{i}^{\prime} \times\left(\mathbf{e}_{p o s}-\mathbf{r}_{i}^{\prime}\right)\right]^{T}} \\ {\left[\mathbf{a}_{i}^{\prime}\right]^{T}}\end{array}\right]$$

Such that $a'$ is the rotation axis in world space, $r'$ is the pivot point in world space, and $e_{pos}$ is the position of the end effector in world space.

However, I don't understand how this can work when the joints have more than one DOFs. Take the following as an example:

The $\theta$ are the rotational DOF, the $e$ is the end effector, the $g$ is the goal of the end effector, the $P_1$, $P_2$ and $P_3$ are the joints.

First, if I were to compute the Jacobian matrix based on the formula above for the diagram, I will get something like this:

$$J=\begin{bmatrix}
((0,0,1)\times \vec { e } )_{ x } & ((0,0,1)\times (\vec { e } -\vec { P_{ 1 } } ))_{ x } & ((0,0,1)\times (\vec { e } -\vec { P_{ 2 } } ))_{ x } \\ ((0,0,1)\times \vec { e } )_{ y } & ((0,0,1)\times (\vec { e } -\vec { P_{ 1 } } ))_{ y } & ((0,0,1)\times (\vec { e } -\vec { P_{ 2 } } ))_{ y } \\ ((0,0,1)\times \vec { e } )_{ z } & ((0,0,1)\times (\vec { e } -\vec { P_{ 1 } } ))_{ z } & ((0,0,1)\times (\vec { e } -\vec { P_{ 2 } } ))_{ z } \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ 1 & 1 & 1
\end{bmatrix} $$

This is assumed that all the rotation axes are $(0,0,1)$ and all of them only have one rotational DOF. So, I believe each column is for one DOF, in this case, the $\theta_\#$.

Now, here's the problem: What if all the joints have full 6 DOFs? Say now, for every joint, I have rotational DOFs in all axes, $\theta_x$, $\theta_y$ and $\theta_z$, and also translational DOFs in all axes, $t_x$, $t_y$ and $t_z$.

To make my question clearer, suppose if I were to "forcefully" apply the formula above to all the DOFs of all the joints, then I probably will get a Jacobian matrix like this:

(click for full size)

But this is incredibly weird because all the 6 columns of the DOF for every joint is repeating the same thing.

How can I use the same formula to build the Jacobian matrix with all the DOFs? How would the Jacobian matrix look like in this case?

答:
Your formula for a 6 dof joint assumes that all 6 joints have the axis $(0, 0, 1)$ in the world frame and that all joints are revolute. Since the 6 joints are thus identical, their columns in the Jacobian are also identical.

Starting over, suppose a joint has an axis $a$ going through a point $r$. Let $e$ be the position of the end-effector. The coordinates of $a$, $r$, and $e$ are all given in the world frame and are being updated as the robot is being moved. The axis $a$ has length $1$.

If the joint is revolute, the column of the Jacobian for the joint is

$J_{\theta}(a, r) = \left[\begin{matrix}
 a \times (e - r) \\
 a
\end{matrix}\right]$

If the joint is prismatic, the column is

$J_{p}(a) = \left[\begin{matrix}
 a \\
 0
\end{matrix}\right]$

Suppose we have a 6 dof joint which is not only spherical but can translate in space too. Suppose the axes of the joint are $a_x$, $a_y$, and $a_z$ and that each revolute and prismatic joint shares an axis, so that the Jacobian for the joint becomes

$J = \left[\begin{matrix}
  J_p(a_x) & J_p(a_y) & J_p(a_z) & J_{\theta}(a_x, r) & J_{\theta}(a_y, r) & J_{\theta}(a_z, r)
\end{matrix}\right]$

The axes $a_x$, $a_y$, and $a_z$ depend on the forward kinematics of the robot. To illustrate, let the transformation of the $k$th joint in the world frame be given by

$F_k = \prod_{i=1}^{k} L_i T_i$

where the transformations $L_i$ are constants, and the transformations $T_i$ depend on the joint variables. Let $R_c(q)$ and $P_c(q)$ be the transformations that rotate and translate by $q$ about the coordinate axis named $c$ (either $x$, $y$, or $z$).

Let $\Delta q = (\Delta p_x, \Delta p_y, \Delta p_z, \Delta \theta_x, \Delta \theta_y, \Delta \theta_z)$ be a displacement, computed by help of the Jacobian, for the $i$th joint. Let $\Delta T = P_x(\Delta p_x) P_y(\Delta p_y) P_z(\Delta p_z) R_x(\Delta \theta_x) R_y(\Delta \theta_y) R_z(\Delta \theta_z)$ and update the local transformation of the joint by:

$T_i \leftarrow T_i \, \Delta T$

In this formulation of the forward kinematics, the axes $a_x$, $a_y$, and $a_z$ of joint $i$ are exactly the columns of the rotation matrix of $F_i$. Also the position $r$ is the translation vector of $F_i$.

ContentLicense: CC BY-SA 3.0


问:
I must determine the resolution of a control system when using an 8-bit encoder for a single-rotation joint

The length of the link is 50 cm and the arm moves 180 degrees. Can anyone help me?

Out of the cosine theorem, $d = \ell \sqrt{2\left(\ell-cos\right)}$, I calculated the distance traveled by a linear axis and the rotation arc through the rotation connection.

The circumfence is $2\pi R$. And $d$, for my drawing is $d=50\sqrt{2\left(50+1\right)}=50\sqrt{101}$

The distance is 502 cm and the rotation is 9000 cm. From here, I don't know what to do. I can't find any equation for the resolution.

I only have the values that I said, and I need to determine the resolution for the control system, when an encoder of 8-bit is used. I don't have anything else..This is the whole exercise. I understand if it's not clear enough. It isn't for me, either.

Body: 2*pi/(2^8) is correct..............


问:
How a quadcopter pitch/roll impacts thrust?
I'm thinking about how a quadcopter flight controller works, and I usually see that each motor speed is determined by a formula like:

```<code>speed_motor_1 = throttle + pitch_pid + roll_pid + yaw_pid
</code>```

This looks fine, but one thing I was considering is throttle -> thrust is not so straightforward.
For instance, a quadcopter in horizontal position have propellers pointing up and the thrust may be X. If you pitch this quadcopter by 30 degrees, now the propellers vector force is inclined and thrust it is X*cos(30 degrees)

Does that make sense? Is that something that must be taking into consideration when calculating "throttle" in the aforementioned formula?

Thanks

答: Typically max-thrust will be bigger than vehicle weight, so that the quadcopter can accelerate upwards.</p>


问:
Head movement using gyroscope
I have a headset that provides 3 axis gyroscope readings. I wish to find out movement of head for e.g. if a person is nodding left to right etc. But the headset give me values in angular velocity for each axis. How can i process these values to get head movement in real time? </p>

答:
You would have to integrate the rotational kinematics equations forward in time with a known initial orientation, such as R(0) = eye(3,3) -- identity matrix.  You will have drift issues if you go out too far in time of course.  But, in any case, now you have an 'estimate' of R(t).  Or get a 3-axis gyro from microstrain.com that gives you R(t).

Is there any way i can find by what angle and in which axis the head is rotated?

Yes, that is the standard Rot-k-theta conversion, for the 3x1 vector k and angle theta. Given R, k and theta are trivially found. See page 51 "Equivalent angle-axis" section of the below book, e.g.: Craig, Introduction to Robotics, 2nd Ed., ISBN 0-201-09528-9. You can get it for free from your interlibrary loan... Rot(k,th) is easily derived, btw, and from it you can derive the standard quaternion equations, although you don't need those here per se.

Title: Head movement using gyroscope


问:
Localization in box using rangefinders
Let's say I have a robot, located in a box. The robot can move in the x and y and rotate.

The robot has 4 rangefinders, mounted 90 degrees apart, that measure the distance to the walls of the box (I think it would be possible with just 3 but let's use 4 as an example). The robot also has an "approximate" +-10 degree estimate of its heading, so it knows in general which quadrant its bearing should be in.

Given this information, how can I calculate the "exact" position and bearing of the robot?

Intuitively I know this should easily be possible as there are three degrees of freedom for the system (x,y, and the angle), but I can't think of a way to actually calculate the position.

答: Suppose your coord axis is at the center of the box and the axes parallel to the walls o the box.  Distance to the min-y-wall tells you y.  Distance to the min-x wall gives you x, with the obvious offsets added in.  Crazy-easy unless I misunderstood.</p>

Title: Localization in box using rangefinders


问:
Accuracy of hall sensor encoders on Raspberry Pi
I have 2 motors (JGA25-370) with hall-sensor encodes.
They emit about 90-100 interrupts every 100ms, so 1000 a second.
Which means I have an interrupt happening every 1ms.

The motors are driven by PCA9685 PWM board and L298N H-Bridge driver.

It's all being operated from Raspberry Pi using a program written in Rust.
It starts 2 threads for sysfs interrupts and emits events when rising edge is detected.

Now, the problem is that the readings are not as consistent as I expected.
I have another thread where I take measurements every 100ms.
This is an example of the results:

```<code>90
81
90
90
85
90
89
79
89
89
79
87
80
88
90
90
79
89
</code>```

The motor is not under any load, just holding it in my hand.

The problem for me are those random jumps from 89 -> 79 -> 89 event though the motor is not under load (except for a built-in gearbox). It makes PID control very hard when I'm adjusting for a 10% drop, but the motor did not slow down.

So I guess my questions are:

 1. Is it just a normal thing and hall effect sensors are just not that precise?

 2. Is it caused by Raspberry Pi not being able to handle interrupts in an accurate manner?

答:
Thanks to @RobReus, who pointed me to a Youtube video describing my issue I was able to fix it.

The issue was in fact my Raspberry Pi not being able to keep up with the amount of interrupts a second and losing some of the events.

The solution I came up with is to attach hall sensor to my Arduino Nano which is connected to Rpi via serial port.

Interrupts are incrementing counters for left and right wheels and then send the data via serial port every 100ms to RPi.

I get consistent readings now and PID control is finally working as expected!


问:
How can I preserve a high framerate while using at least 1280x720 resolution on 2 USB cameras on the same computer?
To expand on this, I have a down-facing camera using the whycon ROS node on Ubuntu 16.04 Kinetic on a quad-core computer with 640x480@60fps MJPG video. I'm also using the usb_cam node to publish the image_raw. I've noticed that the overall CPU consumption would already be above 90% for all 4 cores whenever I try to run just these 2 nodes.

But I also want to add a secondary front-facing USB camera that will only be for streaming video to another computer. This secondary camera ideally should have a 1280x720 resolution. I tried to run both cameras at the same time, but the 1280x720 one is only at 10-12fps, which is too slow for my purposes. Additionally, it would be great if I can also have the whycon node to be using 1280x720, but I think the framerate should have a higher priority.

I realize that I can lower both resolutions to 640x480 and that should help with the framerate issue, but is that really the only way to ensure a smoother video?

I also have a single USB 3.0 port and 2 USB 2.0 ports on my computer and I have plugged in the front-facing camera into the USB 3.0 port. I've also already ran v4l2-ctl --list-formats-ext on my cameras (they are exactly the same) and they both are only capable of 60fps up to 1920x1080.

EDIT: A follow-up question I have is if it would be better to switch to a different computer with a better processor? What I'm currently using has the Intel Cherry Trail 1.8 Ghz Quadcore.

EDIT2: @kaliatech If I run the front camera at 1280x720, I can get up to 34fps with 1 CPU core maxing out at 100% at a time and the rest at more or less 25%. If I run just the down-facing camera at 640x480, I can get up to 60fps with CPU usage around 55% for 1 core while the rest are less than 20%. If I have both the down-facing cam and the whycon node running, I still have 60fps from usb_cam but CPU usage maxes out at 100% and 70% for 2 cores. Finally, if I run all three, the down-facing cam remains the same in terms of framerate but the front-facing has around 12 fps and at least 2 cores max out with the rest at above 60%. At this point, I'm not currently transferring the videos through the network. I'm still conducting some tests on the local computer, but you would be right that it will be much worse on a slower network. I will try to use a different camera driver like cv_camera but I think I skipped it since it seemed older than usb_camera and even less supported

EDIT3: I tried using cv_camera but the resulting framerate seemed about the same, if not worse.

答:
Here are a few things to consider:

First, do you know where the actual bottleneck(s) are? Some possibilities: the usb camera driver or usb_cam and related settings (especially if having to compress/uncompress/transpose the video format without hardware support), cpu processing (perhaps whycon is overloading), network bandwidth/latency/processing (what type and speed network are you using?), or the final video decoding/display. Any one of those could be affecting the frame rates.

If you are trying to transfer HD resolutions over a slower network in MJPG, then that could explain the lower frame rate. And depending on your hardware, some network interfaces require use of main CPU, would could also be adding to the overall CPU load.

MJPG is not very good for capturing and streaming at higher resolutions & rates over a network, compared to something like H264 or other stream based encoders. You mention publishing image_raw, which would require significantly even more bandwidth, though it's unclear to me where in your ROS node network you are doing this.

Some cameras have onboard hardware based encoders, which can significantly lighten the main CPU load. It requires support on both sides though (camera and driver). I'm not sure if usb_cam supports on camera encoding (I don't think it does, but not positive.) It might be worth try something like libuvc_camera, or cv_camera, and experimenting with settings and formats to see if you can get lower CPU and better frame rates.

If this info doesn't help, I would suggest adding more information about the cameras you are using, your network setup, and more about your intended use-case.

I would also suggest testing, if you haven't already, what kind of cpu and framerates you can get from the front camera at 1280x720 without simultaneously running the primary camera and without running whycon.  Based on what you find from doing that, you can probably add more info to your question, or start a new question, to get better answers.


问:
underactuated robot problem
Lets say the robot has 4Dof and the operator gives (x,y,z,roll,pitch,yaw ) as control input( rank(J) < dim(task) ).

Now the robot is overwhelmed and will probably show some jerky movement.
But can someone please explain in a mathematical way why a robot with 4 Dof cannot perform a task of 6 dim. ?

答:
It is hard to tell your mathematical background from the question, so maybe an explanation for a more simple, but similar, problem will help.

Let’s say you have a 1 DOF robot, and command it with 2 DOF tasks.  It has a link length of 1, so it can move along a unit circle about the origin of a coordinate system.  If you command it to go to position (1, 0), it will do so.  Same thing if you command (0, 1), or (0.707, 0.707).  But if you tell the robot to go to (1, 1), or (0.2, 0.5), or any of a double infinity of other points, it cannot achieve that pose.  It will not perform “jerky motion”; instead, the math will not be solvable.

Mathematically, the inverse kinematics are unsolvable.  For the situation you describe, you are trying to solve six independent equations using only four variables.

Title: underactuated robot problem


答:
The question has mixed up two different problems: model predictive control (MPC) and underactuated robot. MPC is about the question which control signals the operator has to send to the robot to reach a certain situation, while underactuation means to use a kinematic chain which has at one point not a motor but a freely movable connection, similar to a rope which hangs from the ceiling.

What kinds of motion a robot can do who is underactuated depends on the so called system identification process. This is about describing the future states a system can reach. System identificiation for underactuation is not more complicated but easier than for a normal system. This sounds paradox. But can be explained with the reason, why underactuation was introduced in robotics.

Title: underactuated robot problem

Body:
Lets say the robot has 4Dof and the operator gives (x,y,z,roll,pitch,yaw ) as control input( rank(J) < dim(task) ).

Now the robot is overwhelmed and will probably show some jerky movement.
But can someone please explain in a mathematical way why a robot with 4 Dof cannot perform a task of 6 dim. ?


问:
Is system identification and a physics engine the same?
In the control theory the term “system identification” is used quite often. A typical sentence in a robotics oriented paper is that the author is trying to “build a model of a plant with matlab”. The idea is, that the model can predict future states of the system and is able to estimate the temperature. The plant is the system, and system identification means to formalize the inner working.

In gaming oriented software development a similar task is done quite often. Each game needs a so called game engine. Part of the game engine is the physics engine which simulates the behavior of the system. A prominent example is the “incredible machine (1992)” physics engine which was the first example for a DOS based game which has provided a realistic rigid body simulation. Similar to system identification in control theory, the simulation was realized with differential equations. In case of a rigid body engine that a newtons equation about mass and velocity under gravity.

My question is: is system identification and a physics engine both the same? And secondly, why are game designer and control engineers are not talking to each other, Is that an example for communication failure between specialists?

答:
No. If we want to simplify things, system identification is more like curve fitting then a game engine.

System identification is used to identify a set of parameters of an existing model or a model which matches reality. The model obtained is then used in a numerical simulation.

The numerical simulation is related to physics engines. Physics engines are numerical simulation "engines" for mechanical phenomena. In most cases there are not focused on precision, but on a balance between precision and performance. There are many other simulation tools available for (controls) engineers, which are (arguably) more precise then game engines. Examples are the Matlab-Simulink-SimMechanics or AlgoryX. Furthermore, many engineering simulation tools include also options to simulate electrical, thermal phenomena.

A concrete example would be the parameters of a car suspension. There is an analytical model of the mechanism and the spring and damper. This can be very well recreated in a physics engine if we have all the parameters (geometrical, spring and damper coefficients).

An even more precise model is a finite element model which would take into account elastic deformation of the linkages. An even more precise model would take into account the exact fluid motions in the hydraulic damper. Since finite element models and computational fluid dynamic models are very slow (take hours to complete, if not days), these cannot be used in a game which requires a 16ms (60 fps) cycle time. These simulations would need the material properties (both for fluid and metal) as parameters.

System identification can be used to identify the material properties as parameters or as a function (model) or the spring and damper coefficients (again as parameter or as a function). These can be used in the simulation (or in the physics engine) to obtain results that match reality as close as possible.

Control Engineers may or may not talk to physics engine developers, but most certainly both groups are in close contact with numerical simulation experts.


问:
Should I use an arduino to control my balancing robot's motors?
I'm building a 2-wheel balancing robot from old parts. DC motors from an old printer, wheels from a BBQ, bodywork from an old optical drive etc.

The brain of the robot is a Raspberry Pi 3. I'm using an L298N motor driver to control 2x 12-35v DC motors. Balance and movement will be 'sensed' using a 10DOF L3GD20 LSM303D Gyro, Accelerometer & Compass board. I'm currently using an Arduino with PWM for multi speed and direction of each motor. A PID loop will keep the robot balanced.

It looks like this:
Raspberry Pi > Arduino > L298N > Motors

So far everything is good (don't worry I'm not going to ask "Where do I start??" :D)

My question is this: should I continue to control the sensors and motors' driver using the Arduino, having the Pi issue higher level commands to the Arduino, OR should I just let the Pi do all the leg work?

I'm trying to keep power consumption to a minimum but I want to keep the processing overhead of the balancing and movement away from the Pi. Additionally, I've read that an Arduino is better at this sort of work due to the fact that it has a built in clock, where a Pi doesn't. I assume the PID loop will be slowed if the device (the Pi) is working on other processing tasks like navigation and face recognition etc.

Are my assumptions correct and which direction would guys steer towards?

Your knowledge and wise words would be very much appreciated!!

答: I was also faced with this dilemma. I was using Arduino to read Kp, Ki and Kd from potentiometers and transferring the data over Serial port to a Raspberry Pi. I found that I had to put a delay of atleast 20 ms on the Arduino side for the Pi to capture the data correctly. If I transmitted the data without any delay, the Pi was unable to cope up with the stream of incoming data. So I decided to do all the balancing and moving part on Arduino. I will use OPEN-CV for image processing and use Pi to send command over Serial port to navigate the robot.  </p>


问:
Loop time for self balancing robot
I have been working on a self balancing robot and there are quite a few parameters and one of them is loop execution time (t_loop henceforth). To my understanding, the smaller t_loop, the better it is for the control algorithm. But, since the motors also need to be given sufficient time to react, we cannot make it very small. Also, making t_loop large so that motors have sufficient time to react will make the system unstable. So there has to be some optimum value. I started with 5 milliseconds and started increasing it. At 5 ms the robot is quiet jerky (but it manages to balance). Between 10 and 20 ms, the vibrations become less. The question is how to find the optimum value of t_loop or control loop execution time.   </p>

答:
A normal game engine at the desktop PC runs with around 40 frames per second. This is equal to 1000/40=25msec of waiting time after a tick. Fasten up the system brings no advantage but it will only increase the CPU consumption. Different from the framerate the motor control has to be executed. A motor needs some time to speed up and stop, especially in embedded systems. What is used in robotics operating systems like VXworks is a concept called realtime control. This means, that the operating systems provides threads. A thread is dropped from the main program and runs in the background until the task is done.

For example, the motor needs 1 second to stop. This means, the task in which the stop signal is send to the motor has a length of 1 second. The motor stop task is activated at timeframe 1000 and runs until the timeframe 1040 (1 second * 40 fps = 40 ticks). .During that time the main program doesn't stop but it runs also. The concept of threading is used at desktop PCs heavenly for creating GUI applications but it is useful for controlling robots as well.

Title: Loop time for self balancing robot


问:
Is robotics and automation a contradiction?
With the Meccano toy it is possible to construct a variety of useful machines. For example a knitting machine, a loom or a steam engine. What these machines have in common is, that they are doing productive work, running fully autonomous and doesn't need a microcontroller or software. On to other hand, robotics are marketed as autonomous systems which will increase the productivity in industry, but most robotics projects who are trying to do so have failed. For example the “Halle 54” project at VW, or the Baxter robot from Rethink robotics, or the Unimation hospital robot.

If meccano like mechanical machines are a great choice for mass automation and robotics project failed to do the same job is maybe the connection between robotics and automation wrong? I mean, who is responsible for the image of robots as a highly productive worker? Is this perhaps only a story and has nothing to do with reality?

Or let me ask the question from the other side, because the danger of misunderstanding is high. Robotics were sold by robotics companies as a technology which will increase the productivity, lower the costs and replace human workers. The idea is, that either humans or robots will work in the factory. That means from a marketing perspective robots are sold as an automation tool. Is this outlook about robotics wrong? Have robots a different kind of social role in future society?

答:
No, robotics and automation is not a contradiction.

The loom and the steam machine represent the mechanisation of production processes. Later came the assembly line and the electrification of the production processes. The next stage is the robotization of the processes (and I inlcude here the numerical controlled machine tools also). What follows, after the "robotization"-era is the current situatuation, sometimes called the IoT era or Industry 4.0.

Each era had their failures and sucesses, but productivity has grown considerably in each era. There is no credible source which disputes the productivity growth. (The argument regarding automation is always related to labour-displacemnet, no credible source argues on the side of overall productivity decrease).

I have to say I do not no anything about the "unimation factory robot" you mention. The other projects seem to be cherry picked and slightly missinterpreted.

The "Halle 54" project was an early project which was a pilot program, probobly something like a prototype program. I think it is normal for early projects to fail to meet all expectations, as I am sure it took a lot of prototyping to get the first loom machine right. There are many other automation projects in the automotive manufacturing industry, which may not be as well known but are increasing productivity. Most automotive manufacturers are steadily increasing the degree of automation of the products. The number of installed and runnig robots is continously increasing since the '90s. My guess it that unexpected things happen when there is a jump (and not gradual growth) in the automation of a manufacturing process (a more recent example is the Tesla production problems). But this is just a guess.

As for the ReThink Robotics story: there are more and more other companies (e.g. Universal Robots, ABB, Kuka) producing so called co-bots (colaborative robots) and the number of installed (and running) co-bots is continously gorwing, therefor the failure of one manufacturer on a steadily growing market is not relevant. The same goes for service robots, if someone considers Baxter/Sawyer a service robot and not a co-bot.

You can take a look at the share prices and market capitalization of the large robotics/automation/machine building companies. Most of them show a growing trend.

EDIT:
Based on the comments below, I would like to re-iterate the conclusions:

There is no credible source disputing the productivity growth due to the use of robots

the number of installed robots doubled in the last 10 years (from approx. 1 million units to more then 2 million units, source is the International Federation of Robotics), proving that the industry uses more and more robots

the projects listed in the question are cherry picked and do not reflect the state of the manufacturing industry.

despite the partial failures of Halle54, Volkswagen is continuously increasing the number of robots manufacturing their cars

My guess is that many projects where a jump in the automation degree of the process instead of a gradual increasted is planned have an increased risk of failiure when compared to project whith a goal of gradualy increasing automation degree. Both cases increase the number of robots in the process, the diffrence is introducing 10 robots at a time for one subprocess or 100 for 10 subprocesses.

Currently in the manufacturing industry, automation in most cases implies the use of robots.


问:
How can I connect arducopter to Raspberry Pi?
This is my school project. I would like arducopter to connect to Raspberry  Pi but I do not know how to do it. Please help me!

答:
To do so, you need to use a USB link between the Ardupilot/Arducopter and use the MAVLink protocol to interrogate the Arducopter in order that it sends back its GPS data. You can etheir way use the C libs of MAVLink, the Python implementation or the ROS one (named mavros). You may find some clues here:

MAVLink dev guide

Python implementation - the easier one to handle

Depending on your programming skills this may requires you some time to reach your aim!


问:
Please help me with stall property of gear motor
i have read a spec. about gear motor and it shows that
Stall: 9-13 Nm torque
          25A max

Per my understanding Stall torque is the maximum torque that can be applied to the shaft and cause the motor to stop rotating.
So i wonder why it appears a range from 9-13Nm. As defination that i found, i think we only need the maximum value 13Nm and the current 25A is for this torque value.
Could you please give me an advice about this range meaning.
Thabk you very much.

答:
Why is there a range? Manufactures often list a range for their torque because their torque is highly dependent on the Voltage applied to a motor. A motor has an operational voltage and you'll reach the upper values of the stall torque by powering your motor with the upper values of the voltage range.

Stall Torque is the amount of weight the motor can hold without moving. Let's say your motor 0 degrees is facing the ground and 180 degrees is facing the sky. If your motor is at 90 degrees (parallel to the ground), then your 9-13Nm stall torque means that your motor can hold ~90-130kg at 1cm from the shaft of your motor (the gear that rotates out of the motor). If you put a weight more than 130kg at 1cm from the motor, the motor will not be able to hold its current position. As a result, the motor will be forced from the 90 degrees position to the 0 degrees position.

The 25A of your motor means that your motor can drain up to 25 amps of current under maximum load.

Remember that stall torque value is often higher than your continuous torque value. Continuous torque is the amount your servo can reliable lift and rotate. It's easier to keep a heavy object in place vs being able to push it against the force of gravity. Sometimes the manual will specify the continuous torque, other times, you'll just have to test it yourself.

So what does Nm means for torque. You'll often see oz/in, kg/cm, or Nm when looking at servo motors. 5 Nm just means your motor can generate 5 newtons of force at 1 meter away from the shaft of the motor. 10 newtons is about 1 kg of force (1 kg * force of gravity = newtons).

Remember that torque of your motor is inversely related to the distance at which it's carrying the weight:

T = F * D where F is force and D is distance. Thus going from 1 cm to 1 m will reduce the carrying capacity of your load by a factor of 100.

If you have more questions, I recommend watching youtube videos that explains the concept of torque.


问:
Are underactuated robots easier to program?
The first examples for passive dynamics were introduced by Ted McGeer in the early 1990s. The main principle of so called underactuated robotics is, that not all joints in the system can be controlled with motors directly, but some variables are free. A good example is a sailboat in the wind, or a one-leg robot who hangs on a rope. On the first look, the freely movable joint will increase the complexity, because the software is responsible for the robot itself and for the environment too. But if these systems are difficult to program, why isn't that case simply ignored by the engineers?

Let us take a look into a robotics laboratory and how new robotics are developed. The first thing what the engineers are doing is to build the frame. It is better known as a harness. On that chassis the robot is mounted. What is the intention of mounting a robot on a frame? Right, the intention is to build an underactuated robot. The robot doesn't have to balance by itself, but the frame around him stabilize the system. The additional freely movable joints doesn't increase the complexity but makes it lower.

So my question is: were underactued robots introduced to simply the programming, especially of biped robots which have a balance problem?

答:
The main reason why underactuated robots were introduced is to make robots more energy efficient. Robots that are not underactuated like Asimo require 20x more energy that humans to walk. In order to solve the energy issue, you need to design more efficient structures instead of brute forcing everything with motors. You need to closely tie the dynamics of walking into the structure of the robot to make it more energy efficient.

In the cases where underactuated robots have simplified the programming, that's more of a positive side-effect rather than the purpose the design team went with the dynamics approach.

MIT offers a great course on edx that is solely about underactuated robots.


问:
How to perform active search in point feature based monoSLAM?
I am modifying an implementation of SLAM with single camera, MonoSLAM [1].  Instead of image patches, I want to use features points (ORB) to track landmarks. MonoSLAM uses a EKF framework. So for every feature tracked, I have a covariance matrix which defines the uncertainty of the measurement in current camera frame.

Had this been an image patch, as in Davidson et al [1], one has to center a sliding window with every pixel inside the ellipse defined by the covariance.  Then check for correlation of pixel intensities between the tracked patch and the patch from the new frame. Some thing like this figure below.

For features, should I search in a similar fashion by calculating the descriptor for each pixel in the ellipse?

or

Since features come with their own detectors, should I leave it to the detector to find the list of features within the ellipse and then match them with my previous frame feature?

[1]: Davison, Andrew J., et al. "MonoSLAM: Real-time single camera SLAM." IEEE Transactions on Pattern Analysis & Machine Intelligence 6 (2007): 1052-1067.

答:
This is not the answer of your question but ORB is a feature detection algorithm. Feature detection and tracking are different. Once you found a feature it is better to track them by a feature tracking algorithm such as KLT. You can also track the features by feature matching algorithms but it is not very efficient.

Since features come with their own detectors, should I leave it to the detector to find the list of features within the ellipse and then match them with my previous frame feature?

-> Yes

The ellipse is usually to find a Mahalanobis distance to fairly count the uncertainty. If Mahalanobis distance of the two matched features is close enough, it can be used. This is how you find a matched features in EKF slam. Just remember that this is a quite old way.


问:
What is a Velocity Smoother?
I'm learning ROS and I have found an expression that I don't understand. I'm reading the book "Mastering ROS for Robotics Programming - Second Edition", and on a controller to move a robot using keyboard said:

differential_teleop_key already has its own built in velocity smoother

You can find differential_teleop_key on Github.

What is a Velocity Smoother?

答:
The velocity smoother part of the code is this:

```<code>if target_speed > control_speed:
            control_speed = min( target_speed, control_speed + 0.02 )
        elif target_speed < control_speed:
            control_speed = max( target_speed, control_speed - 0.02 )
        else:
            control_speed = target_speed
</code>```

as you can see, regardless of how much you increase the target velocity, there will be no large jump in the controled velocity. It will always be incremented or decremented by 0.02 cyclically until it reaches the target velocity.

In essence this is an acceleration limiting approach to motion control when a constant maximum acceleration is assumed and so a trapezoidal velocity profile is generated. Jerk limiting (limiting the derivative of the acceleration) produces even smoother velocity profiles.

More about acceleration and jerk limiting here.

Title: What is a Velocity Smoother?

Body:
The velocity smoother part of the code is this:

if target_speed > control_speed:
            control_speed = min( target_speed, control_speed + 0.02 )
        elif target_speed < control_speed:
            control_speed = max( target_speed, control_speed - 0.02 )
        else:
            control_speed = target_speed

as you can see, regardless of how much you increase the target velocity, there will be no large jump in the controled velocity. It will always be incremented or decremented by 0.02 cyclically until it reaches the target velocity.

In essence this is an acceleration limiting approach to motion control when a constant maximum acceleration is assumed and so a trapezoidal velocity profile is generated. Jerk limiting (limiting the derivative of the acceleration) produces even smoother velocity profiles.

More about acceleration and jerk limiting here.


问:
Libraries to simulate path planning in a dynamic environment for a 2D space
I need to simulate a path planning approach for a 2D space where the obstacles are moving. Initially, I need to implement probabilistic road map, D* lite, A* and Bug2 algorithm. The robot needs to be able to follow the wall of the obstacles.

I do not know which library is most suitable for these algorithms. I have a tight schedule, I need to finish the simulation within 1 month. I found ROS, matlab and Player. Which one can handle the simulation of dynamic obstacles and has the algorithms that I need. Any other suggestions are welcome.

答:
Generally you will need to combine more tools to achive your goals. You will need a path planner library and script, you need to move things around and you need visualisation.

An open source 3D simulation environment which supports dynamic obstacles is Gazebo. You mention Player, as i understand that is also somthing similar, but I have never seen it in use and it seems that Gazebo grew out of the Player Project. Gazebo would take care about moving things around and visualisation. You will need to add a pathplanner.

As for path panning libraries, probably the best known ones are OPML and MoveIt! (MoveIt! is based partially on OPML). MoveIt! is a ROS library and there are tutorials how to couple this library with Gazebo.  However, OMPL and MoveIt does not include all the algorithms you have mentioned out of the box. This means that you have to search for plugins or implement the algorithms yourself.

Matlab probably has most of the algorithms you need, either in the Robotics Toolbox or on Matlab file exchange, or they can be implemented. However, rendered 3D visualisation is not as easily done as with Gazebo. If 3D plots and graphs would suffice Matlab alone is also a viable option. If not, you can connect Gazebo to Matlab by following this tutorial.


问:
Can a neural network emulate a physics engine?
Before a motion controller for a robot can be created, a step before is needed, called “system identification”. The aim is to create a prediction model which can say, what will happen if a certain movement of the robot is executed. For example, a wheeled robot which is designed upon the steering principle will change it's position if both wheels are spin with +1 speed for 1 second. The new x/y position will be ahead of the old position. If the robot's wheel are spinning with different values, for example left=+1, right=+0.5 the new position of the robot will be different.

The problem is, that a dedicated physics engine which can predict the trajectory of a robot is hard to realize by hand. But there are some general techniques available for example genetic algorithm, rule based systems or reinforcement learning which can simplify the programming. These general systems are working with parameters who have to be adapted to a certain domain, which is called machine learning.

Question: Can a neural network be used for predicting future states of a robot? And which kind of dataset is needed for doing so?

答:
I think there are some confusing statements or inaccuracies in this question regarding fundamental concepts in robotics, control engineerging and AI/ML. I am not sure if it helps to list these or not, so I will not I just wanted to draw attention to this fact if somebody tries to used the question as a reference.

However, to answer the final question:

Neural networks are universal function approximators. The dynamic model of a robot is a function mapping input (e.g. wheel torque) to output (e.g. robot velocity). So yes, in theory they can learn the dynamic model of a robot. Care must be taken and the current state of the robot should probably also be used as input to the neural network or some kind of RNN should be used. Also in the case of the dynamic model, only torque input is not enough, the current state of the robot is also needed to compute the cartesian velocity.

In practice the right arhitecture needs to be selected, the dataset needs to be defiend and the networks needs to be trained.

Part of the question refers to the dataset.

The input and output of the neural network is the same as of the function it will learn. So in case of a forward dynamic model, the input can be 2 torques (and the current sate) and the output can the cartesian velocity of the robot.

In order to obtain such a dataset:

one could log the data from a real robot as it drives around, making sure that there are enough samples from all areas of the input space. In this case the dynamic model would not be used while driving aournd, just input tortques would be generated.

one could use an exising dynamic model and learn that. This might be counterintuitive, since the function already exists. This would only make sense if the neural network which learns the function would infer (significantly) faster then the execution time of the dynamic model.


问:
motor controlled lazy susan
I'm trying to figure out an easy lazy susan setup.  This is for video production, I want to be able to put an object on the platter and get a smooth consistent turn in order to shoot the object spinning.  What would be the best way/parts to put this together?

Thanks

答:
Here's the easiest setup with the lowest learning curve I can think of. What you can do is you can buy this robot car kit for $36: https://www.amazon.com/dp/B0794PWD7J/ref=psdc_2528074011_t1_B07KPZ8RSZ
I am not affiliate with this seller in any way.

Then you just need to glue/double-sided tape the bottom of the lazy susan setup to the top of a car wheel and figure out a way to hide the car setup in your video.

You can modify the speed of the wheel by adjusting the sleep time and toggling the motor voltage from low to high in code. When a motor voltage is low, the wheel will not move. When it's high, it will move at max speed. In order to slow down the motor, you can sleep for a fraction of second, then move for a fraction of a second, then sleep again. The car kit will come with a manual to help you understand.

So now the more complex answer requiring more technical know-how:

You will need a DC motor. A motor has a metal rod at the end so you need a shaft attachment so you can glue the lazy susan to the top of it. Make sure the DC motor has enough torque to spin your lazy susan and whatever is on it.

You can control the DC motor with a circuit controlled by an NE555 timer chip. You can google NE555 timer DC motor setups and you'll get some circuit diagrams which you will have to build. Alternatively, you can buy and arduino/microprocessor to control your DC motor.

You can use a servo motor as well such as the MG996R. Servo motors comes with servo horns which you can glue/double-sided tape the lazy susan directly to. You modify the servo motor to be able to spin continuously. Here's all the info you'll need if you go down that route: https://www.youtube.com/watch?v=J8atdmEqZsc

Title: motor controlled lazy susan


问:
bluetooth that could track mobile phone location
newbie here.
after my research, i couldnt find anything that could found what i wanted to search for my project(following robot for indoor location).
without gps, bluetooth only, could i get the exact position of the mobile phone im pairing with?

here some of my research:

bluetooth_study
this project use only bluetoot, but it only detect if somebody arrive in one destination, it didnt detect the exact location of the phone.

Ubertooth
at 6:28, it say it could hunt down specific bluetooth device and track down its location.
However it didnt mention if its the exact location calculated from ubertooth signal itselft or reading the gps location from the phone. as we know, gps is not working indoor.

thus my question here is.

it is possible to track down mobile phone exact location using bluetooth alone?

if possible what kind of bluetooth is needed?

if not. any other solution?

答:
For localization problems, you will always need to have some references to look at (using only the IMUs of the phone will lead in error as time increases).

For example, GPS uses the relative position of the satellites, LIDAR SLAM uses the relative position of features, Wi-Fi positioning systems use the relative position of the access points.

In your case, you would need to have some kind of Bluetooth references, receivers/emitters to check the strength of the signal and estimate the position of your device. I have never seen any of this, but it seems interesting to have more alternatives to localisation techniques.


答: Yes it might be possible to obtain the location of the robot, if you use multiple Bluetooth nodes(preferably 4 excluding the one in the robots for a free space)  and use the rssi values from the Bluetooth nodes to triangulate the position. But still the output is susceptible to high covariance due to some environmental factors, so for a more accurate solution you may try random forest classifiers to find a solution with lesser covariance

Title: bluetooth that could track mobile phone location

Body:
newbie here.
after my research, i couldnt find anything that could found what i wanted to search for my project(following robot for indoor location).
without gps, bluetooth only, could i get the exact position of the mobile phone im pairing with?

here some of my research:

bluetooth_study
this project use only bluetoot, but it only detect if somebody arrive in one destination, it didnt detect the exact location of the phone.

Ubertooth
at 6:28, it say it could hunt down specific bluetooth device and track down its location.
However it didnt mention if its the exact location calculated from ubertooth signal itselft or reading the gps location from the phone. as we know, gps is not working indoor.

thus my question here is.

it is possible to track down mobile phone exact location using bluetooth alone?

if possible what kind of bluetooth is needed?

if not. any other solution?


问:
With a 6-axis robot, given end-effector position and range of orientations, how to find optimal joint values
Given a six-axis articulated robot arm holding a tool at its end-effector,  if I have a desired tool position and tool orientation,  there will be exactly 1 solution to the inverse kinematics equation for the robot to reach that position.

(or rather up to 16 different solutions, depending on range of the joints)

But if the robot is holding something like a pen, and I want the robot to mark a specific point with that pen on the target, then I do not care how the pen is oriented, as long as it is perpendicular to the marked surface.

So the inverse-kinematics equation will have infinitely many solutions.

How can I pick among these solutions the joint configuration that is closest to the current configuration: the one that will require the least amount of movement to reach?

(or the joint configuration that is optimal according to some other similar criterion, such as that all joint angles are furthest from their maximum and minimum?)

答:
Since the question is about an industrial robot, we probably don't have a model of the dynamics of the robot, so I am assuming we are looking for solutions that optimize a kinematic criterion only.

The robot has a closed-form solution for its inverse kinematics, but unluckily the end-effector has an extra rotational degree of freedom, which means that the robot has essentially 7 degrees of freedom. But because this is just one more dof, it is not as much of an issue as one might think.

A common trick for such almost non-redundant robots is to lock the extra degrees of freedom and solve for the remaining joint values analytically. Let's say we write a closed-form IK solver for the 6 dof robot that returns solutions in $0.05$ ms on average. By iterating from $1$ to $360$ you can therefore find the optimal solution for a discretization of the pen angle of $1^\circ$ in about $18$ ms, which given the application is probably more than adequate.

If most of the time the pen is only moving a little (e.g. when drawing a line), another trick to speed up the search is to make use of numerical IK, for example the pseudoinverse method:

Let $q_1$ be the current configuration of the robot, let $J$ be its Jacobian, and let $\Delta x$ be the displacement of the target relative to the current end-effector transformation. Solve $\Delta x = J \, \Delta q$ for $\Delta q$ and compute a new configuration $q_2 = q_1 + \Delta q$. I am skipping details here, but the solution $\Delta q$ should minimize $\|\Delta q\|$ for a properly chosen metric.

This is done for the 7 dof robot and again should take only fractions of a millisecond. Although $q_2$ might not be a valid configuration (the joint values can be out of bounds) and might not be an accurate IK solution (you can take more pseudoinverse steps, though), most of the time it will be a good starting point for a search using the closed-form solver.


问:
Project suggestions
Thank you for any input in advance!  Also I am not totally sure this is the right place for this question.  If not then I apologize but couldn't think of a better place to post it.

I am working on a project that requires several small motors communicating with a phone / raspberry pi / camera in order to perform functions in a regulated order.

Without too many details (hopefully)

1.A wheel advances 1 rotation (roughly) to deliver an item onto a conveyor.

2.A picture is taken of the item

3.data is parsed on the raspberry pi or some kind of computing device

4.depending on the input from the image the conveyor moves the item bi directionally.

5.Process repeats.

Although I have figured out how I want to build most of this (in terms of teh physical structure, the little motors I want to use etc.) I am not sure how to accomplish the communication between all the various parts of the machine / robot.  IE the brains of the operation. Ideally something that can choreograph all the movements I mentioned, receive data from a camera or smart phone / app, send instructions to the motors on when to act etc.

Any expertise you can share would be highly valued.  I am a novice, and an enthusiast only.  Although this project may take on a commercial scale eventually I am essentially working on a prototype and it may only end up ever being something I do as a hobby / for fun anyway.

Thank you!

答:
I can't comment yet your question, I don't have enough reputation, so I apologize for commenting here!

I think that you need to specify a few things so that we can fully understand your problem:

You mentionned a "phone / raspberry pi / camera", as you used "/", are those objects all required or not ? Because the camera seems necessary but not the raspberry pi and the phone (this depends on the global aim of the project)!

You explain that there are some small motors, but have you chosen them or not ?

Do your question concern also the choice of motors ?

I would just advise you to do some system engineering in order to have a top-down view of what is expected with this project. In this kind of projects you need to carefully list the requirements and the interfaces of each component (this approach may also answer a lot of your questions).

To give you some clues, your motors may requires an electronic board (like an ESC for brushless motors, a driver for steppers, etc) to be controlled by a computer. The raspberry is capable of generating PWM commands (usually the kind of signals used to command a motor driver) but with such a slow frequency that we usually don't use it to control motors (this depends on your requirements), if you can't use it you will need a servo-controller like one of these. Then if you use a raspberry pi to communicate with this board, a basic bus like USB may be enough. If you need to have a phone app to remotely supervise all, you will need to use the Wifi... etc

Title: Project suggestions


问:
Self balancing robot: PID Control Algorithm
I am working on a hobby project for self balancing robot. My robot balances quiet well, so my next step is to start moving it. I saw in some blogs that they used a cascade control algorithm as shown below

So I have the following question which is giving me a hard time

When I see some videos about segway like systems (like boston dynamics here ), I see that before moving forward, the robot moves a bit backward (to generate a tilt) which I think is justified because it must first get an error to get started in the forward direction. So will this kind of control system be able to handle that or do I need to code it seperately?

答: After much researching, I found an answer to my question. I think I asked the wrong question. The robot moves in opposite direction initially and then in correct direction because it is a non-minimum phase system meaning it has a pole in right half plane. These kind of systems initially move in opposite direction before moving in correct direction. This is clearly explained in this video at time = 7:46 minute. </p>


问:
Help Interpreting Raspberry Pi GPIO's allocated to Robot starter kit called AlphaBot2
I am a complete newbie to robotics, so please excuse me if this is a simple question. I bought this robot starter kit and need help understanding which features are associated to which GPIO pins:

Here are the schematics:
Schematics

Is this information sufficient for me to know what feature is mapped to the GPIO pins or do I have to follow some type of trial and error process to figure it out? Your help would be greatly appreciated.

答:
Waveshare maintain a wiki page for the Alphabot2.

In the resources section on that page, there are some links to demo code which contains definitions for the allocation of GPIO pins.

It looks like the specific file you want is AlphaBot2-Demo.7z

The compressed file contains a folder named Python:

I've taken the mappings below from these files.  Note that this list of GPIO mappings may not be exhaustive as I haven't fully followed through on checking file dependencies etc.

Note also that the pin assignments used in the code use Broadcom GPIO numbers (BCM). These are the GPIOxx numbers on the diagram below, not the actual pin numbers on the header:

AlphaBot2.py  appears to control the robot's motors. The pin assignments are:

```<code>ain1=12
ain2=13
ena=6
bin1=20
bin2=21
enb=26
</code>```

Ultrasonic_Obstacle_Avoidance.py  and Ultrasonic_Ranging.py specify:

```<code>TRIG = 22
ECHO = 27
</code>```

Which are obviously the pins allocated to your ultrasonic sensor

Similarly, Infrared_Obstacle_Avoidance.py specifies

```<code>DR = 16
DL = 19
</code>```

which are the pins used by the IR sensor

TRSensors.py specifies:

```<code>CS = 5
Clock = 25
Address = 24
DataOut = 23
Button = 7
</code>```

IRremote.py sets

```<code>IR = 17
</code>```

For your remote control

Joystick.py assigns the following pins:

```<code>CTR = 7
A = 8
B = 9
C = 10
D = 11
BUZ = 4
</code>```

Line_Follow.py also sets GPIO7:

```<code>Button = 7
</code>```

Finally, ws2812.py sets the LED pin to 18

```<code>LED_PIN = 18  # GPIO pin connected to the pixels (must support PWM!).
</code>```

Body:
Waveshare maintain a wiki page for the Alphabot2.

In the resources section on that page, there are some links to demo code which contains definitions for the allocation of GPIO pins.

It looks like the specific file you want is AlphaBot2-Demo.7z

The compressed file contains a folder named Python:

I've taken the mappings below from these files.  Note that this list of GPIO mappings may not be exhaustive as I haven't fully followed through on checking file dependencies etc.

Note also that the pin assignments used in the code use Broadcom GPIO numbers (BCM). These are the GPIOxx numbers on the diagram below, not the actual pin numbers on the header:

AlphaBot2.py  appears to control the robot's motors. The pin assignments are:

ain1=12
ain2=13
ena=6
bin1=20
bin2=21
enb=26

Ultrasonic_Obstacle_Avoidance.py  and Ultrasonic_Ranging.py specify:

TRIG = 22
ECHO = 27

Which are obviously the pins allocated to your ultrasonic sensor

Similarly, Infrared_Obstacle_Avoidance.py specifies

DR = 16
DL = 19

which are the pins used by the IR sensor

TRSensors.py specifies:

CS = 5
Clock = 25
Address = 24
DataOut = 23
Button = 7

IRremote.py sets

IR = 17

For your remote control

Joystick.py assigns the following pins:

CTR = 7
A = 8
B = 9
C = 10
D = 11
BUZ = 4

Line_Follow.py also sets GPIO7:

Button = 7

Finally, ws2812.py sets the LED pin to 18

LED_PIN = 18  # GPIO pin connected to the pixels (must support PWM!).


问:
How to use depth map in A* path planning?
I've currently built a quadrotor with standard PID controllers for attitude, angular rates, and position control. I now want to implement obstacle avoidance and path planning using A*. I have a stereo sensor that outputs depth maps, however I am not sure how to use depth maps to translate into the path planner.

Do I have to first use SLAM techniques to create a local map from the depth maps, and then use A* on that local map? Any relevant material is appreciated.

答:
I would recommend using some sort of discretized local map. For 3D use octomap (https://octomap.github.io/) and 2D a grid map. But honestly, I would try the laziest option, putting each depth reading in octomap form and planning with it to see if a local map is really needed. Remember that you have to represent non-occupied space to use A*. The discretized representation of octomap is well suited for it.

Summing up,

Depth map reading -> To discretized octomap form -> Plan -> Repeat


问:
FastSlam2.0: ICP Scan Matching vs Odometry? What is the typical time step?
When working with a FastSlam2.0 algorithm, ICP Scan Matching is supposed to give more accurate measurements than odometry.

The problem is, that given some noisy measurements from the laser scanner, when the robot is stationary, or doing relative small movements, the dispersion from the ICP scan matching is greater than the dispersion from the odometry, especially if working with grid maps instead of landmarks.

In a set of tests I have performed with a simulated laser scanner and a grid map, this is true even for not noisy data. A relatively small movement (0.1m) changes all the points in the scan cloud, and the ICP algorithm can diverge from the expected result. The odometry behaves better in this case.

However, when working with relative big movements from step to step (1m), scan matching will perform better than odometry.

The question is, what is the typical time interval o distance interval to perform the FastSlam2.0 algorithm?
If that interval is small, or the robot makes small distance increments, how is it possible to avoid this problem?

Edit

To illustrate better the problem, here are 2 simulations.

Cyan dots represent the odometry different hypotheses without scan matching.
Red dots represent the odometry different hypotheses with scan matching.
Green dot represents the odometry readings.
Black line (straight) represents the robots real movement (this is the particle that generate the simulated scans for the scan matching).

First one with simulated speed = 1 m/s and simulated time step = 0.5 s.

Second one, simulated speed = 1 m/s and simulated time step = 0.1 s.

Performance of the scan matching with time step = 0.5 is really good, whereas the performance of the scan matching with time step = 0.1 behaves way worse that just odometry.

If there is no way to solve this, then, what are the typical time steps for a real FastSlam 2.0 Application?

In the end, the best approach I have found is to apply scan matching if the displacement is high enough. If not, apply only odometry.

答:
This is the typical calibration you need to do depending on the sensors you have, there is no optimal solution. And this is why you have to know your sensors specs. Actually, that precisely what gmapping (http://wiki.ros.org/gmapping) does.

So, the answer there is no answer. Each situation will force to recalibrate based on your sensors, the type of environment you have, your type of movement, etc.


问:
How to change endian for multi-byte I/O outputs?
When using the Yaskawa Smart Pendant SDK API (Java client), it is possible to set multi-byte I/O values via:

```<code>controller.setOutputGroups(outNum, 2, value16bits);

controller.setOutputGroups(outNum, 4, value32bits);
</code>```

However, sometimes the byte ordering is wrong. Depending on the product vendor or if using Ethernet/IP or IOLink, multi-byte values can be big-endian or little-endian.

How can I swap the ordering?

答:
The API doesn't have any direct support for endian conversion / byte-swapping.  However, there are some Java functions that can handle it:

```<code>Short.reverseBytes(short i16)
Integer.reverseBytes(int i32)
Long.reverseBytes(long i64)
</code>```

So, the calls in the question would become:

```<code>controller.setOutputGroups(outNum, 2, Short.reverseBytes(value16bits));
controller.setOutputGroups(outNum, 4, Integer.reverseBytes(value32bits));
</code>```

Body:
The API doesn't have any direct support for endian conversion / byte-swapping.  However, there are some Java functions that can handle it:

Short.reverseBytes(short i16)
Integer.reverseBytes(int i32)
Long.reverseBytes(long i64)

So, the calls in the question would become:

controller.setOutputGroups(outNum, 2, Short.reverseBytes(value16bits));
controller.setOutputGroups(outNum, 4, Integer.reverseBytes(value32bits));


问:
How can I simulate a changing environment with non-rigid objects?
Many robot applications (actually - the most practical and appealing ones) include the robot's reaction to (and impact on) the evironment, e.g. due to stochastic nature of the environment (e.g. when robot should handle non-rigid objects like clothes) or due to the variability of environment (e.g. harvesting robots should be prepared to pick fruits of different sizes and shapes).

The question is - is there a robotics simulator that can simulate not only robot but also the environment as well? E.g. that can simulate the response of robots action on cloth folding or fruit picking and so on. I guess that such simulator is really non-trivial but maybe there is some ongoing project for it?

答:
The V-Rep simulator can use a few physics engines that have some soft-body support, including:

Vortex Dynamics (commercial) which has some soft-body support for specific cases

The Bullet Physics Engine (FOSS) which has support for soft-body simulation (though it isn't supported in the current version of V-Rep)


问:
Inverse Kinematics Problem of Articulated Manipulators Arm
I have a robotic arm consist of three joints (servomotor for each joint), as shown in the figure below:

Notes:

Each servomotor rotates around 180 degrees.

The angles of the theta2 and theta3 represent 90 degrees in the figure above.

I found the forward kinematics by using the parameters of DH convention, as shown in the figure above.

The Final Transformation Matrix is:

The position of the robotic arm end-effector is correct for any angle of theta1, theta2, and theta3 between -90 and 90 degrees.

My problem is in the inverse kinematics of the robotic arm, where, the theta2 always affected by theta3 and thus the response of theta2 incorrect, while theta1 and theta3 are always correct. Please see the cases below that show this problem.

Thank you.

答:
I think the debate is a bit off topic.  To me, the question is about why is the inverse kinematics wrong when applied to a forward kinematics solution computed for joint angles $\ge$ 90 deg.

To explore this I built a model using my Robotics Toolbox for MATLAB

```<code>>> r = SerialLink([0 133 0 -pi/2; 0 0 98 0; 0 0 220 0])
r =

noname:: 3 axis, RRR, stdDH, fastRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|  1|         q1|        133|          0|    -1.5708|          0|
|  2|         q2|          0|         98|          0|          0|
|  3|         q3|          0|        220|          0|          0|
+---+-----------+-----------+-----------+-----------+-----------+
</code>```

then I computed the forward kinematics for the first and last joint configurations in @B.Antony's question:

```<code>>> r.fkine([0 0 0])
ans =
         1         0         0       318
         0         0         1         0
         0        -1         0       133
         0         0         0         1

>> T = r.fkine([90 90 90], 'deg')
T =
         0         0        -1         0
        -1         0         0      -220
         0         1         0        35
         0         0         0         1
</code>```

and the answers match what's in the graphs provided. So far, so good.

Ignoring the debate about analytical versus numerical solutions I'm going to use a numerical solution since it's general and I have it to hand:

```<code>>> q = r.ikine(T, 'mask', [1 1 1 0 0 0])
q =
   -1.5708   -0.7327    1.5708
</code>```

where mask indicates that we only care about solving for the first 3 elements of the Cartesian pose (x,y,z).

We see this solution is different to what was input to the forward kinematics and it has flipped $\theta_1$ around, but we can easily verify that the solution is correct

```<code>>> r.fkine(q)
ans =
         0         0         1         0
   -0.6689    0.7434         0      -220
   -0.7434   -0.6689         0        35
         0         0         0         1
</code>```

Note: the translation part is correct, the rotation part is different but we don't have enough DoF to independently control that.

We can try and find a solution with a positive $\theta_1$ by setting the initial joint angles for the IK

```<code>>> r.ikine(T, 'mask', [1 1 1 0 0 0], 'q0', [pi/2 0 0])
ans =
    1.5708    1.5708    1.5708
</code>```

which is the set of joint angles we started with, so this is another valid solution, the blue line in the graph.

I don't think the red solution shown in the graph of $\theta$ values is correct

```<code>>> r.fkine([90 -90 90], 'deg')
ans =
         0         0        -1         0
         1         0         0       220
         0        -1         0       231
         0         0         0         1
</code>```

is far from the initial pose shown above.

Conclusion the IK equations implemented are not correct.  There should be at least 4 solutions: 2 for q1 (you have only 1), and 2 for q2 (which you have).  Maybe another set of 4 where $\theta_2$ and $\theta_3$ are offset by 180deg.

I can automatically generate an analytic solution (you need the MATLAB Symbolic Math Toolbox to do this bit)

```<code>>> q = r.ikine_sym(3)
----- solving for joint 1
subs sin/cos q1 for S/C
----- solving for joint 2
lets square and add 1 2
subs sin/cos q2 for S/C
----- solving for joint 3
subs sin/cos q3 for S/C
**final simplification pass

q =
  1×3 cell array
    {1×2 sym}    {1×2 sym}    {1×2 sym}
</code>```

Looking at the solution for $\theta_1$

```<code>>> q{1}
ans =
[ atan2(-ty, -tx), atan2(ty, tx)]

</code>```

we can see the two solutions.

Body:
I think the debate is a bit off topic.  To me, the question is about why is the inverse kinematics wrong when applied to a forward kinematics solution computed for joint angles $\ge$ 90 deg.

To explore this I built a model using my Robotics Toolbox for MATLAB

>> r = SerialLink([0 133 0 -pi/2; 0 0 98 0; 0 0 220 0])
r =

noname:: 3 axis, RRR, stdDH, fastRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|  1|         q1|        133|          0|    -1.5708|          0|
|  2|         q2|          0|         98|          0|          0|
|  3|         q3|          0|        220|          0|          0|
+---+-----------+-----------+-----------+-----------+-----------+

then I computed the forward kinematics for the first and last joint configurations in @B.Antony's question:

>> r.fkine([0 0 0])
ans =
         1         0         0       318
         0         0         1         0
         0        -1         0       133
         0         0         0         1

>> T = r.fkine([90 90 90], 'deg')
T =
         0         0        -1         0
        -1         0         0      -220
         0         1         0        35
         0         0         0         1

and the answers match what's in the graphs provided. So far, so good.

Ignoring the debate about analytical versus numerical solutions I'm going to use a numerical solution since it's general and I have it to hand:

>> q = r.ikine(T, 'mask', [1 1 1 0 0 0])
q =
   -1.5708   -0.7327    1.5708

where mask indicates that we only care about solving for the first 3 elements of the Cartesian pose (x,y,z).

We see this solution is different to what was input to the forward kinematics and it has flipped $\theta_1$ around, but we can easily verify that the solution is correct

>> r.fkine(q)
ans =
         0         0         1         0
   -0.6689    0.7434         0      -220
   -0.7434   -0.6689         0        35
         0         0         0         1

Note: the translation part is correct, the rotation part is different but we don't have enough DoF to independently control that.

We can try and find a solution with a positive $\theta_1$ by setting the initial joint angles for the IK

>> r.ikine(T, 'mask', [1 1 1 0 0 0], 'q0', [pi/2 0 0])
ans =
    1.5708    1.5708    1.5708

which is the set of joint angles we started with, so this is another valid solution, the blue line in the graph.

I don't think the red solution shown in the graph of $\theta$ values is correct

>> r.fkine([90 -90 90], 'deg')
ans =
         0         0        -1         0
         1         0         0       220
         0        -1         0       231
         0         0         0         1

is far from the initial pose shown above.

Conclusion the IK equations implemented are not correct.  There should be at least 4 solutions: 2 for q1 (you have only 1), and 2 for q2 (which you have).  Maybe another set of 4 where $\theta_2$ and $\theta_3$ are offset by 180deg.

I can automatically generate an analytic solution (you need the MATLAB Symbolic Math Toolbox to do this bit)

>> q = r.ikine_sym(3)
----- solving for joint 1
subs sin/cos q1 for S/C
----- solving for joint 2
lets square and add 1 2
subs sin/cos q2 for S/C
----- solving for joint 3
subs sin/cos q3 for S/C
**final simplification pass

q =
  1×3 cell array
    {1×2 sym}    {1×2 sym}    {1×2 sym}

Looking at the solution for $\theta_1$

>> q{1}
ans =
[ atan2(-ty, -tx), atan2(ty, tx)]

we can see the two solutions.


问:
Why do 1000 rpm and 10 rpm DC motors cost the same?
Today I was going to buy a motor online, and saw that 10 rpm and 1000 rpm DC motors cost the same. How is it possible to change the rpm without requiring any additional parts cost?</p>

答: Revolutions per minute (RPM) is merely one of the parameters of a DC motor. Another important criterion is torque, which may be understood as the power output capability of the motor. Perhaps the 10 RPM motor is capable of driving a heavier load, and the 1000-RPM motor simply cannot reach its nominal revolutions per minute with even a very light load. </p>


问:
How can the inverse kinematics problem be solved?
The forward kinematics of a robot arm can be solved easily. We can represent each joint using Denavit–Hartenberg transformation matrices.

For example, if the $i^{th}$ joint is a linear actuator, it may have the transformation matrix:

$T_i = \left[\begin{matrix}
1&0&0&0\\
0&1&0&0\\
0&0&1&d_i\\
0&0&0&1
\end{matrix} \right]$
where the extension length is defined by $d_i$

whereas, a rotating link may be:

$T_i = \left[\begin{matrix}
1&0&0&L\\
0&\cos\alpha_i&-\sin\alpha_i&0\\
0&\sin\alpha_i&\cos\alpha_i&0\\
0&0&0&1
\end{matrix} \right]$ where $\alpha$ is the angle, and $L$ is the length of the link.

We can then find the position and orientation of the end effector by multiplying all the transformation matrices: $\prod{T_i}$.

The question is, how do we solve the inverse problem?

Mathematically, for a desired end effector position $M$, find the parameters $d_i$, $\alpha_i$ such that $\prod{T_i} = M$. What methods exist to solve this equation?

答:
There are two broad approaches:

analytic solutions, given an end-effector pose, directly compute the joint coordinates.  In general the solution is not unique, so you can compute a set of possible joint coordinates.  Some may cause the robot to hit things in its environment (or itself), or your task might help you choose a particular solution, ie. you might prefer the elbow to up (or down), or the robot to have its arm to the left (or right) of its trunk.  In general there are constraints on obtaining an analytic solution, for 6-axis robots, a spherical wrist (all axes intersect)is assumed.  The analytic solutions for many different types of robots have been computed over the decades and you can probably find a paper that gives a solution for your robot.

numeric solutions, as described in the other answers, uses an optimisation approach to adjust the joint coordinates until the forward kinematics gives the right solution.  Again, there's a huge literature on this, and lots of software.

Using my Robotics Toolbox for MATLAB, I create a model of a well known 6-axis robot using Denavit-Hartenberg parameters

```<code>>> mdl_puma560
>> p560

p560 =

Puma 560 [Unimation]:: 6 axis, RRRRRR, stdDH, fastRNE
 - viscous friction; params of 8/95;
+---+-----------+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|  1|         q1|          0|          0|     1.5708|          0|
|  2|         q2|          0|     0.4318|          0|          0|
|  3|         q3|    0.15005|     0.0203|    -1.5708|          0|
|  4|         q4|     0.4318|          0|     1.5708|          0|
|  5|         q5|          0|          0|    -1.5708|          0|
|  6|         q6|          0|          0|          0|          0|
+---+-----------+-----------+-----------+-----------+-----------+
</code>```

then choose a random joint coordinate

```<code>>> q = rand(1,6)
q =
    0.7922    0.9595    0.6557    0.0357    0.8491    0.9340
</code>```

then compute the forward kinematics

```<code>>> T = p560.fkine(q)
T =
   -0.9065    0.0311   -0.4210  -0.02271
    0.2451    0.8507   -0.4649   -0.2367
    0.3437   -0.5247   -0.7788    0.3547
         0         0         0         1
</code>```

Now we can compute the inverse kinematics using a published analytic solution for a robot with 6 joints and a spherical wrist

```<code>>> p560.ikine6s(T)
ans =
    0.7922    0.9595    0.6557    0.0357    0.8491    0.9340
</code>```

and voila, we have the original joint coordinates.

The numerical solution

```<code>>> p560.ikine(T)
Warning: ikine: rejected-step limit 100 exceeded (pose 1), final err 0.63042
> In SerialLink/ikine (line 244)
Warning: failed to converge: try a different initial value of joint coordinates
> In SerialLink/ikine (line 273)

ans =

     []
</code>```

has failed, and this is a common problem since they typically need a good initial solution.  Let's try

```<code>>> p560.ikine(T, 'q0', [1 1 0 0 0 0])
ans =
    0.7922    0.9595    0.6557    0.0357    0.8491    0.9340
</code>```

which now gives an answer but it is different to the analytic solution. That's ok though, since there are multiple solutions to the IK problem.  We can verify that our solution is correct by computing the forward kinematics

```<code>>> p560.fkine(ans)
ans =
   -0.9065    0.0311   -0.4210  -0.02271
    0.2451    0.8507   -0.4649   -0.2367
    0.3437   -0.5247   -0.7788    0.3547
         0         0         0         1
</code>```

and checking that it is the same as the transform we started with (which it is).

Other resources:

free video lectures on this topic, search for kinematics at the Robot Academy

Chapter 7 of Robotics, Vision & Control (2e), Corke, Springer 2017.

Body:
There are two broad approaches:

analytic solutions, given an end-effector pose, directly compute the joint coordinates.  In general the solution is not unique, so you can compute a set of possible joint coordinates.  Some may cause the robot to hit things in its environment (or itself), or your task might help you choose a particular solution, ie. you might prefer the elbow to up (or down), or the robot to have its arm to the left (or right) of its trunk.  In general there are constraints on obtaining an analytic solution, for 6-axis robots, a spherical wrist (all axes intersect)is assumed.  The analytic solutions for many different types of robots have been computed over the decades and you can probably find a paper that gives a solution for your robot.

numeric solutions, as described in the other answers, uses an optimisation approach to adjust the joint coordinates until the forward kinematics gives the right solution.  Again, there's a huge literature on this, and lots of software.

Using my Robotics Toolbox for MATLAB, I create a model of a well known 6-axis robot using Denavit-Hartenberg parameters

>> mdl_puma560
>> p560

p560 =

Puma 560 [Unimation]:: 6 axis, RRRRRR, stdDH, fastRNE
 - viscous friction; params of 8/95;
+---+-----------+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|  1|         q1|          0|          0|     1.5708|          0|
|  2|         q2|          0|     0.4318|          0|          0|
|  3|         q3|    0.15005|     0.0203|    -1.5708|          0|
|  4|         q4|     0.4318|          0|     1.5708|          0|
|  5|         q5|          0|          0|    -1.5708|          0|
|  6|         q6|          0|          0|          0|          0|
+---+-----------+-----------+-----------+-----------+-----------+

then choose a random joint coordinate

>> q = rand(1,6)
q =
    0.7922    0.9595    0.6557    0.0357    0.8491    0.9340

then compute the forward kinematics

>> T = p560.fkine(q)
T =
   -0.9065    0.0311   -0.4210  -0.02271
    0.2451    0.8507   -0.4649   -0.2367
    0.3437   -0.5247   -0.7788    0.3547
         0         0         0         1

Now we can compute the inverse kinematics using a published analytic solution for a robot with 6 joints and a spherical wrist

>> p560.ikine6s(T)
ans =
    0.7922    0.9595    0.6557    0.0357    0.8491    0.9340

and voila, we have the original joint coordinates.

The numerical solution

>> p560.ikine(T)
Warning: ikine: rejected-step limit 100 exceeded (pose 1), final err 0.63042
> In SerialLink/ikine (line 244)
Warning: failed to converge: try a different initial value of joint coordinates
> In SerialLink/ikine (line 273)

ans =

     []

has failed, and this is a common problem since they typically need a good initial solution.  Let's try

>> p560.ikine(T, 'q0', [1 1 0 0 0 0])
ans =
    0.7922    0.9595    0.6557    0.0357    0.8491    0.9340

which now gives an answer but it is different to the analytic solution. That's ok though, since there are multiple solutions to the IK problem.  We can verify that our solution is correct by computing the forward kinematics

>> p560.fkine(ans)
ans =
   -0.9065    0.0311   -0.4210  -0.02271
    0.2451    0.8507   -0.4649   -0.2367
    0.3437   -0.5247   -0.7788    0.3547
         0         0         0         1

and checking that it is the same as the transform we started with (which it is).

Other resources:

free video lectures on this topic, search for kinematics at the Robot Academy

Chapter 7 of Robotics, Vision & Control (2e), Corke, Springer 2017.


问:
Determine what the rotation axis is given a rotation matrix
How do I find out around which axis the coordinate system has to rotate, if the rotation matrix is given?

$ {^{a}R_{b} } $ = $ \left(\begin{matrix} 0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1 \\\end{matrix}\right)$

$ {^{a}R_{c} } $ = $ \left(\begin{matrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \\\end{matrix}\right)$

For $ {^{a}R_{b} } $ I thought, that it has to be a rotation around the z-axis, because
$R(z,\theta) =  \left(\begin{matrix} cos(\theta) & -sin(\theta) & 0 \\ sin(\theta) & cos(\theta) & 0 \\ 0 & 0 & 1 \\\end{matrix}\right)$

the values at the positions $a_{13}, a_{23},a_{33},a_{32},a_{31}$ of $ {^{a}R_{b} } $ and $R(z,\theta)$ are identical.

So I solved $cos(\theta) = 0$ =>$\theta = 90° $ => 90° rotation around z-axis.

But how do I solve it, if there is more than 1 rotation, like for $ {^{a}R_{c} } $?

答:
Consider an arbitrary rotation matrix $\bf R$ $\in$ SO(3).  We can use it transform a vector $v \in {\mathbb R}^3$ by $$ w = {\bf R}v$$
Intuitively, if $v$ corresponds to the rotation axis of $\bf  R$ then it will be unchanged by the rotation, that is, $w = v$.

So the rotation axis must be an eigenvector of $\bf R$.  Since $\bf R$ is  a 3x3 matrix it has 3 eigenvectors.  Each eigenvector has an associated eigenvalue: there is always at least one eigenvalue equal to 1 (ie. the vector's length is unchanged by the rotation), and for non-zero rotation the other two eigenvalues are a complex conjugate pair.  The eigenvector corresponding to the eigenvalue equal to one is the rotation axis.

A simple example in MATLAB

```<code>>> R = roty(0.3)
R =
    0.9553         0    0.2955
         0    1.0000         0
   -0.2955         0    0.9553
</code>```

which is a rotation of 0.3 radians about the y-axis (this function is from my Robotics Toolbox for MATLAB).

```<code>>> [x,e] = eig(R)

x =

   0.7071 + 0.0000i   0.7071 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   1.0000 + 0.0000i
   0.0000 + 0.7071i   0.0000 - 0.7071i   0.0000 + 0.0000i

e =

   0.9553 + 0.2955i   0.0000 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.9553 - 0.2955i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   1.0000 + 0.0000i
</code>```

where x is a matrix whose columns are the eigenvectors, and e is a diagonal matrix of eigenvalues.  The unit eigenvalue is in column 3 so our rotation axis is the third column of x which is real and equal to $[0, 1, 0]^T$ which is a unit-vector parallel to the y-axis — the original axis of rotation.

The complex eigenvalues tell you about the amount of rotation around the axis

```<code>>> angle(e(1,1))
ans =
    0.3000
</code>```

The Toolbox has a function which does all this for you

```<code>>> [theta,v] = tr2angvec(R)

theta =
    0.3000

v =
         0    1.0000         0
</code>```

To go in the opposite direction, from a rotation axis and angle, to a rotation matrix use Rodrigues' formula.  This is provided in the Toolbox as

```<code>>> angvec2r(theta,v)
ans =
    0.9553         0    0.2955
         0    1.0000         0
   -0.2955         0    0.9553
</code>```

Body:
Consider an arbitrary rotation matrix $\bf R$ $\in$ SO(3).  We can use it transform a vector $v \in {\mathbb R}^3$ by $$ w = {\bf R}v$$
Intuitively, if $v$ corresponds to the rotation axis of $\bf  R$ then it will be unchanged by the rotation, that is, $w = v$.

So the rotation axis must be an eigenvector of $\bf R$.  Since $\bf R$ is  a 3x3 matrix it has 3 eigenvectors.  Each eigenvector has an associated eigenvalue: there is always at least one eigenvalue equal to 1 (ie. the vector's length is unchanged by the rotation), and for non-zero rotation the other two eigenvalues are a complex conjugate pair.  The eigenvector corresponding to the eigenvalue equal to one is the rotation axis.

A simple example in MATLAB

>> R = roty(0.3)
R =
    0.9553         0    0.2955
         0    1.0000         0
   -0.2955         0    0.9553

which is a rotation of 0.3 radians about the y-axis (this function is from my Robotics Toolbox for MATLAB).

>> [x,e] = eig(R)

x =

   0.7071 + 0.0000i   0.7071 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   1.0000 + 0.0000i
   0.0000 + 0.7071i   0.0000 - 0.7071i   0.0000 + 0.0000i

e =

   0.9553 + 0.2955i   0.0000 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.9553 - 0.2955i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   1.0000 + 0.0000i

where x is a matrix whose columns are the eigenvectors, and e is a diagonal matrix of eigenvalues.  The unit eigenvalue is in column 3 so our rotation axis is the third column of x which is real and equal to $[0, 1, 0]^T$ which is a unit-vector parallel to the y-axis — the original axis of rotation.

The complex eigenvalues tell you about the amount of rotation around the axis

>> angle(e(1,1))
ans =
    0.3000

The Toolbox has a function which does all this for you

>> [theta,v] = tr2angvec(R)

theta =
    0.3000

v =
         0    1.0000         0

To go in the opposite direction, from a rotation axis and angle, to a rotation matrix use Rodrigues' formula.  This is provided in the Toolbox as

>> angvec2r(theta,v)
ans =
    0.9553         0    0.2955
         0    1.0000         0
   -0.2955         0    0.9553


问:
Are examples for jerking robotarms available?
I'm trying to find some youtube videos which are showing robot arms with some malfunction in it. The problem is, that the keyword is unclear. Should i search for “unstable”, “tremble”, “jerking” or “vibrate” as additional word?

I'm sure, that especially lowcost robot arms have often this kind of behavior. If the mechanic contains only of cheap plastic and the servo motor isn't accurate, the construction will result into an underactuated system which is difficult to control. But i like this behavior, because this provides the challenge to develop a motion controller which can overcome the issue with software.

Are any example videos available, in which the robot arm is quite inaccurate and makes it hard to position the endeffector to the target?

答:
The phenomena you're looking for is called "stick slip."

Static friction is the friction that hold an object stationary. Dynamic friction is the sliding friction between surfaces you get while in motion. In the transition from static to dynamic frictions, it's basically like flicking the load with a force equal to the difference between the two friction coefficients.

The problem comes when that impulse is large enough that it accelerates the load faster than the actuator/actor can keep up. If the load accelerates so much that it has the chance to come to a stop before the actuator catches up to the load, then you re-enter the static friction regime. This happens over and over; stick, slip, stick, slip, and typically happens fast enough that it enters the audible range.

I found a pretty entertaining video on YouTube that gives lots of good examples along with a more detailed engineering explanation. I skipped around a bit, but I don't think they showed a robot arm.


问:
Is it correct to think of forward kinematics as merely a 'check' for the inverse kinematics?
When the only inputs to your robot are the next x,y,z coordinates of the next point on and on, I can simply just calculate IK to find the angles and make my actuators move to these angles. Whats the point in calculating forward kinematics in this case? does it merely act as a check for your inverse kinematics integrity? (this shouldn't be accurate because I don't think an analytical solution of the IK will have errors). I see no purpose in calculating the forwards kinematics in this application.</p>

答: You can control the robot using just the inverse kinematics solution.  However, you must be careful to handle the multiple inverse solutions properly (for example, $acos(\theta) = acos(-\theta))$.  Forward kinematics can help you visualize the selected solution.  They are also helpful when building a graphical simulation of the robot.


答:
Most likely, the difference between the two motors will be the number of times the wire is wrapped around the commutator.

There is a tradeoff between RPM and torque in DC motors, where more windings mean more torque (but a lower maximum RPM).  Depending on the characteristics of the motor, some manufacturers use a thicker wire when building motors with fewer windings -- allowing more current to flow.

So, it's possible that the same amount of copper wire is being used for both motors, or that it's near enough not to bother with pricing the different motor types differently.

Title: Why do 1000 rpm and 10 rpm DC motors cost the same?

Body: Today I was going to buy a motor online, and saw that 10 rpm and 1000 rpm DC motors cost the same. How is it possible to change the rpm without requiring any additional parts cost?</p>


问:
How can I attach an arm to a double-flat drive stepper motor?
This is my first robotics experience, outside of one class 10 years ago. I've been Googling this question for about an hour but I can't find an answer!

I'm using a ROHS Step Motor 28BYJ-48 (with an Arduino Uno). The rotating shaft that sticks out of the step motor seems to be called a "double-flat drive". It's less than 1/4" wide, and is flattened on two sides.

I need to attach a 6" long arm to it, so the arm can spin like the second hand on a wall clock, but in both directions. What can I use to attach the arm securely to the shaft? What's the name of the part that will couple this double-flat drive shaft to a straight, flat piece at a right angle to it? Or are there flat metal circles with holes in them that can be coupled to the double-flat drive shaft without slipping - and what's the Google search phrase I should use to find them?

答: You can use a D or Double D shaped shaft collar/coupler.  Or obtain a Double D shaped punch, depending on the design of the piece you are attaching to the shaft. </p>


问:
What's the difference between a holonomic and a nonholonomic system?
I was wondering if a 1D point mass (a mass which can only move on a line, accelerated by an external time-varying force, see Wikipedia - Double integrator) is a holonomic or a nonholonomic system? Why?

I think that it is nonholonomic since it cannot move in any direction in its configuration space (which is 1D, just the $x$ axis). E.g. if the point mass is moving at $$x=10$$ with a velocity of 100 m/s in positive $x$-direction it cannot immediately go to $$x=9.9$$ due to its inertia. However, I have the feeling that my thoughts are wrong...

The background is the following:

I am trying to understand what holonomic and nonholonomic systems are. What I found so far:

Mathematically:

Holonomic system are systems for which all constraints are integrable into positional constraints.

Nonholonomic systems are systems which have constraints that are nonintegrable into positional constraints.

Intuitively:

Holonomic system where a robot can move in any direction in the configuration space.

Nonholonomic systems are systems where the velocities (magnitude and or direction) and other derivatives of the position are constraint.

答:
A holonomic constraint is a constraint on configuration: it says there are places you cannot go. That is a reduction in freedoms. That’s (usually) bad.

A nonholonomic constraint is a constraint on velocity: there are directions you cannot go. But you can still get wherever you want. That’s (usually) good!

Ref: Mechanics of Manipulation by Mathew T. Mason


问:
What are the prerequisites for entering into robotics?
I'm doing my Engineering in Electronics, what subjects which I need to specialize in order get into robotics and also suggest additional things I have to study</p>

答:
Robotics is an interdisciplinary field in which people from various backgrounds (such as mechanical engineering, CS, electrical engineering, machine learning, control systems...) work together. I guess it depends on you which part of it you are interested in.

You can choose perception and localization, or motion control, or machine learning etc. Then you should take courses based on your interested field.

Although you need basic computer programming skills and some understanding of simulation platforms like ROS or Matlab.

Hope it would help.


答:
I would advise you to start with a basic robot controlled through Arduino (An Arduino Uno/Mega with 2 motors controlled or not by a motor-shield, a few sensors like ultrasonic ones...) like this frame. Arduino boards does an abstraction of the very specific electronics to control motors, you also have an easy language to control your board (with a good community to help you and lots of already existing libraries). This will help you focus on the control part (feedback control)... Then you will realize that for the next step you will need to go further in the code with a microprocessor (like an Raspberry Pi or something similar) and it will add some complexity with the hardware compatibility of your electronics components. Then you may also add image processing with opencv in python or C++ according to your skills and your aim to have an optimized system (if you feel uncomfortable with image processing, you can start it with Matlab, but you will need to pay while Opencv is free).

You will need to acquire a lot of knowledge on how to build an independent system (to think of the power-supply, the way it interacts with its environment, communicate with its internal components... etc). To do so I recommend you to start with the basic system-engineering knowledges (functional architecture, physical architecture, interfaces...). An other way to obtain some knowledges on this kind of competencies (and this is still interesting when you need to perform technologic intelligence) is to read reports made by robotics teams in challenges (some teams made it available when they compete), in my case I have read reports of teams which have been competing at Eurobot (it's a competition for universities and hobbyist).

ROS is a good choice to do some robotics because it is among the most up-to-date middleware to do robotics but before using it you need to understand why it is interesting to use a middleware by doing some low-level job (with micro-controllers). And you need to be very familiar with Linux (Ubuntu, Debian or Fedora are advised).

Title: What are the prerequisites for entering into robotics?

Body: I'm doing my Engineering in Electronics, what subjects which I need to specialize in order get into robotics and also suggest additional things I have to study</p>