问:
Path planning algorithm better than RRT* and Artificial Potential Field
Hello robotics stack exchange community, hope my message finds you well during these challenging times. I need an opinion regarding path planning algorithms.

Goal

I am looking for a path planning algorithm that is able to produce smooth paths that are shorter and more predictable than RRT and RRT*. It shouldn't get stuck in local minima like Artificial Potential Field.

What I tried

I have set up a Linux 16 system with ROS Kinetic Kame and Python. I implemented Artificial Potential Field Path Planning, RRT and RRT* and ran those on a robot in a small arena. The arena was a square and I placed different objects inside of it that needed to be avoided. See the picture below for an example of how my arena configuration looks like.

Artificial Field Path Planning creates nice, smooth curves and a robot executes smooth movements to follow it. My problem with them is local minima where my robot gets stuck.

RRT produced jagged paths, but the nice thing about it was that it always found a path (albeit it was always a different one). I implemented RRT* to get smoother paths, but they're quite "branchy" looking (still better than RRT though).

I have also looked into other algorithm such as A* and MEA, but rather than trying to implement them straight away, I wanted to ask for your opinion.

答:
My understanding is that most people don't use the raw RRT solution directly.  First they smooth it.  A google search will yield many papers on this.  For example: Improved Path-Finding Algorithm for Robot Soccers by Rahib H. Abiyev, Nurullah Akkaya, Ersin Aytac, Irfan Günsel, and Ahmet Çağman.

The smoothed trajectory will necessarily be different than the RRT path and will therefore have a possibility of collision.  So you will have to check for that and possibly adjust the smoothing parameters iteratively.

You can also use a more modern motion planner.  CHOMP is a popular one.  Original paper: CHOMP: Covariant Hamiltonian Optimization for Motion Planning by Matt Zucker, Nathan Ratliff, Anca D. Dragan, Mihail Pivtoraiko, Matthew Klingensmith, Christopher M. Dellin, J. Andrew Bagnell, Siddhartha S. Srinivasa.

Another idea is to use a completely different approach.  TrajOpt is an optimization based approach and produces smooth trajectories without a secondary smoothing step.  Paper here: Motion Planning with Sequential ConvexOptimization and Convex Collision Checking by John Schulman, Yan Duan, Jonathan Ho, Alex Lee, Ibrahim Awwal, Henry Bradlow, Jia Pan, Sachin Patil, Ken Goldberg, Pieter Abbeel.


答: You can apply rrt using a selection of smooth movements, basically you discritize the possible actions making sure you always connect paths in a way which is smooth. It increases the dimensionality of your problem by quite a bit though, so idk.</p>

ContentLicense: CC BY-SA 4.0

Title: Path planning algorithm better than RRT* and Artificial Potential Field

Body:
Hello robotics stack exchange community, hope my message finds you well during these challenging times. I need an opinion regarding path planning algorithms.

Goal

I am looking for a path planning algorithm that is able to produce smooth paths that are shorter and more predictable than RRT and RRT*. It shouldn't get stuck in local minima like Artificial Potential Field.

What I tried

I have set up a Linux 16 system with ROS Kinetic Kame and Python. I implemented Artificial Potential Field Path Planning, RRT and RRT* and ran those on a robot in a small arena. The arena was a square and I placed different objects inside of it that needed to be avoided. See the picture below for an example of how my arena configuration looks like.

Artificial Field Path Planning creates nice, smooth curves and a robot executes smooth movements to follow it. My problem with them is local minima where my robot gets stuck.

RRT produced jagged paths, but the nice thing about it was that it always found a path (albeit it was always a different one). I implemented RRT* to get smoother paths, but they're quite "branchy" looking (still better than RRT though).

I have also looked into other algorithm such as A* and MEA, but rather than trying to implement them straight away, I wanted to ask for your opinion.


问:
Free 2 and 3d simulators
What physics simulators exist which are open source/free? AI Gym uses a proprietary for-cost physics engine making it nonviable. </p>

答:
As for as I am understanding your question, you are asking about open source physics engines for simulation, So here's a short list:

1. Box2D,

2. Bullet Physics,

3. Chipmunk,

4. Chrono::Engine,

5. DynaMo,

6. Moby (Physsim),

7. Newton Game Dynamics,

8. Open Dynamics Engine,

9. Open Physics Abstraction Layer,

10. OpenTissue.

Title: Free 2 and 3d simulators


问:
How can I calculate odometry given two poses?
I have the pose at times t - 1 and time t.
We are given: that the the new pose, at time t, is

$$x_{t - 1} = [0,0,pi/6]$$
$$x_{t} = [0.2,0.1,(11*pi)/60]$$

(Where the vectors are [x, y, theta] with respect to some world frame.)

In my head, I have the two poses. I just need to calculate the difference of the two and that'll be odometry, right?
So, subtracting the two vectors: [0.2,0.1,(11*pi)/60] - [0,0,pi/6] = [.2, .1, pi/60]

However, according to the answer checker that doesn't seem to be the right approach. Can someone suggest a strategy to go about this?

答:
Those POSEs are not 3D vectors or a 3D coordinate point. As such you can't subtract.

A pose is a state vector, and the last value is an angle.

From this, how can you calculate odometry?


答:
Assume you are in a 2D grid.

At time x(t-1), we have the first pose as p_1 = [x_1, y_1, theta_1] and

at time x(t), we have the second pose as p_2 = [x_2, y_2, theta_2].

The distance traveled could be calculated using the Euclidean distance formula as in your case would be:

Distance = Sqrt[(0.2-0)^2 + (0.1-0)^2] = 0.2236.

And the angle traversed would be the difference between theta_2 and theta_1, so we have theta = Pi/60.

Title: How can I calculate odometry given two poses?

Body:
I have the pose at times t - 1 and time t.
We are given: that the the new pose, at time t, is

$$x_{t - 1} = [0,0,pi/6]$$
$$x_{t} = [0.2,0.1,(11*pi)/60]$$

(Where the vectors are [x, y, theta] with respect to some world frame.)

In my head, I have the two poses. I just need to calculate the difference of the two and that'll be odometry, right?
So, subtracting the two vectors: [0.2,0.1,(11*pi)/60] - [0,0,pi/6] = [.2, .1, pi/60]

However, according to the answer checker that doesn't seem to be the right approach. Can someone suggest a strategy to go about this?


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

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

答: I am doing this project right now but it will be more appropriate to use two Arduinos for the number of different sensors you are mentioned. </p>

Title: Arduino for mobile robot


问:
Verifying DH parameters. Unexpected Output

There is a rotating base joint #1 with z/joint axis pointing up and atop sits and arm with 3 z/joint axis facing away from the viewer.

The elbow joint F2 has a kink before it of 90 degrees measuring 25.4mm

The upper arm length between joint F1 and F2 is not as the diagram says 163.2 but actually 137.8

My question is am I using twist offset and length parameters correctly? Because I can't seem to orient the input parameters to reflect the arms various extensions.

I calculate using simple addition that the maximum length upward should be about 500 upward, or horizontally the reach is about 400 and the height is less the 100

This question is a request am I plugging the numbers in correctly?

If I model the green section as a angled joint that protrudes at 10.4 degrees from the base at a length of 140.1mm that helps

答:
Started this as a comment, but moved it here to an answer because (1) it's much longer than a typical comment and (2) hopefully it's got some helpful hints in here to get you started.

Welcome to Robotics, Ddefin Orsstt. I think it would be helpful if you could label your frames and explain why you're choosing the particular values on your table. Typically I've seen z- or y-axes as the "up" axis, but you're stating that the maximum length should be X 503.12, Y 0, Z close to 0. The only way I get 503.12 is if the arm is straight up, which again I would expect to be y- or z-value readings.

The maximum z-value (if z is up) I could calculate would be the F0 to F1 offset (J1) of 101.32 mm, plus the "crook" just before the joint 3 at F3 of 25.4; this give (101.32 + 25.4) = 126.72. My issue with looking at it from this point of view is that then the maximum x/horizontal reach is not the 503.12 anymore, but the "upper arm" length of 137.8, the "forearm" length 163.2, and the end effector length 100.8, or (137.8 + 163.2 + 100.8) = 401.8.

It's also not clear to me what you're using in a particular transform; you should consider including the joint angles in your DH parameter table. I would expect a zero-length transform between an F0 frame ("world origin") and F1, where the output of joint 1 is located, if joint 1's output is coincident with your world origin.

Right now, it's looking like you've got 6 joints, by your DH table, but I'm only counting 4 (or 5?) in your picture:

Joint 1, at the bottom,

Joint 2, 101.32 up from Joint 1,

Joint 3, 137.8 (shown as 163.2) up AND 25.4 over from Joint 2,

Joint 4, 163.2 over from Joint 3.

After joint 4, you have two dimensions: 50.8, to something (can't tell if it's a joint or not), and 100.8, to the tip of the end effector.

