问:
Robot positioning problem
The problem i am facing is to try and calculate the x and y position of a robot with dead reckoning.

Reading from the encoders and getting proper rotations of the wheels of my robot works. The robot has 3 wheels, where 2 of the 3 can be controlled like in this picture:

Calculating the distance from these wheel rotations and from those distances the heading of the robot is tested and works properly. Here is the code for the heading:

```<code>void MotorHandler::UpdateHeading(Position& currentPosition, double leftMotorDistance, double rightMotorDistance)
{
   currentPosition.heading = (double)((int)(((rightMotorDistance - leftMotorDistance) / (2 * PI * AXLE_LENGTH)) * FULL_ROTATION_DEGREES) % 360);
}
</code>```

Where axle_length is the length between both wheels and full_rotation_degree is 360.

But after this, when i try to calculate the x and y of the robot at any given moment i get weird results. Here is the code for calculating the x and y:

```<code>void MotorHandler::CalculateCurrentPosition(Position& currentPosition)
{
double leftMotorDistance = (motors[0]->GetRotation()/FULL_ROTATION_PULSES) * WHEEL_CIRCUMFERENCE;
double rightMotorDistance = (motors[1]->GetRotation()/FULL_ROTATION_PULSES) * WHEEL_CIRCUMFERENCE;

double headingToRadians = (currentPosition.heading * PI) / 180;

if (fabs(leftMotorDistance - rightMotorDistance) < 1.0e-6)
{
    currentPosition.X = leftMotorDistance * cos(headingToRadians);
    currentPosition.Y = rightMotorDistance * sin(headingToRadians);
}
else
{
    double wd = (rightMotorDistance - leftMotorDistance) / AXLE_LENGTH;
    double expr = (AXLE_LENGTH * (rightMotorDistance + leftMotorDistance)) / (2 * (rightMotorDistance - leftMotorDistance));

    currentPosition.X = expr * sin(wd + headingToRadians) - expr * sin(headingToRadians);
    currentPosition.Y = -expr * cos(wd + headingToRadians) + expr *  cos(headingToRadians);
    UpdateHeading(currentPosition, leftMotorDistance, rightMotorDistance);
}
}
</code>```

Where the starting x, y and heading are 0. As said, calculating the heading of the robot works properly, which means that the distances of the wheels also are calculated correctly and works properly.

Links used:

https://www.cs.princeton.edu/courses/archive/fall11/cos495/COS495-Lecture5-Odometry.pdf
http://rossum.sourceforge.net/papers/DiffSteer/

Calculate position of differential drive robot

Ty!

答:
This is another aspect of a longer answer I wrote here. Briefly restated, your problem is that a wheeled robot like this is nonholonomic, which means you can just use absolute encoder counts and get a valid result for position and heading.

You have two axes of control: a left wheel and a right wheel; and you have three degrees of freedom: left/right translation, forward/backward translation, and rotation.

I'll restate the example given at the other answer. Consider:

Moving forward 10 meters and turning 180 degrees, =OR=

Turning 180 degrees and moving forward 10 meters.

How do these scenarios work in your code? It looks like your heading is probably calculated correctly, but your position is based solely on the current heading. In both cases above, the robot ends after having turned 180 degrees. In the second case, your code should give correct answers, because there is no translation before you rotate.

The first case, however, would see your code correctly track the movement as it goes forward 10 meters but then, as the robot rotates, your code uses the current heading to index the distance traveled, and so it would appear as if your robot were quickly scribing a circle of radius 10 meters.

Again, as stated in the other answer, the solution is to do as @50k4 mentioned and accumuluate current position as a differential quantity for each sample, and not just look at overall counts.

Title: Robot positioning problem


问:
Line-following robot with a 5th wheel
Both of these 4 wheel drive line following robots have a fifth wheel in the rear.
My first thought is, that it is used as a braking mechanism. Would that be the case? If so, could someone explain - how does that mechanism work on the first robot?

答:
The first robot is RS-100 and it won this year's all-Japan fine following competition. The fifth wheel is an encoder. The robots are allowed to remember the track - this is specific to this competition as the turns are marked by white markers outside of the line. Look at the winning run of the robot and you will see that it speeds up and down in fast runs (i.e. after the first run) https://www.youtube.com/watch?v=960e5Q_PhWg

Additional trivia: This year was the first in a long time that an Ackermann steering robot won (what is considered MCU-Rally style, a very popular competition in Japan). It looks like this is a good design for competitions in which there are no 90 degree turns. It beat the previous year's winner, Cartis, which is interesting in its own because it uses 4 propellers for downforce http://anikinonikki.cocolog-nifty.com/.shared/image.html?/photos/uncategorized/2016/11/18/cartis45d.jpg They banned using ducted fans (EDFs) for downforce in 2016.

ContentLicense: CC BY-SA 3.0

Title: Line-following robot with a 5th wheel


问:
PID tuning with (Deep) Reinforcement Learning
I am trying to implement a RL algorithm for an adaptive PID in a robot system. My doubt consists in the creation of the possible states in the problem.

I mean, I understand quite well the problem when the possible states are door numbers, but I don't know know what to do with PID. Do I have to create a finite number of possible PID values in which the algorithm learns?

答:
A PID coefficients can be estimated from data using a simple gradient descent approach. MATLAB codes link and detailed text link, that I wrote can be found in the given links.

You can perform this learning iteratively to keep updating the PID coefficients.


问:
Using ROS to control a CMM (Coordinate Measuring machine)
i'm a senior, i really desperate to find answers here. i am building a robotic arm with bunch of low-cost sensors , motors and other actuators. i'm using PI 3 as my Microcontroller.

I need helping to build the software by giving answers to my questions:

Is it efficient to us ROS with low-cost projects? if not what are my other
alternatives?

also is it possible to use another microcontrollers (Arduino's or PI's) in
between so everyone of them can deal with a specific collection of sensors
and actuators ?

is it possible to control stepper motors through Arduino/PI using ROS?

This would be the easiest way to describe my project:

Master (PI 3) ---> Receiving results from 4 microcontrollers ---> each one controls a joint (encoders, sensors, steppermotors)

I'm open to suggestions from any kind i'm still in the start i have 4-6 months period to finish it, i don't know if i'm asking in the right place or not but i don't know much about blogs.

答:
Here are my responses to your questions:

In brief, using ROS does not depend on the project cost, rather the scale of the project. It would help you tremendously in the following cases:

Modular Application: Robotic applications might need various features. For eg (in your case): Sensor input (Grab data from the sensors, process it and make it available to other modules). Frame Conversion (Convert sensor reading to angles and estimate transforms for arm state estimation). Controls (Command the actuators to achieve specific arm state). Calibration (Making sense of arm sensor data).

Thus, as you develop each of the above features one after the other, you can simply keep creating individual ROS nodes/packages for each feature. They will be run independently with ROS managing communications between the nodes.

Communication: Simple example: Suppose you fix a camera on your arm. Only one application can read the camera driver to grab the images. Thus, if you need multiple applications to work with the images, you will need to create a way to make the image available through inter-process communication. In ROS, you have the scalability to simply publish the image in a topic and all others application that needs it will subscribe.

Community Support: ROS has a wide community that has developed many tools that might be useful. For eg: Rviz is a great tool that you can use to visualize your arm and its environment. You may use moveit, a well developed opensource ROS package to control your arm actuators.

Gazebo Simulation: While Gazebo and ROS are independent. They go very well together. You can develop a model of your arm in Gazebo and develop your arm features in simulation (Quicker hardware iterations and software development). Your ROS application would only deal with the ROS topics, thus, it need not know whether it is working with the simulated arm or the physical arm. (Example)

Yes, it can be done. ROS comes to rescue again. Treat a central PI as ROS master, connect all other PIs to the same network over Wi-Fi/Ethernet and all PIs will be able to share ROS topics among themselves. Follow this wiki on ROS to know how ROS can be setup in a network between multiple machines. You can connect the arduinos to PIs using USB and use rosserial package to output arduino sensor data as ROS topics (Tutorial).

Yes, low-level hardware commands can be generated both by PI (IO pins) and Arduino. However, it would be more convenient to use Arduino. Connect stepper motor ---wire----> Arduino ---usb---> PI. Use rosserial as mentioned in (2) above.

I would suggest using a more powerful central computer than PI 3. Odroid XU4 is a good option. PI 3 takes a lot of time in compiling ROS applications in C++ thus slowing down the development process. One way to circumvent this issue is to use interpreted language like python rather than C++. ROS has support for both python and C++.

You can follow moveit ROS package to learn more about controlling Robot arm using ROS.

Hope it helps.


问:
Why does my LSM303 magnetometer reading not change in a while loop?
I am using a LSM303 sensor to compute a heading and I want to turn my robot to a heading.

I have the simple code here:

```<code>int mag;
mag = compass.heading((LSM303::vector){0,-1,0});;   //read the angle of the robot

Serial.println(mag);
while (mag != angle){
    //while it isn't the desired angle turn and continue to update the robot angle
    trex.write(0xE9);
    trex.write(90);
    trex.write(90);
    mag = compass.heading((LSM303::vector){0,-1,0});;   //read the angle of the robot

}
</code>```

In a function called with a speed and angle (heading), the trex part tells the motor controller to turn on a point and the while loop should test for when the desired heading is reached. However, testing using a couple of instances of Serial.println(mag); I have determined that once inside the while loop, mag never changes which just means the robot turns indefinitely.

I have no idea why this would happen. Perhaps someone here does?

Thanks.

答:
I don't know Arduino from Aardvark, so this comment is based purely on how a modern C++ compiler would behave:

Were you asking about a plain ol' C++ problem, I would ask you if compass is declared volatile, or if the 'heading' method of compass's class is declared volatile, or if your system is based on cooperative multitasking.

In the first two cases (lack of things being tagged as volatile) the compiler will optimize the call to compass.heading to just outside the loop (to save you time -- isn't that nice?).

In the third case, whatever the code is that actually acquires the values for the compass structure will never get a chance to run (because your code is stuck in the while loop) and you'll never see results.

I hope this makes sense to the Arduino environment...

OwnerDisplayName: mark mcmurray


问:
What are myopic and non-myopic policies?
I am reading this paper: A survey on Policy Search for Robotics and I came across these terms. Can someone give an answer, please?</p>

答:
You first have to be clear about the core RL terms, to understand myopic and non-myopic policies:

Policy: Suppose each cell in the grid below is a state that the RL agent can be in. From each state, it can transition to another state. Now, the arrows that are given, shows a particular transition it would take from each state to go to another. This depicts a policy that answers (Which direction should I go from any current state?)

Reward: For every transition or a sequence of transitions, the agent gets a Reward for it. It can be positive or negative.

Now, in Reinforcement learning, an agent tries to pick a policy that gives it the maximum reward in the future. The agent might just look 1 step ahead in the future or 1000 (an arbitrary number) steps. If it looks 1 step ahead and based on that picks a policy that gives it a maximum reward, the policy would be myopic. On the other hand, if the agent looks 1000 steps ahead in future and then decides on the best policy, the policy would be termed non-myopic.

In RL, most generally, the number of steps to look ahead in future is determined by the discounting factor $\gamma \in [0,1]$, when the total reward $G_t$ is formulated as:

$G_t = R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} ...  = \sum_{k=0}^{\infty}\gamma^k R_{t+k+1}$

