答:
I don't have time to do a full code review here, but the short version of why you're getting the error is that, as the error states, you're trying to remove an element from queue that either wasn't added or was already removed.

I don't think your code is doing what you think it's doing, so I would highly suggest you attach a debugger and step through your code and watch it operate. For example:

```<code>def minDistance(self,dist,queue):
    minimum = float("Inf")
    min_index = -1
    for i in range(len(dist)):
        if dist[i] < minimum and i in queue:
            minimum = dist[i]
            min_index = i
    return min_index
</code>```

You're comparing all the entries in dist to float("Inf"), but what is dist? That's defined in the calling function:

```<code>def dijkstra(self, graph, src):

    dist = [float("Inf")] * row
</code>```

So if every element in dist is float("Inf"), then will there ever be an element in dist that is less than float("Inf")? No. So what happens then, if your distance entries aren't less than Inf? You will still

```<code>return min_index
</code>```

where min_index is initialized to -1.

The summary on what I think is going wrong here is this:

You build a queue of all rows, then

You check the distance on each row, then

If that distance fails your check, you are returning -1 as the index, then

You are not checking the index on the returned variable, you're instead just blindly removing that index from queue, then

Because queue is a vector of row numbers and -1 is not a row number, you get an exception when you try to remove -1 from your queue.

The part that I don't have time to get into here is your intent. Why are you trying to do with your code? You are running

```<code>while queue:
    u = self.minDistance(dist,queue)
    queue.remove(u)
</code>```

This will remove all the entries in your queue until queue is null/empty, but as mentioned above self.minDistance will return -1 unless the dist[i] < minimum and i in queue.

I can't tell what your intent is, but I think maybe you should just be calling u = self.minDistance once and not repeatedly. This hunch seems to be further confirmed by looking a few lines down in your code:

```<code>while queue:
    u = self.minDistance(dist,queue)
    queue.remove(u)
for i in range(col):
    if graph[u][i] and i in queue:
</code>```

If you are running queue.remove(u) until queue becomes empty/null, then how does it exist later when you check if graph[u][i] and i in queue?

I would guess instead of:

```<code>for i in range(row):
    queue.append(i)
while queue:
    u = self.minDistance(dist,queue)
    queue.remove(u)
for i in range(col):
    if graph[u][i] and i in queue:
</code>```

would you would want

```<code>for i in range(row):
    queue.append(i)
u = self.minDistance(dist,queue)
for i in range(col):
    if graph[u][i] and i in queue:
</code>```

but I'm not a python user and haven't looked more at your algorithm.

At a minimum, though, if you are going to do queue.remove(u) then you need to check if queue contains u first. If it doesn't then print yourself a nice warning and I'd bet that'll reveal your issue.

Title: Path planning for robot car on grid

Body:
I am currently doing a project as my hobby. I am trying to simulate a robot car in a grid arena.      Below is the image of the arena:

The start point of the car is the bottom-right corner(dark green box). And I have to reach at pink grid using the shortest path possible. Shortest path in the sense that cost of crossing the grid. The weights/costs of grids are as follows:

Red:4, Yellow:3, Green:2, White:1. Black grids are block/walls.

My implementation:

I used the OpenCV library in python to segment the colors of the grid and finding the centroids for each grid. centroid matrix is as follows:

```<code>[[( 34,  34) ( 85,  34) (137,  34) (  0,   0) (240,  34) (292,  34)]
 [( 34,  85) (  0,   0) (137,  85) (  0,   0) (240,  85) (291,  85)]
 [( 34, 137) ( 85, 137) (137, 137) (188, 137) (240, 137) (291, 137)]
 [(  0,   0) ( 86, 191) (137, 188) (188, 188) (  0,   0) (291, 188)]
 [( 34, 240) ( 85, 240) (137, 240) (  0,   0) (  0,   0) (291, 240)]
 [( 34, 292) (  0,   0) (137, 291) (188, 291) (240, 291) (291, 291)]]
</code>```

Then I created an adjacency matrix(36*36) based on the nodes connected. Below is the adjacency matrix in form of a list:

```<code>[[0 2 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [1 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 2 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 3 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [1 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 4 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 3 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 2 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 2 0 0 0 0 2 0 4 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 3 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 4 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 2 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 2 0 1 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 1 0 0 0 0 0 0 4 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 2 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 2 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 1]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 2 0]]
</code>```

Then I have implemented the Dijkstra algorithm to find the shortest path as:

```<code>from collections import defaultdict
class Graph:
    def minDistance(self,dist,queue):
        minimum = float("Inf")
        min_index = -1
        for i in range(len(dist)):
            if dist[i] < minimum and i in queue:
                minimum = dist[i]
                min_index = i
        return min_index
def printPath(self, parent, j):
    if parent[j] == -1 :
        print (j)
        return
    self.printPath(parent , parent[j])
    print(j)
def printSolution(self, dist, parent):
    src = 0
    print("Vertex \t\tDistance from Source\tPath")
    for i in range(1, len(dist)):
        print("\n%d --> %d \t\t%d \t\t\t\t\t" % (src, i, dist[i])),
        self.printPath(parent,i)
def dijkstra(self, graph, src):

    row = len(graph)
    col = len(graph[0])
    dist = [float("Inf")] * row
    parent = [-1] * row
    dist[src] = 0
    queue = []
    for i in range(row):
        queue.append(i)
    while queue:
        u = self.minDistance(dist,queue)
        queue.remove(u)
    for i in range(col):
        if graph[u][i] and i in queue:
            if dist[u] + graph[u][i] < dist[i]:
                dist[i] = dist[u] + graph[u][i]
                parent[i] = u
    self.printSolution(dist,parent)
</code>```

However, this code is raising an error on executing as:

```<code>g= Graph()
g.dijkstra(graph,35) #src at node 35
</code>```

Error:

```<code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
<ipython-input-166-4785fe512432> in <module>
      1 g= Graph()
      2 graph = adj
----> 3 g.dijkstra(graph,35)

<ipython-input-146-4fd492228481> in dijkstra(self, graph, src)
     86
     87             # remove min element
---> 88             queue.remove(u)
     89
     90             # Update dist value and parent

 ValueError: list.remove(x): x not in list
</code>```

The output should be like this:

```<code> Vertex           Distance         Path
 0 -> 2          12        0 1 2
</code>```

My doubts/questions:

1) Am I implementing/proceeding rightly to help the car reach its destination? Are these ideas good or I should choose a different approach? If yes, please suggest.

2) How can I resolve the issue in my code? I don't know why I am getting this error. If I should use a different algorithm/approach, please sugget.

3) Is my adjacency matrix right? I made it based on 36 connecting nodes with weights.

I am not a computer science student but doing it because of my interest. I have got no guide/teacher to teach me these things and looking at this site to resolve my issues.
I request you to please provide guidance.

Thank you.

Body:
I don't have time to do a full code review here, but the short version of why you're getting the error is that, as the error states, you're trying to remove an element from queue that either wasn't added or was already removed.

I don't think your code is doing what you think it's doing, so I would highly suggest you attach a debugger and step through your code and watch it operate. For example:

def minDistance(self,dist,queue):
    minimum = float("Inf")
    min_index = -1
    for i in range(len(dist)):
        if dist[i] < minimum and i in queue:
            minimum = dist[i]
            min_index = i
    return min_index

You're comparing all the entries in dist to float("Inf"), but what is dist? That's defined in the calling function:

def dijkstra(self, graph, src):

    dist = [float("Inf")] * row

So if every element in dist is float("Inf"), then will there ever be an element in dist that is less than float("Inf")? No. So what happens then, if your distance entries aren't less than Inf? You will still

return min_index

where min_index is initialized to -1.

The summary on what I think is going wrong here is this:

You build a queue of all rows, then

You check the distance on each row, then

If that distance fails your check, you are returning -1 as the index, then

You are not checking the index on the returned variable, you're instead just blindly removing that index from queue, then

Because queue is a vector of row numbers and -1 is not a row number, you get an exception when you try to remove -1 from your queue.

The part that I don't have time to get into here is your intent. Why are you trying to do with your code? You are running

while queue:
    u = self.minDistance(dist,queue)
    queue.remove(u)

This will remove all the entries in your queue until queue is null/empty, but as mentioned above self.minDistance will return -1 unless the dist[i] < minimum and i in queue.

I can't tell what your intent is, but I think maybe you should just be calling u = self.minDistance once and not repeatedly. This hunch seems to be further confirmed by looking a few lines down in your code:

while queue:
    u = self.minDistance(dist,queue)
    queue.remove(u)
for i in range(col):
    if graph[u][i] and i in queue:

If you are running queue.remove(u) until queue becomes empty/null, then how does it exist later when you check if graph[u][i] and i in queue?

I would guess instead of:

for i in range(row):
    queue.append(i)
while queue:
    u = self.minDistance(dist,queue)
    queue.remove(u)
for i in range(col):
    if graph[u][i] and i in queue:

would you would want

for i in range(row):
    queue.append(i)
u = self.minDistance(dist,queue)
for i in range(col):
    if graph[u][i] and i in queue:

but I'm not a python user and haven't looked more at your algorithm.

At a minimum, though, if you are going to do queue.remove(u) then you need to check if queue contains u first. If it doesn't then print yourself a nice warning and I'd bet that'll reveal your issue.


问:
How to calculate the ground truth of your own simple dataset for testing your SLAM Algorithm?
I have tested my SLAM algorithm on EuRoC, TUM and KITTI Datasets. But I would like to test on my own custom dataset. Moreover, I already rectify how to make my own dataset in TUM dataset format, but I didn't know how to calculate the ground truth of my own data set so that I calculate the accuracy of my SLAM algorithm.

Would kindly provide me any suggestions and recommendation?

Thank you.

答: This depends on how you acquire your data. You can either manually label ground truth or use sensors such as GPS. I have used GPS data with RTK corrections (sub cm accuracy) as ground truth in the past. You could also place markers such as AR/april tags at known locations in your surroundings and use their measurements in your dataset as ground truth.</p>

ContentLicense: CC BY-SA 4.0


问:
Why Hydraulics and Not Motors?
I have noticed everywhere that professional robotics companies use hydraulics over electric motors. I want to know why that is. Why can they make custom electric motors that are really powerful. Surely that would be cheaper than buying hydraulic fluid, solenoids, pumps, etc. Could someone please explain why that is?</p>

答:
Hydraulics and pneumatics let you separate the mechanical power generation component (compressor, hydraulic power unit, etc.) from the actuator. In the case of something like a robotic arm, this means that you only have to move the actuator.