The DH parameters should define one actuator relative to the previous actuator in the arm/chain. You've got joint 3 split out as two actuators in your DH table, which is incorrect, and it looks like maybe you've got something at the end of your DH table to (I'm guessing) correct the orientation of the end effector?

Start with a simple drawing of your arm. Put an "F0" where the base of this would be screwed to a table, then start putting new frames (F1, F2, ..., etc.) at the output of each actuator. Put a frame at the end effector in whatever orientation you want to use for that end effector.

This should be your starting point for making your DH parameters. Try making this drawing and, if you're still having trouble, please edit your question to post that drawing here.

:EDIT:

This is the video I always refer people to when asking about DH Parameters. Going through the video and referring to your diagram, if the joints at F1, F2, and F3 are all oriented in the same direction, then your $d$ vector, the vector of distances along the previous joint's z-axis, is:

$$
d = \left[\begin{matrix}
101.32 \\
0 \\
0 \\
0 \\
\end{matrix}\right]
$$

... but, as you continue to follow along with the video, you can see that the rest of the parameters depend on your frame definitions, especially the base. This is where it becomes really important to have a drawing that shows what your robot arm looks like when all the joints are set to zero.

Generally speaking, though, it looks like all your numbers are probably correct, but you're not using the "standard" terms of $d, a, \alpha, \theta$, so I think it's possible that, especially if you're getting wrong numbers, you could be entering your values into the incorrect vectors in a DH solver (i.e., swapping $d$ and $a$ and/or swapping $\alpha$ and $\theta$). Also, your polarities could be wrong. I personally try to define everything as right-handed. Right-handed rotations can be visualized by putting the thumb of your right hand along the z-axis of a joint; the fingers of your right hand then naturally curl in the direction of positive rotation.

You're still asking if you've plugged the numbers in correctly, but I don't know what you're plugging them into and there's no update on what your software/algorithm is expecting or outputting.


问:
differences between SCARA arm design
I am currently interested in SCARA arm designs and I have few, beginner questions for which I didn't find answers yet.

1/ While comparing professional arms (made by epson, staubli...) I noticed that the actuator used for the translation on the Z axis is at the end of the arm. On "hobby" arms like the makerarm project on kickstarter they use a leadscrew with the actuator at the beginning of the arm.
I thought it was smarter to put the actuator handling this DoF at the begining of the arm (because of its weight) and not at the end, but I assume that these companies have more experience than the company behind the makerarm. So I'm probably wrong, but I would like to understand why :)

2/ Also I would like to understand what kind of actuators are used in these arms. The flx.arm (also a kickstarter project) seems to be using stepper motors but they also say they are using closed loop control, so they added an encoder on the stepper motors right?

Wouldn't it be better to not use stepper and, for instance, use DC brushless motors or servos instead ?

3/ I also saw some of these arms using belts for the 2nd Z axis rotation, what is the advantage ? it only allows to put the actuator at the begining of the arm ?

答: I am answering an old question, but Staubli does make a SCARA arm with the vertical joint over the base. It was called the TS20. https://www.staubli.com/en-us/robotics/product-range/industrial-robots/4-axis-scara-robots/ts20/</p>

ContentLicense: CC BY-SA 3.0

Title: differences between SCARA arm design


问:
Making high CAN baud rates work
I'm dealing with a board that no matter what I do I can't seem to make CAN work over 125 kbit/s. I'll give some detail about the board on the bottom, but I'm going to keep this question generic.

First of all, regarding hardware. From what I've gathered, there isn't any need for a pull-up resistor on the TX of CAN. Is that correct? It may perhaps be chip-specific, but wherever I see, it seems that the TX/RX lines are directly connected to the transceiver.

Second, regarding bit-timing: Using different calculators, for example, Kvaser or the one from Microchip, I can see the following configuration (for 64 kHz input clock):

```<code>             SYNC     PROP     PHASE1      PHASE2       BRP (prescaler)

125  kbit/s   1        1        3           3            32
250  kbit/s   1        1        3           3            16
500  kbit/s   1        1        3           3             8
1000 kbit/s   1        1        3           3             4
</code>```

I've seen this from more than one source. Furthermore, the numbers fit to the formula in the datasheet of the microcontroller.

However, only the configuration for 125 kbit/s works for me. I'm using CANreal to monitor the messages.

I've tried different configurations for the CAN, for example with 16 time quanta instead of 8 as well as changing my microcontroller's clock to 16 MHz and using again different values. Regardless of all that, speeds higher than 125 kbit/s result in only errors and warnings in CANreal (which are taken from the CAN driver). Note that the same CAN board, driver and software works with 1 Mbit/s with some other hardware I have.

This all is made harder since, as soon as I put a probe from my oscillator on the TX line, it becomes a continuous 0-1 alteration like the following:

```<code>      __------     __------     __------     __------     __------
     /       |    /       |    /       |    /       |    /       |
   /         |  /         |  /         |  /         |  /         |
  /          | /          | /          | /          | /          |
  |          | |          | |          | |          | |          |
  |          |_|          |_|          |_|          |_|          |
</code>```

Which is not something I would be outputting by software. In fact, as soon as I remove the probe, the messages start arriving (again, only at 125 Mbit/s). So basically, I don't seem to be able to have any oscillator debugging available.

Back to my "first of all, regarding hardware", the shape of the signal suggests a pull-up resistor may be necessary, but I haven't seen the need for that in any datasheet I found. Furthermore, my microcontroller configures the pin when used as CAN, so I don't have control over making it push-pull (since it looks like it's open-drain). Not to mention the microcontroller doesn't even have a configuration to make the pin push-pull.

Is there any hidden parameter somewhere that should also be set? Is a pull-up resistor necessary after all? Why would the oscillator probe cause such a behavior?

Details from the board:

MCU: P18F45K80. CAN is connected to its default RB2 and RB3.

CAN transceiver: ISO1050

Compiler: mikroC

答:
scope probe

I can sympathize with how frustrating it is when attaching an oscilloscope probe to debug a problem makes the system act differently.

A standard 1X probe (1:1 probe) will load a circuit with a capacitance of about 110 pF.
Many people use a 10X probe or a 100X probe, giving 1/10 or 1/100 the loading on the circuit -- hopefully small enough to be insignificant.

ISO1050

a pull-up resistor on the TX of CAN.
  ...
  the shape of the signal suggests a pull-up resistor may be necessary, but
  I haven't seen the need for that in any datasheet I found.

I think this is it.
Page 4 of the datasheet for the ISO1050 specifically says

NOTE

TXD is very weakly internally pulled up to VCC1. An external pull
  up resistor should be used ...
  An adequate external pullup resistor must be used to
  ensure that the TXD output of the microprocessor maintains adequate
  bit timing input to the input on the transceiver.

PIC18F45K80

I'm assuming you're using the Microchip PIC18F45K80.
The PIC18F66K80 family datasheet has a lot of useful information about the Microchip PIC18F45K80.
In particular, I think you might find section 27.0 ECAN MODULE useful.
Subsection 27.2.5 mentions ENDRHI: Enable Drive High bit, where

ENDRHI = 1: CANTX pin will drive VDD when recessive

ENDRHI = 0: CANTX pin will be tri-state when recessive

Subsection 27.3.1 CONFIGURATION MODE implies that ENDRHI (and all other configuration bits) must be set in configuration mode, and cannot be changed while the CAN module is active.

I suspect that either the pull-up resistor or setting ENDRHI to 1 would be adequate.
However, if I were you, I would run some tests with both a 10 KOhm pull-up resistor and ENDRHI set to 1.

Title: Making high CAN baud rates work


问:
What is the definition of the contents of PointCloud2?
What does the contents of PointCloud2 means in ROS?

fields.offset?

fields.datatype?

fields.count?

point_step?

row_step?

Its documentation is poor

Here is a published PointCloud2 message by Velodyne LiDAR:

```<code>header:
  seq: 1071
  stamp:
    secs: 1521699326
    nsecs: 676390000
  frame_id: "velodyne"
height: 1
width: 66811
fields:
  -
    name: "x"
    offset: 0
    datatype: 7
    count: 1
  -
    name: "y"
    offset: 4
    datatype: 7
    count: 1
  -
    name: "z"
    offset: 8
    datatype: 7
    count: 1
  -
    name: "intensity"
    offset: 16
    datatype: 7
    count: 1
  -
    name: "ring"
    offset: 20
    datatype: 4
    count: 1
is_bigendian: False
point_step: 32
row_step: 2137952
data: [235, 171, 54, 190, 53, 107, 250, ...
</code>```

Why height in Velodyne-HDL64e LiDAR is equal to one? I expected it to be 64.

Finally, for example, what is 171 value in data? is Y or is a range (for which one of the beams)?

答:
I totally agree that the documentation is poor and it took me quite some time to understand what is going on.

I recorded a rosbag for "velodyne_points" topic using a Velodyne VLP-16. The recorded message is PointCloud2 type. Since the recorded file was really large it gave me a lot of trouble even when only trying to take a look at it(initially I had it converted to .csv and used -010 Editor- to read but csv format turned out useless for me).

What worked was that when I converted this bag file to .pcd format. Take a look at this link for that:

https://answers.ros.org/question/235063/bag-file-to-pcd-files/

Then I took a look at one of the .pcd files and used the info in the following link to understand what is in it:

http://pointclouds.org/documentation/tutorials/pcd_file_format.php#pcd-file-format

After these steps I understood what the PointCloud2 message is about...

So the incoming data in that array you asked about is a 1-D array. That is the reason the height is 1. It is called an unordered or unorganized point cloud data. The ring field tells which one of the 16 lasers in VLP-16 is used (though it is different than the laser numbers in the hardware manual), for your case it should be between 0-63.

The datatype tells whether the fields are float, uint16, int8 etc. After taking a look at the .pcd file I understand that the x,y,z,intensity fields are 4 bytes representation of a floating point number (little endian in your message). The ring value is a uint16(unsigned short).

The count is how many of that datatype is there. So you have 4 byte long 1 x, 4 byte long 1 y, 4 byte long 1 z, 4 byte long 1 intensity and 2 byte long 1 ring fields.

Offset tells at which byte the related field starts. For example offset x is 0 so x is 235 171 54 190 in little endian. Then y starts at 4, which is 53 107 ...

Here is the header of my .pcd file:

```<code>.PCD v0.7 - Point Cloud Data file format

VERSION 0.7

FIELDS x y z _ intensity ring _

SIZE 4 4 4 1 4 2 1

TYPE F F F U F U U

COUNT 1 1 1 4 1 1 10

WIDTH 26326

HEIGHT 1

VIEWPOINT 0 0 0 1 0 0 0

POINTS 26326

DATA binary
</code>```

It tells that there are empty bytes after z and ring fields. After z field there are 4 empty bytes (that is why intensity has an offset of 16, not 12), and after ring there are 10 empty bytes.

point_step is the length of a point in bytes says the PointCloud2 document. It is as follows:

4 bytes (x) + 4 (y) + 4 (z) + 4 (empty) + 4 (intensity) + 2 (ring) + 10 (empty) = 32

row_step is the length of a row in bytes, which is 66811 points (width) * 32 bytes = 2137952

Body:
I totally agree that the documentation is poor and it took me quite some time to understand what is going on.

I recorded a rosbag for "velodyne_points" topic using a Velodyne VLP-16. The recorded message is PointCloud2 type. Since the recorded file was really large it gave me a lot of trouble even when only trying to take a look at it(initially I had it converted to .csv and used -010 Editor- to read but csv format turned out useless for me).

What worked was that when I converted this bag file to .pcd format. Take a look at this link for that:

https://answers.ros.org/question/235063/bag-file-to-pcd-files/

Then I took a look at one of the .pcd files and used the info in the following link to understand what is in it:

http://pointclouds.org/documentation/tutorials/pcd_file_format.php#pcd-file-format

After these steps I understood what the PointCloud2 message is about...

So the incoming data in that array you asked about is a 1-D array. That is the reason the height is 1. It is called an unordered or unorganized point cloud data. The ring field tells which one of the 16 lasers in VLP-16 is used (though it is different than the laser numbers in the hardware manual), for your case it should be between 0-63.

The datatype tells whether the fields are float, uint16, int8 etc. After taking a look at the .pcd file I understand that the x,y,z,intensity fields are 4 bytes representation of a floating point number (little endian in your message). The ring value is a uint16(unsigned short).

The count is how many of that datatype is there. So you have 4 byte long 1 x, 4 byte long 1 y, 4 byte long 1 z, 4 byte long 1 intensity and 2 byte long 1 ring fields.

Offset tells at which byte the related field starts. For example offset x is 0 so x is 235 171 54 190 in little endian. Then y starts at 4, which is 53 107 ...

Here is the header of my .pcd file:

.PCD v0.7 - Point Cloud Data file format

VERSION 0.7

FIELDS x y z _ intensity ring _

SIZE 4 4 4 1 4 2 1

TYPE F F F U F U U

COUNT 1 1 1 4 1 1 10

WIDTH 26326

HEIGHT 1

VIEWPOINT 0 0 0 1 0 0 0

POINTS 26326

DATA binary

It tells that there are empty bytes after z and ring fields. After z field there are 4 empty bytes (that is why intensity has an offset of 16, not 12), and after ring there are 10 empty bytes.

point_step is the length of a point in bytes says the PointCloud2 document. It is as follows:

4 bytes (x) + 4 (y) + 4 (z) + 4 (empty) + 4 (intensity) + 2 (ring) + 10 (empty) = 32

row_step is the length of a row in bytes, which is 66811 points (width) * 32 bytes = 2137952


问:
Numeric integration problem in a quadrotor vertical descend code
I'm trying to implement a drone in vertical descend. As for maximum simplification, I maintain all its angles to 0, and just try to get to the my desired descend. However, when I debug, I see that my z_acel variable changes value when it comes to the velocity integration. And obviously cant reach to my desired height, which is 10cm below. Anyone can help?</p>

```<code>import numpy as np
import math
import matplotlib.pyplot as plt

from mpmath import *

#***DRONES****

#Dynamic parameters
L=25
b = 1e-5
I = np.diag([5e-7, 5e-7, 10e-7])
k=3e-5
m=0.5
kd=0.25
#PID Values
Kp, Ki, Kd = 4.05, 0, 20.64
g=9.80
dt=0.1

#variables inicialization
N=500
phi_acel= angulotheta_acel= psi_acel= [0] * N
phi_vel= angulotheta_vel= psi_vel= [0]*N
phi = angulotheta = psi = [0]*N
z= z_vel= z_acel= [0]*N
Torque=inputs=[0]*4

height_objective=-10 #reach from 0 to -10cm height.

for i in range(2,N):

   #HEIGHT CONTROLLER
   err_height=height_objective-z[i-1]

   Torque[0]=err_height*Kp + err_height*Ki*dt - (z_vel[i-1]-z_vel[i-2])*Kd*dt + (m*g)/(math.cos(phi[i-1])*math.cos(angulotheta[i-1]))
   if Torque[0]>20:
       Torque[0]=20
   elif Torque[0]<0:
       Torque[0]=0

   z_acel[i]= -g + (math.cos(angulotheta[i-1])*math.cos(phi[i-1]))*Torque[0]/m  #with all the angles zero, z_acel[i] should be -g = -9.8

   z_vel[i]= z_vel[i-1] + z_acel[i]/2*dt   #however, in this step, the z_acel[i] changes the value

   z[i]= z[i-1] + z_vel[i]/2*dt

   plt.plot(i,z[i],'or')
   plt.pause(0.1)
plt.show()
</code>```

答: Ok, i got the answer. When I inicialize the variables, I wrote $z= z_v= z_a= [0]*N, $, even I thought it had no more influence in the code, it has. As it is written now the code, the value of z_vel is the new value for z_acel in every iteration.


问:
What is wrong with the assignment of X axis in 5DOF robot manipulator's kinematic diagram?
I tried to solve below question by Edx course. One part of the requirement was to assign frames and find the DH parameters of the given robot manipulator. I assigned the x and z axis as below and find the DH parameters like that:

I think I assigned axis correctly. Especially X2, because this one that make the problem. X2 can be both like in the picture and also upward, because in both of them it is perpendicular to both Z2 and Z1. However, when I did like that the answer became wrong. However, when I took the X2 as upward, the  answer became correct. It is interesting for me, why X2 has to be upward while it also can be like in the picture I showed? Thank you very much :)

答:
When assigning the $x_i$ axis, it doesn't just have to be perpendicular to $z_i$ and $z_{i-1}$, it should be along their common normal (and pointing from $z_i$ to $z_{i-1}$).

In the case of $x_2$, $z_2$ and $z_1$ do not have a unique common normal since they are parallel so the exact placement of the origin of frame 2 and the $x_2$ axis is not fixed - imagine a vertical line that intersects $z_2$ and $z_1$ but can move along the $z_2$ (and $z_1$) axis a bit like a trombone (that's what it makes me think of anyway). You would normally want to put the origin in such a place to produce the most zeros in the DH table which is where you have it currently.

So $x_2$ should indeed be pointing upwards to be consistent with the DH convention.


问:
How to get unix/posix time stamp in header of ROS msg?
I am using two sensors each connected to different machine (each machine separately runs Ubuntu 16.04 and ROS Kinetic). When I echo topic on these two machines, I see the time stamps in header of messages are different. Even though they are running at the same time. So I faced issues in synchronizing topics recorded on different machines.

Machine 1:
sec 4583 | nsec 855689180

Machine 2:
sec 1570727234 | nsec 4864000

It seems that the time stamp on machine 1 is based on sim_time. Machine 2 is showing a Posix/Unix time stamp. So on machine 1, I issued the command rosparam set /use_sim_time false. Still when I fire the node on machine 1, time stamp starts from zero which is sim_time.

What I need is to get all time stamps in unix/posix format (10 digit).

P.S. the node running on Machine 1 is OS-1 Lidar Ros Driver

答:
You do not state which topic you are looking at - this answer assumes that you are looking at the pointcloud topic published by the cloud node.

The ROS message time of the pointclouds is not the host system time, but is taken from the lidar's internal clock (see batch_and_publish lambda in os1_cloud_node.cpp and trace back where scan_ts variable comes from).

The ROS message time of the packets is taken from the host system, so if these exhibit the problem you described then I would assume that your problem is indeed with the host time. If not, then your problem is with the lidar clock(s) which you probably want to sync with the host (or some other clock) e.g. via PTP - there are instructions in the software manual.


问:
How can we manage stepper motor cables?
I need to actuate 3 or 4 Cnc-like Nema 23 (~1N.m torque) stepper motors, I would like some cable solution to connect easily the motor to the motor driver.

I have not yet bought anything, I have searched various robotic stores and ebay, but did not yet found a triple (motor, cables, driver) which would be "plug and play".

As stepper motors usually have 4 to 6 cables, and there are multiple motors, manual soldering everything would be too time consuming, error prone and messy.

Is there a standard way to deal with cables for stepper motors ?

答:
The vast majority of the time, I end up cutting off whatever connector is at the end of the cable hanging out of the stepper motor, and crimping on something else compatible with the board I want to connect it to.

Occasionally the board I want to connect it to has some sort of cage clamp terminal strips (also known as spring clamp terminal strips) or some other terminal block, so I can cram in the raw bare wires without any connector on the end.

As I mentioned earlier, many RepRaps use 8P8C "RJ45" "Ethernet" connectors to carry power over CAT5 cable, usually in a way completely incompatible with any power-over-Ethernet standard or any Ethernet data standard.
"Why do many RepRaps have RJ45 connectors?"; a; b; c; d; etc.

( Quite a few people, for reasons inexplicable to me, insist on removing those 8P8C sockets and using their own favorite connector -- http://reprap.org/wiki/PCB_adaptions_for_Mendel ).

Title: How can we manage stepper motor cables?


问:
motion model for forward movement
I thought this is a simple and well known problem and therefore there is a lot of literature. But I'm not able to find the correct keywords to google the answer. Maybe instead of answering the whole question you can already help me by telling me the correct keywords.

My problem is the following:

For a given parametrisation of a robot, for example the simple two dimensional $(\varphi,p_1,p_2)$, where $\varphi$ describes the orientation and $p$ the 2D position, I want to find a trajectory

$c:[0,1]\rightarrow S^1\times R^2$

from one given pose $(\varphi_0,(p_1)_0,(p_2)_0)$ to another given pose $(\varphi_1,(p_1)_1,(p_2)_1)$. This trajectory should also be optimal with respect to an energy functional for example

$\int_0^1 \varphi^2+p^2_1+p^2_2 \;dt$

and I want two constraints to be fulfilled in order to make sure that the robot moves only forward. These constraints are:

$\dot{p_1}=\cos(\varphi)$

$\dot{p_2}=\sin(\varphi)$

With Euler-Langrange I get the ODE system:

$\ddot{\varphi}=\varphi^2$

$\ddot{p_1}=-sin(\varphi)\dot{p_1}$

$\ddot{p_2}=cos(\varphi)\dot{p_2}$

Now I'm wondering if this equation system is solvable with my boundary conditions.

My questions are
1) Are there any theorems that I can use to make statements about the existence of solutions? Whenever I tried to solve this ODE in Matlab the second boundary condition was not reached.

2) Would it be easier to proof the existence if I would use another model for example with an orientation independent stearing wheel?

3) How can I solve this equation system?

