问:
Can't run DC Motor with Arduino and Adafruit Motor Shield
I'm very new with Arduino and Adafruit and I'm trying to get a DC motor running with my Adafruit Motor Shield V2.3, but it's not running. I have connected the motor to the right terminal (M3). I'm following the Adafruit website guide. Does anyone know what I'm doing wrong?

Here is the Arduino and Motor Shield:

And here is my code:

```<code>#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *myMotor = AFMS.getMotor(3);

void setup()
{
  AFMS.begin();
  myMotor->setSpeed(255);
}

void loop()
{
  myMotor->run(FORWARD);
  delay(2000);
  myMotor->run(BACKWARD);
  delay(2000);
  myMotor->run(FORWARD);
  delay(2000);
  myMotor->run(RELEASE);
  delay(1000);
}
</code>```

The code uploads with no errors but nothing happens after that.

答:
To quote Adafruit:

You cannot power motors from a 9V battery. You must use AA batteries or a lead acid battery for motors.

You can grab a decent SLA (Sealed Lead Acid) battery by grabbing an alarm battery from any battery store for a relatively decent price (or an online retailer). Alternatively you could get an AA battery holder that lets you put several AA batteries in series.

The reason why a 9V battery won't work is because 9V batteries are chemically incapable of providing the inrush current required to start a motor.
The 9 volt battery can be used to power the arduino through the power jack since it requires little current to function.


问:
What is a simple way to assign frames to a robot manipulator using D-H convenction?
I am studying the forward kinematics for robot manipulators, and I am focusing on the Denavit Hartenberg convenction for assigning frames to the various joints of the manipulator.

The problem is that I am often confused, and so it is easy to make mistakes for me.

I have understood the concept of the D-H convenction and how it assigns frames, but when I start having more complex manipulators to analyze, for example spacial manipulators with both prismatic and revoulute joints , I start making confusion and assigning frames wrongly.

So, my question is:

Is there a way to assign frames being sure (or at least reducing a lot) the chances of making mistakes?

答:
First of all, I have to share with you this link:

```<code>https://www.youtube.com/watch?v=rA9tm0gTln8
</code>```

I like to think of a few tricks with D-H params.
First, the Z-axis is the axis of rotation/translation.
Then, theta rotates along the Z-axis to align with the start of the next D-H frame.
You then translate along the Z axis such that the point is tangent to the next frame's Z-X plane.
Then, the A term moves along the CURRENT X-axis to the start of the next frame.
Finally, you rotate about the X-Axis to align the Z-axis with the rotation/translation axis of the next frame.

Summary:

Rotate about Z-axis (theta)

Translate along Z-axis  (z)

Translate along X-axis (a)

Reorient Z-Axis about X-axis (alpha)

Note

The starting X-axis can be anywhere. You will want to choose a convenient orientation such that the math is easy later. If there is a world frame you are trying to align to, that can help you think of a start. Remember, you do NOT use the Y-axis for anything.

Does this make sense?

ContentLicense: CC BY-SA 4.0

Body:
First of all, I have to share with you this link:

https://www.youtube.com/watch?v=rA9tm0gTln8

I like to think of a few tricks with D-H params.
First, the Z-axis is the axis of rotation/translation.
Then, theta rotates along the Z-axis to align with the start of the next D-H frame.
You then translate along the Z axis such that the point is tangent to the next frame's Z-X plane.
Then, the A term moves along the CURRENT X-axis to the start of the next frame.
Finally, you rotate about the X-Axis to align the Z-axis with the rotation/translation axis of the next frame.

Summary:

Rotate about Z-axis (theta)

Translate along Z-axis  (z)

Translate along X-axis (a)

Reorient Z-Axis about X-axis (alpha)

Note

The starting X-axis can be anywhere. You will want to choose a convenient orientation such that the math is easy later. If there is a world frame you are trying to align to, that can help you think of a start. Remember, you do NOT use the Y-axis for anything.

Does this make sense?


问:
Rotating a lever with a small servo
I'm trying to rotate a lever link to gently "offload" a load using a servo. Here's a drawing:

Here, the red is a lever, yellow pivot and black is the load. To offload, the lever needs to be turned 90 degrees. I know I could simply put a servo where the yellow pivot is, but the problem is that the servo may not have enough torque to hold the load. The load is typically around 1-2kg and the distance from the pivot is around 15cm. The servo has a stall torque of around 10kg-cm.

Is it a good idea to drive a cable on the right hand side of the lever with a servo? Or is there a link setup that allows such a small servo to drive this lever?

答:
From your numbers, I believe you need something that can support at least ~30kg-cm torque at the load, unless you make other changes.  A few options:

Counterweight - As @jsotla commented, a counterbalance might be added to the opposite side of the load on the lever.  If the servo attachment point or lever can not support that extra weight though, then perhaps it could make sense to use a remote cable or lever-activation mechanism to rotate the lever from the servo.  The servo would operate the cable/lever-activation mechanism to rotate the lever around the lever attachment point/pivot.  This is partly dependent on how much rotation your servo can support, if you need to be able to apply force in both rotation directions, etc.

Gear Reduction - Another option might be to use a gear mechanism, such that extra rotation in the servo is translated into additional torque.  As one example, ServoCity makes interesting gear boxes for RC type servos. Or, a custom worm gear based solution might be particularly useful due to the special properties of worm gears ...depending on your project details.

Pulleys - Similar to gears, a pulley system would also work. Again, depends on the rotation capabilities of your servo, and this would likely be more complex than other solutions.

In summary, you will need to find some way of offsetting the load weight, or else transforming additional movement from your servo into torque.

Title: Rotating a lever with a small servo


问:
Is there a way to determine which degrees of freedom are lost in a robot at a singularity position by looking at the jacobian?
For a 6DoF robot with all revolute joints the Jacobian is given by:
$$
\mathbf{J} =
\begin{bmatrix}
\hat{z_0} \times (\vec{o_6}-\vec{o_0}) & \ldots & \hat{z_5} \times (\vec{o_6}-\vec{o_5})\\
\hat{z_0} & \ldots & \hat{z_5}
\end{bmatrix}
$$
where $z_i$ is the unit z axis of joint $i+1$(using DH params), $o_i$ is the origin of the coordinate frame connected to joint $i+1$, and $o_6$ is the origin of the end effector.  The jacobian matrix is the relationship between the Cartesian velocity vector and the joint velocity vector:
$$
\dot{\mathbf{X}}=
\begin{bmatrix}
\dot{x}\\
\dot{y}\\
\dot{z}\\
\dot{r_x}\\
\dot{r_y}\\
\dot{r_z}
\end{bmatrix}
=
\mathbf{J}
\begin{bmatrix}
\dot{\theta_1}\\
\dot{\theta_2}\\
\dot{\theta_3}\\
\dot{\theta_4}\\
\dot{\theta_5}\\
\dot{\theta_6}\\
\end{bmatrix}
=
\mathbf{J}\dot{\mathbf{\Theta}}
$$

Here is a singularity position of a Staubli TX90XL 6DoF robot:

$$
\mathbf{J} =
\begin{bmatrix}
          -50     &    -425     &    -750      &      0     &    -100      &      0\\
       612.92     &       0     &       0      &      0     &       0      &      0\\
            0     & -562.92     &       0      &      0     &       0      &      0\\
            0     &       0     &       0      &      0     &       0      &      0\\
            0     &       1     &       1      &      0     &       1      &      0\\
            1     &       0     &       0      &     -1     &       0      &     -1
\end{bmatrix}
$$

You can easily see that the 4th row corresponding to $\dot{r_x}$ is all zeros, which is exactly the lost degree of freedom in this position.

However, other cases are not so straightforward.

$$
\mathbf{J} =
\begin{bmatrix}
          -50   &   -324.52  &    -649.52   &         0   &   -86.603   &         0\\
       987.92   &         0  &          0   &         0   &         0   &         0\\
            0   &   -937.92  &       -375   &         0   &       -50   &         0\\
            0   &         0  &          0   &       0.5   &         0   &       0.5\\
            0   &         1  &          1   &         0   &         1   &         0\\
            1   &         0  &          0   &    -0.866   &         0   &    -0.866
\end{bmatrix}
$$

Here you can clearly see that joint 4 and joint 6 are aligned because the 4th and 6th columns are the same.  But it's not clear which Cartesian degree of freedom is lost (it should be a rotation about the end effector's x axis in red).

Even less straightforward are singularities at workspace limits.

$$
\mathbf{J} =
\begin{bmatrix}
          -50     &     650   &       325  &          0    &        0     &       0\\
       1275.8     &       0   &         0  &         50    &        0     &       0\\
            0     & -1225.8   &   -662.92  &          0    &     -100     &       0\\
            0     &       0   &         0  &    0.86603    &        0     &       1\\
            0     &       1   &         1  &          0    &        1     &       0\\
            1     &       0   &         0  &        0.5    &        0     &       0
\end{bmatrix}
$$

In this case, the robot is able to rotate $\dot{-r_y}$ but not $\dot{+r_y}$.  There are no rows full of zeros, or equal columns, or any clear linearly dependent columns/rows.

Is there a way to determine which degrees of freedom are lost by looking at the jacobian?

答:
You need to find the null space, not just look for zero rows or full columns. And I don't mean the null space of any particular jacobian, I mean the analytic space of all singular configurations, given the closed-form Jacobian. Usually this occurs because of a gimbal lock (as opposed to just an unreachable state space)

Doing this in closed form is very, very hard.   But sometimes you can reduce the space a little.

ContentLicense: CC BY-SA 3.0


问:
Hector_Slam orientation probelm for drone
We are using Hector slam(2-D Mapping) for our drone in which we are facing some problems

1) as the orientation(axis) of the lidar changes the orientation of map changes

2) as the plane of the lidar changes the map order distorts.

Please give tips for these problems

答:
Disclaimer:
I have not used the Hector libraries, but I have heard of them in the past.

Have you looked at homogeneous transformation matrices? Assuming that you only have a change in Yaw to keep track of, you can use the Z-axis rotation matrix to rotate the point to the correct location.

```<code>[ cos(theta)  -sin(theta)   0  0 ]
[ sin(theta)   cos(theta)   0  0 ]
[      0           0        1  0 ]
[      0           0        0  1 ]
</code>```

Multiply this matrix with the 3D point vector

```<code>[ x ]
[ y ]
[ z ]
[ 1 ]
</code>```

And then you can rectify for the point for lidar Z-axis rotation.