Consider a gripper on a robotic arm. If you're going to use a motor, then you have to determine how quickly you want the gripper to open and close and how much force you want the gripper to be able to apply; this would determine the gearing and motor specifications.

You can use a smaller motor and get high grip forces with a high gearing, but then you are moving at a slow speed. If you want a high-speed, high-force gripper, then you need to have a larger motor.

The issue then is that your motor, driving the gripper, is at the very end of the robot arm. This increases the torque requirements on all the other joint motors, which have to support that large motor on the end effector.

The alternative is to use hydraulics or pneumatics. A cylinder is a hollow metal tube with a plunger inside. The weight of the actuator is relatively independent of the hydraulic motor, which can be moved off the arm.

When you move the motor off the arm you reduce the weight limit on the other joints, but you also reduce your motor requirements. You are now able to use a low-efficiency (read: cheap) motor to pressurize the hydraulics. If you have one hydraulic power unit then you can probably run multiple hydraulic actuators simultaneously; the incremental cost of getting a marginally larger hydraulic power unit is probably less than the cost of another high-performance electric motor.

The hydraulic cylinders themselves are remarkably cheap; here's one (no affiliation) that is rated for 9,500 lbf with an 8 inch stroke for \$120, here's an electric actuator (again no affiliation) that does about 1/8th of the force (1,200 lbf) at a 50% duty cycle for \$800.

Title: Why Hydraulics and Not Motors?


问:
How do you send multiple data bytes to Irobot Roomba via python serial
So I'm trying to send commands to my Roomba Discovery via python serial and it works fine as long as it only requires the command opcode. The commands that require additional data bytes (like specific movement or music) don't seem to be working. It's an old roomba, however, I do not believe that is the issue as I am able to use Java based applications like RoombaMidi2 from hackingroomba.com. The code below works fine to have the roomba clean for 5 seconds then sleep:

```<code>import serial
import time
import struct

ser = serial.Serial("/dev/ttyUSB0", 57600)

ser.write(bytes([128])) # 128: start command
ser.write(bytes([131])) # 131: Safe Mode
time.sleep (0.25)

ser.write(bytes([135])) # 135: clean command
time.sleep (5)

ser.write(bytes([133])) # 133: puts robot to sleep
ser.close()
</code>```

But if I want to do a move command it doesn't seem to work. I've tried:

```<code>ser.write(bytes([137]))
ser.write(bytearray([255, 56]))
ser.write(bytearray([1, 244]))
</code>```

No error, but it doesn't do anything. I've also tried sending it as 1 byte array:

```<code>ser.write(bytearray([137, 255, 56, 1, 244]))
</code>```

Any idea on what I'm doing wrong?

答:
I'm not sure if this helps or not, but Discovery models manufactured before November 2005 do not contain the entirety of the SCI set. For more information on this, see the first paragraph of the SCI specification for Discovery Series. It is possible that your robot is one of the unlucky ones. Unfortunately, I'm not aware that the OSMO upgrade modules for these robots are still available (I am 99.9% confident iRobot no longer makes or stocks them). It is possible that your problem is not a Python one but a compatibility one. What's the manufacture date on your robot?

Please note that I am an iRobot employee, but the postings on this site are my own and don't necessarily represent iRobot's positions, strategies, or opinions.


问:
Drone lost traj recovery
So I am using slam algorithm to localize the drone which is gps denied . The input to the slam algo is imu data and a video .
Now after the first run of the slam algorithm it creates the trajectory files .so if my video was 600 seconds long it creates traj file upto 400 sec . And then it looses the traj and hence no xyz position from 400-600 seconds . Is there any way I can use the first 400 seconds and I have imu data ,angular velocity and velocity information as well to get those xyz values from 400 sec to 600 sec ?

Edit:

I am using maplab as a slam algo as it takes imu data as an input

Do you think there is something wrong with the imu data at timestamp 400 and beyond ? Or is it maplab doesn't detect key points on the video properly ?

I am thinking of using extended kalman filter from 400 sec to 600 sec and using the output of maplab at timestamp 399 as an input (basically the xyz and the quaternion) to the extended kalman filter . I am new to this so I don't know if EKF is the ticket ,but it appears to be . Maybe you can suggest otherwise or confirm ?

Also how can we know/verify imu is outputting junk ?

答:
The any way would be SLAM itself. The point of SLAM is to reconstruct a trajectory given sensor inputs. That's just semantics though. I'm guessing you want to know how to handle failed sensor cases. If so, you have to detect those cases and reject the results. This can be done with multi-hypothesis SLAM or particle filters, but are significantly more complicated and I'm not aware of tools that do this automatically. You will likely have to manually massage the data until the trajectory reconstruction works better.

If you just want a good result for this run:

Inspect the video / imu data after 400 seconds.. Is it junk? Trim the video using ffmpeg and try again.

Is the IMU outputting junk? Run with camera only.

Honestly, without information about how you're doing SLAM, I can't say.  I'd recommend plugging the whole thing into maplab and see what you get. For video-only you could try a structure from motion pipeline such as OpenSFM.

Title: Drone lost traj recovery


问:
Re-Calibration of an articulated industrial robot
We are planning to recalibrate ABB IRB 1410 robot and conduct series of accuracy & repeatability tests using FaroArm.

My questions are

i) Is there any physical identification marker on the robot which can be used to identify the location of base co-ordinate frame?

ii) If locating the base frame is not possible, can accuracy be measured from fixed arbitrary point in space?

答:
There is reference points on the robot for calibration, including one on the base.

Page 123 of this manual lists them:
http://lecture.sccsc.edu/amt/AMT%20206%20Electricity%20and%20Automation/ABB%20IRB%20140%20Robot/files/3HAC026320-001_revB_en.pdf

ABB does not calibrate the robot by finding the x,y,z position of the effector hand by direct measurement. They calculate it by zeroing the joints rotation sensors, and using that to 'blind reckon' x,y,z position from the 'home position'

The problem is that the manufacturers calibration system requires the manufacturers special pendulum calibration tool. More details on the mark locations and the calibration process is this manual:
http://www2.tec.ilstu.edu/students/ABB%20Robots/IRB1600_Manuals/files/3HAC16578-1_revC_en.pdf

You may be able to rent the calibrator from ABB.

If you don't have the calibration tool, then you may be able to reference using a machinists level, a accurate ruler, and a fair amount of patience!

ContentLicense: CC BY-SA 3.0


问:
How to find angular velocity using pure pursuit algorithm?
I have implemented the pure pursuit algorithm for my differential wheeled robot as described in the following paper:

http://www.enseignement.polytechnique.fr/profs/informatique/Eric.Goubault/MRIS/coulter_r_craig_1992_1.pdf

Such that the steering angle is given by λ=2x/l^2

I want the robot to have a constant linear velocity V (say of 0.5m/s) but I am unsure of how I'd go about finding the angular velocity ω using this calculated steering angle.

I wish to plug the angular and linear velocity into the following inverse kinematics formuala for a  differential wheeled robot as shown in the figure below.

Where the formulas are described in section 3.2.2 'Introduction to Autonomous Mobile Robots' found here:

https://ieeexplore.ieee.org/book/6267528

I'm unsure of what I need to do to translate the steering angle into a form where it can be input into the formula described above for each of the wheel speeds. I'm sure there is a simple solution but I am lost as to the next steps to take

答:
You can set the angular velocity to whatever you want, that's the control input and depends on the algorithm. You have to set it to be something proportional to the difference in the desired angle (from the intercept trajectory) and the actual angle as measured. You then update the desired angle and velocity and re-calculate.

Try this:

https://robotics.stackexchange.com/a/12497/163

Which will show you how to derive angular velocity as a function of desired heading / speed to a fixed point. Then note that in the paper you linked, they do the same, calculating a velocity that converges to a "look ahead" point.


问:
Attaching electronics to a very bad chassis
I had a misfortune to buy this very poorly made tracked chassis.

I now have some Arduino-based controller to attach to it. I see three posts with what seems to be holes for screws, and two of them even appear level :). Nothig I find on the internet matches the layout. In fact, there is no documentation on that chassis that would describe the layout.

Is there some generic part I could customize to cover this situation? Any tips and tricks for attaching PCBs to chassis would be appreciated.

答:
If you need to use a chassis so poorly made, its manufacturer has pushed you out of the realm of engineering and into tinkering.

I would suggest that you release yourself from the desire for precision, elegance, and beauty. Instead, embrace the embarrassment of cardboard, foamcore, X-acto knives, hot glue, and toothpicks.

Especially when it's necessary, such tinkering can actually be freeing. Commenter jsotola might agree.


问:
How to find Inverse Kinematics solution to 6 link manipulator planar robot using DH parameters
I want to find out the inverse kinematics solution of 6 link manipulator planar robot, using DH Parameters, but I don't know how to, I know how to calculate for 3 link manipulator but not for 6 links, I found out that we have to use Inverse Transformation Matrices for higher DOF problems but I was not able to find the solution even with those, and I couldn't find any example either, in which they would show how to solve this problem. Can anyone tell me the solution to this problem or provide me with a link to the solution?</p>

答:
This question is a bit too broad to answer here.  I recommend you find a good robotics manipulation textbook and work through it.  Here are three classics:

Robotics: Modelling, Planning and Control by Bruno Siciliano, Lorenzo Sciavicco, Luigi Villani, and Giuseppe Oriolo.  Available on Amazon or pdf.

Robot Modeling and Control by Mark W. Spong, Seth Hutchinson, and M. Vidyasagar.  Available on Amazon or pdf.

A Mathematical Introduction to Robotic Manipulation by Richard M. Murray, Zexiang Li, and S. Shankar Sastry.  Available on Amazon or pdf.

But there are many others on the topic.  I prefer the first book by Siciliano et al.  Note that the last book by Murray et al uses a different formulation for kinematics.  They use Product of Exponentials instead of DH Parameters.


问:
Determining the turn of robot using gyroscope and accelerometer data
I have the "x", "y" and "z" readings of gyroscope and accelerometer. From these readings I want to interpret that wether my robot took a right turn or left turn. Can some one guide me how should I proceed?</p>

答:
Just monitor the rotation velocity of z-axis (z value from gyroscope or any other axis according to your setup).

If the value is over some threshold and the sign is positive, it is turning left. If the sign is negative it is the right turn.

The right way to do this is to accumulate the value stream and see if the accumulated angle is near to 90 or -90 degree. But it would be difficult for you.