4) In literature I only found very complicated models with a lot more parameters or the paper was not about reaching a specific goal pose can you advise me more basic literature with approches similar to what I derived here?

One step back to the onedimensional model

My parameters are $(p,v)\in R^2$, where $p$ indicates the onedimensional position and $v$ the velocity.

I used the energyfuctional $\int v^2 dt$ and the constraint $\dot{p}=v$.
The resulting ODE system is

$\ddot{x}_1=\dot{v}$

$\ddot{x}_2=0$

I didn't find a solution for the boundary values $(0,1)$ and $(1,1)$.

And a new question araised. Maybe I should not assume that I get a continuous solustion for all my model parameters?

答:
Let me start by saying I haven't done trajectory optimization or anything, but I've done quite a bit of differential equations for controls. I think your equations might not be solvable because of the way you've defined your constraint conditions:

$$
\dot{p}_1=\cos{\phi} \\
\dot{p}_2=\sin{\phi} \\
$$

If you want your heading/orientation to remain steady, how do you change the translational speeds? In your ODE system,

$$
\ddot{\phi} = \phi^2
$$

What if your starting heading $\phi(0) = 0$? It would look like $\ddot{\phi}$ is "trapped" to be always zero, and your translational accelerations are always stuck at $\ddot{p}_1=−\sin(0)\dot{p}_1 = 0$ and $\ddot{p}_2=\cos(0)\dot{p}_2 = \dot{p}_2$.