As you can see, if $\gamma = 0$, the total reward $G_t$ will contain reward of only one time-step ahead in future $R_{t+1}$ (myopic). If $\gamma = 1$, rewards till $\infty$ are considered (non-myopic).

You can follow Dr. David Silver's lecture on RL to learn more: Link


问:
RRT algorithm in C++
I want to implement RRT for motion planning of a robotic arm. I searched a lot on the internet to get some sample code of RRT for motion planning, but I didn't get any. Can someone please suggest a good source where I can find RRT implemented in C++ for any type of motion planning.</p>

答:
You can follow this GitHub repository to find RRT, RRT* and RRT with dynamic vehicle constraints (Dubin's dynamics).

https://github.com/ManashRaja/rrt-star-dubins-sim

It has a simple codebase to learn the implementation in C++ and modify as per your requirement.

Title: RRT algorithm in C++


问:
Inverse Kinematics 5DOF - general approach - Wrong solution MATLAB
Can anyone name a good source for a general approach (cookbook-like) for the inverse kinematics regarding a 5-DOF?

The paper by De Xu et al. is aiming for a general approach, but it doesn't work for my code. Maybe you could check that one as well?!

I am new to MATLAB, the code is no masterpiece:

Parameter used:

a=[0 82 93 55 95 0];

d=[47 0 0 0 0 10];

alpha=[90 0 0 0 0 0];

theta=[15 30 40 -90 -15 0];

Result for Theta 1-5:

5,080

38,029

75,947

-90,247

20,719

EDIT:
The results 1-5 mentioned above are the one the code gave me. But those are wrong, because:

Position of TCP (taken form the Forward Kinematics):

px= -5.7853

py=  5.7606

pz=  25.908

Position of TCP (using the calculating values for Theta 1-5):

px=  47.0

py= -151.0

pz=  43.9430

All values in degrees.
I am using 5 servos by Dynamixel ax-12a.

```<code>a=[0 82 93 55 95 0];
d=[47 0 0 0 0 10];
alpha=[90 0 0 0 0 0];
theta=[15 30 -90 0 45 0];
rad=57.295779513082;

T01=[cos(theta(1)),-sin(theta(1))*cos(alpha(1)),sin(theta(1))*sin(alpha(1)),a(1)*cos(theta(1));
    sin(theta(1)),cos(theta(1))*cos(alpha(1)),-cos(theta(1))*sin(alpha(1)),a(1)*sin(theta(1));
    0,sin(alpha(1)),cos(alpha(1)),d(1);
    0,0,0,1];
T12=[cos(theta(2)),-sin(theta(2))*cos(alpha(2)),sin(theta(2))*sin(alpha(2)),a(2)*cos(theta(2));
    sin(theta(2)),cos(theta(2))*cos(alpha(2)),-cos(theta(2))*sin(alpha(2)),a(2)*sin(theta(2));
    0,sin(alpha(2)),cos(alpha(2)),d(2);
    0,0,0,1];
T23=[cos(theta(3)),-sin(theta(3))*cos(alpha(3)),sin(theta(3))*sin(alpha(3)),a(3)*cos(theta(3));
    sin(theta(3)),cos(theta(3))*cos(alpha(3)),-cos(theta(3))*sin(alpha(3)),a(3)*sin(theta(3));
    0,sin(alpha(3)),cos(alpha(3)),d(3);
    0,0,0,1];
T34=[cos(theta(4)),-sin(theta(4))*cos(alpha(4)),sin(theta(4))*sin(alpha(4)),a(4)*cos(theta(4));
    sin(theta(4)),cos(theta(4))*cos(alpha(4)),-cos(theta(4))*sin(alpha(4)),a(4)*sin(theta(4));
    0,sin(alpha(4)),cos(alpha(4)),d(4);
    0,0,0,1];

T45=[cos(theta(5)),-sin(theta(5))*cos(alpha(5)),sin(theta(5))*sin(alpha(5)),a(5)*cos(theta(5));
    sin(theta(5)),cos(theta(5))*cos(alpha(5)),-cos(theta(5))*sin(alpha(5)),a(5)*sin(theta(5));
    0,sin(alpha(5)),cos(alpha(5)),d(5);
    0,0,0,1];

T56=[cos(theta(6)),-sin(theta(6))*cos(alpha(6)),sin(theta(6))*sin(alpha(6)),a(6)*cos(theta(6));
    sin(theta(6)),cos(theta(6))*cos(alpha(6)),-cos(theta(6))*sin(alpha(6)),a(6)*sin(theta(6));
    0,sin(alpha(6)),cos(alpha(6)),d(6);
    0,0,0,1];

T06=T01*T12*T23*T34*T45*T56;        %transformation matrix
inv_T01=inv(T01);
inv_T12=inv(T12);
inv_T23=inv(T23);
inv_T56=inv(T56);
T05=T06*inv_T56;
%needed for theta4 and theta5
Inverse=inv_T23*inv_T12*inv_T01*T06*inv_T56;
T_4_5=T34*T45;

N=T06(1:3,1);
nx=N(1,1);
ny=N(2,1);
nz=N(3,1);
O=T06(1:3,2);
ox=O(1,1);
oy=O(2,1);
oz=O(3,1);
A=T06(1:3,3);
ax=A(1,1);
ay=A(2,1);
az=A(3,1);
P=T06(1:3,4); %comapre to (17) in paper
px=P(1,1);
py=P(2,1);
pz=P(3,1);
px_2=T05(1,4);
py_2=T05(2,4);

%theta1
help1=px_2;               %not sure
help2=py_2;                 %not sure
help3=(px_2*(-1));         %not sure
help4=(py_2*(-1));         %not sure

theta11=atan2(help2,help1);
theta12=atan2(help4,help3);     %using this
theta1=atan2(py,px);            %most common way

%Theta2
B1=(az*d(6)-pz+d(1));
B2=(sqrt((-ax*d(6)+px).^2+(-ay*d(6)+py).^2))-a(1); %taking only positive value, alternative: [1 -1]*sqrt
B3=((B1.^2+B2.^2+a(2).^2-d(4).^2));
%auxiliary angle
beta=(atan2(B2,B1));
root=((a(2)*a(2))*sqrt(B1.^2+B2.^2));

theta21=(asin(B3/root)-beta);%works best
theta22=pi-theta21;

%theta3

theta3=atan2(B1-a(2)*sin(theta21),B2-a(2)*cos(theta21))-theta21; %using theta21 is close to determined angle BUT still far away from acceptable

%theta4
%auxiliary
OX=(ox*cos(theta1).*sin(theta21+theta3));
OY=(oy*sin(theta1).*sin(theta21+theta3));
OZ=(oz*cos(theta21+theta3));
theta4=atan2(-OX-OY-OZ,ox.*sin(theta1)*oy.*cos(theta1));%as in the case

%theta5
%auxiliary
NX=(nx*cos(theta1).*cos(theta21+theta3));
NY=(ny*sin(theta1).*cos(theta21+theta3));
NZ=(nz*sin(theta21+theta3));
AX=(ax*cos(theta1).*cos(theta21+theta3));
AY=(ay*sin(theta1).*sin(theta21+theta3));

theta5=atan2(NX+NY-NZ,-AX+AY-az*sin(theta21+theta3));%as in the case

theta12*rad
theta21*rad
theta3*rad
theta4*rad
theta5*rad

enter code here
</code>```

答: I never saw a conversion between degrees in radians in your code, so that would be the number one problem to fix. All of your transform matrices are using sin and cos terms, which only accept values in radians, and using them with values in degrees. I'm a bit busy at the moment but I'll go over the code in more detail later today.


问:
Jacobian determinant of three degree of freedom robot
I want to determine Jacobian determinant of spherical wrist structure, but my Jacobian is 6x3, so it is not square. How can I get it?</p>

答:
If $J(q)$ isn't square, you're looking for some alternate metric to take its place. You can take the determinant of $J(q)J^T(q)$. per this tutorial or any number of other pseudo-inverse methods (from Introduction to Inverse Kinematics with Jacobian Transpose, Pseudoinverse and Damped Least Squares methods, by Samuel Buss).

:EDIT:

As highlighted by @SteveO and @PetchPuttichai in the comments, it would appear that the $J(q)J^T(q)$ only when $J(q)$ has full row rank. In any other case, use $J^T(q)J(q)$.


问:
Iterative Closest Point for 2-D LIDAR Data
I have two 2-D point clouds obtained from LIDAR (Light Detection And Ranging) scans at two different poses (positions and orientations) inside a circular structure, where a small object (vertical cylindrical column) is placed at a fixed location. My objective here is to match as closely as possible the two point clouds and find the planar transformation (translation and rotation) to do that. One useful technique—I believe—would be the point set registration using the ICP (Iterative Closest Point) algorithm.

The issue now is that the algorithm fails to match perfectly the two point clouds, specifically in terms of rotation because it didn't complete matching the data points related to the object inside the circle. Therefore, my question is: would this be a limitation of the ICP algorithm, or a problem in implementing it (which I doubt it since I double-checked with Matlab ICP embedded function)?

Are there other methods/algorithms that can solve this problem?

答:
Iterative closest point is iterative. You have to seed a starting match, and it will find a local minima from there. If you're getting poor results, try feeding a better seed guess or try increasing the size of the steps the algorithm is allowed to take.

Increasing the step size could be dangerous, though, because the results may not converge. It's not clear what the application of this is; I don't know if you're just doing this to do it or if you're trying to get some kind of an automatic alignment procedure to reconcile two lidar poses ("known good" and unknown, maybe?)

I would start by feeding it a better guess before looking to monkey with any of the ICP step sizes.

ContentLicense: CC BY-SA 4.0


问:
How to compute the observation matrix for a Kalman Filter?
If my state vector is just a representation of the error state of a quaternion represented as $[\delta \bf{q} ]$ which is a 3x1 vector and my external update is from an accelerometer, how would I compute the jacobian $\bf{H}$ matrix?

One implementation that I've found uses $$
\bf{H} = [R^w_b g]_\times
$$

where $\times$ represents the skew symmetric matrix and $\textbf{g} = [0, 0, 9.80665]^T$, $\textbf{R}^w_g$ the rotation matrix obtained from the true state quaternion.

How does $z = Hx$ make sense in this formulation? Thank you!

答:
The way to relate Accel measurements to orientation is through Gravity. When there is no user motion, only force experienced by the accel is Gravity.

In your case, I think the interpretation must be:
How does my measurement of Gravity match up to predicted Gravity?


答: In order to answer your question it would be interesting why you need the determinandt of the Jacobian... maybe there is another way for your problem. </p>

Title: Jacobian determinant of three degree of freedom robot

Body: I want to determine Jacobian determinant of spherical wrist structure, but my Jacobian is 6x3, so it is not square. How can I get it?</p>


答:
You can use 3D feature descriptors here to register two point clouds. I've personally used two most recent ones that performed well enough for a similar application.

Following are the references to the papers:

A novel binary shape context for 3D local surface description link

TOLDI: An effective and robust approach for 3D local shape description link

The approach is: a) Detect good keypoints from the point clouds -> b) Compute descriptors for them -> c) Match descriptors -> d) Use RANSAC to find inlier matches and compute rigid body transformation between the point clouds.