问:
Robots without microcontrolers (beam robots). Are they technologically limited?
BEAM robotics seem to be a good approach to teach learners about electronics in robotics. But can these robots be like regular programmed "cognitive" robots? Can these robots, with just analog circuits, take us to the level of robotic assistants, worker robots and other kinds of self sufficient autonomous robots?

I specifically want to know that, when creating mission critical robots ->

1) What are the areas in robotics which are practically impossible without a real time software system?

2) What areas of the field can be done without programming? If yes, are these areas feasible without an onboard software system?

3) Could an intelligent space rover, work without a cpu in the future?

答:
If we are defining BEAM robots as ones that do not use microprocessors, and only use analog circuits, then yes I think it is possible, but not practical.

A microprocessor is essentially a programmable circuit, and if we define what we want our robot to do, then we should be able to program the hardware (by building the proper circuit) without needing a microprocessor and programming software for it.

To answer your sub questions:

1) Without a real-time software system you can still have a real-time hardware system, so the only areas that would be impossible are areas where the robot needs to be functionally flexible and programmable post-manufacturing.

2) As answered in 1), all robots can be manufactured without software as long as the "programming" is defined in the hardware circuitry and doesn't need to change.

3) Yes.

Note: I'm not a hardware expert, please correct me if I'm wrong.


答:
Expanding on the answer given by C.O Park and comment by Ben.

The gyroscope and accelerometer will give you 6 sensor values corresponding to the $x$/$y$/$z$ linear accelerations and the $x$/$y$/$z$ angular velocities. If you are looking to interpret whether your robot is turning left or right at any particular moment then you can simply check the sign of the angular velocity about the z-axis (assuming you are taking z to be the vertical direction). If you are looking to interpret whether your robot has turned left or right relative to its original direction then you can keep track of an accumulated angle through numerical integration. A simple algorithm for this would be the following:

Let $\theta(t)$ denote the rotation about the vertical axis (also called heading angle) at time $t$. Let $\omega(t)$ denote the angular velocity about the vertical axis at time $t$. Every $t_s$ seconds you will take a measurement of $\omega(t)$ from your gyroscope sensor. The rotation can then be estimated by
$$\theta((k+1)t_s) = \theta(kt_s)+\omega(kt_s)t_s,$$
where $k$ is an integer that denotes how many measurements you have taken so far. $\theta(0)$ can be assumed zero since it is your initial direction. In words, the heading angle at timestep $k+1$ is the heading angle at timestep $k$ plus the rotation that occurred during that timestep. Then to interpret whether your robot has turned left or right relative to its original direction you can look at the sign of $\theta$. In pseudocode:

```<code># intialize heading angle estimate
theta = 0;

# update information every ts seconds
loop:

    # read sensor and update estimate
    omega = read_rotation_rate();
    theta = theta + omega*ts;

    # check turning direction
    if omega > 0: turning = left;
    else if omega < 0: turning = right;

    # check net direction
    if theta > 0: turned = left;
    else if theta < 0: turned = right;
</code>```

In practice there will be some complications like sensor noise and drift that will result in errors in your estimate of the heading angle, but this should provide you with a starting point.

Title: Determining the turn of robot using gyroscope and accelerometer data

Body: I have the "x", "y" and "z" readings of gyroscope and accelerometer. From these readings I want to interpret that wether my robot took a right turn or left turn. Can some one guide me how should I proceed?</p>

Body:
Expanding on the answer given by C.O Park and comment by Ben.

The gyroscope and accelerometer will give you 6 sensor values corresponding to the $x$/$y$/$z$ linear accelerations and the $x$/$y$/$z$ angular velocities. If you are looking to interpret whether your robot is turning left or right at any particular moment then you can simply check the sign of the angular velocity about the z-axis (assuming you are taking z to be the vertical direction). If you are looking to interpret whether your robot has turned left or right relative to its original direction then you can keep track of an accumulated angle through numerical integration. A simple algorithm for this would be the following:

Let $\theta(t)$ denote the rotation about the vertical axis (also called heading angle) at time $t$. Let $\omega(t)$ denote the angular velocity about the vertical axis at time $t$. Every $t_s$ seconds you will take a measurement of $\omega(t)$ from your gyroscope sensor. The rotation can then be estimated by
$$\theta((k+1)t_s) = \theta(kt_s)+\omega(kt_s)t_s,$$
where $k$ is an integer that denotes how many measurements you have taken so far. $\theta(0)$ can be assumed zero since it is your initial direction. In words, the heading angle at timestep $k+1$ is the heading angle at timestep $k$ plus the rotation that occurred during that timestep. Then to interpret whether your robot has turned left or right relative to its original direction you can look at the sign of $\theta$. In pseudocode:

# intialize heading angle estimate
theta = 0;

# update information every ts seconds
loop:

    # read sensor and update estimate
    omega = read_rotation_rate();
    theta = theta + omega*ts;

    # check turning direction
    if omega > 0: turning = left;
    else if omega < 0: turning = right;

    # check net direction
    if theta > 0: turned = left;
    else if theta < 0: turned = right;

In practice there will be some complications like sensor noise and drift that will result in errors in your estimate of the heading angle, but this should provide you with a starting point.


问:
difference between the two constructors
What is the difference between the 2 pieces of code -

```<code>tf2_ros::Buffer buffer(ros::Duration(10));

costmap_2d::Costmap2DROS costmap_one("costmap_one", buffer);
</code>```

and

```<code>costmap_2d::Costmap2DROS *costmap_one = new costmap_2d::Costmap2DROS("costmap_one", buffer)
</code>```

I understand that in the first case, we get a costmap_2d::Costmap2DROS object named costmap_one whereas in the second case, we get a pointer named costmap_one that points to a costmap_2d::Costmap2DROS object.

When should we use one over the other?

答:
IMHO the main difference is, that inside function/method the first one (object) is allocated on the stack and destroyed after leaving the function, while the other (pointer) allocates its data on the heap, so it can be safely returned from the function and survive its end. It must be destroyed more explicitly, when you want to get rid of it.

Allocating on the stack does not fragment the memory and living scope is clearly visible.
Allocating on the heap may fragment the memory, may stay living much longer than needed and its living scope is much less clear - but can be used for making more complicated structures such as graphs, buffers and similar ...

Title: difference between the two constructors


问:
How to investigate the relation between planning frequency and control response?
I have a speed control system which is part of a hierarchical planning and control stack. The final output of this system is torque and the input is desired speed. The system is experiencing some oscillation which seems related to the highest level of the target speed planning frequency. I have a hunch that the different operational frequencies of various levels of the stack might be having an impact, but I am unsure how best to investigate and quantify the impacts. So I am wondering the following:

What are the terms I can use to find information about the impact of input frequency on control response?

Are there any well known approaches to analyzing the relation between input frequency and control response so I can more clearly conclude if this is the issue?

The system is developed using ROS, so if there are any ROS package which might help the analysis please let me know.

答:
This seems like an interesting question! Read it once and haven't put a ton of thought into this, but my gut reaction was a disturbance model.

Suppose you had some optimal path, $P$. Your path planning could be attempting to map that optimal path, but the calculated path might be constantly updating based on noise in sensor readings, localization estimates, etc.

Your path updates are occurring on some sample interval, which is introducing a disturbance input on the input-side of your control loop. I would try running some models that inject noise at the same frequency and see if that reproduces the results you're seeing.

I don't know what form of control you're using for the controller, but disturbance rejection should be well-studied regardless of the format.


问:
How do industrial robots solve the inverse kinematic problem?
I want to make a real-time end-effector position control simulation of a 6 DOF robotic arm. To do so, I should solve the inverse kinematic problem, but due to the complexity of calculations, it is impossible to do that in real-time. As I know, industrial robots like KUKA or ABB can solve the inverse kinematic problem in real-time. Can anyone help me with the algorithms and explain those solutions to me?</p>

答: Closed-form inverse kinematic equations are used to determine joint angles based on the end effector pose.  These equations are well established in the literature.  For example, the classic robotics books by Craig or by Paul show the equations for typical 6dof industrial arms.</p>


问:
Center of Mass of a Box
If I have the following area-split box:

Depending on the mass distribution of the box, the center of mass (CM) could be inside the light gray area labeled A, the red area labeled B, the blue area labeled C, the pink area labeled D, the green area labeled E, the yellow area labeled F, or the dark gray area labeled G. These areas come close to, but do not touch, the dashed force lines that bound them.

During quasistatic pushing, the contact forces acting on the box, from the pushing finger and the table, must balance the downward gravity force. If the contact mode is SrSr (the box slides to the right without tipping) as the finger moves to the right, in which areas might the center of mass be?

This is for a course I'm taking now, and I have tried every possible answer and it didn't work.

答:
Let's consider the rectangle to be in a vertical plane, all one single rigid part. The bottom edge is the one resting on the table.
Since you specified quasistatic, we only care about the first infinitesimal motion. If the box starts sliding, we don't care about tipping. If it starts tipping, we don't care about sliding.

Nothing in the problem statement quantifies the coefficient of friction, so we'll have to carry it around symbolically. We might have to do the same with the finger height.

We will compute the forces and torques that resist tipping and sliding. If tipping occurs, the rectangle will rotate about the bottom-right corner, so we'll put the origin there.

Definitions

point $O$: the bottom-right corner. This is the origin of the coordinate system. Coordinate $y$ increases going up, $x$ increases to the left.

point $C$: the center of mass

$X$, $Y$: coordinates of point $C$

$h$: the height of the finger above table

$F$: the horizontal force of the finger pushing

$W$: the weight (mass * g)

$\mu$: coefficient of (static) friction at the table.

Tipping

First, consider the tipping torques at point $O$. The finger is trying to rotate the box clockwise. The rectangle's weight is trying to rotate it counterclockwise.

The force $F$ pushing from the left (between area B and area D) is equivalent to a force pulling at the right (between area C and area F). Operating at height $h$, that applies a torque of $F h$.

Consider the weight $W$ to be concentrated at the center of mass $C$ (that is, at $(X,Y)$). It's trying to rotate the rectangle counter-clockwise about $O$. The downward weight vector operates about $O$ with moment arm $X$. So the torque due to weight is $W X$.