Given your constraint conditions $\dot{p_1} = \cos(0) = 1$ and $\dot{p_2} = \sin(0) = 0$. The constraints and accelerations seem to match, but it's a trivial solution that doesn't get you anywhere; $\dot{p}_1$ is a constant speed of $1$ and $\dot{p}_2$ is a constant speed of $0$, so again it looks like you're not able to change speed (e.g., stop) and you're not able to change position at all on the $p_2$ axis.

You haven't provided a diagram of your system, so I'm not sure why you have that "forward motion" is defined by the sine/cosine of the heading. If I had to guess, I would think maybe you're looking at a steered vehicle, but in that instance you'd have an extra term - the vehicle's linear speed - and this would be reflected in your constraints:

$$
\dot{p}_1 = \dot{x}\left(\cos{\phi}\right) \\
\dot{p}_2 = \dot{x}\left(\sin{\phi}\right) \\
$$

This might be what's missing from your equations that's precluding you from obtaining a solution. Again, I haven't done anything with trajectory optimization, but in looking around I found the following paper that might be of use:

Guidelines in Nonholonomic Motion Planning for Mobile Robots

J.P. Laumond S. Sekhavat F. Lamiraux

This is the first chapter of the book:
  Robot Motion Planning and Control

Jean-Paul Laumond (Editor)

You had asked too about terms to search, and I found this paper by looking for "nonholonomic trajectory control."

Title: motion model for forward movement


问:
Path finding: A* vs Fast marching
Context: I am working on a 20 cm x 20 cm indoor robot on a 2D terrain and I need to decide on its path planning algorithm.

Algorithms: A* and Fast marching are two popular (and fundamentally different) approaches for path planning for UAVs in 2D terrain.

A star advantages: A* is faster than fast marching because it runs linear in path length whereas fast marching runs linear in map size. Also it has variants which works with dynamic changes in maps.

Fast marching advantages: Both algorithms discretize the 2D space. Fast marching approximates the geodesic distances better than A* (which suffers due to discretization) and hence its optimal results is closer reality than A*'s optimal results.

Question: Is there any body of literature which compares these two algorithms conceptually and empirically? Are there any other awesome algorithms for 2D terrains?

答:
I'm not sure there's a body of literature exactly, but I was able to find at least one article comparing A* to FMM:

Chiang, Chia Hsun, et al. "A comparative study of implementing Fast
  Marching Method and A* SEARCH for mobile robot path planning in grid
  environment: Effect of map resolution." 2007 IEEE Workshop on Advanced
  Robotics and Its Social Impacts. IEEE, 2007.

If there is a thread of articles on the subject, you can look for it by checking its references, as well as other articles that cite this one.

As for other path planning algorithms, you may want to look into sampling-based motion planning. The OMPL project provides both a number of reference implementations and a nice overview of the approach.

Title: Path finding: A* vs Fast marching


问:
Data collected from ROS
How can we collect the flight data after a ROS simulation and what kind of dataset do we obtain? Can we get the sensor and video dataset with timestamps to be used in analysis?</p>

答:
As Ben noticed, you may want to elaborate on your question, but in general data collection in ROS is performed using tools from the rosbag package.

As you'll find when you read the documentation, data (either from a simulation or the real world) can be recorded during a session, but not after it has already finished.

Recorded data can be replayed or extracted for analysis on various ways. In particular I recommend you check the API for programmatic manipulation of rosbag files, it includes many useful features, such as recovering message record times (which is very convenient for messages that don't already include a timestamp field).

Title: Data collected from ROS


问:
Understanding KGf.CM in Camera Robotic Head Design
I am attempting to design a robotic camera head - however, I am struggling to calculate the torque (in terms of KGf.CM) I will require to rotate the Y (tilt) axis of the head.

The motor I intend to use is rated at 40KGf.cm at 30RPM - however, I do not know by how many centimetres I should divide the 40KG to determine my head capacity when factoring in the height of the camera and it's centre of mass.

To explain myself better, please see this image:

Considering the centre mass of the camera (let's say 10KG) exactly lines up with the motor, can I leave the the equation to stand at 1CM - or do I need to factor in the 10CM drop to the bottom of the camera basket?

Many Thanks in advanced!

答:
Considering the centre mass of the camera (let's say 10KG) exactly lines up with the motor, can I leave the the equation to stand at 1CM - or do I need to factor in the 10CM drop to the bottom of the camera basket?

I don't know what you mean by "leav[ing] the equation to stand at 1 cm," because I'm not sure where the 1 cm is coming from. If the center of mass of the camera is in-line with the motor shaft, then there should be no static torque required to hold the camera in any particular position.

You'll still have to deal with the moment of inertia of the camera, which has more to do with mass distribution than with the mass itself; the moment of inertia will determine how quickly you can change speeds (i.e., how long it takes to get from stopped to 30 rpm and back to stopped).


问:
What should be the prediction step in particle filter?
I am implementing a particle filter using MATLAB. I am implementing it first time. I have written the system model and measurement model. Given below:

```<code>%% SYSTEM MODEL
noise1 = sd*randn(1, 1); v_init(i)= (normrnd(mean,sigma));
x_init(i)=(x_init(i-1)*noise1+v_init(i-1)); %p(x_k | x_(k-1))
%% MEASUREMENT MODEL
noise2 = var(wgn(10,1,1)); n_init(i) = (normrnd(mean,sigma));
y_init(i) = noise2*x_init(i)+ n_init(i);    %p(y_k | x_k)
</code>```

As far as I know, the prediction step involves the following equation:

$$ p\left ( x_{k} \right|D_{k-1} ) = \int p\left ( x_{k} \right | x_{k-1} )p\left (x_{k-1} \right|D_{k-1} ) dx_{k-1}
 $$

I cannot understand, how do I implement it. Kindly guide me what should be my next step?

答: The prediction step is to pass every particle's state [for e.g (x,y, theta)] through the system model that you have written as p(xk|xk-1). You have to update the state for each particle using this model. This comprises of the prediction step in the particle filter.</p>


问:
Applications of Reinforcement Learning
Many global-control applications of robotics involve incomplete world information and at best can be represented as a POMDP.

Given this, can we really apply RL to most robotics applications? From what I have seen RL almost always needs full state information to work even remotely well.

What areas of robotics do you have sufficient state information to use RL in? I have my doubts on its tractability for global planning so what subproblems work for RL and how can they be integrated into a global planning framework?

答:
It's true that using RL in robotics involves many challenges, including the usually high dimensionality of problem spaces, the cost and limitations of real-world sessions, the impossibility or perfectly modelling the robot-environment system, and the complexity of reward functions that accurately reflect desired behaviors.

That said, a number of approaches have been proposed to address these issues: reducing space dimensionality through discretization or abstraction, enhance learning models with domain information, provide prior knowledge through demonstration and clever use of simulations, and handle uncertainties through probabilistic techniques.

There have been in fact many successful RL experiments involving robot navigation (both ground and aerial) as well as manipulator control. I recommend you check the following articles for an overview and further references:

Kober, Jens, J. Andrew Bagnell, and Jan Peters. "Reinforcement learning in robotics: A survey." The International Journal of Robotics Research 32.11 (2013): 1238-1274.

Kormushev, Petar, Sylvain Calinon, and Darwin G. Caldwell. "Reinforcement learning in robotics: Applications and real-world challenges." Robotics 2.3 (2013): 122-148.

Title: Applications of Reinforcement Learning


问:
Using Integral gain for motor positioning
I'm struggling to see how Integral gain is used for motor positioning (with an encoder on the shaft).

Suppose we have an AC motor connected to a winch which drives an object forwards and backwards. At 0 speed and 0 torque, there is no movement.

Now, using Proportional gain, we can drive the motor to a position and as it approaches the setpoint, the output to the motor decreases. The motor hopefully lands close to the setpoint.

If we use Integral gain, where the error accumulates, when we reach the setpoint the value of I is still high and the motor overshoots (even with very little ki). This wouldn't be a problem if the motor required a non-zero voltage to maintain its position (e.g. using the motor as a hoist).

A basic solution I've come up with is to use Integral gain to "push" the motor to its setpoint (effectively correcting the steady-state error), and when the motor is "close enough" to the setpoint, set the output to 0.

Is this a commonly used method? Are there any other approaches?

答:
At 0 speed and 0 torque, there is no movement.

Correct, but, consider what would happen if the winch was not perfectly level when it was installed. In that case, the object would pull on the winch, like a car trying to roll downhill if left in neutral.

If your winch were setup to only use a proportional gain, then the position would "droop" from the ideal/setpoint until such a position was reached that the object's torque matched the torque provided by the proportional controller's output.

Even if your winch were perfectly level before installation, the system will have friction, and that friction will prevent a purely proportional controller from ever achieving the desired setpoint. At some point, the proportional gain simply won't result in enough torque to overcome the system friction and get to target.

You could increase the proportional gain to push the system closer to target, but this is a bad idea because it's going to make your system way more sensitive to large steps in command position, to the point that you could drive your system unstable.

Besides stability issues, the integral term automatically pushes the system for you - an integral term "watches" the error. If it "looks" at error and sees you're not in position, then it automatically pushes a little harder.

Once the integral term sees you're in position, it stops increasing the applied force. Whatever it had been applying is retained, and this is what makes up for position droop.

It is possible for an integral term to send you into instability, but that would only happen if the integral gain were too large for your system and you can get the same instability from a strictly proportional controller if the proportional gain is too high.

If you're struggling to tune the system, then I would refer you to the Ziegler-Nichols method. From that page,

This tuning rule is meant to give PID loops best disturbance rejection.

It yields an aggressive gain and overshoot – some applications wish to instead minimize or eliminate overshoot, and for these this method is inappropriate. In this case, the equations from the row labelled 'no overshoot' can be used to compute appropriate controller gains.

If that's not quite what you're looking for, then I would highly recommend some form of model-based control, like a feed-forward controller. You can use both feed-forward and PID (and I have, to great success!)

Feed-forward control allows you to exploit your knowledge of the system to get better performance by being proactive, rather than waiting for setpoint errors to appear as in a reactive PID controller. For example, if you know you want to accelerate your 10 kg load at 1 m/s^2, then you already know the winch should output (10*1) = 10 N of force. You don't need to wait for the position errors to appear before applying that 10 N of force.

Once you're using feed-forward, you apply PID control to whatever error is left, and in this way your PID controller is only really making up for modeling errors. The PID controller will make up for any friction you failed to account for, any errors in your load mass (e.g., if it's 9 kg instead of 10 kg), etc. Your PID controller is no longer doing the "heavy lifting" of getting the bulk positioning response, so it should be much less sensitive to large step changes. Since it's only performing a positioning error adjustment, you can tune the PID controller much more aggressively than if it were trying to also perform the bulk motion.


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

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

and the possible answers were:

Estimates the location of features in the environment?

Controls the robot's flight through the environment?

Causes the robot to avoid obstacles in the environment?

Navigate in a cluttered environment?

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

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

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

答:
Estimates the location of features in the environment
Estimates the position and orientation of the robot with respect to the environment

only these two


问:
I2C Arduino Connection
I am working on a wheel mobile robot with multiple sensors which are IMU, two encoders, four ultrasonic sensors, and using two Arduino: Uno and Mega. The IMU, encoders, and ultrasonic sensors are connected to Arduino Mega while the motor controller with every other sensor attached to the robot is connected to the Arduino-Uno. The Uno is attached to the robot by the manufacturer and nearly all the pins have been used or attached to a function on the robot.
To use I2C to communicate these two Arduinos I connect SDL to SDL, SDA to SDA, GND, and VCC. Do I need to connect two separate Arduino USB cables to the Arduino simultaneously? Also, do I need to attach these lines of code from each Arduino before I can further write the codes?  Attached below the slave and then the master code

```<code>// Include the required Wire library for I2C<br>
#include <Wire.h>
int LED = 13;
int x = 0;
void setup() {
  // Define the LED pin as Output
  pinMode (LED, OUTPUT);
  // Start the I2C Bus as Slave on address 9
  Wire.begin(8);
  // Attach a function to trigger when something is received.
  Wire.onReceive(receiveEvent);
}
void receiveEvent(int bytes) {
  x = Wire.read();    // read one character from the I2C
}
void loop() {
  //If value received is 0 blink LED for 200 ms
  if (x == 0) {
    digitalWrite(LED, HIGH);
    delay(200);
    digitalWrite(LED, LOW);
    delay(200);
  }
  //If value received is 3 blink LED for 400 ms
  if (x == 1) {
    digitalWrite(LED, HIGH);
    delay(400);
    digitalWrite(LED, LOW);
    delay(400);
  }
  if (x == 2){
    digitalWrite(LED,HIGH);
  }
}
</code>```

this is the master code

```<code>#include <Wire.h>

// Include the required Wire library for I2C<br>#include

int x = 0;
void setup() {
  // Start the I2C Bus as Master
  Wire.begin();
}
void loop() {
  Wire.beginTransmission(9); // transmit to device #9
  Wire.write(x);              // sends x
  Wire.endTransmission();    // stop transmitting
  Wire.beginTransmission(8);
  Wire.write(x);
  Wire.endTransmission();
  x++; // Increment x
  if (x > 3) x = 0; // `reset x once it gets 6
  delay(500);
}
</code>```

答:
The code you provide is only to give you example on how 2 arduino communicate using I2C protocol. You will need to modify it so it can fully work as intended. You can modify it so Arduino Mega can send command to Arduino Uno and Arduino Uno can send sensor data to Arduino Mega

When using I2C communication, you need common ground, so connect both arduino ground.

Edit (March 9, 2020)

Example on reading sensor, processing it and send. Case : Arduino mega will receive range from SRF, if obstacle still far away it will keep moving. If it too close, robot stop.

Master.ino

```<code>#include <Wire.h>
const unsigned int TRIG_PIN=13;
const unsigned int ECHO_PIN=12;
int data;
byte buffer1, buffer2;

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  //For SRF
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
}