In the paper (1) above, methods for (a) and (b) are given. I found them to be robust enough in an application I used which is similar to yours. For (c), I used Hamming distance based descriptor matching algorithm BFMatcher of OpenCV (link). For (d) I developed my own RANSAC implementation and used estimateRigidTransformation method in pcl library (link).

You can follow an example implementation of point cloud registration at pcl library in this link, that uses different feature descriptors. It did not work for me, but you can give it a try.

If you need help in implementing paper (1) above, you may follow my codes in this link

Title: Iterative Closest Point for 2-D LIDAR Data

Body:
I have two 2-D point clouds obtained from LIDAR (Light Detection And Ranging) scans at two different poses (positions and orientations) inside a circular structure, where a small object (vertical cylindrical column) is placed at a fixed location. My objective here is to match as closely as possible the two point clouds and find the planar transformation (translation and rotation) to do that. One useful technique—I believe—would be the point set registration using the ICP (Iterative Closest Point) algorithm.

The issue now is that the algorithm fails to match perfectly the two point clouds, specifically in terms of rotation because it didn't complete matching the data points related to the object inside the circle. Therefore, my question is: would this be a limitation of the ICP algorithm, or a problem in implementing it (which I doubt it since I double-checked with Matlab ICP embedded function)?

Are there other methods/algorithms that can solve this problem?


问:
Building robots with high reliability, durability, and battery life
I'm involved in research on psychologically plausible models of reinforcement learning, and as such I thought it'd be nice to try and see how well some to the models out there perform in the real world (i.e. sensory-motor learning on a mobile robot). This is already been done in some robotics labs, such Sutton's implementation of the Horde Architecture on the "Critterbot". However, these implementations involve robots custom-build by robotics experts in order to deal with the trials and tribulations of learning on a long time-scale:

"The robot has been
  designed to withstand the rigors of reinforcement learning
  experiments; it can drive into walls for hours without damage or burning out its motors, it can dock autonomously
  with its charging station, and it can run continuously for
  twelve hours without recharging."

Unfortunately I'm no expert when it comes to designing robots, and don't have access to a high quality machine shop even if I did; I'm stuck with whatever I can buy off-the-self or assemble by hand. Are these constraints common enough for amateur robotics suppliers to cater to, or should I expect to have to start from scratch?

答: Off-the-shelf robot kits are a good place to start for an amateur. If you're not using system-based kits (i.e. Lego), then they can usually be modified. Mount bumpers around the sides to help it withstand crashes and add a larger battery with a higher milli-amp-hour (mAh) rating for longer battery life. It's tough to provide any more specific solutions than that.</p>


问:
Accelerometers in a self-balancing robot, can't we do better?
I'm currently reading on self-balancing robots that use an IMU (gyroscopes + accelerometers) to estimate their current tilt angle.

Most documents that I have found say the same things:

You can't just take the arc-tangent of the accelerometers data to find the gravity direction because they are affected by "inertial noises".

You can't just integrate the output of the gyroscope over time because it drifts.

There are two generally accepted solutions to merge those data:

A Kalman filter estimating the current tilt along with the current gyroscope bias.

A complimentary filter applying a low-pass filter on the accelerometer data (they can be trusted in the long term), and a high-pass filter on the gyroscope data (it can be trusted in the short term).

All sources that I have found seem to use the raw data from the accelerometers in those filters, disregarding the fact that, in a self-balancing robot, we can have a very good estimate of the "inertial noise" mentioned above.

Here's my though

Let's model our robot with an inverted pendulum with a moving fulcrum and use this poor drawing as a reference.