The box will tip (if it doesn't slide) if the torque at $O$ due to the finger exceeds the torque due to gravity $F h > W X$. Call the limiting tipping force $F_{tip}$:

$F_{tip} = W X/h$

Sliding

Now examine the friction at the table. The max friction force is $W \mu$, pushing horizontally to the left (countering the finger). It cannot exert any torque at $O$. Thus the box will slide (if it doesn't tip) when the finger force exceeds the friction. Call the limiting force $F_{slide}$:

$F_{slide} = W mu$

Comparison

Imagine the finger gradually pushing harder and harder.  At first, nothing happens.  Eventually, the box will start to move. It will either tip or slide, depending on which of $F_{tip}$ or $F_{slide}$ is reached first -- that is, which one is less. In comparing the two forces, both have a factor of $W$ which we can divide out. So comparing $X/h$ with $\mu$:

slide if $X > h*\mu$

We can sanity-check this by looking at limiting cases.  High friction (high $\mu$) means $X$ can't be large enough so it will tip. With no friction (zero $\mu$) any $X$ will let it slide. If $X=0$ ($C$ anywhere on the right edge) it will always tip.

Conclusion

Restated, the box will slide if $C$ is to the left of $h \mu$. The boundary between the tip region and the slide region will be vertical. (It is curious, perhaps suspicious, that the results do not depend on $Y$, the height of point $C$.)

Recall that the problem statement doesn't specify anything about $\mu$. Neither does it say those angles that look like 45 degrees really are, so we can't relate $h$ to the width. Without that critical information, I don't see any way to connect analysis to geometry in order to answer the question about the regions.

Title: Center of Mass of a Box


答:
Well, I embraced my inner Tinkerer as @r-bryan and @jsotola suggested. Index cards and sewing needles and toothpicks and a digital caliper. Also QCad :) .

For any unfortunate who got stuck with the "3V-7V Light Shock Absorbed Smart Robot Tank Chassis Car DIY Kit With 130 Motor" (I place the full thing here advisedly to make it findable), here is the cad file that got me there. Print it, tape to the rectangle of a plastic of your choice, drill the holes as indicated. Your plastic will fit. The thick column that goes through the plastic will need a spacer of ~2.5 mm under it, I am yet not done with that part. But the holes fit, as tested by the two toothpicks.

Title: Attaching electronics to a very bad chassis

Body:
I had a misfortune to buy this very poorly made tracked chassis.

I now have some Arduino-based controller to attach to it. I see three posts with what seems to be holes for screws, and two of them even appear level :). Nothig I find on the internet matches the layout. In fact, there is no documentation on that chassis that would describe the layout.

Is there some generic part I could customize to cover this situation? Any tips and tricks for attaching PCBs to chassis would be appreciated.


答: 3 motors from the base decide the xyz position of the end effector and the other 3 on the tip decide the rotation of it. This is a really simple model as Steve mentioned. I don't know how much speed do you need but it will easily reach 10kHz and over to numerically solve the inverse kinematics with a modern computer and modern lib such as ceres.</p>

Title: How do industrial robots solve the inverse kinematic problem?

Body: I want to make a real-time end-effector position control simulation of a 6 DOF robotic arm. To do so, I should solve the inverse kinematic problem, but due to the complexity of calculations, it is impossible to do that in real-time. As I know, industrial robots like KUKA or ABB can solve the inverse kinematic problem in real-time. Can anyone help me with the algorithms and explain those solutions to me?</p>


问:
Good Microcontrollers/SOCs for a Robotics Project
I am looking for a starting point for my project, preferably using popular systems (ones there is a lot of support for). I have an Arduino Uno, a Raspberry Pi, and a lot of willpower :) Anyone here built a project using the systems above?

Observation: I'd like to start with a simple line-following vehicle and build up afterwards.

答:
I would suggest using lower end Atmel AVRs for beginning robotics projects.  An AVR can take a lot of abuse and can sink and source more current without burning out than the PIC microcontrollers I have used.

If you are going to be building multiple projects, you should consider investing in building your own breakout boards.  You can design your own PCB with standard power circuitry, a bunch of headers for I/O and whatever microcontroller you choose.  You can get your cost down to around $15 per board for the PCB and then a couple bucks worth of components.  This way, you can leave your project intact, instead of having to harvest out the microcontroller for your next project.  As a bonus, you will gain valuable experience in PCB design and soldering.


问:
Suitable control algorithm for Air Muscle based joint?
I have a joint actuated by an antagonistic pair of Pneumatic Muscles.

There are two valves per muscle, one to fill and one to empty each muscle. The joint has an angle sensor, and each muscle also contain an air pressure sensor.

What is a suitable control algorithm set up?

A PID controller controlling the valve orifice sizes?

A PID controller controlling the mass flow rate?

A PID controller controlling the pressure using two PID pressure controllers?

A Fuzzy Logic controller?

A Neural Network?

答:
According to the Wikipedia page on Pneumatic artificial muscles:

This is one of the major advantages; the mathematical model that supports the PAMs functionality is a non-linear system, which makes them much easier [citation needed] then conventional pneumatic cylinder actuators to control precisely. The relationship between force and extension in PAMs mirrors what is seen in the length-tension relationship in biological muscle systems.

I'm not convinced that non-linear functionality would make them easier to control, in fact in my experienced, non-linear systems are substantially less easy to control than linear systems.

This article references a number of papers which may form the basis of useful research into the kinematics of these devices. In particular Pneumatic Artificial Muscles: actuators for robotics and automation look slike it would be quite useful as a review of the research, including plenty of citations for following up.

I would guess that these air muscles suffer many of the same myths and prejudices that Proportional Pneumatic Motion Control system have, so reading up on these systems might be useful too.


问:
How to remap /move_base_simple/goal to my own topic in turtlebot3_navigation?
I am running turtlebot3_navigation and want to make it subscribe to my own waypoints topic /my_waypoints rather than RVIZ's Set 2D Goal topic /move_base_simple/goal. What I actually want to do is roslaunch turtlebot3_gazebo turtlebot3_world.launch /move_base_simple/goal:=/my_waypoints. Command-line remapping of topics isn't working in this case, neither the remapping in launch file /opt/ros/kinetic/share/turtlebot3_navigation/launch/move_base.launch.

Can anyone please help me remapping the topics?

答:
You cannot rename topics in your node and use them from the command line. If you want to use command line, you have to define them as args before the node. In your case, under arguments, define:

```<code><arg name="goal_topic" default="/move_base_simple/goal" doc="goal topic for turtlebot3"/>
</code>```

and in your remap,

```<code><param name="/move_base_simple/goal" value="$(arg goal_topic)"/>
</code>```

Then you should be able to use it over he command line as:

```<code>roslaunch turtlebot3_gazebo turtlebot3_world.launch goal_topic:=/my_waypoints
</code>```

Body:
You cannot rename topics in your node and use them from the command line. If you want to use command line, you have to define them as args before the node. In your case, under arguments, define:

<arg name="goal_topic" default="/move_base_simple/goal" doc="goal topic for turtlebot3"/>

and in your remap,

<param name="/move_base_simple/goal" value="$(arg goal_topic)"/>

Then you should be able to use it over he command line as:

roslaunch turtlebot3_gazebo turtlebot3_world.launch goal_topic:=/my_waypoints


答:
Some common accelerometer/gyro chips have built-in processor that performs integration for you. An example I am familiar with is MPU-6050.

Given that capabilty, you can get the ready-made data for current direction of your chip directly from the chip using I2C.

Please search for "mpu 6050 dmp" to see some examples.


问:
How to calculate Current for pancake stepper motor - To change in Pronterface
DISCLAIMER: New to electrical engineering topics. I'm a 3d-printing hobbyist. I don't know all the Jargon being used but trying my best to keep up.

PROBLEM

Recently bought a Nema 17 stepper pancake motor to replace the Ender 3 extrusion stepper. It's only used for direct extrusion with a BMG 3/1 gear ratio, which leads me to believe it doesn't need a lot of juice to have it work optimally.

```<code>*Got this from TriangleLab:*
</code>```

https://www.aliexpress.com/item/32768043304.html?spm=a2g0s.9042311.0.0.27424c4d4HQcug

This thin stepper is running very hot. Via pronterface and/or octoprint, I adjusted the "current" from the default ender 3 E850 to E50, using command M906 and saving with M500.

```<code>It is still running hot and TriangleLab hasn't been very forthcoming.
</code>```

NOTE: i'm not sure what "current" is being referred to, amps or voltage. I just followed this youtuber's advice for the adjustment...

Used this guy's method: https://youtu.be/GHUr1a3nXDU

Question

How do I know if the stepper is running TOO hot?
(not sure what the consequences of a hot stepper might be, other than the thing burning out and becoming a fire hazard.)

Is there a calculation that is better than just eyeballing the situation and doing random tweaks?

Any info would be much appreciated.
Thanks in advance.

```<code>**Triangle Lab's Stepper specifications**

NEMA 17

 - 1.8° Step Angle
 - 200 Steps Per Revolution
 - 1.0 Amp
 - per phase 5.1 Ω 5.9mH
 - 21 N/cm Holding Torque
 - 23mm Body
 - 20mm Output Shaft(5mm diameter)(17mm D-Shaped)
</code>```

......

答:
Ender 3's stock mainboard does not allow you to set driver currents in firmware, as it requires a TMC driver in UART mode and creality 1.x and 4.2.x mainboards run the stepper drivers in standalone mode. There's a little screw pot by each driver for setting the reference voltage.

This might be helpful https://teachingtechyt.github.io/calibration.html#steppers

Note whilst TMC drivers use rms current, supplied formula VREF = (RMS current * 2.5) / 1.77 simplifies to VREF= RMS Current * 1.41 so VREF ~= peak current for your convenience.


问:
Stepper Motor: Direct Drive vs. Belt Drive vs. Geared Stepper Motor
I have built a juggling machine. Each arm is driven by a 4A 23mm stepper motor. The motors are each driven by a TB6600 set to 800 microsteps. By trial and error, I have found that the motors skip when the drivers are set at 2A (running at 36v) but not when set at 3A.

The motors are directly attached to the panto-graph arm mechanism. Each arm makes 81 start-and-stop revolutions per minute. The each arm is at rest for 25% of the time. I believe this causes the arms to jerk and induces error into the balls trajectory.

The obvious advantage of direct drive is simplicity. The next easiest options are belt drive or a geared stepper motor.

Would a geared or belt drive help reduce the vibration in the mechanism?

Would I be able to run the drivers at a lower power setting if I used gearing?

This is the Arduino Code.

Video of the machine running.

答:
Vibration is a matter of optimal motion control problem, not the type of motor that is used (as long as you used more than 16 micro steps for your steppers). You already used AccelStepper which is the best thing you can do without the complicated motion control.

If your system still works with slower speed than your current motor speed you are good to use a geared motor and lower your motor current. But if you need the same speed as the motor without gear, you need to rotate the stepper very fast which requires either high current or high voltage. For example, if your gear is 1:5 you need to run your stepper five times faster to achieve the same rotation speed.