int readSRF()
{
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);
  const unsigned long duration= pulseIn(ECHO_PIN, HIGH);
  int distance= duration/29/2;
  if(duration==0)
  {
    return -1; // if pulse from srf not found
  }
  else
  {
    return distance;
  }
}

void loop()
{

  Wire.beginTransmission(4); // transmit to device #4
  //sending 2 byte, so u can have more resolution of data to send (if u want)
  int read = readSRF()
  if(read==-1)
  {
    send = 0; //Stop
  }
  else if(read<5)
  {
    send = 0; //Stop too
  }
  else
  {
    send = 2; // Move
  }
  buffer1 = send >> 8; //high order byte
  buffer2 = send;      //lower order byte
  Wire.write(buffer1);              // sends one byte
  Wire.write(buffer2);
  Wire.endTransmission();    // stop transmitting

}
</code>```

Slave.ino

```<code>#include <Wire.h>

byte temp1, temp2;
int setpoint;

void setup()
{
  Wire.begin(4); //Address of slave
  Wire.onReceive(receiveEvent); //point where the function that handle if data arrive to slave
}

void loop()
{
  if(setpoint == 0)
  {
  //some code to stop motor
  }
  else if(setpoint ==2)
  {
  //some code to run motor
  }
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  if(Wire.available() >= 2)
  {
    temp1 = Wire.read();
    temp2 = Wire.read();
    setpoint = ((unsigned int)temp1<<8)+temp2; //combining 2 bytes
  }
}
</code>```

Title: I2C Arduino Connection

Body:
The code you provide is only to give you example on how 2 arduino communicate using I2C protocol. You will need to modify it so it can fully work as intended. You can modify it so Arduino Mega can send command to Arduino Uno and Arduino Uno can send sensor data to Arduino Mega

When using I2C communication, you need common ground, so connect both arduino ground.

Edit (March 9, 2020)

Example on reading sensor, processing it and send. Case : Arduino mega will receive range from SRF, if obstacle still far away it will keep moving. If it too close, robot stop.

Master.ino

#include <Wire.h>
const unsigned int TRIG_PIN=13;
const unsigned int ECHO_PIN=12;
int data;
byte buffer1, buffer2;

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  //For SRF
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
}

int readSRF()
{
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);
  const unsigned long duration= pulseIn(ECHO_PIN, HIGH);
  int distance= duration/29/2;
  if(duration==0)
  {
    return -1; // if pulse from srf not found
  }
  else
  {
    return distance;
  }
}

void loop()
{

  Wire.beginTransmission(4); // transmit to device #4
  //sending 2 byte, so u can have more resolution of data to send (if u want)
  int read = readSRF()
  if(read==-1)
  {
    send = 0; //Stop
  }
  else if(read<5)
  {
    send = 0; //Stop too
  }
  else
  {
    send = 2; // Move
  }
  buffer1 = send >> 8; //high order byte
  buffer2 = send;      //lower order byte
  Wire.write(buffer1);              // sends one byte
  Wire.write(buffer2);
  Wire.endTransmission();    // stop transmitting

}

Slave.ino

#include <Wire.h>

byte temp1, temp2;
int setpoint;

void setup()
{
  Wire.begin(4); //Address of slave
  Wire.onReceive(receiveEvent); //point where the function that handle if data arrive to slave
}

void loop()
{
  if(setpoint == 0)
  {
  //some code to stop motor
  }
  else if(setpoint ==2)
  {
  //some code to run motor
  }
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  if(Wire.available() >= 2)
  {
    temp1 = Wire.read();
    temp2 = Wire.read();
    setpoint = ((unsigned int)temp1<<8)+temp2; //combining 2 bytes
  }
}


问:
Problem understanding a paper about visual odometry
I am reading the following paper: SVO: Semi-Direct Visual Odometry for Monocular
and Multi-Camera Systems
, and I am having some problem understanding some concepts.

Before starting I have to say that I am new to visual odometry, so maybe some simple concepts are not clear to me.

The chapter of the paper i cannot undesrtand is the one related to relaxation and refinement at pag.4 of the paper.

For what I have understood here, the paper says that for perfoeming image alignment, instead of using an image from the enviroment, it is better to use an image from a frame, so a 2D image instead of a 3D image, and in particular it is used the oldest frame in which the image was first reconstructed, and it is done because the oldest frame minimizes the feature drift (I don't undestand why).

Moreover, it says that by doing this, there is the problem of having a reprojection error.

After this, there is a more mathematical analysis, which is also really unclear to me.

I know that it is a lot to ask an explaination on a full chapter of a paper, but can somebody please help me?

答:
So SVO works a bit differently then other VO systems as it uses dense image alignment. You need to understand this concept first before understanding SVO. Look up Lucas and Kanade image alignment. The best paper on this topic can be found here. This is required understanding, so you can't skip it.

Required Understanding:

Lucas and Kanade(LK)

How Sparse VO works (VINS MONO or ORB-SLAM2 are my recommendations)

Bundle adjustment

KLT tracking (OpenCV's KLT tracker)

Oldest Frame

The reason it uses the oldest frame is to eliminate the accumulation of errors. Imagine we have frames $F_1,F_2,F_3$. What VO does is estimate the transform $T_{ab}$ between 2 frames. Here our goal is to estimate the position of $T_{3}$. So $T_3$ is equal to $T_3=T_1*T_{12}*T_{23}$. Now notice here that we have estimate both $T_{12},T_{23}$. Every time we estimate we introduce error/drift into the system. Now what if instead we estimate $T_{1,3}$ directly. There is 1 less transform we need to estimate so 1 less chance for error.

Lets take a more extreme example with $F_1,...,F_{10}$. Which one will have less error?

$$ T_{10}=T_{1}*T_{12}*T_{23}*T_{34}*....T_{9,10}$$

or
$$ T_{10}=T_{1}*T_{1,10}$$

Assuming it is possible to match $F_1$ and $F_{10}$.

2D vs 3D Image

Short answer:

3D dense image alignment does not work well when the images are far apart. So it switches to standard sparse VO and uses KLT tracking.

Longer answer:

It is possible to use the LK algorithm in multiple different ways depending on the warp. The way SVO uses it normally, and also how LSD-SLAM and DVO do it is through warping the 3D image with a 3D rigid body warp. A point we are warping is parameterized by $[u_{pixel},v_{pixel},d_{meters}]$(3D image). Now this formulation only works if the images are taken very close together. If they are too far apart then it switches to working like a Sparse VO system. It tracks the movement of the 2D keypoints in the image plane(KLT algorithm). Since we are tracking in the image plane we don't need the 3D information and can work only on the pixels. These 2D locations are then fed into the bundle adjustment algorithm.


问:
Self motion with multiple constraints
I am trying to control a 7 DOF robot (a Franka Panda). I use jacobian based control (resolved rate motion control) to generate a joint trajectory from a cartesian trajectory.

My contraints for the motion are, that I need to follow a trajectory, and I need to avoid obstacles, self collision and joint limits. I know how to satisfy each constraint independently by projecting joint velocities that avoid onto the null space.

How can I do all at the same time - is that even possible? Should I switch between constraints based on some kind of urgency?

答:
The way this is usually solved is by the use of a planner and a controller. The planner generates a sequence of configurations (joint states in the case of a manipulator) that satisfy the desired constraints, and the controller generates the necessary velocities to move the arm across the target configurations. The idea is that the plan is detailed enough that transitioning from one state to the other can be trivially done.

There are a number of packages that implement planning algorithms, I recommend looking into MoveIt if you're working with ROS.

Title: Self motion with multiple constraints


问:
ROS sensor implementation
From this page, there are lots of sensors to be used in ros robots.

http://wiki.ros.org/Sensors

But, I could not install any of them to the robots in my simulations.

For example, I want to install the camera:

```<code>$ sudo apt-get install ros-kinetic-usb-cam
</code>```

I get the error:

```<code>Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package ros-kinetic-usb-cam
</code>```

What is the most straightforward way to install any sensor or camera to a robot? What can be the reason of the error I am getting?

Thanks!

答:
This isn't a problem with sensor packages specifically, the error message says that a package by that name wasn't found, which is more of an issue with the package manager.

You can use the following command to list all ROS Kinetic packages available in your package manager:

```<code>$ apt-cache search ros-kinetic
</code>```

To check whether a specific package is available, enter the full package name, for example:

```<code>$ apt-cache search ros-kinetic-usb-cam
</code>```

If the package is not available, nothing will be printed.

In your case, since you're using a cloud environment that is exclusively geared towards simulation, probably no sensor packages will be available. That is not a problem, as you don't need them — the Gazebo simulator used in ROS includes plugins to simulate sensors and other hardware components. See here for details.

Title: ROS sensor implementation

Body:
This isn't a problem with sensor packages specifically, the error message says that a package by that name wasn't found, which is more of an issue with the package manager.

You can use the following command to list all ROS Kinetic packages available in your package manager:

$ apt-cache search ros-kinetic

To check whether a specific package is available, enter the full package name, for example:

$ apt-cache search ros-kinetic-usb-cam

If the package is not available, nothing will be printed.

In your case, since you're using a cloud environment that is exclusively geared towards simulation, probably no sensor packages will be available. That is not a problem, as you don't need them — the Gazebo simulator used in ROS includes plugins to simulate sensors and other hardware components. See here for details.


问:
Stream Real-time Video with Environmental Data Overlaid
I want to embed environmental data collected from sensors into a live video stream from a camera. Has anyone done this or know how I would go about doing something like this? Is there a library available for the arduino or RPi?</p>

答:
There is no easy way of doing it. I've done it in many of my projects, the best method I found was to use http://opencv.org/ to capture the frames, and overlay each frame with your data before displaying it again. The code below gives you an idea (written in the old opencv version 1 syntax)

```<code>/**
* Display the video from webcam and overlay text
*/