You can take the RPY values from an IMU and then check to see if the R and P values pass a threshold. If the magnitudes of those R and P values are too large, then you can simply not count that point in the reading. You will be dropping data points, but that isn't necessarily a bad thing.

The smarter way (IMHO) to use the data is to use 3D SLAM to create a full-on point cloud. That is probably too computationally expensive, but I think these methods are good enough for a start, and it looks like you want a simpler methods anyways.

Body:
Disclaimer:
I have not used the Hector libraries, but I have heard of them in the past.

Have you looked at homogeneous transformation matrices? Assuming that you only have a change in Yaw to keep track of, you can use the Z-axis rotation matrix to rotate the point to the correct location.

[ cos(theta)  -sin(theta)   0  0 ]
[ sin(theta)   cos(theta)   0  0 ]
[      0           0        1  0 ]
[      0           0        0  1 ]

Multiply this matrix with the 3D point vector

[ x ]
[ y ]
[ z ]
[ 1 ]

And then you can rectify for the point for lidar Z-axis rotation.

You can take the RPY values from an IMU and then check to see if the R and P values pass a threshold. If the magnitudes of those R and P values are too large, then you can simply not count that point in the reading. You will be dropping data points, but that isn't necessarily a bad thing.

The smarter way (IMHO) to use the data is to use 3D SLAM to create a full-on point cloud. That is probably too computationally expensive, but I think these methods are good enough for a start, and it looks like you want a simpler methods anyways.


问:
Forward kinematics of spherical parallel manipulators with revolute joints
I found an article that can help in my investigations.

Forward kinematics of spherical parallel manipulators with revolute joints

The problem is solved for the following system of vectors, which is shown in the figure.

The methodology described in the article allows, using simple numerical calculations on a computer, to determine the angles $\psi$, $\psi$'and $\phi$, $\phi$'.

All other angles ($\alpha_2$,$\alpha_3$,$\alpha_4$,$\alpha_5$,$\mu$) are known.

The coordinates of points $B_1$,$B_2$,$B_3$ and $C_1$,$C_2$,$C_3$ are also known.

I do not know how, knowing these parameters, it is possible to determine the coordinates of points $A_1$,$A_2$,$A_3$.

In the same article on page 525 there is such a sentence:

But I do not understand how to do this.
I ask for help.

答:
Vectors $v_i$ are restored very simply.

For example, vector $v_1$.

First we need to rotate the $C_2$ vector by the angle $\phi_1$ around the $C_1$ vector. This way we get the intermediate vector $v*_1$.

And then rotate this vector by the angle $(\alpha_2 - C_1 \cdot C_2)$ around axis of rotation $(v*_1 \times C_1)$.

Vectors calculated in this way are similar to the calculated data given in the publication.

For the remaining vectors, the principle is similar.


问:
Problem defining rotation matrix
I am studying robotic kinematics , and given the following manipulator with its D-H frames assigned:

I have to find the rotation matrix $R_{e}^{2}$, which is the rotation matrix of frame $e$ with respect to frame $2$.

I know that this matrix is :

$\begin{pmatrix}
0 &sin\beta   & cos\beta \\
 0& cos\beta & -sin\beta\\
-1 &0  &0
\end{pmatrix}$

but I cannot understand why.

Can somebody please help me understand how does this reotation matrix comes out?

答:
It looks like both frames are attached to the end effector at point P, and are offset by a constant angle $\beta$. So you don't really have to consider the D-H parameters to answer this question - just do a simple rotation matrix evaluation.

So how are the frames, $F_2$ = $[\hat{x_2} \; \hat{y_2} \; \hat{z_2}]^T$ and $F_e$ = $[\hat{x_e} \; \hat{y_e} \; \hat{z_e}]^T$, related? Well, from the diagram you have above, we have the following relationships:

$$\hat{x_2} = \cos\beta \hat{y_e} + sin\beta \hat{z_e}$$
$$\hat{y_2} = \cos\beta \hat{y_e} - sin\beta \hat{z_e}$$
$$\hat{z_2} = -\hat{x_e}$$

Note that $\hat{x_e}$ points into the page and $\hat{z_2}$ points out of the page.

Then do you see how your rotation matrix above falls out of that? Clearly,

$$F_2 = R_e^2F_e$$

Title: Problem defining rotation matrix


答:
A rotation matrix is also called a director cosine matrix. The elements of the rotation matrix are the cosines of the unit vectors of two coordinate systems involved. You can find a more generic explanation here.

Let $\angle (e_{2,i}, e_{e,j})$ denote the angle between the angle between unit vector on the i axis of the fixed reference frame and the unit vector of the j axis of the rotated frame.

$$
R_{2e} = \\
\begin{pmatrix}
cos(\angle (e_{2,x}, e_{e,x},)) & cos(\angle (e_{2,x}, e_{e,y},)) & cos(\angle (e_{2,x}, e_{e,z}))\\
cos(\angle ( e_{2,y}, e_{e,x},))) & cos(\angle (e_{2,y}, e_{e,y},)) & cos(\angle (e_{2,y}, e_{e,z}))\\
cos(\angle (e_{2,z}, e_{e,x},)) & cos(\angle (e_{2,z}, e_{e,y},)) & cos(\angle (e_{2,z}, e_{e,z}))
\end{pmatrix}
=
\begin{pmatrix}
0 &sin\beta   & cos\beta \\
 0& cos\beta & -sin\beta\\
-1 &0  &0
\end{pmatrix}
$$

In your case we identify that:

$cos(\angle (e_{2,x}, e_{e,x})) = 0$

This translates to a $90^\circ $ angle between the unit vectors of the two x axes.

$cos(\angle (e_{2,y}, e_{e,x})) = 0$

This translates to a $90 \deg $ angle between the unit vectors of the y axes of the reference frame and the x axis of the rotated frame.

$cos(\angle (e_{2,z}, e_{e,x})) = -1$

This translates to a $180^\circ $ angle between the unit vectors of the z axes of the reference frame and the x axis of the rotated frame.

Similarly for all other elements of the matrix, but here is the most interesting ones:

$cos(\angle (e_{2,y}, e_{e,y},)) = cos(\beta)$

This translates to a $\beta^\circ $ angle between the unit vectors of the y axes of the reference frame and the y axis of the rotated frame.

$cos(\angle (e_{2,z}, e_{e,x})) = cos(\beta)$

This translates to a $\beta^\circ $ angle between the unit vectors of the z axes of the reference frame and the x axis of the rotated frame.

$cos(\angle ( (e_{2,y}, e_{e,z}) ) = -sin(\beta)$

Using the quarter period phase shift property $cos(x + \frac{\pi}{2}) = -sin(x)$

$cos(\angle ((e_{2,y}, e_{e,z})) = cos(\beta + \frac{pi}{2})$

This translates to a $\beta + 90^\circ $ angle between the unit vectors of the y axes of the reference frame and the z axis of the rotated frame.

Title: Problem defining rotation matrix

Body:
I am studying robotic kinematics , and given the following manipulator with its D-H frames assigned:

I have to find the rotation matrix $R_{e}^{2}$, which is the rotation matrix of frame $e$ with respect to frame $2$.

I know that this matrix is :

$\begin{pmatrix}
0 &sin\beta   & cos\beta \\
 0& cos\beta & -sin\beta\\
-1 &0  &0
\end{pmatrix}$

but I cannot understand why.

Can somebody please help me understand how does this reotation matrix comes out?


问:
Can you have a career in robotics if you hate mechanics?
I'm a first year electronics engineering student. I love almost all the aspects of robotics - the electronics, algorithms, control theory etc. I can't stand the mechanical aspect of robotics though.

Can I have a fulfilling career in Robotics if I hate mechanics but love all other parts of robotics? I'm ready to learn mechanics if I absolutely have to, but would strongly prefer not to learn any more than the absolute basics.

答:
I have been working with Numerical Control for more than 30 years. This is a arm of the robotics genera which doesn't appear to be touched upon. What I do is programming, not mechanics. There are several types of jobs available in NC without getting your hands dirty.
Most of the people I interface with are mechanical and manufacturing engineers. </p>


问:
Where to include velocity in a Kalman filter
I am trying to understand some of the basics of the Kalman filter. The problem I am working on is quite complex, but I have spent some time trying to simplify the problem with an example.

So, let's say we want to track the position $p$ of a car, and the car can move left or right, at velocity $v$, in a 1-dimensional world. Noisy measurements of the car's position are being made by an external camera:

I am struggling to understand how to formulate a Kalman filter for this problem. What I don't understand, is whether the velocity should be included in the state or the control input, given that it is something we are actually controlling.

To show my thinking, I have created two potential implementations of the Kalman filter below. I would like to know which of these are correct, or most appropriate, and why.

1) In the first method, there is no control input. The state changes by inspecting other elements of the state.

The state at time $t$ contains position $p_t$ and velocity $v_t$:

$x_t = \begin{bmatrix}p_t\\v_t\end{bmatrix}$

The prediction stage only includes the state transition model $A$ and noise $\epsilon$; there is no control input:

$x_{t+1} = Ax_{t} + \epsilon$

The state transition model says that the car's position changes based on the velocity in the state, by calculating the velocity multiplied by the timestep $\Delta t$. And the velocity remains the same:

$A = \begin{bmatrix}1&\Delta t\\0&1\end{bmatrix}$

We then have an observation $z_t$ of the position, which is dependent only on the position and noise $\delta$:

$z_t = Cx_{t} + \delta$

The observation model is just identity, i.e. the observation is a direction observation of the position:

$C = \begin{bmatrix}1 & 0\end{bmatrix}$

2) In the second method, we introduce a control input. The state changes by inspecting elements in both the state and the control input.

This time, the state only contains the position:

$x_t = \begin{bmatrix}p_t\end{bmatrix}$

And the state change is based on the state transition matrix, and the control input matrix.

$x_{t+1} = Ax_t + Bv_t$

This time, the state transition matrix is just identity, since we no longer include velocity and the dynamics is only due to the control input:

$A = \begin{bmatrix}1\end{bmatrix}$

And the control input matrix simply multiplies the velocity by the timestep $\Delta t$:

$B = \begin{bmatrix}\Delta t\end{bmatrix}$

And we know the velocity $v_t$ because this is the command we are controlling the car with.

And we have the same observation model as before, but this becomes a 1-by-1 matrix rather than a 1-by-2 matrix, since we have dropped the velocity component from the state vector:

$z_t = Cx_{t} + \delta$

$C = \begin{bmatrix}1\end{bmatrix}$