The inertial forces felt by the accelerometers at C can be derived from (if I didn't make any mistake)
$$
\begin{pmatrix}
\ddot{c_r}
\\
\ddot{c_\Theta}
\end{pmatrix}
=
\begin{pmatrix}
-\ddot{x}\sin(\Theta)-R\dot{\Theta}^2
\\
-\ddot{x}\cos(\Theta)+R\ddot{\Theta}
\end{pmatrix}
$$

Assuming that

Our robot is rolling without slipping

We can measure x (either by using stepper motors or DC motors with encoders)

Then we can have a good estimate of all those variables:

$\hat{\ddot{x}}_k$ : Finite differences over our current and previous measures of $x$

$\hat{\dot{\Theta}}_k$ : The current gyroscope reading

$\hat{\Theta}_k$ : Previous estimation of $\Theta$ plus the integration of $\hat{\dot{\Theta}}_k$ and $\hat{\dot{\Theta}}_{k-1}$ over one $\Delta t$

$\hat{\ddot{\Theta}}_k$ : Finite differences over $\hat{\dot{\Theta}}_k$ and $\hat{\dot{\Theta}}_{k-1}$

Once we have that, we can negate the effect of the inertial forces in the accelerometers, leaving only a much better measure of the gravity.

It probably still is a good idea to use this as the input of the usual Kalman filter as in 1. above.

Maybe we can even build a Kalman filter that could estimate all those variable at once? I'm going to try that.

What do you think? Am I missing something here?

I think self-balancing-robot could be a good tag, but I can't create it

答:
While this isn't a complete answer to your question, I want to leave some of my thoughts. I think you missed:

Gravity itself, which points downward and is typically about 9.81 m/s² but might be different dependent on your location (you only measure 0 gravity when the robot is in free fall)

Sensors are typically not aligned 100% to your x/y/z-axis (the chip is not totally horizontal on the PCB... the PCB isn't mounted totally horizontal/vertically into your robot and so on); you need to compensate for this

Accelerometer-sensors have an offset and gain value, which you have to compensate. They are affected by e.g. temperature and manufacturing tolerances. There are online calibration algorithms for this; but you can put these unknown variables into a Kalman-filter, too.

Gyroscopes have a drift, which is also dependent on temperature. It's not a constant but might change over time. This drift can be slightly compensated with the help of a magnetometer.

Magnetometers aka Compass sensors in 3D can be used to compensate the drift of Gyroscopes. However, they are sometimes affected by electromagnetic fields (motors, magnets, steel in walls etc). So they can't be totally trusted.

A Kalman-filter model is a good approach. The more knowlege about the motion model you put into the model, the better it will work. You also need to know (co-)variances of all variables... How sure you think measurements of each sensor are.


问:
Controlling a quadrotor from a PC
I need to control quadrotor from a PC, without using a joystick.

I have got a mini-beetle quad V929 Beetle 4-Axis  and also have this NRF24L01+ Wireless Transceiver Module Chip (2.4 GHz transceiver)
Is it possible to write an Arduino program to make them speak to each other?

I did some research and found that the quad V929 model uses FlySky protocol and only works with A7105 NRF24L01 2.4 GHz transmitter chip not the one which I mentioned above.

Are there any other better ways of controlling the quad from PC or Arduino board?

答: If you're open to purchasing a new quadrotor, take a look at the Crazyflie from Bitcraze. It operates exactly this way via USB dongle attached to a PC.</p>

Title: Controlling a quadrotor from a PC


问:
Are there any big size open source robot project(servant like robot maybe)
I am trying to build a big size robot (150CM height) like this:

But I don't have mechanical engineering knowledge for that. Also it's only a prototype to show how the robot will act(it's more relies on image/voice recognizing and processing). So I am looking for an open source project to build a robot that it's easy and cheap to build.(I mean something like instructable projects)

答:
I think that your best bet is to start with an InMoov and to customize it to add a mobile base.

InMoov is a 3D-printed, open source, life size robot created by Gael Langevin. It's pretty amazing.

Good luck!


问:
How to reduce the small free rotation/movement of a stepper motor shaft?
I was successful in running a 28BYj-48 stepper motor with 4096 steps per revolution. I am happy with the result. But there is a free movement of the motor shaft itself - you can move the motor shaft slightly with your hand without making any steps. Feels lose, but event the brand new ones has that motion, so I am sure its manufactured like that.

Is there any way to reduce that unwanted free motion? I am trying to add a hand with the motor and now that small movement became quite a noticeable gap.

This is my first question on robotics - so please be pardon any mistakes.

答:
It's a geared stepper, which means that it's a stepper (64 steps, I gather) followed by a 64:1 (approximately) gearbox.  What you're seeing is almost certainly backlash in the gear train (see where I "suspect a poor mechanical joint...,  below).  Any gear motor, stepper or not, is going to have backlash.  Because there's a tradeoff between the precision of the gears and how much backlash you can get out of the assembly before the thing binds up, a cheap motor is going to have more.

If you can preload the motor with a constant torque that only points in one direction, then you could reduce the backlash (although maybe not eliminate it, given the amount of gear reduction and the cheapness of the unit).  If you need more precision that that, then you're going to either need a direct-drive stepper (which, thinking about, is going to be hard to find with that many steps), or possibly a geared stepper with a much higher precision gearbox, or you're going to need something like a bazillion-pole brushed or brushless "regular" motor, position feedback, and a controller.

(Former answer left in because it's valid for a direct drive stepper, if you find one with 4096 steps).

How much motion are you seeing?  Just by the way that the magnetic circuit is designed, you should expect some motion within a step (in an unpowered motor it's not terribly inaccurate to think of the rotor as being connected to the frame through a spring, at least until you overcome the motor's holding torque).

If there's more slop than that (which works out to less than 1/10th of a degree in your case!) then I'd suspect a poor mechanical joint between rotor and shaft, which is just wrong.  Did the motor come from a reputable source?


问:
A* algorithm for Arduino robot path planning
Im in the process of getting into robotics. I have decent experience with symbolic AI and am wanting to start off using symbolic AI strategies to give a wheel, arduino based robot some "intelligence". (later I hope to use neural networks, but baby steps). Anyways, I started researching various symbolic approaches, and I found the the A* algorithm is one that can be used, but this puzzled me. My experience with A* is that the problem needs to be fully observable for it to work, so I dont see how a robot could use it to solve a maze for example. Would the robot first need to randomly explore the maze, store all paths taken, then apply A* to find the optimal path?

Thanks for the help

答:
Well, if you want the optimal path to be found over the entire course, irrespective of the planner you use, you will require the map before hand.

Although, the issues with A* are that it is meant for a Holonomic robot (or entity for the path is being planned) and also the one you have encountered, its ease of implementation makes it so popular for planning. There are quite a few other planning algorithms which circumvent these issues. Take a look at RRT (Rapidly-exploring Random Tree) and other similar algorithms for that.

If you wish to use A* only, and do not have prior information about the entire course, may I suggest you try using locally optimal path to navigate by generating local goal points for the observable map at every certain instance of time.


答:
You may find this example useful. I recently used A* for highway driving in traffic, driving at 50 mph and passing other cars.

https://github.com/ericlavigne/CarND-Path-Planning

The A* algorithm supports decision-making only in discrete problems. I discretized highway driving by only considering positions that are either in the middle of a lane or halfway between lanes and by only allowing changes in direction once per second.

Even with incomplete information, you can still create a cost function based on the information that you do have. A* can be used for guiding the exploration process, such as by considering "explore a new area" as a good result in your cost function. For highway driving, I don't know what the other cars will do even one second later, but I model their likely behavior and use A* to plan a route several seconds out.

Title: A* algorithm for Arduino robot path planning

Body:
Im in the process of getting into robotics. I have decent experience with symbolic AI and am wanting to start off using symbolic AI strategies to give a wheel, arduino based robot some "intelligence". (later I hope to use neural networks, but baby steps). Anyways, I started researching various symbolic approaches, and I found the the A* algorithm is one that can be used, but this puzzled me. My experience with A* is that the problem needs to be fully observable for it to work, so I dont see how a robot could use it to solve a maze for example. Would the robot first need to randomly explore the maze, store all paths taken, then apply A* to find the optimal path?

Thanks for the help


问:
Virtual Testing Environment for Drones
Does anyone know of a robotics developer environment ideal for testing AI programs for drones (e.g. quadrocopters, planes, helicopters, etc.)? I would like something like Microsoft Robotics Developer Studio that includes a virtual environment (such as an outdoor environment with gravity, wind, etc.) to test out flight dynamics. I would like the options to add sensors to the virtual drone, such as gps, altimeter, gyros, etc. that the AI program can then use to steer the drone.</p>

答:
Microsoft AirSim is a photorealistic simulator for drones. You'll find videos, instructions, and downloads on this page:

https://github.com/Microsoft/AirSim#welcome-to-airsim

Title: Virtual Testing Environment for Drones


答:
With Flightgear, which is open source, you can define and fly custom aircraft and custom algorithms for handling its automatic flight controller.

Flightgear allows flying all around the world, and you could add / integrate sensor models into it.

It also has quite a flexible API, to integrate to existing codes, models, and algorithms.

Title: Virtual Testing Environment for Drones

Body: Does anyone know of a robotics developer environment ideal for testing AI programs for drones (e.g. quadrocopters, planes, helicopters, etc.)? I would like something like Microsoft Robotics Developer Studio that includes a virtual environment (such as an outdoor environment with gravity, wind, etc.) to test out flight dynamics. I would like the options to add sensors to the virtual drone, such as gps, altimeter, gyros, etc. that the AI program can then use to steer the drone.</p>


问:
how do i select light-weight 6dof robot?
I plan to do some scientific research, after modeling and path planning for the robot, The algorithm outputs the Joint control torque(or Joint variable), and then i want to input this result to the robot Control platform to check my algorithm, as far as I know, most robot can only provide point-to-point tracking instructions(NOT torque\joint variable input API),any robot can supports torque or joint variable as the robot input(when i input joint variable or torque, robot can move)?

How can I program a 6 DOF robot using torque rather than joint positions as input?

If you have any questions or concerns, don't hesitate to let me know.

答:
This article explains how to implement joint-torque control on top of position-controlled robots.

Implementing Torque Control with High-Ratio Gear Boxes and without Joint-Torque Sensors
https://hal.archives-ouvertes.fr/hal-01136936/document

Copied from another StackExchange question:

https://robotics.stackexchange.com/a/7531/18316


答:
If you properly construct a Kalman filter with an 'x' input, then yes, it'll be better.  Notably, the inertial sensor cannot give you an absolute value for x in any case, because you're (essentially) trying to double-integrate an accelerometer signal into a position, and that is exquisitely sensitive to noise in the accelerometer output.

Some things you may wish to consider in your travels:

A full-blown Kalman filter is computationally intense, but a steady-state Kalman is basically a complimentary filter with rolloff frequencies selected by construction rather than b'guess and b'gosh.

Speaking of b'guess and b'gosh, if you want a Kalman to work well (and, sometimes, at all) you need to very accurately account for everything that goes into your variances.  Kalmans are notorious for not responding well to mismatches between your model and reality.  If you're willing to do the math, look into H-infinity and other robust state estimation techniques.

If you do go down the H-infinity road, you can also find the steady-state H-infinity filter and get the same computational advantage (and, in fact, the actual filter structure in your embedded code will be the same; it'll just have different values in the coefficients).

Title: Accelerometers in a self-balancing robot, can't we do better?

Body:
I'm currently reading on self-balancing robots that use an IMU (gyroscopes + accelerometers) to estimate their current tilt angle.

Most documents that I have found say the same things:

You can't just take the arc-tangent of the accelerometers data to find the gravity direction because they are affected by "inertial noises".

You can't just integrate the output of the gyroscope over time because it drifts.

There are two generally accepted solutions to merge those data:

A Kalman filter estimating the current tilt along with the current gyroscope bias.

A complimentary filter applying a low-pass filter on the accelerometer data (they can be trusted in the long term), and a high-pass filter on the gyroscope data (it can be trusted in the short term).

All sources that I have found seem to use the raw data from the accelerometers in those filters, disregarding the fact that, in a self-balancing robot, we can have a very good estimate of the "inertial noise" mentioned above.

Here's my though

Let's model our robot with an inverted pendulum with a moving fulcrum and use this poor drawing as a reference.

The inertial forces felt by the accelerometers at C can be derived from (if I didn't make any mistake)
$$
\begin{pmatrix}
\ddot{c_r}
\\
\ddot{c_\Theta}
\end{pmatrix}
=
\begin{pmatrix}
-\ddot{x}\sin(\Theta)-R\dot{\Theta}^2
\\
-\ddot{x}\cos(\Theta)+R\ddot{\Theta}
\end{pmatrix}
$$

Assuming that

Our robot is rolling without slipping

We can measure x (either by using stepper motors or DC motors with encoders)

Then we can have a good estimate of all those variables:

$\hat{\ddot{x}}_k$ : Finite differences over our current and previous measures of $x$

$\hat{\dot{\Theta}}_k$ : The current gyroscope reading

$\hat{\Theta}_k$ : Previous estimation of $\Theta$ plus the integration of $\hat{\dot{\Theta}}_k$ and $\hat{\dot{\Theta}}_{k-1}$ over one $\Delta t$

$\hat{\ddot{\Theta}}_k$ : Finite differences over $\hat{\dot{\Theta}}_k$ and $\hat{\dot{\Theta}}_{k-1}$

Once we have that, we can negate the effect of the inertial forces in the accelerometers, leaving only a much better measure of the gravity.

It probably still is a good idea to use this as the input of the usual Kalman filter as in 1. above.

Maybe we can even build a Kalman filter that could estimate all those variable at once? I'm going to try that.

What do you think? Am I missing something here?

I think self-balancing-robot could be a good tag, but I can't create it


问:
Optimal-time trajectory in 2D and 3D with simple constraints
I'm trying to find the optimal-time trajectory for an object (point mass) from point p0 with initial velocity v0 to point p1 with velocity v1. I'm considering a simple environment without any obstacles to move around. The only constraint is a maximum acceleration in any direction of a_max and optionally a maximum speed of s_max.

This is easy to work out in 1D but I struggle with the solution 2D and 3D. I could apply the 1D solution separately to each dimension, but this would only limit acceleration and speed in a single dimension. The actual acceleration might be larger in multiple dimensions.

Are there any textbook, closed-form solutions to this problem? If not, how can I solve this in a discrete-event simulation?

答:
In case you're not already aware, the problem you are asking about is generally referred to as the two-point boundary value problem. For some systems, a closed form solution may be extremely difficult to calculate and may not even exist. As such it would help to know more about your dynamics.

Your description would seem to imply that you are working with a double integrator system. If that's accurate then you could use a fixed-final-state-free-final-time controller. Because the dynamics matrix is nilpotent you can find a closed form solution in terms of time, then minimize the function to find the optimal arrival time. From there you can use your favorite numerical integration method to verify that the accelerations are within the desired bound. This approach will actually work for any linear system with a nilpotent dynamics matrix. For additional details please see section IV, Optimally Connecting a Pair of States, of my paper Kinodynamic RRT$^*$: Asymptotically Optimal Motion Planning for Robots with Linear Dynamics.


问:
Estimating yaw angle and yaw rate for a frontal vehicle
I would like to know if it is possible (and if it is possible how can it be done) to estimate the yaw angle and yaw rate of a vehicle in front of me knowing the following information:

-my speed (x,y,z),my position(x,y,z),my yaw angle and my yaw rate

-the relative speed to me(on x and y) of the vehicle/robot to which I want to find the yaw and yaw rate

-the position(x,y,z) of a point on the vehicle( corner of a vehicle) the length, width and height of the vehicle

答:
If you had such information for at least two different times, that could be combined to determine the yaw and yaw rate. The "point on the other vehicle" information would need to be the same point on the vehicle for both times. (With such information about only one time, the best you could do is make a "guess" such as "not moving" or "same yaw and yaw rate as me".)

You would need to use the information about your own vehicle to convert the information about the other vehicle from relative to absolute coordinates. The change in the other vehicle's position would give you the yaw. The change in the point on the other vehicle, relative to the center of the other vehicle, would represent motion in a circle around that center: the yaw rate.

BTW, since you are interested in determining yaw and yaw rate based on measurements of position, you may find this project useful as an example. I used radar and lidar measurements to estimate the position, yaw, and yaw rate of a vehicle. By combining multiple measurements, it was possible to estimate position more precisely than any of the individual measurements and to estimate yaw and yaw rate which were never directly measured.

https://github.com/ericlavigne/CarND-Unscented-Kalman-Filter


问:
How to develop subsumption architecture using two Arduinos?
I know what subsumption architecture is, and I'm sure I should have two different hardware modules (Arduinos) taking responsibility for low level computational tasks.

Now my problem is I have an two Arduinos and I want Arduino A to subsume or inhibit a signal from Arduino B . Does anyone have any idea how this is done? As I can wire Arduino A to send a signal to Arduino B but I'm unsure how to subsume or inhibit the signal? I want to use the Arduino Interrupt pin and functionality; instead of simply saying if the input A signal is < something, do something. As Modules should be activated in their own right, right?

答:
Here is an article (videos included) about how to navigate a maze using subsumption architecture and arduino.

http://www.codingnaked.com/post/arduino-powered-robot-solves-a-maze-using-subsumption-architecture-in-c/


问:
Recognizing a line from three r-theta ultrasonic distance readings?
Anyone know of sample Python code, or a tutorial, on the polar coordinate math for recognizing that three ultrasonic distance readings form a straight line?

```<code>Deg  Distance

-10°  20 cm
  0°  18 cm
+10°  16 cm
</code>```

Once I understand the math, I'll have to deal with the lack of precision.

I want my bot to recognize a wall, and eventually recognize a corner.

答:
Checking for three is a subset of checking for many; so, I am going to consider the more general solution.  I will discuss the three point solution at the end.

First, convert the polar coordinates to Cartesian Coordinates.
First, to make things simple, use your robot as the reference frame (make it the center of the universe).

That means, for each target calculate:
x=Distancecos(Deg), y=Distancesin(Deg)

Here is a Post on Converting Coordinates in Python

After you have all these calculate the slope and intercept of the line using linear regression; then, calculate R-squared (the Coefficient of determination) to determine how well the measurements fit a line.  Note: Any measurement system is going to have errors; so, the points will likely never perfectly fit a line.

If the number is too high, try dropping out points the deviate furthest from the line.  Maybe you could group them together and if they have a low r-squared then you have found another wall.

I am sure there are lots of Python regression libraries. Here is a reference I found on Calculating R-squared in Python.

If you are only going to use three points, you could likely simplify this by using the middle point as your reference and see if the slope to the other two point are exactly/nearly opposite.

Here are some other approaches for How to find if three points fall in a straight line or not.


问:
Algorithm for Determining Mobile Base Positioning Given End Effector Pose
I have a 6 DOF arm robot with a mobile base, and a given x/y/z/quaternion vector that the end effector must match. I am to determine the most optimal position of the mobile base such that an IK solution for the arm can be constructed from the end effector vector. I already have an IK method for the arm alone, but not one that includes the mobile base.

Not to mention, there is a collision aspect to this too. There is collision that the arm must avoid around the vector, which can easily be filtered with my simulator, but is just something that must be considered. Could anybody point out any algorithms that could possibly help? Thank you for your time.

答: You can simply add three joints to the kinematic chain. The 6 Dof of your arm are preceeded by two prismatic and one revolute joint representing the mobile base. The resulting 9 dof chain forms a redundant manipulator. Now it depends on how you define optimality as to which ik is derived. You can look up Orocos Kdl for starters. Their chain ik solver is  initialized with a random configuration. Simply repeat the process of calculating the ik until your cost yields an acceptable level. Its somewhat brute force but should be straight forward to implement.</p>


问:
Error during turtlebot launch in ROS
When I run
roslaunch turtlebot_gazebo turtlebot_world.launch

I am getting this error:-

```<code>> from defusedxml.xmlrpc import monkey_patch ImportError: No module
> named defusedxml.xmlrpc while processing
> /opt/ros/kinetic/share/turtlebot_gazebo/launch/includes/kobuki.launch.xml:
> Invalid tag: Cannot load command parameter [robot_description]:
> command [/opt/ros/kinetic/share/xacro/xacro.py
> '/opt/ros/kinetic/share/turtlebot_description/robots/kobuki_hexagons_asus_xtion_pro.urdf.xacro']
> returned with code [1].

Param xml is param command="$(arg urdf_file)" name="robot_description"/>
Param xml is The traceback for the exception was written to the log file
</code>```

答:
Since It was related import module I solved using </p>

```<code>pip install defusedxml
</code>```

Title: Error during turtlebot launch in ROS

Body:
Since It was related import module I solved using

pip install defusedxml


问:
Denavit-Hartenberg parameters for SCARA manipulator
I'm going through the textbook Robot Modeling and Control, learning about the DH convention and working through some examples.

I have an issue with the following example. Given below is an image of the problem, and the link parameter table which I tried filling out myself. I got the same answers, except I believe there should be a parameter d1 representing the link offset between frames 1 and 2. This would be analogous to the d4 parameter.

If anyone could explain why I might be wrong, or confirm that I have it right, that would be great. I hate it when it's me against the textbook lol.

Cheers.

答:
There is no mistake here.
The scara robot has 2 vertical Z-axis in wich it rotates.
therefore There is no real translation in the Z-direction between j0 j1 and even j2.

that's why d1 and d2 are zero because there is no change of Z opposed to the previous joints.

If you would fix that mistake, you could move j0 up so it coincides with j1 and j2.
and then add a j-1 and a new row at the top of the table for joint 0. then d0 is indeed needed. (distance between X-1 and X0 along Z.


答: In short, yes, there are a number of robotics companies catering to just your needs. Specifically which apply to you depends on what type of robot you desire. Naturally cost varies with the complexity and durability. For example if you would be satisfied with a differential drive robot for indoor use then the iRobot Create may suit your needs. If you need something for outside use then you could look at Clearpath Robotics products. For a full humanoid robot the Aldeberan Nao is a good choice. For quadrotors check out the AR.Drone Parrot. And I understand Liquid Robotics offers a good selection of water based robots. </p>

Title: Building robots with high reliability, durability, and battery life

Body:
I'm involved in research on psychologically plausible models of reinforcement learning, and as such I thought it'd be nice to try and see how well some to the models out there perform in the real world (i.e. sensory-motor learning on a mobile robot). This is already been done in some robotics labs, such Sutton's implementation of the Horde Architecture on the "Critterbot". However, these implementations involve robots custom-build by robotics experts in order to deal with the trials and tribulations of learning on a long time-scale:

"The robot has been
  designed to withstand the rigors of reinforcement learning
  experiments; it can drive into walls for hours without damage or burning out its motors, it can dock autonomously
  with its charging station, and it can run continuously for
  twelve hours without recharging."

Unfortunately I'm no expert when it comes to designing robots, and don't have access to a high quality machine shop even if I did; I'm stuck with whatever I can buy off-the-self or assemble by hand. Are these constraints common enough for amateur robotics suppliers to cater to, or should I expect to have to start from scratch?


问:
I²C read multiple registers with DMA
I am using an STM32-L432KC microcontroller to read data from an I²C Device (Bno-055) via DMA.

On a microcontroller without DMA i would try to minimize the IO-Wait by only reading the necessary registers of the device and only reading them as often as necessary (for example the calibration status only needs to be read every second etc.).

But with DMA i am thinking about just reading the first 64 registers (that's where the information is stored) at once and store them in memory. So my library is reduced to a little bit of HAL code in the interrupt and only some defines for the values. Furthermore reading values from the sensor is nothing more than reading some values from RAM which reduces IO-Wait by a lot.

Assuming i have enough memory what are problems that occour with this solution? What are the advantages of the "traditional" approach as opposed to my approach?

答:
DMA lets peripherals access memory directly. What component is it that is putting the information into your microcontroller's memory? It sounds like, from your post, you're having the microcontroller itself pull data on an interrupt basis. I don't think your sensor is going to push its own data to the microcontroller.

If you're having the microcontroller do all the work of getting the data into memory, then you're missing the point of DMA altogether, which may explain why this post is getting downvoted so much. If there is data you don't need then I don't understand why you would bother to acquire it, regardless of whether it's via DMA or not. You have to index the registers you want somewhere, whether that's when you pull the data from the sensor or when your program goes to read the correct data from memory.

You might be able to "speed things up" if you had a means to read I2C and then write to memory; an example would be getting a second microcontroller. The second microcontroller could then handle I2C comms and push the results directly to the memory of the first microcontroller. The first microcontroller is free to just use whatever's in memory. My concern here would be getting stale data and not realizing it's stale, or getting data mid-write.

In any event, if you don't have something that's not your primary microcontroller writing directly to memory, then whatever you're doing isn't DMA and your question doesn't really matter because you're not doing DMA.

To answer your question specifically, though,

Assuming i have enough memory what are problems that occour with this solution? What are the advantages of the "traditional" approach as opposed to my approach?

Even if you have enough memory to bulk read every bit of data the sensor has to offer, you still have to get the useful data into your program. Now, instead of having a library that indexes registers on the sensor, you have to index memory in the microcontroller. Now you need a library that can access BNO055 register data in the memory of a STM32L432KC microcontroller. That is, instead of one BNO055 library, you now have a BNO055-STM32L432KC library. If you change sensors or change microcontrollers you need to re-write the library.

Obviously, then, the advantage of doing it the "traditional" way is that you have a portable BNO055 library.

I'll also point out that, if the time it takes to communicate with your sensor is a deal breaker, your microcontroller doesn't have enough overhead and you should probably be looking to move to a different platform.

Title: I²C read multiple registers with DMA


问:
Understanding differential drive
I am a beginner in robotics and I have just come across the concepts of differential and steer drive. I don't understand them very clearly yet.

I found the following write up describing differential drive as follows:

If the angular velocities are identical in terms of both values and
  direction, i.e. if both the wheels are driven at the same speed and
  same direction (either clockwise or anticlockwise) then the robot
  tends to spin around its vertical axis. This complete turn capability
  is one of the greatest advantages of a differentially driven robot
  (a.k.a zero radius turn).

Being a complete beginner, I concede I could be entirely incorrect in disagreeing with the above.
I just imagine that "both wheels" driving at the same speed and direction (clockwise or anticlockwise) would mean a robot is travelling along linearly i:e straight ahead.
I don't understand why the writer says the robot is actually spinning around it's Z axis.

If I'm wrong, please explain what I'm missing.

And please, let me have links to material that would help me understand differential and steer drive.

Thanks in advance.

答:
Your instincts are correct if you are talking about rotating both wheels forward (or reverse) with the same rotational speed.  In that case, the robot would move linearly forward (or backward), just as you describe.  The drawings at the link you provide seem to support this.  However, this analysis is different from what the text describes.

I think the problem you're having is from the text describing each wheel's rotation as either clockwise or anticlockwise.  The text seems to describe a situation in which you define the $\hat{z}$ axis of each wheel as originating at the center of the axle which connects the two wheels.  Also define each wheel's $\hat{z}$ axis with a positive direction that passes through the center of the wheel.  In other words, both of the wheels will rotate about an axis that is parallel to the axle, but the left wheel's axis of rotation will be opposite in direction to the right wheel's axis of rotation.

Now consider a clockwise or an anticlockwise rotation about each of these two axes.  For the wheel on the left, an anticlockwise rotation turns the wheel in the forward direction, but an anticlockwise rotation of the right wheel rotates it in the backward direction.  And so on.

Given the above construct, the textual description of a differential drive makes sense.  It's unfortunate that the picture does not make this clear.

Title: Understanding differential drive


问:
Jacobian for Inverse Kinematics with quaternion of end effector
Quaternion has four parameters. Calculating Jacobian for inverse-kinematics, 3 positions and four quaternion parameters make Jacobian $7\times7$ instead of $6\times6$. How to reduce Jacobian to $6\times6$ when using quaternion?</p>

答:
Quaternions need to have a constant length. This property will give a constraint while writing the Jacobian matrix. Maybe you can use this property to reduce the size of the matrix to 6 x 6?

Reference : Practical Parameterization of Rotations Using the Exponential Map


问:
How can I run Tests/Simulations of Control and Motion Planning for a Bare Metal Robot?
I am using a raspberry pi to practice low level development with a differential drive robot; bare metal without an OS underneath.

I've gotten to the point where I have a very small, single purpose kernel that drives a couple of DC motors, and reads an IR sensor over I2C with an Analog Digital Converter.

I have also started writing code for a PID controller: so far so good.

I use a bootloader over USB to UART to update the Pi with new versions of the kernel, and I also started looking at the Check unit test framework, so I can avoid too much trial and error

However, many of the online material about robotics use simulators (which makes great sense).

I am familiar with Gazeebo, and the one from GA Tech as well, and this lists a great number also

However I am having trouble understanding how I can use my C code for bare metal on one of these simulators?

答:
You can alter the C code structure in the Controller, so that the code you want to test is indepencent from platfrom specific code. (You can only test the platform independent code using Software in the Loop anyways.) I am not sure what ways are available in C in order to achive this, but all inversion of control methods, e.g. Dependency injection,  have this goal.

The platform independen code then can be compiled not only for the bare metal implementation, but also for Linux (assuming Gazeebo only runs on Linux), you will need different build settings (e.g. make file or project, depending on what you use to build the project).

The code which is platform independent can be included in a Gazeebo simulation. Since I have never used Gazeboo, I cannot help with this, but here are my assumptions:

Gazeebo is aimed for developing high level algorithms, so testing code for a PID controller or similar, will probably need a different simulation software (e.g. Matlab Simulink).

You will have to re-implement all platform dependent code, this time, instead of bare metal platform dependent code it will be Gazeboo dependent. If you use dependeny injection, for one build your logic is injected with the bare metal platform specific code, for the test build it will be injected with Gazeebo specific code E.g. instead of reading a lidar, you will need to find a way to emulate that lidar read using the Gazeebo environment and feed the sam data to your logic, as it would come from the lidar.


问:
Identifying the connector on a micro planetary gear motor
I have purchased a couple of nifty little planetary gear motors and would like to incorporate them into my next project. could anyone help identify whether the connector is a commonly used one an whether i could purchase an adapter for to make it easy to engage with other custom parts? i have a 3d printer but it is only an FDM one and not quite precise enough to print the part myself. Thanks.</p>

答:
I don't think this is a standard connector. So you would need to produce your own adapter or whatever you want to drive using your motors. These parts do not need to be totally accurate. Usually you need to add 0.2 mm for each dimension, if it is the outside part of a connector, so that it fits inside.

You should avoid printing gears, which would need to be precise. I would either print a pulley, that can be connected or something that is put directly onto an axle. Here is some OpenSCAD example:

```<code>$fn = 64;  // higher accuracy for round shapes
ar = 0.01; // anti-residual

depth_adapter = 5;

diam_adapter = 6;
diam_axle = 1.5;

fit = 0.2;
shape_w = 2 + fit;
shape_h = 4 + fit;
shape_d = 3 + fit;

difference() {
    // outside shape of the adapter
    cylinder(h=depth_adapter, d=diam_adapter);

    // a hole for the axle
    translate([0,0,-ar])
    cylinder(h=depth_adapter+2*ar, d=diam_axle);

    // shape of the motor-connector
    translate([0,0,shape_d/2-ar])
      cube([shape_w, shape_h, shape_d], center=true);
    rotate([0,0,90])
    translate([0,0,shape_d/2-ar])
      cube([shape_w, shape_h, shape_d], center=true);
}
</code>```

which would look like this:

Of course you should print this part rotated bottom-up, so you wont need any support material. And you should probably make the hole for the axle smaller than the axle actually is and then use a electric drill to drill in the hole with an accurate diameter. Also you need something that would need to keep your axle in place relative to your motor. This is where the mounting holes at the side of the motors come in handy. You should think about using bearings for holding the axle, but in some cases (slow speed) a hole that is just big enough for the axle should work.

Without knowing what you want to build, it is hard to suggest any special shapes. But, I hope you got the Idea how this could look like.

If you have any more questions, just ask...

Body:
I don't think this is a standard connector. So you would need to produce your own adapter or whatever you want to drive using your motors. These parts do not need to be totally accurate. Usually you need to add 0.2 mm for each dimension, if it is the outside part of a connector, so that it fits inside.

You should avoid printing gears, which would need to be precise. I would either print a pulley, that can be connected or something that is put directly onto an axle. Here is some OpenSCAD example:

$fn = 64;  // higher accuracy for round shapes
ar = 0.01; // anti-residual

depth_adapter = 5;

diam_adapter = 6;
diam_axle = 1.5;

fit = 0.2;
shape_w = 2 + fit;
shape_h = 4 + fit;
shape_d = 3 + fit;

difference() {
    // outside shape of the adapter
    cylinder(h=depth_adapter, d=diam_adapter);

    // a hole for the axle
    translate([0,0,-ar])
    cylinder(h=depth_adapter+2*ar, d=diam_axle);

    // shape of the motor-connector
    translate([0,0,shape_d/2-ar])
      cube([shape_w, shape_h, shape_d], center=true);
    rotate([0,0,90])
    translate([0,0,shape_d/2-ar])
      cube([shape_w, shape_h, shape_d], center=true);
}

which would look like this:

Of course you should print this part rotated bottom-up, so you wont need any support material. And you should probably make the hole for the axle smaller than the axle actually is and then use a electric drill to drill in the hole with an accurate diameter. Also you need something that would need to keep your axle in place relative to your motor. This is where the mounting holes at the side of the motors come in handy. You should think about using bearings for holding the axle, but in some cases (slow speed) a hole that is just big enough for the axle should work.

Without knowing what you want to build, it is hard to suggest any special shapes. But, I hope you got the Idea how this could look like.

If you have any more questions, just ask...


问:
Optimal Control for a simple pendulum
I'm studying various optimal control methods (and implements them in Matlab), and as test case I choose (for now) a simple pendulum (fixed to the ground), which I want to control to the upper position.

I managed to control it using "simple" feedback method (swing-up based on energy control + LQR stabilization for the upper position), and the state trajectory is show in figure (I forgot the axis description: x is theta, y is theta dot.

Now I want to try a "full" optimal control method, starting with an iterative LQR method (which I found implemented here http://homes.cs.washington.edu/~todorov/software/ilqg_det.m)

The method requires one dynamic function and one cost function (x = [theta; theta_dot], u is the motor torque (one motor only)):

```<code>function [xdot, xdot_x, xdot_u] = ilqr_fnDyn(x, u)
    xdot = [x(2);
        -g/l * sin(x(1)) - d/(m*l^2)* x(2) + 1/(m*l^2) * u];
    if nargout > 1
        xdot_x = [ 0, 1;
            -g/l*cos(x(1)), -d/(m*l^2)];
        xdot_u = [0; 1/(m*l^2)];
    end
end

function [l, l_x, l_xx, l_u, l_uu, l_ux] = ilqr_fnCost(x, u, t)
    %trying J = x_f' Qf x_f + int(dt*[ u^2 ])
    Qf = 10000000 * eye(2);
    R = 1;
    wt = 1;
    x_diff = [wrapToPi(x(1) - reference(1)); x(2)-reference(2)];

    if isnan(t)
        l = x_diff'* Qf * x_diff;
    else
        l = u'*R*u;
    end

    if nargout > 1
        l_x = zeros(2,1);
        l_xx = zeros(2,2);
        l_u = 2*R*u;
        l_uu = 2 * R;
        l_ux = zeros(1,2);

        if isnan(t)
            l_x = Qf * x_diff;
            l_xx = Qf;
        end
    end
end
</code>```

Some info on the pendulum: the origin of my system is where the pendulum is fixed to the ground. The angle theta is zero in the stable position (and pi in the unstable/goal position).
m is the bob mass, l is the rod length, d is a damping factor (for simplicity I put m=1, l=1, d=0.3)

My cost is simple: penalize the control + the final error.

This is how I call the ilqr function

```<code>tspan = [0 10];
dt = 0.01;
steps = floor(tspan(2)/dt);
x0 = [pi/4; 0];
umin = -3; umax = 3;
[x_, u_, L, J_opt ] = ilqg_det(@ilqr_fnDyn, @ilqr_fnCost, dt, steps, x0, 0, umin, umax);
</code>```

This is the output

Time From 0 to 10. Initial conditions: (0.785398,0.000000). Goal: (-3.141593,0.000000)
   Length: 1.000000, mass: 1.000000, damping :0.300000

Using Iterative LQR control

Iterations = 5;  Cost = 88230673.8003

the nominal trajectory (that is the optimal trajectory the control finds) is

The control is "off"... it doesn't even try to reach the goal...
What am I doing wrong? (the algorithm  from Todorov seems to work.. at least with his examples)

答: iLQR is an iterative method but you do not in fact appear to be iterating. Todorov supplies a test script that should elucidate the approach though it may need to be customized for your system.</p>

Title: Optimal Control for a simple pendulum


问:
State prediction of vehicle with Ackermann steering geometry using Kalman-Filter
I am trying to have a Kalman-Filter (or Extended-KF) give me positions for a small remotely controlled vehicle with an Ackermann steering geometry (moving on a plane surface). The control commands I can send to the vehicle are wheel speed and steering angle. To measure the position I have available an Inertial Measurement Unit, gyroscope (electronic), odometry and in the future a indoor positioning system. Trying to set up the filter, I am already stuck with the prediction phase. I assume my state vector is something like
$
x=\begin{bmatrix}
x\\
v_x\\
a_x\\
y\\
v_y\\
a_y
\end{bmatrix}
$

and having read an introduction for Kalman filters I think that I should get the new state by doing

$x_k = A x_{k-1} + B u_{k-1}$

where A is the predictor matrix, and $u_{k-1}$ the control input which I assume to be
$
u=\begin{bmatrix}
\omega\\
\alpha
\end{bmatrix}$
, where $\omega$ would be the wheel speed and $\alpha$ the steering angle. I guess A is something like
$
A=\begin{bmatrix}
1 & \Delta t &\Delta \frac{1}{2}t^2 & 0 & 0 & 0\\
0&1&\Delta t &0 &0 &0\\
0&0&1 &0 &0 &0\\
0&0&0 &1 & \Delta t &\Delta \frac{1}{2}t^2\\
0&0&0 &0 &1  &\Delta t\\
0&0&0 &0 &0  &1\\
\end{bmatrix}
$

However, I don't really know how I should deal with the control input. For once, the velocity change due to a stearing angle $\alpha$ is not linear, is this a problem? Also, my control input for the wheel speed is basically the velocity already present in A. Should I then only use the wheel speed change as control input?

Furthermore: I get updates form my sensors every 10 ms. I wonder how fast the motor will react to my steering commands. Could it be that it makes sense to neglect the control inputs altogether?

Thank you for your help!

答:
Using the commanded speed in the prediction update of a Kalman filter which estimates speed and higher order states can be entirely reasonable. In situations where the time constant of the controller is slow, you will gain a considerable amount state estimate accuracy by estimating state derivatives using the control loop dynamics. In situations where the control loop time constant is much faster than the kalman filter update rate, far less accuracy will be gained.

First, in situations that have a fast control loop time constant, estimating the higher order states (in your case this is acceleration) will not benefit you a whole lot. By the time the kalman filter routine has been called, we know that the dynamics within the control loop have settled and the higher order states will be nil. Estimating something that will basically be zero at every timestep will not get you a whole lot of information.

In the second case, where the control loop time constant is slow compared to the kalman filter update rate, estimating the higher order states can profit your estimates greatly. Use a model of the controller with your time step to solve for the expected state. to do this you will need some model for your controller but this can be something as simple as a first or second order system.

In both cases it is best to use your commands in the prediction step of the KF as they give you a better idea of your current state.

Now, a bit about the states you've chosen. I think it is going to be difficult to use your set of states.  I think it would be more natural to estimate position, speed, vehicle direction ( which way the body of the vehicle is pointed), and steering angle. I am completely unfamiliar with the standard approach to localizing ground vehicles, these are just my first thoughts.

About the nonlinear aspects of your system. At the very least you will want to use an EKF. The A matrix in an EKF is a Jacobian that is evaluated at the given state estimate at every time step. To get this, you will need to derive the nonlinear relation between your state and the state time derivative. Take the Jacobian of that relation with respect to the state. This is then evaluated at every time step to get an A matrix.

Also, using only odometry and IMU data will result in a system that is not observable. This means that the error in your estimate will get worse over time because you have no way to correct for the error in your odometry readings. This isn't necessarily a problem, just know that without a measurement of position, your position estimate error will be unbounded. You'll still be able to drive around for a bit, but your estimate will get worse over time.

I strongly recommend reading Optimal State Estimation by Simon. It's the first estimation book I turn to when I brush up.


答:
The answer is very simple;

Steer drive is what you know from a car where one motor powers both the wheels (either the front or the rear wheels) and then steering is achieved by turning the front wheels right or left.

Differential drive means having two motors, one that powers all wheels (or the track) on the right side and one that powers all wheels on the left side, the way steering is achieved with a differential drive is by making the wheels on one side of the vehicle turn faster than the other side making the vehicle turn to the opposite side of the wheels turning faster. this is the way a tank works.

One of the great advantages of differential drive is, as you quoted, that it can spin around its own axis (z-axis) if the wheels are driven in opposite direction making it capable of turning on the spot. this is not possible with steer drive because you have to move forward to turn.

Title: Understanding differential drive

Body:
I am a beginner in robotics and I have just come across the concepts of differential and steer drive. I don't understand them very clearly yet.

I found the following write up describing differential drive as follows:

If the angular velocities are identical in terms of both values and
  direction, i.e. if both the wheels are driven at the same speed and
  same direction (either clockwise or anticlockwise) then the robot
  tends to spin around its vertical axis. This complete turn capability
  is one of the greatest advantages of a differentially driven robot
  (a.k.a zero radius turn).

Being a complete beginner, I concede I could be entirely incorrect in disagreeing with the above.
I just imagine that "both wheels" driving at the same speed and direction (clockwise or anticlockwise) would mean a robot is travelling along linearly i:e straight ahead.
I don't understand why the writer says the robot is actually spinning around it's Z axis.

If I'm wrong, please explain what I'm missing.

And please, let me have links to material that would help me understand differential and steer drive.

Thanks in advance.


问:
unexpected inefficiency of a motor driver
I purchased one of these motor drivers and noticed that i was not getting as much time from my battery as i had expected. I tested the current draw when connecting my motor directly to the battery and then when connected via the controller. the results were disappointing, i got 70mA direct connection and 144mA using the controller so more than double the current! i then tried through a mosfet and that was good, 73mA.
If i want to get a more efficient circuit am i going to have to build an h-bridge myself or am i just using a rubbish controller? Thanks</p>

答: You connected your (one) motor to the battery and got 70mA draw. You use a two motor driver and are seeing 144mA draw. I'm not sure what the problem is. What command are you sending to the second motor?


问:
6DOF serial robot (PUMA robot) dynamic model equations
I'm trying to find the most simplified (though accurate) calculations for the dynamic model of a standard 6DOF serial robot (PUMA robot).

I found this great paper:
https://www-cs.stanford.edu/group/manips/publications/pdfs/Armstrong_1986.pdf

The paper contains the full equations with 28 constants of the system, and it specifies the calculation for each constant.

However, I have a problem regarding the 6th link. It has the inertia symmetric values - Ixx6 Iyy6 Izz6, but Iyy6 never appears in any constant.
The specific robot in the paper (and actually it should be for every robot) has a 6th link that Ixx6 = Iyy6, but the same is true for Ixx5 and Iyy5 and still they both appear in the constants.

Do you think this is a mistake?
I need the exact equations has I want to expand them to the case of a payload - I want to replace m6 and I6 with updated values that include the payload mass and transferred inertia and then the equilibrium Ixx6 = Iyy6 will not necessarily exist.

Do you know of any other source of the full equations? Or maybe you have a solution to understand which of the Ixx6 relates to Ixx6 or Iyy6?

答:
There are ten inertial parameters for a rigid link, namely, mass ($m$), product of mass and center of mass ($m a_x$, $m a_y$, $m a_z$), inertia tensor ($I_{xx}$, $I_{yy}$, $I_{zz}$, $I_{xy}$, $I_{yz}$, $I_{zx}$).

Case 1: Consider a rigid link, which can freely translate and rotate in space in 3D. For such a link each and every inertial parameter appears in the dynamic model and affects it simply because the body is allowed to move in all the 6 dimensions (3 translational + 3 rotational).

Case 2: Let us take the same rigid link and fix to an immovable base with a revolute joint, referred to as a 1-DoF manipulator. Such a fixture constraints the motion of the rigid link. Constraining the motion of the manipulator to only a few dimensions renders some of the inertial parameters to be purposeless to the dynamic model.

Dynamic model of the 1-DoF manipulator is:

$\tau = (I_{zx}+I_{yz}+I_{zz})\ddot{\theta_{1}} + mg(a_{x} cos(\theta_{1}) + a_{y}sin(\theta_{1}))$

In the above dynamic model, 5 out of the 10 inertia parameters have no effect.  Similarly, when multiple links are connected to each other with 1-DoF joints it constraints the relative motion of the links, which renders some inertial parameters futile and they do not appear int he dynamic model.

To verify the equations of motions you obtained, you may use Recursive Dynamics Simulator (ReDySim) symbolic module, which generates the symbolic equations of motion.


问:
Scara robot design
I found this drawing on google photos:

I don't understand why he used this part.

Is it for reduction?

What is its equation?

答:
One of the problems with a belt driven SCARA system like this is that as the belts age, they stretch, so every belt should have a tensioner.

If you look carefully, it is clear that plate 106 rotates around shaft 114, and you can see the spring which provides the tension below it. Cogs 102 and 104 are free running. When the belt is new, plate 106 will be pushed close to the position shown. As the belt ages, the force of the spring will rotate plate 106 anti-clockwise, maintaining the tension of the belt.

This design cleverly tensions both straight sections of belt at the same time, by the same amount, and with the same pressure. This should make the system less susceptible to problems with unidirectional repeatability (moving from -90 to 0 resulting in a different position than moving from 90 to 0 for instance).

Title: Scara robot design


答:
The circled assembly is a bi-directional tensioner which maintains the tension in the drive belt at a pre-determined level as the belt ages and stretches. The detailed description of the function of the assembly is explained in the original patent document (US Patent 4,693,666), available on Google patents:

The bidirectional tensioning for the belt 60 ... as shown in FIG 5, is achieved by the bidirectional belt tensioning and idler device 100 positioned within the belt loop and intermediate the toothed gears 56 and 62.

The device 100 includes rotatable toothed rollers, or pulleys, 102 and 104 for internal engagement with opposite lengths L1 and L2 of the belt 60 which are moving in opposite directions. The rollers 102 and 104 are connected by a yoke 106 which connects the supporting axes of the rollers. The device 100 is rotated about a torquing arrangement 110 which extends through a mounting plate 112. The torquing arrangement 110 includes an adjustable tensioning element 114 for rotating the 100 relative to the belt 60 to establish the desired tensioning of the belt 60.

Once the proper tensioning is established, the device 100 is secured by the fasteners. The desired belt tension corresponds to a predetermined torque associated with the tensioning element 114 and thus the belt 60 can be pretensioned via the tensioning device 114 without requiring visual access to the interior of the primary arm assembly P.

I've included the original diagram below for ease of reference:

When modelling the SCARA robot, this assembly should not need to be modelled with a separate equation. The function of the unit is simply to ensure that the drive assembly performs as expected, so you do not need to modify the equations for the drive assembly to account for the drive belt ageing and stretching over time.

Title: Scara robot design

Body:
I found this drawing on google photos:

I don't understand why he used this part.

Is it for reduction?

What is its equation?


问:
How to build a robotics ontology?
According to some papers about robotics soccer Ontology Driven Development of Domain-Specific Languages, 2000 and Domain knowledge for surveillance applications, 2007, i need an ontology for programming my robot control system. The main idea is to describe the domain with a vocabulary plus an inheritance network. But how exactly this can be done? In the literature are two main strategies: the first one is using Semantic Web technology like RDF-Triples and DAML Markup Language for the agents. The second strategy uses normal C++ structs which are enhanced with methods. A working example is given here Grounding Robot Sensory and Symbolic Information using the Semantic Web, 2003 on page 8 a complete robot ontology is in the figure. But this time as some kind of UML chart. Is using a robot ontology really a good idea?</p>

答:
If your main question is how to work through your ontology (i.e. after defining your vocabulary you want to generate a rdf or owl file) you can look into some tools like Protege, which is a quite well know and well-documented tool for developing ontologies. Although, this will only help you on creating the knowledge representation (KR). If you want to use it effectively for programming your robot control system, you will need to query this KR using some query language like SWRL or SPARQL.

Also, if you are thinking about developing this for your case maybe you should take a look at some standards that exist concerning ontologies for robotics IEEE ORA-P1872

Title: How to build a robotics ontology?


问:
Introduction to AI Robotics book: robot implementation, with ROS?
I'm reading the book Introduction to AI Robotics By Robin R. Murphy and it the first character said, more or less, that after chapter 5 I will be able to design and implement my own robots, either in a real robot or in simulation.

I don't have a lot of money to buy the components to implement a robot, so I want to do it in simulation.

My question is: where I can do a robot simulation?

I've found ROS is suitable for this but I'm not sure. Is a good idea to use ROS with this book?

I have no idea about how to do it or what do I need because this is the first time I do something with robotics.

I have also found this Virtual Simulator For Robots.

答: Some well-known simulators used in robotics include Gazebo (probably one of the most adopted), Player/stage and Webots.</p>


问:
Hexapod walking algorithm
I am making a hexapod project with my friend. There is a issue about its walking style. Generally tripod gait is formed as two steps: first move legs 1,3,5, then 2,4,6 which corresponds to moving one leg from one side and two legs from other side but the legs are located circular instead side by side. So, this situation makes us wondering if it would rotate or not instead of moving forward when the
tripod gait is implemented.

Our robot's legs are like this one: https://www.youtube.com/watch?v=iPdRUbJcNzM

What kind of walking algorithm is suitable for that kind of robot?

Thanks in advance.

答: This paper might help decide what sort of walking algorithm suits your purpose.</p>

Title: Hexapod walking algorithm


问:
loop closure detection in visual SLAM
A robotic system is moving a getting its current location using visual odometry (incremental estimation of rotation and translation). To correct its localization, a loop closure technique may be added. However, this technique based on image comparison is costly. I want to find a way to only use this technique of loop closure only when a potential loop closure is present.
Is there a way to use the $x$ and $y$ coordinates of the vehicle provided by visual odometry to say that based on their values a loop closure may have occured?</p>

答: You can of course check if the robot is close to a prior position and looking in a similar direction (after he had moved away from this position sufficiently). But if your odometry was reliable enough to do this, you wouldn't really need loop closing. Loop closing was invented for exactly the reason that you cannot trust your odometry over a long time. </p>

Title: loop closure detection in visual SLAM


问:
router tilting mechanism
I am trying to design a very rigid tilting mechanism for my router. For this purpose I had a look at table saws, which seem to be supported by 2 mechanisms, one in front, one at the back, called "trunnions".

Such a trunnion consists of part of a circle, with a circular precision ground track, and a mating mart. The part of the circle is as such that the center of rotation coincides with the surface of the table.

However, when looking for "trunnion", I find medieval cannons as well as brand/product-specific constructions, which seem rather expensive. Does such a mechanism have other names? The router in question is a 20kg model, just as an indication of size. My last attempt was "circular track bearing", but i doubt that i am looking in the right direction.

Could anyone provide a pointer?

Thanks!

答:
Search circular motion guide.  or curved linear guide. THK's HCR product is one example.

This assumes you want to move the router while cutting. If you will lock it down, someone could cut and weld you a trunnion out of steel plate a lot cheaper than it would cost to design and fab the structure needed to mount the circular rail.

Title: router tilting mechanism


问:
Estimate Disparity Error for Depth Accuracy Estimation
I would like to get a rough estimate of the depth accuracy / uncertainty of a stereo camera system. For this I would like to use the basic formula in the attached image. What is still unclear to me is what's a reasonable choice for the disparity error $\Delta$D. Unfortunately, for example this answer (in point "Resolution") describes the assumption of the size of the disparity error only very quickly.

Is a reasonable assumption just the width of one pixel? Why yes, why not?

答:
Disparity error varies greatly with the algorithm you're using to compute stereo. There are a number of benchmarks for evaluating the quality of different stereo algorithms. See, for instance

The Middlebury Stereo Benchmark: http://vision.middlebury.edu/stereo/eval3/, a pioneer in this area.

The Stereo section of the KITTI scene flow benchmark: http://www.cvlibs.net/datasets/kitti/eval_scene_flow.php?benchmark=stereo, which may be more relevant to robotic applications.

The KITTI benchmark's rankings are based on what percentage of pixels are outliers, where inliers are defined as being disparity error of < 3px or < 5%. Middlebury has a number of different error criteria, but the default is a similar outlier percentage, with a threshold of 2 px error. By looking through some of the other options for Middlebury error metrics, you can see that most algorithms achieve sub-pixel accuracy for the vast majority of pixels, but there are a few percent (or more) of pixels that don't get correct correspondences, which leads to outliers. The errors of these false correspondences are distributed somewhat randomly, so benchmarks opt for these thresholded metrics to avoid being too sensitive to the outliers.

The choice of an appropriate value will therefore depend on what you're trying to model. If you're interested in the common case of being able to find a good match, you can look at the median error on Middlebury (metric A50), which for the leading algorithms is around half a pixel.

Keep in mind, however, that many of these methods are more computationally expensive than is practical for a lot of robotics applications, with runtimes of several seconds. If you're looking for methods that will run at high frame rates, take a look at the "time" metric. A method like Semi-Global Block Matching (SGBM) can run several times per second, but raises median error to 1.27 for SGBM1.

For any of these methods, the error from outliers can be much higher. You could try to characterize the distribution of the error for a more complete picture, though it will depend on your inputs (are they similar to those in the benchmarks?) as well as the choice of algorithm.


问:
Using ROS to control a CMM (Coordinate Measuring machine)
i'm a senior, i really desperate to find answers here. i am building a robotic arm with bunch of low-cost sensors , motors and other actuators. i'm using PI 3 as my Microcontroller.

I need helping to build the software by giving answers to my questions:

Is it efficient to us ROS with low-cost projects? if not what are my other
alternatives?

also is it possible to use another microcontrollers (Arduino's or PI's) in
between so everyone of them can deal with a specific collection of sensors
and actuators ?

is it possible to control stepper motors through Arduino/PI using ROS?

This would be the easiest way to describe my project:

Master (PI 3) ---> Receiving results from 4 microcontrollers ---> each one controls a joint (encoders, sensors, steppermotors)

I'm open to suggestions from any kind i'm still in the start i have 4-6 months period to finish it, i don't know if i'm asking in the right place or not but i don't know much about blogs.

答:
You may be intrested to know that there is already an Arduino library for ROS.  It is called rosserial_arduino,

The Arduino and Arduino IDE are great tools for quickly and easily programming hardware. Using the rosserial_arduino package, you can use ROS directly with the Arduino IDE. rosserial provides a ROS communication protocol that works over your Arduino's UART. It allows your Arduino to be a full fledged ROS node which can directly publish and subscribe to ROS messages, publish TF transforms, and get the ROS system time.
  http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup


问:
How many stages necessary to stabilize position while controlling torque?
I'm assuming that since torque translates into acceleration, the basic transfer function from torque to position becomes

$1/s ^ 3$

Does this mean that 3 pid controllers are required to properly control the process? ie acceleration, velocity and finally position? Perhaps a two stage position+velocity controller can decently aproximate the solution, but from mathematical standpoint, how many stages are actually needed for optimal control?

答:
I would say the transferfunction becomes $\frac{1}{s^2}$ iff you assume you have a perfect drive without any dynamics.

Since this system is unstable you have to be careful choosing your controllers.
The best way in my opinion is to use a standard state feedback controller (LQR, Ackermann). The huge advantage using state feedback is that you can chose the pole location (in case of Ackermann) resp. the weight (in case of LQR) for each state separately.

Loop shaping in the frequency domain will work as well, see e.g. Loop Shaping, (Department of Automatic Control LTH,
Lund University).


问:
Are S-Curve (constant jerk) motion profiles significantly better than constant acceleration?
I've been investigating S-Curve motion profiles for CNC router and 3D printer applications, and haven't come across any definitive source that says an S-Curve profile is necessary in any application.  And in fact, it may even slow down a print.

This simulator compares S-Curve and trapezoidal motion profiles, showing that with the same velocity and acceleration, a move will take longer to complete.  Interestingly, the maximum acceleration of the S-Curve profile can be increased a small amount while keeping the maximum positional error (and force) beneath that of the trapezoidal profile.  This is because the slow ramp in acceleration allows the driven object to accelerate closer to the target speed, thus reducing the overall force.

In theory, an instantaneous change in force will also excite natural vibrations in a system as well (in the same way connecting an inductor/capacitor directly to a 12v source induces ringing).  Is this a problem in real-world mechanical systems?  And in those systems, would using an S-Curve profile reduce the ringing?

答:
Short version, yes having an s-curve profile is beneficial for smoother and more accurate tracking.

Longer version:
For all real hardware systems I've worked with it has been important to use an internally consistent profile. By this I mean, the derivative of your profile needs to match your velocity and the derivative of your velocity profile needs to match your acceleration. If that's not the case you are asking the system to do something that is physically impossible. Instantaneous acceleration changes are not possible so the control system simply cannot track perfectly at those points in the profile).

That said, there are practical times when things are good enough without meeting this condition. Some systems are, practically speaking, velocity controlled instead of force controlled. Other systems have a lower-level controller that will effectively turn your step-acceleration profile into an s-curve by limiting jerk of the profile (often a lower-level system parameter.


问:
How can i convert Torque input into PWM signal?
I am working on a project in which i have a robot working with stepper motors. I wish to control this robot with simulink. How can i convert the input( Analog sin input ) into the PWM that can be used as input for the system??? </p>

<p>The Robot is Arduino2560 Based. </p>

答: Basic  Comperator circuits/systems can be implemented. For example if your sin wave's frequency equals to some frequency value. You can compare it with another sin wave or a DC value and hence you can generate modifiable (via second input to Comperator) PWM signal.</p>


问:
automatic sorting with barcode identification inside a refrigerator
I'm endeavoring to prototype a challenging sorting mechanism inside a fridge and would appreciate any constructive tips on how to get from the specs to a plausible design.

Problem

The aim of the game is to identify and sort food items in the limited space of a fridge
-   such that a user would push their unsorted shopping into a chamber at the top of the enclosure
-   and the machine inside would then try to identify the contents with help of bar-codes (first big problem)
-   and then sort and move the items according to their identities into different chambers below (second big problem).

Solution?

Are there any existing devices that already serve such functions (automatic bar-coding and sorting), the designs of which could perhaps inform the mechanics of the device I'm planning to construct?

I'm thinking maybe manufacturing plants

or packing factories with conveyor belts etc may use systems that already solve such problems?

Or filtering mechanisms in candy dispensers,

mechanized lifting forks?

Textbook engineering mechanisms?

答: Moving it around requires, apart the mechanics, always a free and therefore unused space. Wouldn't you rather like to know, what is in which position? And for the barcode: it can become unreadable by ice. I'm thinking of using RFID for a similar project for about 10 fridges with each 30 boxes in it.