#include <stdio.h>
#include "cv.h"
#include "highgui.h"

int main(int argc, char** argv)
{

    CvCapture *capture;
    IplImage  *frame;
    double    t, ms = 0;

    bool finished = false;
    /* initialize webcam */
    capture = cvCaptureFromCAM(0);

    CvFont myFont;

    //Initialise font
    cvInitFont(&myFont,CV_FONT_HERSHEY_COMPLEX_SMALL ,1.5f,1.5f,0,1,8);

    while (!finished)
    {
        /* display frame */
        frame = cvQueryFrame(capture);
        cvPutText( frame, "My Text", cvPoint(50,50), &myFont , cvScalar(128) );
        // use other functions to draw something
        cvShowImage("Stream",frame);
    }

    /* free memory */
    cvReleaseCapture(&capture);
    return 0;
}
</code>```

It also depends if you want to write your own code, or if you want a simple off the shelf solution. If you are writing your own code, then have a look at some of my scene rendering components, https://sourceforge.net/p/visionmagic/code/ci/master/tree/src/modules/sceneRendering/ , not perfect, but will give you an idea on how to render things in OpenGL, and Qt.

Body:
There is no easy way of doing it. I've done it in many of my projects, the best method I found was to use http://opencv.org/ to capture the frames, and overlay each frame with your data before displaying it again. The code below gives you an idea (written in the old opencv version 1 syntax)

/**
* Display the video from webcam and overlay text
*/

#include <stdio.h>
#include "cv.h"
#include "highgui.h"

int main(int argc, char** argv)
{

    CvCapture *capture;
    IplImage  *frame;
    double    t, ms = 0;

    bool finished = false;
    /* initialize webcam */
    capture = cvCaptureFromCAM(0);

    CvFont myFont;

    //Initialise font
    cvInitFont(&myFont,CV_FONT_HERSHEY_COMPLEX_SMALL ,1.5f,1.5f,0,1,8);

    while (!finished)
    {
        /* display frame */
        frame = cvQueryFrame(capture);
        cvPutText( frame, "My Text", cvPoint(50,50), &myFont , cvScalar(128) );
        // use other functions to draw something
        cvShowImage("Stream",frame);
    }

    /* free memory */
    cvReleaseCapture(&capture);
    return 0;
}

It also depends if you want to write your own code, or if you want a simple off the shelf solution. If you are writing your own code, then have a look at some of my scene rendering components, https://sourceforge.net/p/visionmagic/code/ci/master/tree/src/modules/sceneRendering/ , not perfect, but will give you an idea on how to render things in OpenGL, and Qt.


问:
Directional hearing for Linux robot?
I want to give my Linux robot the ability to locate a sound source and drive towards it. I am reading a paper on sound localization that seems to cover the theory well enough, but I'm at a loss as to how do I implement it. Specifically I would like to know:

How do I connect two microphones to a Linux PC?

How do I record from two microphones simultaneously?

Is there any library of sound processing algorithms (similar to how OpenCV is a library of computer vision algorithms) available for Linux?

答:
The easiest way to connect multiple microphones to a Linux PC is probably to use USB mics. There are myriad brands appealing to all tastes and pocket sizes, check your favorite online marketplace for options.

The PortAudio C++ library (and its Python wrapper, PyAudio) enable cross-platform access to multiple audio devices in either callback or blocking modes. Also see here for a list of audio-processing libraries; specifically, the Open embeddeD Audition System (ODAS) and Time Difference of Arrival (TDOAS) libraries are concerned with determining the direction of sound sources. Additionally, a solution implemented directly on PyAudio is discussed here.

For an integrated solution, the ReSpeaker project builds a variety of microphone arrays that can be controlled through a Python API. See here for how it can be used to determine sound source direction.

Title: Directional hearing for Linux robot?


问:
Understanding types of hand eye calibration
I have been reading about hand eye calibration for a couple days. Basically, I have 2 setups I want to execute hand eye calibration.

Camera is fixed in a position and arm is moving (eye on base);

Camera is fixed to the robot wrist (eye on hand).

I have read Tsai's paper and a lot of other documents and read some similar question posted here (Hand Eye Calibration)

I also, have found some libraries that I can achieve this with ROS.

easy_handeye: https://github.com/IFL-CAMP/easy_handeye

handeye_calib_camodocal: https://github.com/jhu-lcsr/handeye_calib_camodocal

I believe that both hand-eye setups I described before can be solved with formulation AX=XB (since easy_handeye solves this way). Furthermore, I believe that setup 2 (eye-on-hand) is the classic problem for AX=XB. However, I cannot understand how to model the problem in order to solve for setup 1 (eye-on-base). Also, I cannot understand the difference between AX=XB and AX=ZB (which sometimes is written as AX=YB).

This is a more theoretical question, but I like to understand the theory before start using any tool, otherwise I will have some technical debt that can generate problems in the future. If someone can explain to me or provide material to clarify these points, I will be very grateful.

答:
The references you gave actually have all the information that you need. I think you are maybe getting confused a bit with the different coordinate systems. As the same symbol can have subtle different meanings.

difference between AX=XB and AX=ZB

If you write the transforms with the coordinate subscripts then it becomes more clear. The equations then become:

$$A_{12}X=XB_{12}$$
$$A_{wc}X=Z_{w}B_{wh}$$

$w$ is world origin

$c$ is camera frame

$h$ is hand frame

So $AX=XB$ is used when you have delta transforms. You have the camera on the wrist(scenario 2). You move the robot arm around to estimate $X$, which is the sole quantity you are trying to estimate. Note you don't ever actually care about any absolute poses. You only care about the transforms between 2 poses. If you look at the image you can see that $A$ and $B$ are between different poses. Not from some origin.

$AX=ZB$ is used when you have or are interested in the poses with respect to some coordinate frame(e.g World). You then need an extra term to represent this transform which is $Z$. Now $Z$ might be given to you are it might be something you have to simultaneously estimate. It depends on your specific problem.

The images in the stackoverflow post you link to show this quite well. The parameters with the question marks are the ones you are trying to estimate.

1 (eye-on-base)

It is a bit different then the general $AX=XB$ or $AX=ZB$ as here $X$ is not constant. Instead it is the value that changes and we are interested in estimating $A$.

The equation should be something like this

$$ A_{bc}X_{ch}=B_{bh}$$

$b$ is the robot base

and could be modified to look like $AX=ZB$ by adding a world coordinate frame.

$$ A_{wc}X_{ch}=Z_{wb}B_{bh}$$

which corresponds to the picture.

To solve this you put a marker on your robot hand so the camera can track it as seen in your link here. $Z_{wb}$ is arbitrary and depends on what you consider your origin. $B_{bh}$ comes from your odometry/encoders, and $X_{ch}$ comes from the marker tracking. You can then solve for $A_{wc}$


问:
DC motors are stalling at low voltage (L298N controller)
I'm building a small tracked robot. Currently it's just a Raspberry Pi, two motors and an L298N controller.

The problem I'm facing is that the motors are stalling at low voltages (which is what I assume the control controls). So it's impossible to move the robot slowly.

I don't have any kind of datasheet for the motors. I only know that the "recommended voltage is 3 - 9V" and they draw 300mA without load at 6V. They came as part of the kit I bought. The kit is no longer for sale, but here is an old sales page for it: https://www.botnroll.com/en/robots-educational-kits/1158-iron-man-4-tracked-chassis-for-arduino.html
(note that this is not where I bought the robot and I don't know botnroll at all)

The motors are powered by a rechargeable 9V battery (Duracell NiMH 8.4V, 170mAh) which I had lying around and was the correct voltage.

The motors are controlled by a L298N module I got from AliExpress.

I've been trying to learn a bit about how these DC motors work (https://medium.com/luosrobotics/how-to-read-a-dc-motors-datasheet-f70fa440452b) and it looks like they need the highest current when stalled. So just before the robot begins to move, the motors need more current than when it is moving.

This leads me to believe that the problem is most likely the battery. The battery is not able to deliver the required current to overcome the stall. I haven't been able to find the max current for the battery. This is the only datasheet I have found: http://www.farnell.com/datasheets/2039764.pdf

Before going on a shopping spree, I'd like to ask you guys these questions:

Is this conclusion correct and is the problem the battery?

If yes, what battery solution would you suggest?

Here are some images if you are interested:
https://photos.app.goo.gl/vT24qVB1xPFqTVScA

答:
You have two motors that

draw 300mA without load at 6V

and you have one battery that is rated at

8.4V, 170mAh

Combined, you have two motors that draw a combined (2 * 0.3 * 6) = 3.6 Watts unloaded. Compare that with your battery, that has a capacity of (8.4 * 0.17) = 1.428 Watt-hours.

That is, you can run your motors unloaded for (1.428/3.6) = 0.4 hours, or 24 minutes, and that's assuming you can get 100% of the power out of the batteries.

As NomadMaker pointed out, you're drawing a very high amount of current for that battery.

Drawing high current from a battery will heat the battery, which increases the internal resistance and results in more power lost in the battery.

It could be that the battery is undersized for your application, but I would bet it's just dead. I would typically only count on being able to charge to 90%, and only being able to discharge down to 20% before brownout, which means I typically only count on being able to access 70% of a battery's rated capacity. This would lower your operating time from 24 minutes down to ~17 minutes, and again that's assuming the motors are unloaded.

Stall current is what the motors would draw if you held the shaft stationary; it's not the same as starting current, though starting current is higher (~3x) than running current. Still, your stall current is rated at 4 A (!!) each - if your normal running current is 1 A each then I'm guessing you've got about 5 minutes of run time before your battery is dead.

So, tl;dr here: Measure the battery voltage. I would guess it's dead at around 8V. If it's not dead then the battery might not be able to supply the current, but you should consider changing batteries anyways as you don't have much runtime even under ideal conditions.


问:
AC Motors vs Hydraulic motors for skid-steering robot
I'm designing a mobile robot with tracks and skid-steering driving system and I am evaluating whether an electric motor would be better than a hydraulic one.

I did some calculations, the total weight of the robot is 1200Kg, there are two rubebr tracks and their sprocket had a diameter of 0.3 meters. The maximum velocity should not exceed 0.5 m/s and I do not think the robot will have to face slopes greater than 20%.

If I use the hydraulic system, I would go with:
- 1 x 12kW AC Motor, 48VAC, 2900 RPM
- 2 x Oleodynamic pumps 8.5 cc/rev, 120Bar working pressure
- 2 x OMP 250 hydraulic motors
- 1 x AC motor controller 300A
- 1 x proportional valve controller
- 2 x proportional hydraulic valves
- 1 x 19kW/h battery pack

If I use the electric solution, I would go with:
- 2 x 2500W AC Motor, 48VAC, 2200 RPM
- 2 x gearbox 1:35
- 2 x AC motor controllers 300A
- 1 x 19kW/h battery pack

If my calculations are correct, the first solution should be easy to maintain while the second one should be easier to implement.

What can you suggest?
I usually would go with the second solution, but since it is a big machine, I would like to save some money and keep the system easy to check, maintain and control.

答:
A hydraulic system requires a hydraulic power unit (hpu), and then you still need a motor everywhere you want an electric motor, and then you've got hydraulic hoses (carrying full hydraulic pressure) running through your robot.

The hydraulic system will not be easier to maintain, will not be easier to install, and I'm pretty sure it'll be dramatically more expensive.

The only time I would consider hydraulics are:

If you have space constraints that really require the actuator to be as small as possible, or

If you only intend to operate one axis at a time (and thus can essentially have an undersized HPU), or

You really need to use a fossil fuel system for motive power, or

There's already hydraulics in use for some other aspect.

Especially vs. an AC motor, maybe the only thing you have to do for the AC system is grease a bearing. The hydraulic system has all the hoses to purchase or make up (don't screw that up!), hydraulic reservoir to fill, lines to bleed, etc. And if one of those lines ruptures (because everything fails eventually) then it could ruin the rest of the robot.

And did I mention it's expensive?


问:
How to solve dynamics of cardan joint manipulator
We can use the Recursive Newton-Euler Algorithm to solve the dynamic problems of open chains manipulator, but how about the Cardan-joint manipulator?

For example, if we have one Cardan joint (Universal joint),2 degrees of freedom, like this picture, one is rotate around the z-axis,and another is rotate around the y-axis

In order to solve the inverse dynamics of this model, my idea is to set the virtual link between $\theta_1$(assume rotation axis is z-axis) and $\theta_2$(rotation around y-axis), and then the problems become open chains, so in forwarding iterations of Newton-Euler Algorithm, the velocity of $\theta_1$ can transfer to the velocity of $\theta_2$ by virtual link, and finally, the wrench of end-effector can be transfer by backward iterations. But the inertia matrix of virtual link is diag([0,0,0,0,0,0]), is my idea correct?

I didn't know how to transfer the velocity and wrench between $\theta_1$ and $\theta_2$ in the Recursive Newton-Euler Algorithm Framework, Or maybe I should use another method to build the dynamics of this model.

答:
In your diagram now, if it were real and "unpaused," your end-effector would drop. I think the trouble you're having with your dynamics is that you're missing a constraint - what holds the end-effector stationary? To illustrate, if the following were a snapshot frozen in time:

And then you "unfroze" time, then the "dynamics" you would see would result in:

The cross, being an unactuated bearing, cannot support a moment. If it weren't for the faces or end-caps colliding with one another, the entire assembly would swing completely down:

This is what I meant when I said the cross moves - you have one joint between the base and the cross, and then you have another joint between the cross and the end-effector cylinder. The complex part here isn't the joint definitions, it's the addition of the constraint. You don't have one pictured here, so I'm not sure what you're expecting is going to hold the end-effector up.

You either need a bearing or support of some kind for the end-effector or you need to actuate the universal/Cardan joint.


问:
roslaunch not found
Running ROS melodic on Ubuntu 18.04 and I keep getting this error.

```<code>$ roslaunch arm robot_spawn.launch