I don't really understand which is the most suitable method.  Method 2 seems to be better than method 1, because we are directly using the velocity, rather than estimating it. And since we actually control the velocity, it makes sense to actually use it in the estimation.

But would method 1 even work? Would it be able to update its estimate of the velocity, even though the velocity is never measured or used in the dynamics model? Or can the velocity component of the state only change beyond its initial estimate if it is directly measured?

If anybody is able to help me with this, I would really appreciate it. Thank you!

答:
I have split this into two main questions:

"whether the velocity should be included in the state or the control input"

"would method 1 even work?"

Question 1

The answer to question 1 is what information do you have available and what are you attempting to estimate? If you have measurement of the velocity or if estimating the velocity is not necessary, then Method 2 is probably what you are looking for.

If you require velocity estimates, from the KF, then the velocity will need to be part of the state vector.

Question 2

will it work?

So the problem here is inertial navigation, more or less. In a basic sense one would take acceleration measurements, integrate twice, and compare with the position measurements.

Method 2 is more or less inertial navigation applied with velocity measurements instead of acceleration. Therefore this method should work fine.

Method 1 on the other hand has assumed the following model for the velocity dynamics:
$$
v_{k+1} = v_{k}
$$
i.e. assumed that the velocity is constant. The problem here is the filtering performance is dependent on the validity of this model and the initial state estimate. I don't know your context but I imagine near constant velocity is probably not likely.

In addition it is slightly strange that there is no input at all. It kind of implies that this model is purely a zero-input response, i.e some decay from initial state for an asymptotically stable system.

If the velocity estimate is desired one would maybe expect to see something along the lines of
$$
\dot{{x}} = \left[\matrix{0 &1\cr 0 &0}\right] + \left[\matrix{0 \cr 1}\right]u
$$
where $u$ is the acceleration from an accelerometer. This way a model for the velocity dynamics is just simply
$$
\dot{v} = a
$$
This is a very simplified version of the mechanization equation for an inertial navigation system, i.e. 1 dimension and no noise.

TLDR: Where you include velocity depends on what information (read: measurements) you have available and what you want the Kalman filter to estimate.


问:
Transforming between a local and global frame for a Kalman filter
I want to track an object in a global Cartesian frame, denoted $G$. The object has a local frame, denoted $L$. The object is controlled by a velocity command $v$, defined in its local frame. This "world" is a 2D space as below:

In this world, the object can only translate (no rotation), and the local axes and global axes are aligned. Therefore, I can track the object using a regular Kalman filter.

I define the state as $x_t = \begin{bmatrix}x_t\\y_t\end{bmatrix}$ where $x$ and $y$ are the positions in the global frame. The control velocity is defined as $v_t = \begin{bmatrix}a_t\\b_t\end{bmatrix}$, where $a$ and $b$ are the local velocities defined in the local frame. The state transition matrix is defined as $A = \begin{bmatrix}1&0\\0&1\end{bmatrix}$ and the input matrix is defined as $B = \begin{bmatrix}\Delta t&0\\0&\Delta t\end{bmatrix}$, where $\Delta t$ is the time step.

So overall, my prediction stage of the Kalman filter is:

$\begin{bmatrix}x_{t+1}\\y_{t+1}\end{bmatrix} = \begin{bmatrix}1&0\\0&1\end{bmatrix} \begin{bmatrix}x_t\\y_t\end{bmatrix} + \begin{bmatrix}\Delta t&0\\0&\Delta t\end{bmatrix} \begin{bmatrix}a_t\\b_t\end{bmatrix}$

But now I want to allow the object to rotate, about the axis going into the screen. So, my "world" now looks like this:

And now, the axes of the two frames are not aligned, so I cannot use the state transition model I defined above. So, to account for this in the Kalman filter, I do the following.

I take the current estimate of the object's pose, and create a transformation matrix to represent this frame. Let us denote this $T_{GL}$, which transforms a vector from the object's local frame to the global frame. Then, I take the velocity vector $v_L$, which is currently defined in the local frame, and transform to the global frame as follows: $v_G = T_{GL} v_L$.

Once this is done, I have the control velocity defined in the global frame, instead of the local frame. And so then I just use this velocity in the Kalman filter defined in the first example above. My intuition is that once the velocity is transformed to the global frame, I can use the simple state transformation model defined above, because the axes of the velocity and the global frame are now aligned.

But I am rather confused now. It seems like I have effectively implemented the Extended Kalman Filter (EKF), because the relationship between the local velocity and the state update is actually non-linear, due to the rotation. The EKF involves linearising around the current estimate, and I am effectively doing this by computing the transformation matrix for the current estimation of the object's pose. However, when I read about the EKF, the maths is much more complex. It involves Taylor series expansions and partial derivatives, whereas all I am doing is transforming a vector from the estimated local frame to the global frame.

Have I actually implemented an EKF, unknowingly? Or is there something about my implementation that is fundamentally wrong?

Thank you!

答: You have not accidentally implemented an Extended Kalman filter. All you are essentially doing is preprocessing the data with a known quantity $T_{GL}$ into your global frame. You therefore removed any indication of rotation and therefore your math is still happening in the global frame which allows you to continue to use your Kalman filter implementation.


问:
Can standard SLAM techniques be used in maritime environments, where waves and currents move the vessel even with no control input
I am trying to implement a functioning SLAM system for an autonomous surface vessel (ASV). I don't have any direct experience with SLAM, and I am therefore researching the topic before I try to implement anything.

I am trying to figure out, if a maritime environment will make this job much harder than if our vessel was in a more static environment.

From my readings, I am getting the impression that you need to have a fair estimate of your location over time, given your inputs. Usually SLAM techniques are described for robots that don't move, if you don't tell it to, and this puts a strong constraint on the possible error between estimated location and actual location.

For ASV's the position moves constantly, depending on waves and currents, both in xyz and in pitch, yaw and roll directions. Will this be a problem for standard SLAM techniques? If I have an IMU, can I potentially correct for these disturbances?

For reference, the ASV I'm working with has a GPS and an IMU, and a lidar and cameras for landmark detection.

答:
One of the central elements of SLAM is the map itself, build from sensor readings. There is a wide range of sensors which can be used, but they all have in common a capability of building a map (2D or 3D). In the case of an ASV, in a generic maritime environment, I doubt that there are features in the surrounding environment which can be picked up by a lidar/cameras and used to create a map. As the map element is unlikely, I would say that SLAM does not make sense.