问:
ROS Webcam Stream Really Slow
I am trying to stream the images from my camera to a VM via ROS. Here is my setup:

Raspberry Pi 3B+ with Picamera v2. It is running ROS Noetic with cv_camera_node

An Ubuntu 20.04.1 VM with ROS Noetic. I am reviewing the live stream using rosrun rqt_image_view rqt_image_view

When I tried this, the stream is really laggy and slow. I am barely getting 10 fps. I was able to do camera calibration with it but mapping with it will be really challenging. Is there any way to speed it up. Can I decrease the quality of the camera capture? Any help is truly appreciated.

Here is my launch file:

```<code><launch>
  <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video0" />
    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="pixel_format" value="uyvy" />
    <param name="camera_frame_id" value="camera" />
    <param name="io_method" value="mmap"/>
    <param name="framerate" value="30" />
    <param name="autofocus" value="true" />
    <param name="camera_name" value="camera" />

  </node>
  <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
    <remap from="image" to="/camera/image_raw"/>
    <param name="autosize" value="true" />
  </node>
</launch>
<span class="math-container">```
```

答: The problem is that you are using VMWare. For some reason, when I used a physical machine with ROS and Ubuntu, it worked! Maybe there is a fix in VMWare. If anybody knows the solution, they are free to explain.</p>

Title: ROS Webcam Stream Really Slow


答:
On the theory side, this is related to the Nyquist Sampling Rate, which is how frequently you must measure a single to get an accurate reconstruction of it's peaks / valleys.

Not suprisingly, Nyquist as a name appears all over some fundamental results in optimal control like the nyquist stability theorem. I suspect the insight you are looking for is right there, but understanding it will require some study. Begin with Nyquist stability, and follow the keywords "Stability, Optimal Control, Sampling Rate", and probably "Nyqist" on Google Scholar. Start with textbooks on optimal control. Understanding the state of the art is actually near impossible from paper sampling (that's where you go to understand what's just beyond the SoA).

On the practical side, I have never seen anything done except the following:

Increase the low-level controller to the maximum possible rate (e.g., 100Hz). This loop tries to achieve velocities.

Decrease the input to the controller (desired velocities) to the minimum rate and increase only as necessary (e.g 1Hhz). This loop tries to follow paths.

Re-plan paths very infrequently (e.g., every few seconds or slower).

For time-critical events like hazard avoidance, the robot just ceases these loops temporarily and goes into a hard-coded avoidance maneuver (e.g., BRAKES!) until it can replan.

Title: How to investigate the relation between planning frequency and control response?

Body:
I have a speed control system which is part of a hierarchical planning and control stack. The final output of this system is torque and the input is desired speed. The system is experiencing some oscillation which seems related to the highest level of the target speed planning frequency. I have a hunch that the different operational frequencies of various levels of the stack might be having an impact, but I am unsure how best to investigate and quantify the impacts. So I am wondering the following:

What are the terms I can use to find information about the impact of input frequency on control response?

Are there any well known approaches to analyzing the relation between input frequency and control response so I can more clearly conclude if this is the issue?

The system is developed using ROS, so if there are any ROS package which might help the analysis please let me know.


问:
gear motor with encoder and Arduino Uno
I'm working on a project where using a gear motor with an encoder and an Arduino Uno. I have not done Arduino in a long time and am struggling getting it to do what I want. If you look at the wiring guide for the motor below here is what I have currently wired up:

1 - M1 (-) wired to the ground of the voltage source, 2-GND Encoder wired to the GND pin on the Arduino, 3-Encoder A phase wired to Pin9, 4-Encoder B phase wired to Pin10, 5-3V3 Encoder + wired to 3V3 pin on the Arduino, 6-M1 motor (+) wired to the hot voltage source.

When I supply a voltage source the motor begins to spin. I want the motor to start not moving even when the power is supplied. Then I want to be able to set the angle that the position of the motor will turn to that spot and have it stop moving. I will then turn off the power supply and the motor will stay in that position until power is supplied again a new position is programed into the code. This motor can rotate in both directions. Please help even suggestions what commands to use will be great.

答:
The motor should not be connected directly to your power source since this will not allow it to be controlled by the Arduino. The encoder is a passive add-on to the motor (mechanical coupling only). There is no electrical connection between the encoder and the motor to allow for control of motor motion. You'll need to use the H-Bridge to allow the Arduino's DIO pins to control the motor and the encoder to provide rotation feedback to the Arduino through DIO pins so you can decide when to turn on and off the motor. This motor/encoder combination does not provide accurate rotational position, i.e. you won't be able to "tell" the motor to go to a specific angle with any reasonable accuracy.

Here is a generic application of the H-Bridge... You should find a datasheet for your specific H-Bridge for a more detailed idea of the proper application of the circuit.

Title: gear motor with encoder and Arduino Uno


问:
Are there any analog data loggers for recording PCB 353b33 accelerometer datapoints for a minute or more?
I'm currently recording data points from an analog accelerometer(PCB 353b33) using a TDS3014B oscilloscope which has a Record Length of 10,000 points at a Sample Rate of 1.25 GSa/s. Since the oscilloscope is a triggered data logging device, it's not capturing the whole cycle of the experiment.
I trying to look into analog data loggers that would help in seamless data logging for a minute or more with a good sampling rate that would help me capture data for at least one cycle. Is analog data logger the only option remaining?
I'm not sure if an analog data logger would be a good solution for my problem, so if anything else would work for my case please suggest that as well.</p>

答: There are many devices that would provide the recordings that you need. National Instruments makes a large number of DAQ devices that can record analog signals with very high fidelity. You could also use products from DATAQ. I would recommend something very cheap like the Adafruit Feather M0 Adalogger for projects that don't require the high precision of NI-DAQ or DATAQ instruments.</p>


问:
Eliminating drift generated from double integration of acceleration signal using Envelope Method
I'm trying to remove the drift generated upon the double integration of a noisy acceleration signal. But this question discusses only removing the drift upon single integration to generate velocity signal.

I'm following this research paper which uses Envelope method to remove the drift generated upon double integration of a signal.

TLDR Envelope Method for a given discrete signal $x(n)$:

Identify all the local extrema of $x(n)$

Interpolate between maxima (resp., minima) by a cubic spline to form the upper envelope $e_{u}(n)$ (resp., the lower envelope $e_{d}(n)$)

Calculate the mean of the envelopes $e_{a}(n) = (e_{u}(n) + e_{d}(n))/2$

Compute $y(n) = x(n) - e_{a}(n)$

Example I was trying to solve using envelope method

```<code>t = np.arange(0, 20, 0.1)
f1 = lambda t: 0.1*np.sin(np.pi*t) + 0.1*np.sin(20*np.pi*t) #Clean accleration signal
f2 = lambda t: 0.1*np.sin(np.pi*t) + 0.1*np.sin(20*np.pi*t) + 0.01 #Noisy acceleration signal
</code>```

Upon Single integration for velocity:

Then located maxima and minima and performed cubic interpolation to generate upper and lower envelopes respectively using CubicSpline Method from the scipy package.

Then Generated mean of the envelopes:

Then Subtracting the mean of the envelopes from the Drift prone velocity:

I don't know what I did wrong but as it can be seen in the final plot, clean signal of velocity does not match the noisy signal corrected using the envelope method.
I know there are other/better methods for correcting the baseline offsets but as starting point, the envelope method seemed easier to implement. If there are methods better than this and easier to implement, I'm all ears.

I would like to know what mistake I made along the way.

code

答: It looks like you are adding a constant for noise, so it makes sense the envelope output is a constant offset from the clean.  I would think you need to add gaussian noise to simulate more realistic noise.  Guassian noise would be centered around the clean signal.</p>


问:
Extract Euler angles from angular velocity profile
I Solved inverse velocity (joint velocity) at velocity level problem. So, I have actual orientation of the manipulator. Now I wanted to get the desired orientation from angular velocity that I used to solve inverse kinematics. So I can calculate the orientation error.
$$ \boldsymbol{V} = \begin{vmatrix} 0 \\ 0 \\ 0 \\ \hline 10 \cos(2 \pi t) \\ 10 \sin(2 \pi t) \\ 5 \cos(2 \pi t) \end{vmatrix} $$ is a velocity profile used to solve joint velocity.

Thanks

答:
Although this is quite late, I believe this question should get an answer. The solution for this problem is:
If one has no other information but the angular velocity and needs to get the Euler angles, using the relation of quaternion derivative and angular velocity is the best option I found.  Then, the quaternion derivative can be integrated numerically to get the Euler angles. Integration of quaternion derivative perfectly satisfies the property of special orthogonal group S0(3).

Let me know if otherwise.


问:
Parallel spatial mechanism - DOF

The parallel mechanism is composed of a moving platform
and a base (or frame) connected by four legs. Each leg is composed of five
revolute joints numbered 1, 2, … 5 from the base to the moving platform. The
axes of the revolute joints 3, 4 and 5 in leg 1, the revolute joints 1 and 5 in leg 2,
as well as the revolute joints 1, 2 and 3 in leg 3 are all parallel to the Z-axis. The
axes of the remaining revolute joints in each leg are parallel

I want to know the DOF. Can someone help?

答:
So I guess you want to know the DOF of the moving platform. First of all keep in mind that for a parallel mechanism with a fixed base and one moving platform the maximum degrees of freedom for the moving platform are 6, e.g. 3 rotational and 3 translational DOF.

In this case it is kind of hard to see intuitively what DOF the moving platform could reach. So I would suggest following procedure:

Imagine the legs without the revolute joints, linked to the moving platform in a way they can provide the 6 DOF to the moving platform. In this case the link should be able to change its length and be able to rotate around the joints at the base and the moving platform freely. The first example that comes to my mind would be telescopic legs with ball joints at the base and the moving platform.

Now we know what kind of motion the legs need to be able to achieve to have 6 DOF at the moving platform. This means you can analyze the legs individually to determine the actual DOF of the platform. Take the actual leg 2 for example and forget the moving platform. Think only about the leg which is attached to the base. The leg can achieve all translations and rotations, at least inside a very small workspace. (Take a minute to think about it)

Do the same for leg 1 and 3. Looking at leg 3 we can see that we could remove the revolute joints 1 and 2 and the moving platform would have the same DOF, so we only have to consider 3, 4 and 5. Where it is clear that the leg can achieve all rotations but is not variable in length, e.g. the translational motion can't be achieved and therefore has only 3 DOF. And since leg one is the same as leg 3 only in reverse, it also has only 3 DOF.

The moving platform can only achieve the DOF of the leg with the minimum DOF. This is because all legs have to provide the same 'amount' of DOF in order to achieve the DOF. This sounds a bit weird but again take a minute and think about it. For example if wanted the platform to move towards us in an only translational motion, leg 2 would try to pull the platform towards us but leg 1 and 3 would only come towards us including some rotational motion. Therefore an only translational motion would not be possible. Try to think about more restrictions. The final conclusion would therefore be that the moving platform has only 3 DOF.

Maybe somebody else knows about some special formula you can apply, but I hope this helps a bit in terms of intuitive understanding about DOF.

Title: Parallel spatial mechanism - DOF


问:
Elegant way to mathematically relate joint positions (without a root/base joint) for easy re-rooting?
I'm pretty new to robotics, but have learned about the tranformation matrices and how to relate relationships between joints using transformation matrices.

I just wonder if there is a system that represents these relationships without having to choose a root node?

The reason I'm asking is for re-rooting of an arm.

If we think of a simple robotic arm in 2-D, we usually have a base or root joint, then a few links and an end-effector.

We can then compute each joint position in the global (root) reference frame using the transformation matrices for each link.

But what if we want to suddenly switch and fix the end-effector as the new root/base and move the old root (as the new end effector)?

Normally, we need to re-create the transformation matrices from the new root out to the new end effector.

Is there a more elegant way to do this?

thanks in advance

答:
If $T^{ee}_{root}$ is the homogeneous transformation that relates coordinates expressed in the end-effector frame into coordinates expressed in the root frame, then it holds that $T^{root}_{ee} = \left( T^{ee}_{root} \right)^{-1}$.

Interestingly, the computation of the matrix inverse is straightforward and can be done by applying the rules reported in https://robotics.stackexchange.com/a/7539/6941.


问:
SLERP velocity and acceleration (3d Orientation interpolation)
Hey guys I am quite new to quaternions and I am a bit unsure as to how to use them. How are the velocities and accelerations trajectories determined using quaternions?

I have been using slerp to interpolate the orientations.

$$
\begin{align}
Slerp(Q_0, Q_1,t) = Q_0(Q_0^{-1}Q_1)^t
\end{align}
$$

Where $t$ is the interpolation parameter from $[0;1]$. I read on wikipedia that:

*The derivative of $Slerp(q_0, q_1; t)$ with respect to t, assuming the ends are fixed, is $log(q_1 q_0^{−1})$ times the function value, where the quaternion natural logarithm in this case yields half the 3D angular velocity vector.*

This is further supported by a document I found on the topic of quaternion interpolation in animation (Dam, E. B., Koch, M., & Lillholm, M., (1998)), where in equation: (6.12), they show the first and second derivative (using their notation):

$$
\begin{align}
\frac{d}{dt}Slerp(p,q,h) &= \frac{d}{dt} p (p^* q)^h \\
&= p(p^* q)^h log(p^* q)\\
&= Slerp(p,q,h) log(p^*q)\\\\
\frac{d^2}{dh^2}Slerp(p,q,h) &= p(p^* q)^h log(p^*q)^2\\
&= Slerp(p,q,h) log(p^* q)^2
\end{align}
$$

In other words, to get the second derivative of $Slerp$ you need to times the function value with $log(Q_1, Q_0^{-1})^2$.

Is this legitimate? And can I use these resulting quaternions for:

$$
\begin{align}
X_d = \begin{bmatrix}p_d\\ Q_d \end{bmatrix}, \quad \dot{X}_d = \begin{bmatrix}\dot{p}_d\\ \dot{Q}_d \end{bmatrix} \quad \ddot{X}_d = \begin{bmatrix}\ddot{p}_d\\ \ddot{Q}_d \end{bmatrix}
\end{align}
$$

where $p = [x,y,z]^\intercal$ and $Q = \{\eta, \epsilon \}$, and the dots $\dot{X}$ and $\ddot{X}$ are the respective velocities and accelerations.

Because I am not sure what to make of the results. Maybe because I don't really understand quaternions. For context here's an example:

Python:

```<code>import numpy as np
import quaternion
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.style.use('seaborn')
plt.rcParams['figure.figsize'] = [10, 15]