Command 'roslaunch' not found, but can be installed with:

sudo apt install python-roslaunch
</code>```

I was able to launch prior to this but decided to add another node though. When I try to reinstall it, I get a recursive errors like in this question. Anyway, I checked the solution provided in the question link that says that I need ros-melodic-launch and not python-roslaunch so I go ahead and try to source melodic's setup.bash but I already had

source /opt/ros/kinetic/setup.bash in my .bashrc.

Upon further digging I find another question.  I have checked the logs of apt in /var/log/apt/history.log and can confirm that I have it.

答:
Even though you have added source /opt/ros/kinetic/setup.bash to your .bashrc, the fact you get a "command not found" error indicates that somehow Bash can't find the roslaunch executable. To double-check your configuration, run the following command:

```<code><span class="math-container">$ echo $</span>PATH
</code>```

If your environment is correctly configured to run ROS Kinetic, you should see an output of the form:

```<code>/opt/ros/kinetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
</code>```

Notice that the first entry in the colon-separated list above is /opt/ros/kinetic/bin; if that's not the case in your system, that's probably the cause of the issue.

Even if the apt logs say roslaunch was installed, it's better to double-check whether it really is anywhere to be found. Search for the executable file using the command below:

```<code>$ sudo find / -name roslaunch
</code>```

You should see the following output:

```<code>/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch
/opt/ros/kinetic/share/roslaunch
/opt/ros/kinetic/bin/roslaunch
</code>```

If that's not the case, then roslaunch is not (correctly) installed. Otherwise, you might also check whether executable permissions are set for good measure:

```<code>$ ls -l /opt/ros/kinetic/bin/roslaunch
-rwxr-xr-x 1 root root 1657 Oct  8  2019 /opt/ros/kinetic/bin/roslaunch
</code>```

Check whether the x flags are present in the output.

Generally speaking, (re)installing packages should be your last resort when dealing with environment issues. It's all too easy to run into conflicts and wreck your system to a degree that you might as well rebuild it from scratch. It's better to first try and determine what the problem is to begin with, before rushing into attempts at a solution.

If you installed the ros-kinetic-desktop-full meta-package then you should already have everything needed to run roslaunch; in any case, that certainly wouldn't have changed because you added another node to your project, either as sources in your workspace or by installing a binary package.

All that said, if roslaunch isn't found in your environment or you can't otherwise determine why calling it doesn't work, you might want to try reinstalling the whole ROS setup:

```<code><span class="math-container">$ sudo apt purge ros-kinetic-desktop-full # or whatever meta-package you used
$</span> sudo apt autoremove
$ sudo apt install ros-kinetic-desktop-full
</code>```

But I personally think the best approach is to cut your losses and reinstall the system from scratch, then if you get the same issue again try to determine the cause before (re)installing anything.

Title: roslaunch not found

Body:
Even though you have added source /opt/ros/kinetic/setup.bash to your .bashrc, the fact you get a "command not found" error indicates that somehow Bash can't find the roslaunch executable. To double-check your configuration, run the following command:

$ echo $PATH

If your environment is correctly configured to run ROS Kinetic, you should see an output of the form:

/opt/ros/kinetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Notice that the first entry in the colon-separated list above is /opt/ros/kinetic/bin; if that's not the case in your system, that's probably the cause of the issue.

Even if the apt logs say roslaunch was installed, it's better to double-check whether it really is anywhere to be found. Search for the executable file using the command below:

$ sudo find / -name roslaunch

You should see the following output:

/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch
/opt/ros/kinetic/share/roslaunch
/opt/ros/kinetic/bin/roslaunch

If that's not the case, then roslaunch is not (correctly) installed. Otherwise, you might also check whether executable permissions are set for good measure:

$ ls -l /opt/ros/kinetic/bin/roslaunch
-rwxr-xr-x 1 root root 1657 Oct  8  2019 /opt/ros/kinetic/bin/roslaunch

Check whether the x flags are present in the output.

Generally speaking, (re)installing packages should be your last resort when dealing with environment issues. It's all too easy to run into conflicts and wreck your system to a degree that you might as well rebuild it from scratch. It's better to first try and determine what the problem is to begin with, before rushing into attempts at a solution.

If you installed the ros-kinetic-desktop-full meta-package then you should already have everything needed to run roslaunch; in any case, that certainly wouldn't have changed because you added another node to your project, either as sources in your workspace or by installing a binary package.

All that said, if roslaunch isn't found in your environment or you can't otherwise determine why calling it doesn't work, you might want to try reinstalling the whole ROS setup:

$ sudo apt purge ros-kinetic-desktop-full # or whatever meta-package you used
$ sudo apt autoremove
$ sudo apt install ros-kinetic-desktop-full

But I personally think the best approach is to cut your losses and reinstall the system from scratch, then if you get the same issue again try to determine the cause before (re)installing anything.


问:
Robot - Wall Avoiding (Plinko Robot)
I am looking to build a robot that will travel and zig-zag down the hallway.It will be headed towards a wall at roughly 45 degrees and then use a IR LED to detect when a wall is nearby. From there, the robot will rotate and head towards the other wall at a 45 degree angle. The robot will zig zag back and forth until it reaches the end of the hallway.

I have researched a lot of various robots using a search of "Obstacle Avoiding Robot". However, all of these designs use IC L293D motor drivers. However, for my class, I am only able to use a select few diodes, power MOSFETs, BJTs, OP-amps, and 555-timers, and no microcontroller.

Can anyone give me advice on how to create a motor driver using these parts? Also, do you have any additional tips to help me build this robot?

Thank you!

答:
Perhaps what you are looking for is a Braitenberg vehicle.  These are simple theoretical vehicles that exhibit advanced behavior without traditional microcontrollers.  (The Wikipedia page is just a small summary of the full book which is definitely worth a read).

These vehicles are typically concerned with driving towards a light source.  But I think you can probably use two distance sensors instead of light sensors to drive down the center of the hallway.  Maybe like this:

Assuming the distance sensors return a small value when close to a wall, and large value when far from a wall. For example the left sensor is close to the wall, and the right sensor is far, so the right motor gets a small signal and the left motor gets a large signal, thereby steering the robot away from the wall.

Title: Robot - Wall Avoiding (Plinko Robot)


问:
Extended Kalman filtering for IMU and Encoder
I am trying to fuse IMU and encoder using extended Kalman sensor fusion technique. how do I fuse IMU pitch, roll with the orientation data I obtained from the encoder. Also, how do I use my position x and Y I got from the encoder which is the only position data i have because integrating IMu acceleration to obtained position is almost impossible due to errors.
I guess my state are position x, y, pitch, roll and control input are velocity of the right and left wheel.</p>

答:
EKF sensor fusion is achieved simply by feeding data streams from different sensors to the filter. So all you need to do is setup your implementation to accept both encoder and IMU data. This is basically a matter of providing different versions of the observation model matrix $\mathbf{H}$ that converts states to sensor measurements, one for each sensor.

It's often the case that each sensor captures a different subset of the full state. In the case of a state as below:

$$
\mathbf{x} =
\begin{bmatrix}
x \\
y \\
roll \\
pitch \\
yaw
\end{bmatrix}
$$

Encoder readings reflect $[x \quad y \quad yaw]^T$, while IMU readings reflect $[roll \quad pitch \quad yaw]^T$. This is encoded in the $\mathbf{H}$ matrices by having the number of rows match the number of captured state components, the number of columns match the full state size, and the position of non-zero elements correspond to the position of the captured components in the state vector.

For example, the encoder observation model matrices $\mathbf{H}_{encoders}$ and  $\mathbf{H}_{IMU}$ would be defined as:

$$
\mathbf{H}_{encoders} =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 \\
\end{bmatrix}
$$

$$
\mathbf{H}_{IMU} =
\begin{bmatrix}
0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 1 \\
\end{bmatrix}
$$

Notice how for the matrices above:

$$
\mathbf{H}_{encoders} \mathbf{x} =
\begin{bmatrix}
x \\
y \\
yaw
\end{bmatrix}
$$

$$
\mathbf{H}_{IMU} \mathbf{x} =
\begin{bmatrix}
roll \\
pitch \\
yaw
\end{bmatrix}
$$

All that said, I would counsel against having $(x, y)$ coordinates in a state estimated by a Kalman filter. The reason is that encoder drift error is not bounded, but grows endlessly with distance traveled — that's why we need SLAM after all. Instead I would recommend keeping track of linear and angular velocities, and integrate those over time outside of the filter to get a position estimate, if no better alternative is available. Velocity estimates can be trivially computed from encoder tick counts as below:

$$
v = \frac{c_L \alpha_L + c_R \alpha_R}{2 \Delta t}
$$

$$
\omega = \frac{c_R \alpha_R - c_L \alpha_L}{2 l \Delta t}
$$

Where $(v, \omega)$ are linear and angular velocity, $(c_L, c_R)$ the tick counts,  $(\alpha_L, \alpha_R)$ coefficients that convert tick count to traveled distance, $\Delta t$ the tick collection interval, and $l$ the lateral distance between wheels.


答:
This looks like a BEAM robot. According to Wikipedia, "BEAM robotics (from biology, electronics, aesthetics and mechanics) is a style of robotics that primarily uses simple analogue circuits, such as comparators, instead of a microprocessor in order to produce an unusually simple design. While not as flexible as microprocessor based robotics, BEAM robotics can be robust and efficient in performing the task for which it was designed."

The BEAM Reference Library provides an overview of the paradigm, an extensive library of commonly used circuits, and schematics for some robot designs. In particular, I believe this one might be a good start for you: it desribes a robot that drives in the direction of a light source, I imagine that with a few modifications it could be reworked into moving away from obstacles instead.

Title: Robot - Wall Avoiding (Plinko Robot)

Body:
I am looking to build a robot that will travel and zig-zag down the hallway.It will be headed towards a wall at roughly 45 degrees and then use a IR LED to detect when a wall is nearby. From there, the robot will rotate and head towards the other wall at a 45 degree angle. The robot will zig zag back and forth until it reaches the end of the hallway.

I have researched a lot of various robots using a search of "Obstacle Avoiding Robot". However, all of these designs use IC L293D motor drivers. However, for my class, I am only able to use a select few diodes, power MOSFETs, BJTs, OP-amps, and 555-timers, and no microcontroller.

Can anyone give me advice on how to create a motor driver using these parts? Also, do you have any additional tips to help me build this robot?

Thank you!


问:
Alternatives to Finite State Machines (FSM's)?
In Udacity's Self-Driving Car Engineer online course, one instructor claims that "[Finite State Machines are] not necessarily the most common [approach for behavior planning] anymore, for reasons we will discuss later." I suppose the later assertions that FSM's are easily abused and become harder to understand and maintain as the state set increases amount for the "reasons", but we're never told what's used in its place.

I have been using FSM's for years, mostly for parsing-related problems in enterprise systems programming, but more recently for behavior planning problems. In my experience they're great for breaking down complex problems into manageable parts, not only when modelling but also in implementation – I usually implement each state as a separate class or function, allowing me to concentrate on the respective behavior and transition rules in relative isolation to the rest of the architecture.

That's why I find it frustrating that the lesson failed to discuss what is currently used instead of FSM's for behavior modelling: if a better approach exists for keeping track of a system's context and adjusting its behavior in response, I'm yet to hear of it, and I'd very much like to.

答:
Both FSM's and optimization approaches such as MPC will suffer as scenario constraints multiply. While at first glance FSM's may seem better suited to handle the increased complexity, in practice the interaction between different transition rules can quickly become difficult to track. This is most clear in the case of the so-called Zeno phenomenon, where a hybrid (FSM-based) controller repeatedly switches between states. Similarly, approaches based on optimizing a cost function can descend into "weight-tuning Hell", where increasing the weight of one objective has detrimental effects on another.

In either case the problem is not so much with the approach itself, but with taking a "flat" view of robot navigation, a problem that is hierarchical in nature. Instead of trying to satisfy every constraint at the same level of abstraction, modern navigation architectures divide them among a stack of modules:

Router: find a route from the current robot location to a desired destination, satisfying environmental constraints (keep to driveable roads, respect direction of traffic, etc.) and maximizing optimality metrics (distance traveled, fuel consumption, etc.);

Planner: Find paths that keep the robot advancing alongside the planned route, while also avoiding unexpected obstacles;

Kinematic controller: compute velocities that drive the robot forward alongside the planner path;

Dynamic controller: compute actuator commands that match the velocities generated by the kinematic controller.

In an architecture such as this "discrete" decisions are taken at the inter-module level — for example, the planner could report failure searching a path around an obstacle, prompting the router to generate an alternative route — while "continuous" policies are enforced at the intra-module level. In this latter case optimization-based approaches do have an edge over FSM's, as the former are fundamentally better at handling continuous domains.

That said, navigation systems based on Linear Temporal Logic (LTL) have successfully enabled discrete logic planning to be applied in continuous domains. LTL is a step up from FSM's, but still an appealing alternative for describing complex navigation objectives in a more human-readable form.


问:
how to calibrate gyroscope using raw gyro data?
I wrote a simple code for where I take 500 samples with stationary gyro and subtract those offset values to get calibrated gyro data.

Question:

Is this much calibration enough to implement this gyro for a quadcopter system ?

What other methods exist for better and accurate gyroscope calibration ?

答:
No (for best outcome) it is not enough. As you might have observed, the error that Gyro produces during stationary position is very random and has no specific order. No matter how much reading you take for average offset, you cannot eliminate it.
One solution is simply to use sophisticated sensor which is not always possible. Another solution is to use sophisticated algorithms. For example Gyroscope can be fused with Accelerometer and then to apply Complementary Filter.
Similarly if you want to dynamically calibrate Gyroscope at every reading then you can use Kalman Filter for estimation. Kalman Filter is slightly difficult to apply but it gives way better results.

Ref: Kalaman Filter by Phil Kim


问:
How to understand the angular velocity of link i+1?
My question is a basic one about velocity propagation from link to link, that is how to understand the following equation.

$
{^i\omega_{i+1}} = {^i\omega_{i}} + {_{i+1}^{\;\;\;i}{R}} \cdot {\dot{\theta}_{i+1}} \cdot {^{i+1}\hat{Z}_{i+1}}
$

The interpretation of this equation from Introduction to Robotics by John J. Craig is:

The angular velocity of link i+1 is the same as that of link i plus a new component caused by rotational velocity at joint i+1. This can be written in terms of frame {i}

Take the following figure as an example, I assume this equation is trying to compute the angular velocity of Link 2 with respect to the frame {1}. i.e., $^1\omega_2$

What bewilders me most is I don't think every point on Link 2 share the same angular velocity with respect to joint 1, because the axis of rotation is not joint 1. Then how come $^1\omega_2$ be computed?

Can anyone please help me out?

答:
I don't think it's that difficult. If you look closely the statement from Craig's book is self-explanatory. Let me explain this further. When you measure the angular velocity of link $2$ it has a unit vector in frame $2$. Then you multiply it with a rotation matrix which transforms this angular velocity to frame $1$. But since it is not necessary that link 1 will be in a stationary position so the angular velocity of link $1$ will be added with the final angular velocity of link $2$ which is a common sense.

Then comes the last part of your question. You might know the convention in this book but let me mention it here. ${^i\omega_{i+1}}$ means that you are measuring the velocity of frame $i+1$ in frame $i$.

Edit:
The last part of your question.
I thought you were were confused in linear velocity.

The angular velocity in rigid bodies is same. Thanks to the one who pointed it correctly in the comments.