I am not familiar with sonar and the resolution/performance of sonars. It might be possible to use the ocean floor as a map and then SLAM would make sense (similar to upward facing cameras for robots in environments with ceilings.

Also, if you are near a coastline, which can be detected by sensors, than again, slam does make sense.


问:
Why in trajectory planning in joint space the manipulator never crosses a singularity?
I am studying robotics kinematics and I have studied that if we plan a trajectory in joint space it is impossible for the robot manipulator to cross a singularity during its motion, while in cartesian space this is possible.

But why in joint space the manipulator never meet a singularity?

答:
The term "singularity" characterizes those configurations in the joint space where the Jacobian matrix loses rank and thus it is not directly invertible.

The Jacobian, in turn, is used to remap a trajectory from the Cartesian space to the joint space.

Therefore, if you plan the trajectory straight in the joint space, then you are not going to use the Jacobian and, as a consequence, you will not have to deal with singularities.


问:
Are Rospy subscriber callbacks executed sequentially for a single topic?
Suppose a ROS node receives new batch of data on a topic while the previous batch is still being processed by callback. Will ROS wait for its completion or will it spin a new thread and run both at the same time?

I'm asking because if they are sequential there is no need for a lock, but if they're not I'd need to use locking inside the callbacks.

I looked up the documentation for the rospy.Subcriber class, but it has no mention of this.

答:
The short answer is yes. In rospy, every subscriber/timer gets its own thread. So for a single topic that means the callback will be executed sequentially. If you are going to be regularly receiving messages before the previous callback has finished, you want to be sure to have reasonable queue size, or you might end up dropping messages!

You're right though, I don't seem to be able to find this documented on the wiki. You can dive into the Topic source code, it looks like the thread on a per-subscriber bases is created here - and in the most basic case it will just start a loop which receives messages and handles callbacks in a receive loop.


问:
ABB RAPID - calculating seam length
I have an Arc welding RAPID program with many seams. One of them looks like this:

```<code>ArcLStart W007_On, vtoArc, sm01, s_12, fine, R1_tWeld\WObj:=R1_wFix;
ArcL W007_1, vWeld, sm01, s_8, z1, R1_tWeld\WObj:=R1_wFix;
ArcC W007_2, W007_3, Vweld, sm01, s_8, z1, R1_tWeld\WObj:=R1_wFix;
ArcL W007_4, vWeld, sm01, s_8, z10, R1_tWeld\WObj:=R1_wFix;
ArcL W007_5, vWeld, sm01, s_8, z5, R1_tWeld\WObj:=R1_wFix;
ArcLEnd W007_Off, vWeld, sm01, s_8, z1, R1_tWeld\WObj:=R1_wFix;
</code>```

What I want to do is measure/calculate the seam length programatically. Calculation can take place during normal program execution or in specialised routine (doesn't matter). How can I do that in RAPID?

答:
Can you run something like this, parallel a parallel task (623-1: Multitasking) to the welding process?

```<code>VAR iodev Pos_file;
VAR string FilePath:="TCPPos";
VAR string TCP_str;
FilePath:=FilePath+"_"+CDate()+".log";

Open FilePath, Pos_file\Append;

//Cycle until Welding process is active
  TCP_str:= .. Add current TCP position
  WRITE TCP_str;

Close FilePath
</code>```

Then you can take the TCPPos_DATE_.log file and post process it on a PC

Title: ABB RAPID - calculating seam length

Body:
Can you run something like this, parallel a parallel task (623-1: Multitasking) to the welding process?

VAR iodev Pos_file;
VAR string FilePath:="TCPPos";
VAR string TCP_str;
FilePath:=FilePath+"_"+CDate()+".log";

Open FilePath, Pos_file\Append;

//Cycle until Welding process is active
  TCP_str:= .. Add current TCP position
  WRITE TCP_str;

Close FilePath

Then you can take the TCPPos_DATE_.log file and post process it on a PC


问:
What does "resolution of a sensor" mean?
I am studying robotics and I am focusing my attention on the sensors used on robot manipulators. I have seen that there a proprioceptive sensors, such as encoders, and exteroceptive sensors, such as range finders and sonars.

During my studies on this topics I have encoutered the concept of resolution of a sensor and I have seen in paericular that the encoder, both absolute and incremental, have a way of calculating resolution, and also exteroceptive sensors have the resolution, such as depth resolution , angular resolution and width resolution.

I am tryin to understand how everything works, but I cannot understand the concept of resolution. I have seen that the definition is :

The resolution of a sensor is the smallest change it can detect in the quantity that it is measuring. The resolution of a sensor with a digital output is usually the resolution of the digital output. The resolution is related to the precision with which the measurement is made, but they are not the same thing. A sensor's accuracy may be considerably worse than its resolution.

which I have found here.

But I don't understand this concept very well since I don't know how to apply it in the various problems and cannot idetify the concept of resolution with the various type of resolution I mentioned above.

Can somebody please help me?

答:
This ruler has a resolution of 1 inch:

It has a resolution of 1 inch because the only readings on the ruler are 0, 1, 2, or 3 inches. It can't measure anything smaller than an inch; it only measures inches.

The ruler below has a resolution of a half-inch (0.5 inches). This ruler now has the capacity to measure 0, 0.5, 1.0, 1.5, ..., 3.5 inches.

For these rulers, you or I could look at them and maybe guess a better reading, but digital circuits need to quantize the data at some point so it can be counted. The reading is more than an inch or it isn't. It's more than 2 inches or it isn't. Etc.

Consider a LIDAR unit. It flashes a laser and starts a stopwatch. It counts time until it sees the reflection, and then estimates the distance to the reflecting object by half the speed of light times that elapsed time (because the laser shines out and then returns - it travels twice the distance).

The stopwatch counts the elapsed time down to some degree of precision, and that precision then determines the positioning accuracy of the LIDAR.

Digital cameras have to measure the intensity of light that strikes the receptor; that intensity has to be counted, so again the ability to differentiate light intensities (and thus shades of color) is limited by how many values the sensor has available for counting.

The odometer in your car might read to the nearest tenth of a mile/kilometer, but your car actually moves smoothly between those points. Again, your car's odometer is limited in the distance it represent because it has a limited number of digits from which to choose. You could have an odometer accurate to the nearest hundredth of a kilometer if you wanted, or meter, millimeter, etc., but then the display would be very large, the dials would turn very quickly and wear, etc., and what's more is that it wouldn't provide the driver with useful information.

It all comes down to counting. To be digital, it must necessarily be countable. To be countable, there must then be some approximation. How close of an approximation is required will depend on your application requirements and is really at the heart of a lot of engineering work.


答:
Consider a single digital pin input into your microprocessor of your robot. What does the software record when the external pin voltage:

Is greater than zero, but less than the trigger point?

Is less than maximum, but greater than the trigger point?
(omitting the probable hysteresis of that trigger point).

The pin electronics resolves the input voltage into either 0 or 1; there are no other possible values. So, if the input voltage increases from zero by anything less than the trigger voltage, it is still detected as 0. That change is too small to be resolved by the pin electronics. The resolution of a digital pin is $\pm{1\over2}$ bit.

This is a specific example of the limit of resolution in action. The little changes cannot be resolved by the tool being used.

Note that accuracy and reproducibility are also both factors in how wrong an answer might be.

Title: What does "resolution of a sensor" mean?

Body:
I am studying robotics and I am focusing my attention on the sensors used on robot manipulators. I have seen that there a proprioceptive sensors, such as encoders, and exteroceptive sensors, such as range finders and sonars.

During my studies on this topics I have encoutered the concept of resolution of a sensor and I have seen in paericular that the encoder, both absolute and incremental, have a way of calculating resolution, and also exteroceptive sensors have the resolution, such as depth resolution , angular resolution and width resolution.

I am tryin to understand how everything works, but I cannot understand the concept of resolution. I have seen that the definition is :

The resolution of a sensor is the smallest change it can detect in the quantity that it is measuring. The resolution of a sensor with a digital output is usually the resolution of the digital output. The resolution is related to the precision with which the measurement is made, but they are not the same thing. A sensor's accuracy may be considerably worse than its resolution.

which I have found here.

But I don't understand this concept very well since I don't know how to apply it in the various problems and cannot idetify the concept of resolution with the various type of resolution I mentioned above.

Can somebody please help me?


答:
This is a good robotics question, IMHO. A 3D printer extruding molten plastic has to do this task, so the right amount of plastic is squeezed out (e.g. Marlin, Repetier). The slicer can give the total amount needed for a given object (e.g. Cura by Ultimaker). It is not a trivial thing to calculate, yet very useful to know (so you don't run out of filament before object finishes printing).
But all the 3D printers I work with use GCODE as file format. I do not know RAPID, but a pre-processor must be possible to create. Effectively, just need to parse the file, adding up lengths as they occur (and quietly ignoring anything irrelevant). Is there a simulator available (that might already implement the parsing part)?</p>

Title: ABB RAPID - calculating seam length

Body:
I have an Arc welding RAPID program with many seams. One of them looks like this:

```<code>ArcLStart W007_On, vtoArc, sm01, s_12, fine, R1_tWeld\WObj:=R1_wFix;
ArcL W007_1, vWeld, sm01, s_8, z1, R1_tWeld\WObj:=R1_wFix;
ArcC W007_2, W007_3, Vweld, sm01, s_8, z1, R1_tWeld\WObj:=R1_wFix;
ArcL W007_4, vWeld, sm01, s_8, z10, R1_tWeld\WObj:=R1_wFix;
ArcL W007_5, vWeld, sm01, s_8, z5, R1_tWeld\WObj:=R1_wFix;
ArcLEnd W007_Off, vWeld, sm01, s_8, z1, R1_tWeld\WObj:=R1_wFix;
</code>```

What I want to do is measure/calculate the seam length programatically. Calculation can take place during normal program execution or in specialised routine (doesn't matter). How can I do that in RAPID?


答:
Not sure about all the way to SLAM but I know companies like Sonardyne or Teledyne implement inertial navigation systems for their autonomous underwater robots.

Given underwater using GNSS as an aiding sensor is obviously not necessarily possible so instead they use sonar pointed at the ocean floor instead. For this to be possible they obviously need a map of some kind.

I'm not sure if what they do extends all the way to SLAM or just stops at localization.

Title: Can standard SLAM techniques be used in maritime environments, where waves and currents move the vessel even with no control input

Body:
I am trying to implement a functioning SLAM system for an autonomous surface vessel (ASV). I don't have any direct experience with SLAM, and I am therefore researching the topic before I try to implement anything.

I am trying to figure out, if a maritime environment will make this job much harder than if our vessel was in a more static environment.

From my readings, I am getting the impression that you need to have a fair estimate of your location over time, given your inputs. Usually SLAM techniques are described for robots that don't move, if you don't tell it to, and this puts a strong constraint on the possible error between estimated location and actual location.

For ASV's the position moves constantly, depending on waves and currents, both in xyz and in pitch, yaw and roll directions. Will this be a problem for standard SLAM techniques? If I have an IMU, can I potentially correct for these disturbances?

For reference, the ASV I'm working with has a GPS and an IMU, and a lidar and cameras for landmark detection.


问:
Are rotary encoders necessary for ball shooting mechanism?
I'm designing a bot for a TDP(Team Documentation Profile) for a competition which is supposed to throw a rugby ball. Since the deadline is closing in soon, I can't test things out myself.

After going through multiple ideas, I settled on using two wheels throwing mechanism.

The mechanism

Can I implement the above-shown mechanism without using rotary encoders for the two motors?

Basically I just want to ask if the two BLDC motors have any difference in angular velocity even when powered with the same voltage.

答:
Yes.  Motors of the same type, by the same manufacturer, driven by the same voltage may still have different angular velocities (and different torque curves and any other parameter).  There are a variety of reasons for this: manufacturing tolerances resulting in different amounts of internal friction or mass, different magnet strengths, differences in winding, differences in internal resistance of the copper winding, the list goes on.  Furthermore, a motor's characteristics may change over time too as mechanical parts wear.  Depending on the quality of motor, these differences may be large or small.

Typically in robotics, this manifests as "why doesn't my robot go straight"?  When people simply provide the same voltage to both wheel motors without a velocity controller.


答:
Using quaternions for 3D rotations avoids the 'gimbal lock' problem, being one form of singularity in a manipulator.
For a start to learning about quaternions in gaming and robotics, see https://www.3dgep.com/understanding-quaternions/</p>

Title: Why in trajectory planning in joint space the manipulator never crosses a singularity?

Body:
I am studying robotics kinematics and I have studied that if we plan a trajectory in joint space it is impossible for the robot manipulator to cross a singularity during its motion, while in cartesian space this is possible.

But why in joint space the manipulator never meet a singularity?


问:
How to define the degrees of freedom of a flexible manipulator?
Consider a cable-driven flexible manipulator which has 3 cables. Consider the 3 cables to be actuated by 3 motors. Assume that by pulling the three cables in different configurations, we can span the entire 3D space in the workspace of the manipulator.

The manipulator is made up of a single flexible backbone and has disks mounted on it as shown in the figure..

I read on some sources as the manipulator is flexible it has infinite degrees of freedom. Is that correct?

How to define the degrees of freedom of the manipulator in task space and in configuration space?

答:
Your diagram has 6 cables and your question refers to 3 cables, so I'll just consider the simpler case.

The distal end (effector) moves in 3D space (a volume) - task space. Whilst the accessible space is limited, it does require 3 axes to describe its terminal point.

The input is 3 cables, so you only have 3 variables to play with to get a particular (accessible) distal end position. I suspect that is what you have called the configuration space. That looks like 3 dof to me.

The mapping of 3 inputs to 3 outputs is possible, and that transformation has no superfluous components (meaning you have enough, but not too much, information).

A little change to any input makes a little change to the output; there are no discontinuities in the transformation. In this sense, the manipulator can, theoretically, move infinitely small distances.

In a jointed manipulator (like an arm, with a hand), there can be lots of servos. However, at the end of the first finger, we still only need 3 numbers to describe its position in space, even if we chose to move 17 servos to get it there. Our 17-dof manipulator still only achieves the position in 3D, needing only 3 numbers to define its position.

(Note that we have ignored the orientation of the manipulated object. Yes, there's lots more to think about, yet.)


问:
EKF partial state update question
This is a follow up to

Maintaining positive-definite property for covariance in an unscented Kalman filter update

...but it's deserving of its own question, I think.

I am processing measurements in my EKF for a subset of the variables in my state. My state vector is of cardinality 12. I am directly measuring my state variables, which means my state-to-measurement function $h$ is the identity. I am trying to update the first two variables in my state vector, which are the x and y position of my robot. My Kalman update matrices currently look like this:

State $x$ (just test values):
$$
\left(\begin{array}{ccc}
0.4018 & 0.0760
\end{array} \right)
$$

Covariance matrix $P$ (pulled from log file):
$$
\left(\begin{array}{ccc}
0.1015 & -0.0137 & -0.2900 & 0 & 0 & 0 & 0.0195 & 0.0233 & 0.1004 & 0 & 0 & 0 \\
-0.0137 & 0.5825 & -0.0107 & 0 & 0 & 0 & 0.0002 & -0.7626 & -0.0165 & 0 & 0 & 0 \\
-0.2900 & -0.0107 & 9.6257 & 0 & 0 & 0 & 0.0015 & 0.0778 & -2.9359 & 0 & 0 & 0 \\
0 & 0 & 0 & 0.0100 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0.0100 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0.0100 & 0 & 0 & 0 & 0 & 0 & 0 \\
0.0195 & 0.0002 & 0.0015 & 0 & 0 & 0 & 0.0100 & 0 & 0 & 0 & 0 & 0 \\
0.0233 & -0.7626 & 0.0778 & 0 & 0 & 0 & 0 & 1.0000 & 0 & 0 & 0 & 0 \\
0.1004 & -0.0165 & -2.9359 & 0 & 0 & 0 & 0 & 0 & 1.0000 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.0100 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.0100 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.0100 \\
\end{array} \right)
$$

Measurement $z$ (just test values):
$$
\left(\begin{array}{ccc}
2 & 2
\end{array} \right)
$$

"Jacobean" $J$:
$$
\left(\begin{array}{ccc}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\end{array} \right) $$

Measurement covariance $R$ (just test values):
$$
\left(\begin{array}{ccc}
5 & 0 \\
0 & 5 \\
\end{array} \right) $$

Kalman gain $K = PJ^T(JPJ^T + R)^{-1}$:

$$
\left(\begin{array}{ccc}
0.0199 & -0.0024 \\
-0.0024 & 0.1043 \\
-0.0569 & -0.0021 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0.0038 & 0.0000 \\
0.0042 & -0.1366 \\
0.0197 & -0.0029 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
\end{array} \right) $$

$K$ is 12x2, meaning that my innovation - and therefore both measurement and current state - would need to be 2x1 in order to have a 12x1 result to add to the current full state:

$x' = x + K(z - h(x_s))$

where $x_s$ is a vector containing only the parts of the full state vector that I am measuring.

Here's my question: $K(z - h(x_s))$ yields

$$
\left(\begin{array}{ccc}
    0.0272 \\
    0.1969 \\
   -0.0948 \\
         0 \\
         0 \\
         0 \\
    0.0062 \\
   -0.2561 \\
    0.0258 \\
         0 \\
         0 \\
         0 \\
\end{array} \right) $$

Does it make sense that this vector, which I will add to the current state, has non-zero values in positions other that 1 and 2 (the x and y positions of my robot)? The other non-zero locations correspond to the robot's z location, and the x, y, and z velocities. It seems strange to me that a measurement of x and y should yield changes to other variables in the state vector. Am I incorrect in this assumption?

Incidentally, the covariance update works very well with the Jacobean in this form, and maintains its positive-definite property.

答: According to your covariance matrix it does make sense. The third column of the first row is sigma_xz, and is nonzero, which means, according to your covariance matrix, the random variable z is correlated to the random variable x, and so changes in x will affect z. If you further analyze your covariance matrix, it seems that Z is correlated to Y (element (2,3) of covariance matrix is nonzero) and, of course, itself (element (3,3) of covariance matrix). For the velocities, it certainly makes sense that updates in position will update your velocity because the EKF is simply capturing information regarding changes in state. Again if you look at the covariance matrix, I assume the 7th, 8th and 9th elements of your state vector are the velocity in x, y and z. In the covariance matrix, the elements (1,7), (1,8), and (1,9) are all nonzero so the 3 velocities are correlated to your x position...further analysis shows that they're also correlated to your Y and Z position by similar arguments.</p>

Title: EKF partial state update question


问:
(not trivial) ROS how to subscribe to multiple topics and publish to another topic within one loop
My question is related to this one (here) but not exactly. Assume now I have 4 topics: topic_A,topic_B,topic_C,topic_D. Inside my control loop, I need to read the sensor values from the first three topics (all of them are publishing at 1000 Hz for example), calculate my control input and publish the control input to topic_D for each iteration. My question is related to how to write the control loop properly. My current pseudo code is summarized as below:

1) I used the rospy.wait_for_message because it guarantees that my control_input is being calculated from the most recent sensor values (a few ms before I calculate my control_input). Now I want to replace them because it seems like the subscriber callback function is faster, which is very important for my application.

2) In terms of code structure, I didn't use subscriber because I didn't know how to incorporate three callback functions properly to publish my control gain (I need to the three sensor values to update even though I'm running the while loop in the main_control_loop function to get my control).

Based on the discussion from here. It looks like I can have several subscribers running together for rospy. Now assume I have three subscribers running as listed below, will the sensor_X_value be updated in each iteration of my main_control_loop function?

答:
What you have there should be okay.

Basically, each time you construct a subscriber for a new topic, rospy.Subscriber(...), a thread will be started to poll for messages received on that topic. So in your code above, the callback functions will asynchronously handle processing the latest message received and updating the value accordingly. Maybe use a queue size of 1, to ensure it's only the latest value you're polling from your sensors (See rospy docs on publishers/subscribers.

So in your control loop, you shouldn't have to worry about it. Just make sure that your control loop rate is appropriate for the publishing rate of your control inputs.

```<code>def main_control_loop(self,scan,pose):

    # This is up to you
    r = rospy.Rate(1000)  # 1000 Hz

    while not rospy.is_shutdown():

        # compute control input
        # These will be the most up to date values
        control_input = some_function(self.topicA_value,
                                      self.topicB_value,
                                      self.topicC_value,
                                      **other args)

        self.pub_topicsD.publish(control_input)

        # sleep
        rate.sleep()
</code>```

There are a few caveats here - one of which being that depending on your publisher queues, latency, etc... there's a strong likelihood that your control loop will update with "stale" values (ie, use the same value twice), but that all depends on your control loop rate and your publishers.

Also, I don't know what the application here is, but if you really need to run at 1000 Hz then you might consider writing your application in roscpp to have more control over what threads are doing what, and when.

Body:
What you have there should be okay.

Basically, each time you construct a subscriber for a new topic, rospy.Subscriber(...), a thread will be started to poll for messages received on that topic. So in your code above, the callback functions will asynchronously handle processing the latest message received and updating the value accordingly. Maybe use a queue size of 1, to ensure it's only the latest value you're polling from your sensors (See rospy docs on publishers/subscribers.

So in your control loop, you shouldn't have to worry about it. Just make sure that your control loop rate is appropriate for the publishing rate of your control inputs.

def main_control_loop(self,scan,pose):

    # This is up to you
    r = rospy.Rate(1000)  # 1000 Hz

    while not rospy.is_shutdown():

        # compute control input
        # These will be the most up to date values
        control_input = some_function(self.topicA_value,
                                      self.topicB_value,
                                      self.topicC_value,
                                      **other args)

        self.pub_topicsD.publish(control_input)

        # sleep
        rate.sleep()

There are a few caveats here - one of which being that depending on your publisher queues, latency, etc... there's a strong likelihood that your control loop will update with "stale" values (ie, use the same value twice), but that all depends on your control loop rate and your publishers.

Also, I don't know what the application here is, but if you really need to run at 1000 Hz then you might consider writing your application in roscpp to have more control over what threads are doing what, and when.


问:
How to check for a sharp angle with a line follower?
I have the mBot robot and I want to program it to follow the line. So far it can pass any kind of line that is >90°.

I want it to be able to pass 90°-ish angles as well. Like this one:

90° angle">

The problem is that my mBot robot has only 2 line following sensors (they are 5 mm apart and the line is 2 cm wide) so I can't use just the sensors.

Most of the times it just goes to the line and when it's supposed to turn it just misses the line (goes on the white) and goes back to get back on track. Once it's back on the black line it once again tries to go forward but goes on the white instead of taking a turn. This happens endlessly.

Sometimes it passes the angle by going back and forth and accidentally turning, but that's not even a workaround, let alone a solution.

Here's a test course of the first round of the competition.

My robot can pass this without a problem, but it gets stuck on this (poorly edited, sorry) course:

It can't pass the 20 block if the robot enters it from a 15 or 20 block (so basically it gets stuck if it's coming from an angle and hits a 90 degree turn).

The sensor value could be read as either 0, 1, 2 or 3 depending on what the robot currently sees:

0 - on the line

1 - on the right of the line

2 - on the left of the line

3 - not on the line

Pseudo code of my current program:

```<code>loop forever:
    if (on the right of the line):
        turn_left()
    if (on the left of the line):
        turn_right()
    if (on the line):
        go_forward()
    if (not on the line):
        go_backwards()
</code>```

So how would I go about taking such sharp turns?

答: In my configuration I have a PID algorithm for the main following mechanism. Then I have a separate routine to move into if The car ever goes off the line and all 6 sensors are sensing white. This tells the car to turn the direction that it saw the line last. This seems to work up to 45 degree turns for me. </p>


答:
It seems that you can have 4 possible readings (w,w), (w,b), (b,w) and (b,b). So, the program what to decide what to do in each situation. To help figure out the next action, the past history can also be used. So, it is up to you to decide how much history is useful, or practical. I suggest some kind of state diagram, but use whatever you are already familiar with.

Now, in your pseudocode, how much do you turn left and right? How far are you moving between each reading? Can you measure how far each wheel has gone?Is it possible to go backwards until line is found? How straight are your moves forward and backward? These questions are just some of the considerations for you to think about as you refine your strategy.

The bottom line is that the dual sensor does not provide enough data from a single reading, to, for example, identify whether you've just run over the edge of a straight line, the line has bent, or (if it has bent) by how much!

The whole point of a line robot competition is to get each builder to design (and test) their strategy.

Title: How to check for a sharp angle with a line follower?

Body:
I have the mBot robot and I want to program it to follow the line. So far it can pass any kind of line that is >90°.

I want it to be able to pass 90°-ish angles as well. Like this one:

90° angle">

The problem is that my mBot robot has only 2 line following sensors (they are 5 mm apart and the line is 2 cm wide) so I can't use just the sensors.

Most of the times it just goes to the line and when it's supposed to turn it just misses the line (goes on the white) and goes back to get back on track. Once it's back on the black line it once again tries to go forward but goes on the white instead of taking a turn. This happens endlessly.

Sometimes it passes the angle by going back and forth and accidentally turning, but that's not even a workaround, let alone a solution.

Here's a test course of the first round of the competition.

My robot can pass this without a problem, but it gets stuck on this (poorly edited, sorry) course:

It can't pass the 20 block if the robot enters it from a 15 or 20 block (so basically it gets stuck if it's coming from an angle and hits a 90 degree turn).

The sensor value could be read as either 0, 1, 2 or 3 depending on what the robot currently sees:

0 - on the line

1 - on the right of the line

2 - on the left of the line

3 - not on the line

Pseudo code of my current program:

```<code>loop forever:
    if (on the right of the line):
        turn_left()
    if (on the left of the line):
        turn_right()
    if (on the line):
        go_forward()
    if (not on the line):
        go_backwards()
</code>```

So how would I go about taking such sharp turns?


问:
How is this torque value arrived?
I'm going through this person's torque calculation of a simple crane setup. the servo used has a max torque of 57oz.in:

At the top, if Mservo is 34.12oz.in, how is it 62.38% of stall torque when 34.12/57 = 0.5986?

答:
I haven't seen the degree symbol $^{\circ}$ to denote a percentage, but both percentages on your drawing result in the same torque: 54.7, not 57. (10.12/0.185) $\approx$ (34.12/0.6238) $\approx$ 54.7.

This, in turn, is about 96 percent of the "rated torque," so I don't know if they de-rated the max torque or not. On the webpage you linked, they said,

Lastly, we assumed that the max torque by the servo was 57 oz-in. After some prototyping, we discovered that we weren't getting anywhere near that torque despite that was what the manufacturer rated the servo for.

So again, they may have de-rated the max torque in the calculations there but failed to denote it (though I wouldn't say 96 percent of datasheet torque is not "anywhere near" the rated torque).

But really, the major flaw with their design is that they're trying to move something while the load is rated at stall torque. They're not left with any additional torque to accelerate the load. If you want to change positions, you have to have speed. If you're starting from a stopped (stalled) position, then you have to accelerate.

$\tau = I\alpha$, so if you're going to accelerate the load (and move from positions) then you need to have some torque reserve.

There's an email address on the page, though! Try contacting the person that posted the page and ask them directly.

Title: How is this torque value arrived?


问:
How to Correct for Gyroscopic Drift?
I know similar questions have been asked before, but I have researched for hours now and have not been able to find a viable solution. </p>

<p>I have a Raspberry Pi 4 and the Adafruit LSM9DS1 IMU, which has a gyroscope, an accelerometer, and a magnetometer. I am trying to build a VR headset and find the 3D orientation of the IMU. What would be the best way (simplicity, lack of complicated math, and performance wise) to correct for gyroscopic drift using sensor fusion? I barely have any knowledge of quaternions, so a solution with Euler angles would be preferred. </p>

答:
I can propose you two solutions to solve your problem:

The first one is a not easy to implement with a MEMS but it works: A Kalman filter (maybe more a Extended Kalman filter for navigation). The advantage of this method is that it can gives you the covariance for each state of your model. The disavantage is that you need to implement the model of the sensor (MEMS). You can find models on internet relative to your sensor.

The second possible solution is called 'complementary filter'. The goal of this filter is to 'estimate' (even if there are no covariances about the data compared to the Kalman Filter) the angles with the gyro data and the accelerometers data. It is easy to implement but less precise compared to a Kalman Filter in my opinion.
You will find below an article dealing with it, plus a github with it.
https://www.researchgate.net/publication/336208125_A_Fast_and_Robust_Algorithm_for_Orientation_Estimation_using_Inertial_Sensors

Title: How to Correct for Gyroscopic Drift?


问:
Shifting through Z axis for Calculating Kinematics?
In CS223a homework there is a question to calculate DH parameters of given robot as below:

When he try to solve DH parameters of the robot in the solutions he set first and second frame positions same as below:

As you can see first frame of the joint shifted through Z, and now first and second frame starting positions are same.

I would like to know what is the rule for this? By intuition I believe joints frames can be shifted through Z axis. Is it the only rule? Is there any other thing I should know?

PS: Solution manual for HW2 https://see.stanford.edu/materials/aiircs223a/solution2.pdf

答:
If I understand your question correctly you are asking about what rules there are for assigning coordinate frame axes compatible with DH parameters?

There are definitely rules when assigning coordinate frames. In order to guarantee that there exists a homogenous transformation from frame 1->0 must follow the properties

Axis $x_1$ is perpendicular to axis $z_0$

Axis $x_1$ intersects axis $z_0$

In order to guarantee these the textbook Robot Modeling and Control introduces three possible cases for how to set up the frames compatible with the DH convention. This is in sections 3.2.2 on page 80.

In short the coordinate frames are assumed to be right handed and picked iteratively based on some guidelines. $z_0$ can be assigned arbitrarily and the following are assigned based on the cases

$z_{i-1}$ and $z_{i}$ are no coplanar

$z_{i-1}$ is parallel to $z_{i}$

$z_{i-1}$ intersects $z_{i}$

For a more thorough explanation and examples reference the book: Robot Modeling and Control by Spong, Hutchinson, and Vidyasagar.


问:
How many landmark measurements to localize a planar robot?
How many landmark measurements are required to localize a robot (i.e. find its x,y position and orientation) moving in a 2D world using 1. only range measurements 2. range plus bearing measurements?</p>

答:
1) Only range measurements

Minimal landmarks is 3 for position $[x,y]$. This one is pretty easy to visualize. Just draw the distance from the landmarks as a circle. The intersection of the 3 circles is your position.
You can see the problem with 2 landmarks below as it has 2 valid solutions.

Orientation($\theta$) is impossible with just landmarks. You must have odometry information. So you must be able to calculate $p_{R_1,R_2}$ and $\theta_{R_1,R_2}$ which is the movement from robot pose $R_1$ to $R_2$ as estimated from your odometry.

2) Range + Bearing

Minimum is 2 points. With 1 landmark you only have two knowns ($r$,$\phi$) and 3 unknowns ($x,y,\theta$). Geometrically you can again imagine the distance circle. Now set the robot heading always tangent to the circle. By moving the robot around this circle you change the state $\theta$ , but the measurement $\phi$ stays the same.

With odometry information you can get away with 1 landmark.


问:
How do you create a log of create_autonomy published messages?
I'm completely new to robotics and software as a hobby. I've got my irobot create2 up and running and I'm trying to create a log file for specific messages in "create_autonomy" https://github.com/AutonomyLab/create_autonomy.

I'm hoping to log this once a minute in the terminal window or a .txt file

hour:minute:second    battery/charge
(95%)

hour:minute:second   joint_states        (forward, 1.5
mph)

Any ELI5 help would be awesome, I'm not sure where to start

This video ends at what I'm trying to do
https://www.youtube.com/watch?v=T4KRgNBRA2U&t=9s

答:
,

there is a standard tool for that: rosbag, it can record any message on the ROS network, you can take a look at the following link to see its usage

http://wiki.ros.org/rosbag


问:
How to calculate the right and left speed for a tank-like rover?
I am trying to control the Rover 5 robot using an Android app with a touch-based joystick control in the app UI. I want to calculate the speed of the left and right motors in the rover when joystick is moved.

From the joystick, I get two values, pan and tilt. I convert them into the polar coordinate system with r and theta. Where r ranges from 0 to 100 and theta from 0 to 360. I want to derive an equation which can convert the (r, theta) to (left_speed, right_speed) for rover. The speed values also are in the [0;100] range.

Now, here is what I have figured out till now. For any value of r,

If theta = 0 then left_speed = r, right_speed = -r (turning right on spot)

If theta = 90 then left_speed = r, right_speed = r (moving forward at speed r)

If theta = 180 then left_speed = -r, right_speed = r (turning left on spot)

If theta = 270 then left_speed = -r, right_speed = -r (moving backwards at speed r)

For other values, I want it moving and turning simultaneously. For example,

If theta = 45 then left_speed = alpha*r, right_speed = beta*r (moving forward while turning right)

So, basically for any (r, theta), I can set speeds as,

(left_speed, right_speed) = (alpha*r, beta*r)

I need to formulate an equation where I can generalize all these cases by finding alpha and beta based on theta.

How can I do this? Is there is any existing work I can refer to?

答:
What you want is angular velocity proportional to the cosine of the angle, it seems, with positive to the right, and negative to the left.

So, since we know that angular velocity is given by $\frac{V_l - V_r}{D}$ where $D$ is the diameter of the robot, we're all set.  Try this:

if $\theta\ge0$ and $\theta\le90$: $V_l \gets r$ and $V_r \gets r\sin(2\theta-90)$

if $\theta < 0$ and $\theta\geq-90$: $V_r \gets -r$ and $V_l \gets r\sin(2\theta+90)$

Swap the velocities for the other quadrants. Note, this won't "feel" like driving a car, as moving the stick to the lower-right will turn backwards and rotate right, whereas a car in reverse with the wheel right will move backwards and turn leftward.  Just a weirdness of differential drives...  You can adjust for this by just applying the fourth quadrant rules to the third quadrant $\theta$ and visa-versa.

I used $\theta \in [-180,+180]$, which you can get by:

$\theta \gets \text{atan2}(\sin\theta,\cos\theta)$ (watch your units though, atan2 is usually radians.


问:
Tracking 3D motion using a stereo camera
Assuming you have a fixed stereo camera, looking at a rigid object, what are the techniques used to track the object?

My google searches lead me to optical flow and similar algorithms, but I believe they are only for the 2D image space.

Is there something similar for the 3D case, especially when the object of interest fills up most of the FOV of the camera.

edit: this has to be without fiducials

Thank you

答:
from my experience, you can do it on the 2D image together with the disparity information.

Reason:

tracking based on image has been well developed in recent years, there should be many  advanced algorithms you can use directly(may based on NN

you can project the detection result from the 2D image to your disparity to get a distance of the object, which helps:

2.1. you can get the distance between your robot and target besides the x,y coordinates in camera view, which makes your control easier

2.2. when the 2D tracking failed, like the result jumped to somewhere else, you can use the distance info to identify this kind of jump


问:
catkin build with multi-core make for building individual packages
I have multiple libraries and the main program.
When I run catkin build command it starts with 8 jobs but after finishing building libraries continues to build the main program only using 1 job (one CPU core).

How do I force catkin build to distribute multiple cores on building each individual libs?

答:
```<code>catkin build -j15 --make-args="-j5"
</code>```

uses 15 make jobs with 5 processes each.

Body:
catkin build -j15 --make-args="-j5"

uses 15 make jobs with 5 processes each.


问:
Usage of Multibeam 2D Imaging Sonar for AUVs, testing them in the pool environment
I belong to an AUV team at my university. We are planning to have a Multibeam 2D Imaging Sonar (the Blueview P900) for our AUV to detect obstacles underwater.

I have the following questions to ask on the feasibility of testing/implementing such sonars on AUVs.

As we know that these multibeam sonars have multiple reflections arriving at different times from various surfaces while testing in a pool, is there any recommended way to filter these noises in the image obtained from the sonar pings?

Are such sonars in use/test by any other team/organization anywhere else who do pool testing other than a ocean/reservoir testing where multiple reflections are almost zero except the reflections from the obstacle(s)?

Also i would like to know the recommended image processing algorithms that can be implemented/used to detect obstacles from the sonar images.

答: I've worked with the same sonar in a similar setting, and your only real option (if you can't do anything to the pool itself) is to find an open water testing area. You could also contact BlueView. They're pretty responsive.</p>


问:
Controller algorithm implementation in ROS/Gazebo
I am doing some robotic simulations in ROS/Gazebo and wondering what is the best way (programming-wise since I don't have a CS background) to implement a robot's motion controller.

Here are the questions:

Where should I call my Controller function (In a callback? which callback if I have multiple callbacks running simultaneously)?

How to sync data coming from different nodes i.e. callbacks?

What if my sensor nodes are running faster than my controller loop, then how should I implement the controller?

Is there any way to subscribe to different topics with a single callback?

Should I process the data in a callback or process it in the controller function?

What is the exact use of buffers in ROS subscribers?

Sorry for a long list of inquiries but these questions have been bothering me for some time and I would like to make my code more efficient and aesthetically pleasant at the same time if possible.

P.S: I am using C++ in ROS.

答:
That is a long list of broad questions. Some of the answers depend heavily on application and personal preference. Assuming you're not using ROS2, then you might consider looking at the ros_control package. Not necessarily to use - just read through their architecture and tutorials for now. It will at least help give you an idea of where to start.

As for the specifics:

In general your control loop should be running at a fixed rate (e.g. 50 Hz), so your control function should be running independently of your sensor callbacks.

It depends, what is your sensor data and where is it coming from? In your control node, you sensor subscribers could just provide your control loop with the most up to date data possible.

This also depends on the application. Obviously if your sensor data is coming in at 10 Hz you probably don't need a 2000 Hz control loop.

Maybe look at the message_filters package. It sounds like it'll answer some of your questions, too.

Depends on your data. But you probably want your controller function to handle combining all of your sensor input and processing it at the controller's loop rate.

Do you mean the queue sizes? It gives flexibility into the timing of processing published messages. For your sensor data your probably only care about the latest available reading, and your callback should probably never fall behind on processing messages from the queue. But say you had a sensor that produce a huge burst of information in a short amount of time, then with a sufficient queue size all of those messages could be published and processed without losing any of the data.

Hope that helps. I think the ros_control stuff might be a good place for you start.


问:
How to drive mecanum wheels robot: code or algorithm
I have a robot with four mecanum wheels and I would like to make it move correctly by using a RC transmitter (my controller has two sticks and several buttons, each stick has a proportional range of [1000 - 1500 - 2000] where 1500 is the center position).

I've read different documents about how to control a robot with mecanum wheels, but I wasn't able to find any suitable example to use as starting point.

Basically, I would like to understand what kind of algorithm I need to use to set the velocity and the direction on each wheel depending on the stick position.

The motor controllers I'm using for my robot use a proprietary language, so I do not need any code, I just need to know how it should work and then I'll translate it to make it work with my electronics.

I hope you can help me!

EDIT:
I was thinking something like this:

```<code>left stick UP = forward
left stick DOWN  = backward
left stick RIGHT [UP/DOWN=0]= SLIDE left
left stick RIGHT [UP/DOWN=0] = SLIDE right
left stick UP/RIGHT = diagonal and so on..
right stick RIGHT = turn on RIGHT
right stick LEFT = turn on left
</code>```

my joystick has a left stick with two axes and a right stick with two other axis.
Both stick are proportional.

EDIT2:

The figure shows the directions I would like to implements for my robot.
In order to keep things simply, we can not consider the turning on rear axis and on a single wheel.

My motor controllers move each motor by using motor_command function which ranges from 0 to +/-1000, where 0 means motors stop and +1000 means motors at 100% forward while -1000 means motors at 100% backward.

答:
I've built one and added the code here: https://github.com/charlch/MecanumBot/blob/master/MecanumBot.ino

The core of the maths is this:

Firstly turn the 1000 to 2000 input into -1.0 to 1.0

```<code>float norm(int in) {
    return (float(in-1500.0)) / 500.0;
}

float forward = norm(forward_raw);
float strafe = norm(strafe_raw);
float turn = norm(turn_raw);
</code>```

Then calculate the speed for each wheel and set the motor to that speed:

```<code>float m1 = (forward+strafe+turn)/3.0;
float m2 = (forward-strafe-turn)/3.0;
float m3 = (forward-strafe+turn)/3.0;
float m4 = (forward+strafe-turn)/3.0;

motor1.set_signal(m1);
motor2.set_signal(m2);
motor3.set_signal(m3);
motor4.set_signal(m4);
</code>```

Body:
I've built one and added the code here: https://github.com/charlch/MecanumBot/blob/master/MecanumBot.ino

The core of the maths is this:

Firstly turn the 1000 to 2000 input into -1.0 to 1.0

float norm(int in) {
    return (float(in-1500.0)) / 500.0;
}

float forward = norm(forward_raw);
float strafe = norm(strafe_raw);
float turn = norm(turn_raw);

Then calculate the speed for each wheel and set the motor to that speed:

float m1 = (forward+strafe+turn)/3.0;
float m2 = (forward-strafe-turn)/3.0;
float m3 = (forward-strafe+turn)/3.0;
float m4 = (forward+strafe-turn)/3.0;

motor1.set_signal(m1);
motor2.set_signal(m2);
motor3.set_signal(m3);
motor4.set_signal(m4);


问:
How to derive the camera trajectory from ICP
This may be a very simple question so please bear with me...

Suppose I have a stationary object and point clouds, $n$ $(x,y,z)$ points, of that object taken by a moving camera at time steps $t_i$, $t_{i+1}$, ...

Using ICP on the point clouds from subsequent time steps I get the relative transformation (a rotation matrix and translation vector $\in SE3$) needed to map the cloud from some $t_i$ to to the cloud at $t_{i + 1}$.

Is the Camera trajectory from time $t_i$ to $t_{i + 1}$ the same? ie I simply take the position of the camera at $t_i$ and multiply it by the rotation matrix and then add the translation vector to get the new position?

答:
Yes that is correct. Easiest way is probably to work with the homogeneous 4x4 Tranform Matrix($T$) composed of $\begin{bmatrix}R & t\\0 & 1\end{bmatrix}$. Then your new pose is then just $T_i$ multiplied by $\Delta T_{i+1}^{i}$(relative transform). For every new relative transform just do this concatenation.

So
$T_{i+1}=T_i*\Delta T_{i+1}^{i}$

Note:

Depending on your ICP implementation you may actually get the inverse relative transform $\Delta T_{i}^{i+1}$. If this happens then just invert the matrix and continue as normal.


问:
What does Simultaneous Localization And Mapping (SLAM) software do?
I took a course to have a better understanding of drones and their design. At the end of the course there was a test question that I got wrong and I would like to understand why.

I was supposed to select the choices that best describe SLAM.

and the possible answers were:

Estimates the location of features in the environment?

Controls the robot's flight through the environment?

Causes the robot to avoid obstacles in the environment?

Navigate in a cluttered environment?

Estimates the position and orientation of the robot with respect to
    the environment?

At first I knew that at least 3 and 4 were right because I watched a drone doing these things. I also thought that the last answer was linked to these two so I said yes to it too. Finally, I thought that the only thing that was still controlled by the user would be the flight...

Yet I failed again... Therefore what does Simultaneous Localization And Mapping (SLAM) software do?

答:
Estimates the location of features in the environment

Estimates the position and orientation of the robot with respect to the environment


问:
Arduino for mobile robot
Is it possible to drive the whole mobile differential drive robot with single arduino? Sonar sensor, servo motor, two encoders, two motors, imu, etc. I mean would it give a reasonable performance or very slow or impossible? If we use two arduinos would it be much better?

For example, two motor+encoder, imu, one servo motor for sonar sensor and one sonar sensor, + bluetooth communication with pc. The task is for example building map of the room, and kinematic control for tracking some trajectory. I mean it should do PID control for motors, kinematic control for robot, sensor fusion for imu+encoders, communicate with PC (this is to do some computationally intensive tasks such as trajectory planning or to store maybe the complete map in pc etc.).

答: You can try a board named teensy. It is programmed in the arduino IDE but it got much higher performance. </p>

Title: Arduino for mobile robot


问:
Accelerometers error (BMA020 and BMA180)
Recently I am working with two accelerometers: BMA020 and BMA180. I will try to explain my problem using BMA020 as example because it is less accurate therefore problem is more visible. When I hold my Acc in neutral position I get correct average result: -1G. Now I turn my Acc upside down but this time my average result is +0,91G. The same problem occurs for other axis. For BMA180 problem is less visible (-1G in normal position and +0.98G upside down). Do you know why accelerometer behaves like this ?</p>

答:
You have to calibrate the accelerometer to compensate for this. Usually, calibrating an accelerometer consists of finding a scaling factor and an offset vector. So the calibrated measurement vector Z can be written as:

Z = aX + B, where a is the scaling factor, B the offset vector and X is the 'raw' measurement vector.

If you mount the accelerometer on a device, the accelerometer axis system should be aligned with the device body axis system. If this is not the case, for example if the pcb is rotated or upside down, the calibrated measurement Z should be converted to the body axis system using a rotation matrix. You can combine the rotation matrix with the scaling factor a, so you get:

Z = AX + B.

A is now a 3x3 matrix. Z is the calibrated measurent in the device body axis system.
The values of the 3x3 matrix A and the 3-element vector B are found by putting the device in a number of known, fixed orientations, so you know Z. By measuring X, you get a set of linear equations that you can solve to find A and B.

Hope this helps.


问:
Why are strain-wave/harmonic gears used in robots?
Also, what is the difference between the above gear drive vs other gear drives?</p>

答:
Strain wave gears have practically zero backlash and high torque density (i.e. torque per unit weight) compared to other solutions available.  Gearbox weight is important in articulated arms, since it adds to the weight of each link in succession.  The extra weight means that each actuator must provide additional torque to maintain a specific speed target, but higher rated torque requires more gearbox mass, which increases the torque requirement, etc., etc.  Ultimately, the arm speed ends up getting limited.

Strain wave gearing were invented in the 1950's.  There are a couple of start-ups working on alternative solutions today, but they are still the most popular high torque density solution on the market that has near-zero backlash.


问:
What Software Is Used For Autonomy Software Simulation?
I don't have a physical robot but I would like to test the performance of my C++ code for odometry, SLAM, and path planning. Are there any good simulation software where I can test my algorithm implementation?</p>

答:
If you want to test everything together then you need to setup a simulator like Gazebo(integrates well with ROS which I assume you are using). Other options could be Airsim, or some custom simulator. These options though and are more involved in required setup on your part.

Testing separately:

SLAM is pretty easy to test. Just download some dataset such as KITTI, or Euroc, and test your algorithm on their data.

For path planning I would take a look at what OMPL integrates into, and setup your code in the same way.


答:
It depends what Arduino you are going to use. I don't think that you can use Arduino Nano/Micro for this because you will not have enough I/O and memory. You can use Arduino Mega (maybe UNO) but you will have to utilize hardware interrupts for all the communication and measurement stuff.

I have done a similar robot a few years ago utilizing interrupts only on Arduino MEGA 2560 runnig at 500 Hz (the computation for all PID regulators, IMU complementary filter and low pass filters for signals was made every 2ms).
Using interrupts you can drive up to 10x servo motors using just one timer, measure analog values by ADC, communicate using I2C/SPI/UART at almost no cost because all the work will be done by dedicated hardware and not by the CPU. This is why it is called a micro-controller and not a micro-processor. You will utilize the CPU just to process the results from the interrupts and compute values for PID regulators, filters, etc. The sad thing is that a lot of libraries are not using interrupt because it's easier that way and therefore waste a lot  of computation work just waiting for the result.

Nowadays, I would use a little bit more powerfull Arduino or another board that can run some kind of RTOS e.g. FreeRTOS. For this project is the Arduino Mega 2560 the absolute minimal requirement.

So the answer is simple: Yes, you can use Arduino but the less powerfull board you utilize the more sophisticated solution you will have to make.

Title: Arduino for mobile robot

Body:
Is it possible to drive the whole mobile differential drive robot with single arduino? Sonar sensor, servo motor, two encoders, two motors, imu, etc. I mean would it give a reasonable performance or very slow or impossible? If we use two arduinos would it be much better?

For example, two motor+encoder, imu, one servo motor for sonar sensor and one sonar sensor, + bluetooth communication with pc. The task is for example building map of the room, and kinematic control for tracking some trajectory. I mean it should do PID control for motors, kinematic control for robot, sensor fusion for imu+encoders, communicate with PC (this is to do some computationally intensive tasks such as trajectory planning or to store maybe the complete map in pc etc.).


问:
Multiple antenna styles on FPV without true diversity
I did a search and couldn't find a site that stood out as RC. I was hoping you guys would be closest. Here's my question.

I bought a set of Eachine EV100 FPV goggles. Every resource I've looked at said I should update the dipole antennas. These have antenna diversity and not true diversity. I'm new to FPV and can't say I know what that means. As best I understand it true diversity has two receivers and it switches to the antenna with the strongest signal, where as antenna diversity just uses one receiver and combines the signals somehow to improve it. I could be completely pulling that out of a hat, though. It might not be right at all.

So one youtuber upgraded his, using a clover leaf style and a patch antenna. Another youtube source I trust suggested using two clover leaf styles.

I'd like to know if you can use a clover and a patch together with just antenna diversity or if I would be better off getting the two pack of clover leafs the other guys recommended.

I know the clover leaf is for picking up signals in 360 degrees where the patch is much stronger when it's pointed directly at the source. I just don't know how this stuff works, so I don't know if it works like that with these goggles or if they actually interfere and make it worse. If it doesn't cause issues, I'd think the patch and clover leaf would be the way to go.

Thanks for any help you can provide, even if it's telling me the correct forum to post this in.

答:
There are a few different types of diversity.  You can find a decent description here.  The specs for your unit don't say what your unit has, but chances are it is a simple selection combiner that is determining which antenna element has the highest signal strength and switching to it.

Whatever it is, it's not really something you have any control over, unless you are thinking of modifying the RF front end of your FPV.

What you might consider instead is replacing the stock antenna elements with a higher gain solution.  Your model's antennas screw in with a standard SMA connector, so you could take them out and maybe try something like this, which also has an SMA connector.

The challenge in all of this is that none of what we are looking at is military or industrial grade, so it's hard to gauge how much of what you might see is design-related or manufacturing quality related.


问:
Torque commands for velocity reference motor
I have a controller board for a motor, where I can read the motor current (to transform to torque), the position, the velocity and I can give a velocity command. There is not really a torque mode on this controller, that is I can only command velocity and read torque but I cannot give a torque reference.

How can use it to give a torque reference?, hence to comply with the standard robotic equation of the type

$\tau = m \ddot{q} + H(\dot{q},q) + G(q)$

That is that I get the $\tau$ value to send as reference, but in my case the controller board I have receives $\dot q$ and sends $\tau$. Is there a way to still use the standard equation for control ?

答:
The $m$ in your equation looks like the symbol for mass.  Really it should be $M$, the inertia matrix, but maybe you meant this.

If you are only dealing with a dual-link arm in a single plane, then you should be able to determine the inverse.  This is dealt with in a lot of books, but the clearest explanation I have found is in an old MIT AI Lab paper.  See p.12ff.


答:
This behavior is usually specified in the datasheet. For example, in table 1 of the datasheet of the BMA020 accelerometer you have the entry "Sensitivity". Probably you are operating your sensor with a 2g range. If your sensor has a temperature of 25°C, according to the datasheet the raw output of your sensor is typically 256 LSB if it is exposed to a acceleration of 1.0 g. As specified in the datasheet, this is only the typical value. Each manufactured sensor is a little bit different and thus the "min" and "max" columns define other possible values, depending on your specific sensor.

In your question you talk about measurements in g units and not in LSB. Thus, the code operating your accelerometer already converts the raw measurements to g units. The conversion algorithm can range from very simple algorithms to very sophisticated algorithms. An ideal conversion algorithm would incorporate all errors your sensor makes due to production variations and due to the current operation conditions. To compensate for the production variations this conversion algorithm should make use of calibration values which you found for your specific accelerometer or which are known from factory calibration (expensive sensors). Additionally, if you look at your datasheet again, you see that the sensitivity of your accelerometer depends on the operation temperature. Thus, if the defined error due to temperature change is too high for your application, you need to add an temperature sensor and your conversion algorithm should use the temperature to correct for this error too. There are also additional error sources defined in the datasheet and the algorithm for converting your raw measurements to g units can get very sophisticated.

Thus, the reason why your sensors don't output 1 g is simply that you're using some conversion algorithm to get from the raw sensor readings to g units and this algorithm probably neither uses any calibrated values specific to your sensor nor does it incorporate the current environment conditions.

Title: Accelerometers error (BMA020 and BMA180)

Body: Recently I am working with two accelerometers: BMA020 and BMA180. I will try to explain my problem using BMA020 as example because it is less accurate therefore problem is more visible. When I hold my Acc in neutral position I get correct average result: -1G. Now I turn my Acc upside down but this time my average result is +0,91G. The same problem occurs for other axis. For BMA180 problem is less visible (-1G in normal position and +0.98G upside down). Do you know why accelerometer behaves like this ?</p>


答:
There are quite a lot options for this, each with different features, strengths and weaknesses. A few examples:

Gazebo (as mentioned by edwinem): very well known in the robotics community, some would say it's a little bit dated

Microsoft Airsim (also mentioned by edwinem): originally developed for autonomous drones and autonomous driving, uses the unreal engine for high image quality (experimental support for Unity)

NVIDIA Isaac SDK: a "newcomer" with a lot of manpower from NVIDIA in the background where the focus is more on indoor applications, also has the ability to work with ROS. It uses the Unity engine for high quality image rendering (Unreal support was planned, but doesn't seem to get pursued at the moment)

webots: general purpose simulator with quite a few robot models included, has C++ and Python APIs and is known to work with ROS

robotbenchmark: builds on webots and allows you to develop your skills in different challenges presented on the website (note: the robot is programmed in Python, not C++)

Title: What Software Is Used For Autonomy Software Simulation?

Body: I don't have a physical robot but I would like to test the performance of my C++ code for odometry, SLAM, and path planning. Are there any good simulation software where I can test my algorithm implementation?</p>


问:
Path-following algorithm and suggestions for mecanum robot
I have a robot with four mecanum wheels (blue square) that can move in an open-space room.
The position x,y of the robot is measured in a very accurate way by a fixed position sensor (red circle) that is placed in the origin of the place and has coordinates (0,0,0). The position of the robot is updated at 10Hz.

I want to make the robot follow different paths like the one from A to B as showed in the picture (in green color).

What is the best and accurate way to do that?
I think I should have to create the path like a series of x,y points and make the robot move towards them but I don't know how to derive the motion equations.

Can you give me some advices or examples, please?

答: You could try to implement a pure pursuit controller. </p>


问:
Driving a small motor
I am trying to drive a small motor using (software emulated PWM) from a Pi like device.  I'm following a circuit that looks like this:L
https://www.instructables.com/id/Raspberry-Pi-GPIO-Circuits-Controlling-High-Powere/

Main differences are:  My power source is a 3.74 LIPO battery, and my load is a motor, not an LED.

When I turn the GPIO pin fully on (not even PWM at this point), I don't get the full speed of the motor.

I'm not really sure what I am missing in my understanding.

答: Transistors have voltage drop too! Try measuring all voltages. What is the nominal voltage for the motor?</p>

Title: Driving a small motor