t = np.linspace(0,1,100)
Q = np.zeros((4,100))
Qd = np.zeros((4,100))
Qdd = np.zeros((4,100))

rot0 = np.array([[ 1.0,  0.0,  0.0],
                 [ 0.0, -1.0,  0.0],
                 [ 0.0,  0.0, -1.0]])

rotf = np.array([[ 0.0, -1.0,  0.0],
                 [-1.0,  0.0,  0.0],
                 [ 0.0,  0.0, -1.0]])

q0 = quaternion.from_rotation_matrix(rot0)
qf = quaternion.from_rotation_matrix(rotf)

for i in range(100):
    slerp = q0 * (q0.inverse() * qf)**t[i]
    slerp_d = slerp * np.log(qf * q0.inverse())
    slerp_dd = slerp * np.log(qf * q0.inverse())**2

    Q[:,i] = quaternion.as_float_array(slerp)
    Qd[:,i] = quaternion.as_float_array(slerp_d)
    Qdd[:,i] = quaternion.as_float_array(slerp_dd)

fig, (ax1, ax2, ax3) = plt.subplots(3, 1)
ax1.plot(Q.T)
ax1.set_title("Slerp")
ax1.legend(['w','i','j','k'])
ax2.plot(Qd.T)
ax2.set_title("Slerp_d")
ax2.legend(['w','i','j','k'])
ax3.plot(Qdd.T)
ax3.set_title("Slerp_dd")
ax3.legend(['w','i','j','k'])
plt.show()
</code>```

答:
I think you may have a mistake in python code.
That is:

slerp_d = slerp * np.log(qf * q0.inverse())

I think the correct one is:

slerp_d = slerp * np.log(q0.inverse()*qf)


问:
What does SE mean in robotics literature?
I've come across the abbreviation SE several times recently. I know it has to do with the pose of the robot, and the degrees of freedom. Most recently I found it on page 8 of this paper: </p>

<p>D. Kragic and H. I. Christensen, “Survey on visual servoing for manipulation,” Royal Institute of Technology (KTH), Stockholm, Sweden, Tech. Rep. ISRN KTH/NA/P-02/01-SE, CVAP259, 2002. </p>

答:
$SE(3)$ is the representation for both translation and rotation in 3D space, whereas $SO(3)$ is only the representation for rotations. $\mathbb{R}^3$ is for translations in 3D space.

If you only consider 2-dimentional space, then you can simply change 3 to 2, i.e., $SE(2)$, $SO(2)$, $\mathbb{R}^2$.

I wouldn't worry too much about it. You can just consider these as mathematical notations.


问:
How to find Joint Angles or Theta for 7DoF Robotic Arm
I am trying to find the joint angles or at least theta to be used to find the Denavit-Hartenberg Parameter for a robotic arm (Baxter's right arm). I have the link lengths and such, but I don't know how to find theta using the link lengths or anything. Help with anything would be appreciated.

答: Since that arm is redundant, there are an infinite number of solutions for the inverse kinematics.  Fortunately, Dr. Williams at Ohio U has developed the forward and inverse kinematics for this arm here.   He describes the complete forward kinematics, and the inverse kinematics two ways:  once for the case where $\theta_3$ is fixed at zero degrees, and again using a numerical approach to resolve the redundant system.


问:
Use 2 Cameras as 1 Stereo Camera
I have one Picamera and one normal USB Webcam and would like to use them together as one stereo camera. Is this even possible as the 2 cameras aren't exactly the same? I would like to use them in ROS where I want to do SLAM. If it is possible, is there a guide on how to do it because as of now, I have only been using one camera for SLAM and it is not working too well.</p>

答:
Yes, it is possible. That is often called a heterogeneous stereo camera.

Step1: stereo camera calibration.

Find relative camera location to each other (extrinsic).

Find camera lens distortion parameters (intrinsic).

Lens distortion is simply done by usual camera calibration but for the extrinsic finding, you need a bit of coding.

Step2: image rectifying

If you make the two cameras look in the same direction( same z-direction), you can make the processing a lot faster. But even if you make the hw well the z-direction can't be the same. Image rectifying makes the two images virtually parallel.

Step3: stereo matching.

Find a correspondence of a pixel on the left image in the right side image. The result is a disparity or depth map.

Step2 and 3 are where your problem is complicated due to the heterogeneous setup. It is likely you won't find an open-source code for the heterogeneous stereo camera. Even if you find one, it will be hard to use it without thoroughly understanding the stereo camera algorithm.

Camera synchronization is a big problem too especially if you need it for SLAM.

My recommendation is to try your best to void this configuration. Tell your supervisor it is semi-impossible and the expected outcome quality is way lower than a low-cost visual-inertial camera (I am sure this should be cheaper than your picam + usb cam configuration).

If you still would like to give it a try, see if Opencv supports a heterogeneous stereo camera setup.

Title: Use 2 Cameras as 1 Stereo Camera


问:
How can i make a boat
I'm having an event for a boat race.Simple boat has to be made.All i have is 5 days.The restriction is 24V motor not more than 1000 rpm.What best material and shape will you suggest to make a boat.I know basic circuits.We have to make a boat with a wired circuit.That circuiting i can do but what can be an ideal shape for boat with maximum speed it can achieve? </p>

答:
Believe it or not, but the maximum speed a boat can achieve is related to its length.  See http://en.wikipedia.org/wiki/Hull_speed.  The longer the better.  The front and rear designs also have a large contribution to drag.  The pointier the better.  That's why crew racing boats are very long and pointy.  Boats with a flat stern (like a lot of speed boats) go fast because the boat planes at high speed (gets up on top of the water instead of plow through it).  So the flat back doesn't really affect them as much.

I am not sure if you will be able to make your model boat plane or not with those motor specs.  But i will also say that your prop also has a big part in the speed of the boat.  If you have the same motor, but with different props, the boat can have very different speeds.  Depending on the number, angle, and shape of the blades, the prop can be torqueier for slow speeds, or faster for higher speeds.  Kind of like a transmission after a motor.

Naval architecture is a large field, that i admittedly know very little about.  I only know some of these very high level concepts.  Hopefully these rules of thumb will help you out.

Title: How can i make a boat


问:
Mobile robot behaviour
I want to ask people who have designed the control/behaviour system of the mobile robot? As far as I know, architecture might be implemented as a finite-state machine or a behaviour tree. What are the key advantages of using a tree as opposed to a finite-state machine? Does it make sense to use a neural network in conjunction with a behaviour tree  (interested in the real implementation experience or example)? If so, what opportunities can this provide?</p>

答:
The similarity between finite state machines and behavior trees is, that both concepts are model-free control strategies. The programmer writes down a script, e.g. “movetoball(), opengripper(), graspball()” and if the script fails to reach the goal, the programmer is in charge to improve the written statements. The reason why model free policies are used in the reality is because they don't need any form of CPU resources, but can be executed very fast. At the same time, the programmer gets a working robot who is moving it's servo motors without implementing complicated reinforcement learning- or motion planning algorithms.

Within the AI gaming domain, behavior trees are perceived as more powerful than finite state machines because they are containing a hierarchical component to structure nested tasks. They are often visualized as a mindmap and lots of documentation is available how to create a behavior tree for ingame AI characters in a certain game engine (without naming one of the larger one which are starting with the letter U).

Title: Mobile robot behaviour


问:
Uniform and non-uniform cost maps
I can not find a clear answer on the internet about the difference between a uniform and non-uniform cost map. I am interested in getting an answer in the context of grid maps for robot navigation.

EDIT: I found the answer, in my case the uniformity was referring to the cost of traversing from one cell to another. Thus, if the cost is fixed the cost map is said to be of uniform cost. Otherwise, if the cost is variable the map is said to be of non-uniform cost.

答:
The cost map is indeed an important sub problem within robot navigation, because it guides a solver into a certain direction. The idea is, that a sampling based solver like RRT is searching in the cost map for a gradient descent which reduces the state space to interesting regions. A fast path planner and a well created cost map are the same.

Uniform cost maps for path planning are the easier one. The distance to the goal is determined by the distance in the euclidean space which is sqrt(diffx²+diffy²) and all the coordinates on the map can be traversed. Non uniform cost maps are more realistic because each position is labeled with a probability value for the existence of an obstacle.

Title: Uniform and non-uniform cost maps


问:
Calculate Torques & Forces From Jacobian Matrix
Dear Robotics Stack Exchange,

I am trying to calculate the torques and forces for a 2DOF robot.

I’m used the partial differentiation method to find the Jacobian matrix. I managed to find the Transformation martix to find the Jacobian matrix in as shown in the figure but, I have hit a stopping block when I’ve been calculating the torques and forces. I’ve shown my working out below just as a reference.

I was wondering if anyone can shed light into finding the torques as im very close into gathering the equations.

答:
Your computations of the transformation matrices are incorrect.  DH transformation matrices are computed as a multiplication of four matrices:  rotate about z by $\theta$, translate along z by $d$, translate along x by $a$, and rotate about x by $\alpha$.  More simply: you are missing the $\theta$ terms in the rightmost columns of your transformation matrices.

The result will be that your Jacobian becomes a 2x2 matrix when differentiated.


问:
Range of a heading angle [0,2π) or [−π,π)
Consider the unicycle dynamics in 2D plane:

$$\begin{array}{l}
\dot x = v\cos \varphi \\
\dot y = v\sin \varphi \\
\dot \varphi  = \omega
\end{array}$$

What is the range of the heading angle $\phi$? Some texts say $\varphi  \in [ - \pi ,\pi ) $ and other use this convention $\varphi  \in [ 0 ,2\pi ) $. What is the reason for this difference?

答: No difference at all although φ∈[−π,π) is much more reasonable and intuitive. It is just a matter of system definition.</p>


问:
What devices can I use as a flight controller in a Quadcopter project?
I know that the flight controller is the heart of the quadcopter and a device which has to be considered greatly when building a quadcopter project. In regards to this quadcopter project that I'm working on what microcontrollers can I use to actually make myself a flight controller from scratch? Would something like an Arduino mega2560, STM32 board, Raspberry Pi work? To follow up with this, what would be the first step in developing the flight controller on these microcontrollers? If anyone knows please inform.

答:
STM32F103C8T6 blue pill, the microcontroller can be a good candidate.

You can program it with Arduino and Arduino IDE.

Importantly, it is really weightless and has a small footprint.

Supports high-speed UART and SPI(400KHz) which would be necessary for IMU-based feedback control.


问:
How would i go about learning to code a flight controller?
I'm interested in quadcopters/multi-rotors and want to eventually code my own flight controller ala an APM and/or Pixhawk. I've got a little experience in programming (i.e i know about if/else/else if conditionals), and have done a little programming with PHP, though it was procedural code.

I currently have a quadcopter that i built/assembled myself that is running on a f450 frame, using a APM 2.6 flight controller,so i have a reasonable grasp of how a quad works, and i would like to take it a step further and make my own adjustments to the code base, with the eventual aim of coding my own flight controller.

I've had a look at the code base, but am still unable to get a grasp of what the code is actually doing....yet. How would i go about learning how to code a flight controller?

I'm thinking that i would have to learn C++ & OOP first, but how familiar/proficient would i have to be with C++ before i can reasonably attempt to edit the code base?Also, what else would i need to learn apart from C++ & OOP?I am looking at setting a 6 month timeframe/deadline for me to do this, would it be possible?

答:
Steps one should take to eventually write a flight controller software:

Step 1

Learn the mathematics and physics laws behind the airplanes, helicopters, multi-rotors, etc.

Step 2

Learn electronics.

Electronics is a huge field and learning the robotics related stuff would be enough.

Step 3

Learn how computers work.

The electronics behind a computer. How does a computer stores information, how does a CPU or micro-controller processes those information, how would you send those information to another system through the wire or air, etc. The concepts are same from an Arduino Uno to a bad-ass gaming PC.

Step 4

Learn a programming language.

Choosing a language depends on the platform you want to target. Are you targeting a specific micro-controller? then you need to learn that micro-controller's specific language (which is an assembly language or maybe a C like language). Are you targeting an Operating System? For example your goal may be that I want to write a flight controller for the Linux OS which requires the real-time patch and would work on any Linux enabled SBC with some specified MPU sensors that I support. In that case you need to learn C (because Linux's native APIs are in C) and you also need to master the Linux kernel. There are wrappers around native APIs in many languages but none of them cover all of the APIs and may give you less control over how you can call them.

Step 5

Put it all together!

At this point you can start writing a flight controller.

Depending on how much time and energy you have, this may take from a few years to a few decades! :D

This is why these things are usually created in a team work.


问:
Compute Maximum End Effector Velocity Along Path
Let's say I have a 2-link planar robot arm. The motors in both joints have maximum angular speeds that limit how fast they can spin. If I plan a path from point A to point B with a constant end effector velocity, how do I calculate the maximum velocity the end effector can travel with along this path?

I know I can calculate the velocity of the end effector with this equation: $v=J(q)\dot{q}$.
I could iterate through points along the path plugging in the joint's maximum angular speeds to calculate the maximum velocity at each point. Then I would use the smallest velocity as the "maximum" velocity the end effector can travel at.

Is this the best way to accomplish my goal?

答:
Nope, you cannot simply plug the maximum joint velocities in the differential forward kinematic law, as you need to guarantee that $\mathbf{v}$ will always point toward the target: in fact, $\mathbf{v}$ is a vector.

As a result, you need to solve the inverse kinematics problem first for each point of the path. This can be done iteratively:

Assign a desired $\mathbf{v}$ with a given magnitude and direction.

Solve for each point $\dot{\mathbf{q}} = \mathbf{J}^{-1} \cdot \mathbf{v}$.

Check if the components of $\dot{\mathbf{q}}$ are within the allowed range of the motors throughout the entire path. If not, reduce the magnitude of $\mathbf{v}$ and iterate again.

In practice, you ought to consider that the kinematic singularities may impede the simple solution resorting to the (pseudo)inverse of the Jacobian.

To get around the singularities, one usually resorts to the Damped Least-Squares inversion $\mathbf{J}^*$ of the Jacobian $\mathbf{J}$, where

$$
\mathbf{J}^* = \mathbf{J}^T \left( \mathbf{J}\mathbf{J}^T + k^2\mathbf{I} \right).
$$

Then, because of the tuning of $k$, you won't have most likely a unique correspondence between the joint and the end-effector velocity, but rather you would need to reason in terms of margins.

To elaborate more on the particular 2D case, I could argue the following:

We need first to solve the IK problem and come up with the exact solution $f \left( q_1, q_2 \right) = \left( x, y \right)^T$.

Then, we need to solve a constrained optimization problem to find the couple $\left( \dot{q}_1, \dot{q}_2 \right)$ that maximizes the Cartesian velocity knowing that this velocity is required to be along a given direction and we have bounds for the speed of the motors.

Of course, the above procedure needs to be iterated throughout the points of the entire path anyway, to finally determine which is the lowest Cartesian velocity that can be attained. This will be your final value as it will guarantee that the bounds on the motor speeds won't be violated at any point of the path.

Here below some more details.

Step 1

We know the exact solution of the IK problem:
$$
\begin{cases}
q_1 = \arctan{\frac{y}{x}} + \tan{\frac{a_2\sin{q_2}}{a_1+a_2\cos{q_2}}} \\
q_2 = -\arccos{\frac{x^2 + y^2 -a^2_1 -a^2_2}{2a_1a_2}}
\end{cases},
$$
where $a_1$, $a_2$ are the link lengths.

Step 2

The velocity equations are:
$$
\begin{cases}
\dot{x} = -a_1\sin{q_1}\cdot\dot{q_1} -a_2\sin{\left(q_1+q_2\right)} \cdot \left(\dot{q_1}+\dot{q_2}\right) \\
\dot{y} = a_1\cos{q_1}\cdot\dot{q_1} +a_2\cos{\left(q_1+q_2\right)} \cdot \left(\dot{q_1}+\dot{q_2}\right)
\end{cases},
$$
where $\left(q_1, q_2\right)$ are determined in step 1.

The Cartesian velocities $\left( \dot{x}, \dot{y} \right)$ cannot be generic as they need to enforce the assigned direction; so, it holds that $\frac{\dot{y}}{\dot{x}} = \text{known constant} = c$.

By aggregating all this information, we get that the solution $\left( \dot{q_1}, \dot{q_2} \right)^*$ is the outcome of the following constrained optimization problem:

$$
\begin{array}{lcr}
\left( \dot{q_1}, \dot{q_2} \right)^* = \arg \max\limits_{\dot{q_1},\dot{q_2}} \frac{1}{2}\left( \dot{y}\left(\dot{q_1},\dot{q_2}\right) \right)^2 \\
\text{s.t.} \begin{cases} \frac{\dot{y}}{\dot{x}} \left(\dot{q_1},\dot{q_2}\right) = c \\
-M_1 < \dot{q_1} < M_1 \\
-M_2 < \dot{q_2} < M_2
\end{cases}
\end{array},
$$
where $M_1$ and $M_2$ are the motors max speeds.

The 2D case boils down to the maximization of a quadratic cost function subject to a hyperbolic constraint.

Concluding remarks

In the 2-steps procedure, I didn't mention that you would likely need to deal with kinematic singularities depending on the type of path you have in mind. This will certainly add up more difficulties on top of the process so that, I reckon, the fully-iterative routine detailed in the first place tends to be easier to implement, clearer to maintain, and definitely more scalable with respect to the number of DOF.


问:
What's the difference between factor graph optimization and bundle adjustment?
I see that in SLAM literature, factor graph optimization is frequently used. While in Structure from Motion (SfM) literature , they usually use bundle adjustment. What's the difference between the two methods?

Furthermore, can we implement one method with libraries for the other? E.g. implementing bundle adjustment with g2o, or implementing factor graph optimization with ceres solver?

答:
The simplest explanation will be:

In structure from motion, it estimates structure(xyz points), camera locations, camera intrinsic.

In graph optimization, it only estimates camera locations. In the graph SLAM, the structure is just a by-product of a corrected trajectory or graph nodes.

E.g. implementing Bundle adjustment with g2o -> You can do it by modifying g2o but simply there is no reason to do that. g2o is not designed to estimate the structure and camera intrinsic. It doesn't mean that you can't estimate these but BA and SLAM are fundamentally different. You will end up changing 99% of the existing g2o code.

implementing factor graph optimization with ceres solver ? -> Ceres solver is an optimization library, not a bundle adjustment software although one of the ceres problem examples is bundle adjustmemt. Anyway, you can modify ceres bundle adjustment example to do graph optimization with a lot of modifications.


问:
How to detect loop closures in 2D laser SLAM?
I am trying to build an occupancy grid map using odometry and 2D lidar data through graph optimization. I am not aware of any reliable loop closing methods using only the 2D laser scans. I have been reading about ICP for scan registration and am thinking that it may be what I need for loop closure detection.

What are some common methods of loop closure detection given only the 2D laser scans?

答:
The most traditional method is to keep looking at the trajectory and see if your current location is close enough to the previously visited place. Once this happens run the ICP. If ICP converged normally, that is your loop closure.

A bit more advanced method is doing a place recognition. Generate a keyframe every few meters and extract a feature descriptor from the keyframe. Whenever you create a new keyframe compare this descriptor to the previously created descriptor. If you find any similar descriptor, you are likely re visited the place. Run ICP and see if it is really the case.


问:
I've got a few servo motor questions
How can I measure the amount of voltage I'm giving a servo motor? How can I give a servo motor the correct amount of power it needs to run at it's full potential? Say I had this motor:

ANNIMOS 60KG Digital Servo 8.4V High Voltage Stainless Steel Gear Large Torque High Speed Waterproof Baja Servos - 180 Degrees
(this is an example that I copied from amazon)

What does the 60KG mean? I assume that 8.4V High Voltage is the amount of power it needs to run at full potential. Large torque means it can lift a lot of weight, but how much?

I've tried to find answers to these questions, I've watched a lot of YouTube videos and read a lot of tutorials, but I found nothing about my questions. Thank you for taking the time to read  through this!

答:
That's a hobby servo, from a dubious source.  It's not a technical device marketed to technical people, so don't expect a datasheet that has technical, verifiable specifications.

There are hobby servos that come with specifications, and sometimes they even meet their claims.  If you want to buy one and have it Just Work, start with a company that lists said specifications, and that has a reputation for standing behind their work.

What does the 60KG mean?

It's very possibly a model name.  Servos produce torque, and a kilogram is a unit of mass.  Even when misused as a unit of force (i.e., $\mathrm {kg} \cdot 9.8\mathrm{m/s}$ it's still not a torque.

I assume that 8.4V High Voltage is the amount of power it needs to run at full potential.

If it were a technical specification, $\mathrm{8.4V}$ would be enough.  "High voltage" just indicates that it uses more than the old-style 4-cell Nicad pack (4.8V nominal, essentially between 4V and 5V).

Assuming that it's a quality part, "$\mathrm{8.4V}$" almost certainly means that it's designed to run off of two unregulated Lithium-Polymer batteries in series.  But you're buying a no-name part from an unreliable vendor.

Large torque means it can lift a lot of weight, but how much?

"Large" is a marketing word, designed to make stop thinking long enough to buy the thing.  A real specification would list a torque in inch-pounds or Newton-meters.  A better specification would have short-term torque and holding torque (but you won't find that in a hobby servo from any source).

"Large" torque means it can twist hard.  Force = torque / diameter, so large torque means nothing in terms of how much weight it can lift unless you specify a lever arm.

Title: I've got a few servo motor questions


问:
Programming Robots with JavaScript
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus?

Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable for developers like myself? I would even be interested in virtual environments where all code is executed in a simulation.

答: A new compiler is available through the Microsoft App Store called "Robot JavaScript".  This compiler works in Windows10 and compiles code for EV3 Mindstorms robots.  If you have a Lego Mindstorms EV3, check out: https://www.microsoft.com/en-us/p/robot-javascript/9nb6w06lpx68</p>

Title: Programming Robots with JavaScript


问:
Line following robot with EV3 Colour Sensor
I am trying to build an advanced coloured lines following robot with the ability to differentiate between many different coloured lines and follow them. I am looking for the right sensor that will help my robot achieve its objective.

As I was researching I came across the EV3 Colour Sensor which can detect up to 7 colours.

Is this sensor suitable for my project?

What other sensors can I use and how?

Thank You

答:
The EV3 color sensor can easily be used to follow different colored lines (e.g., red lines, green lines, blue lines).  The important part about using the sensor is selecting the proper mode for following the particular colored line.  For example, if the line is just a black line on a white background, then set the sensor to reflected light.  However, if the line is a colored line (red/green/blue/other), then set the sensor to RGB Color mode which will output three numeric values (r, g, b).  Each numeric value will range from 0% to 100% of that color.  If the colored line is on a white background, then the percentages of the various colors may range from 100% to 50% or lower depending on how much of the sensor is over the line.  For example, if it is a red line, then the red value from the sensor will be 100% regardless of whether the sensor is over the red line or white background.  This is because the white background will generate a value of 100% for each RGB color.  If the red line is over a black background, then the value for red will vary between 100% (over the red line) to 0% over the black background.  So, if the line is red and the background is white, how do you follow the line since the sensor will only show 100% red?  The answer is to use one of the other values from the sensor (e.g., green or blue).  If the line is red and the background is white, then use the blue value from the sensor which will show 0% when over the red line and 100% when over the white background.

For example programs about using the EV3 sensors for line following, and detection and for  examples about detecting colors, see: https://robotjavascript.com/line-following-examples.htm and https://robotjavascript.com/sensor-examples.htm#colorSensorValue

These examples are written in Robot JavaScript.  The colorSensorValue() function returns an object with three numeric properties: { r: [0-100] , g: [0-100], b: [0-100] }

To follow the line, use the syncMotors() function and set the steering parameter to your desired sensor value:  colorObject=colorSensorPct(); syncMotors(2, 3, constantPower, gain*(colorObject.b-target));
Then all you need to do is adjust the constantPower, gain, and target for your particular needs.


问:
Mindstorms: EV3 Brick files vanished
The EV3 brick turned off by itself (the battery is not low), we restarted it and the file finder was empty, all our files are not there right now. Have they disappeared from the brick forever or is there a way to restore them(without re-downloading)?

This has never happened before, what are some of the reasons this might happen?

We tried a reset with the very top, and center buttons, it did not return our files.

答: No.  The files are no longer accessible from the brick.  You will have to re-download them.  The EV3 operating system (LMS2012) is sensitive to unexpected shutdowns.  When an unexpected shutdown occurs, information is lost in the internal memory of the device.  There is no hard-drive inside the EV3.  So, programs are stored in a Flash Memory chip.  I have found from personal experience that all of the file in the user programs folder are wiped out and disappear completely as if they never existed on the brick.  Sorry.  That has been my experience.</p>

Title: Mindstorms: EV3 Brick files vanished


问:
Low speed control of bldc motors
I'm having a problem with controlling my BLDC motor when starting up and when running in low rpm. I have a custom board to measure rotation of the motor using an optical sensor and send servo pwm commands to an esc.
The problem is, that I can't start the motor smoothly. When I slowly increase the control signal, it starts stuttering and then jumps directly up to about 1500rpm.

Is there a way to improve this situation without using a sensored motor/esc combo?

答:
Brushless DC motors should have excellant lower speed performance.  Your problem is probably not the motor but rather the electronic speed controller.  Those sensorless controllers generally don't perform well in low speeds because there is very little signal for them to key on.

It also sounds like you may be "fighting" the ESC's built in controller with your own control loop on top of it.  The first thing I would check is what's the lowest speed command the ESC can reliably take before trying to close a loop with an additional sensor.  What is your loop doing?

If you want to build your own system you may want to replace the ESC with an amplifier and change your control algorithm to control the current/torque rather than speed.  Since you have your own position sensor it may somehow be possible to fake out the back-emf signature the ESC is looking for but this isn't easy and is probably a waste of time.

Title: Low speed control of bldc motors


问:
Measurements of IMU (accelerometer and gyroscope) are drifted or with too much error
I placed my drone on a table (i.e, at rest) and save (using a ROS topic) the IMU readings:

As you can see, there's a lot of drift or error. I would expect the $x$ and $y$ acceleration to be 0 (I know about the drift, but this is not something that keeps growing, it just has a bias) and $z$ 9.8. What could happen? Before I measure everything, I called the topic flattrim. And I would expect also a better performance for the gyroscope

What can I do to make if work better?

The funny thing is that the velocities (I suppose it integrates the accelerometer readings) are noisy, but their mean is approximately 0:

The covariance matrix is 0 for everything

答:
The acceleration raw data looks weird, because of the discrete jumps. For comparison here is raw data from a stationary MPU-9150 (MEMS IMU):  The raw accelerometer and gyroscope data are not integrated, and thus should not experience integration drift. The roll and pitch are integrated quantities, which then follow a random walk, and could end up anywhere.

Other error sources may be the following: Depending on the dynamic range, you may see different quantization levels, such as in the gyro raw data. There might also be a slowly time-varying bias, such as in the y-axis of the accelerometers.