问:
How do I download libraries onto the Ubiquity Robotics Raspberry Pi image
I downloaded an sd card image by Ubiquity Robotics which is an Ubuntu OS with ROS preinstalled onto my Raspberry Pi. This image creates a pifi access point for the Raspberry Pi and allows me to ssh into the Raspberry Pi by connecting my laptop to the access point created and doing ssh ubuntu@10.42.0.1. Now then I tried connecting to my home router by using pifi add <ssid> [<password>] and then sudo reboot. I was able to connect to my home router this way. So after this I tried downloading the library I needed, pygame. So i typed sudo apt-get install python3-pygame

And this is what i got:

```<code>Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3-pygame is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
</code>```

So I went to a pygame site and tried downloading the library another way:

```<code>sudo apt install libsdl2-dev libfreetype6-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev libjpeg-dev libpng-dev libportmidi-dev
</code>```

And this is what I got:

```<code>Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libpng12-dev' instead of 'libpng-dev'
E: Unable to locate package libsdl2-dev
E: Unable to locate package libsdl2-mixer-dev
E: Unable to locate package libsdl2-image-dev
E: Unable to locate package libsdl2-ttf-dev
E: Unable to locate package libportmidi-dev
</code>```

Now I have no clue on what to do and how to go about downloading the library. Is there a way I can directly download the library into the sd card image or what. Help me out pls.

答:
First do this

```<code>sudo apt-get update
sudo apt-get upgrade
</code>```

Then you try doing

sudo apt-get install python3-pip ?

Then do

```<code>sudo pip3 install pygame
</code>```

If you are still getting the error related to SDL.

Then do this

```<code>sudo apt-get install libsdl2-dev
</code>```

Body:
First do this

sudo apt-get update
sudo apt-get upgrade

Then you try doing

sudo apt-get install python3-pip ?

Then do

sudo pip3 install pygame

If you are still getting the error related to SDL.

Then do this

sudo apt-get install libsdl2-dev


问:
What is the cheapest 20mm-diameter roll-angle-sensor (+/-10deg, 60Hz update) you have come across?
What is the cheapest roll-angle-sensor (10degree accuracy, 60Hz update) you have come across for airborne
mobile robots that have a 20mm diameter, shaped like a rocket?  (The robot
is shaped like a rocket and one may need to fit a roll sensor inside of it.)
   I realize that for purely vertical travel, some type of compass would work, but the robot here needs to be able to travel horizontally as well as vertically.  This one below at inertiallabs.com is 554dollars.  I am hoping to find cheaper:
https://inertiallabs.com/os3d.html
Buy here for 554dollars:
https://ozrobotics.com/shop/sub-miniature-3d-orientation-sensor-os3dm/</p>

答:
Asking for the cheapest sensor does not make much sense without specifying a maximal error. Otherwise I propose to add a small rock, guess a zero-roll angle and you have a 'sensor' for free with a maximal error of 180deg. </p>

<p>A real solution would rather be any IMU with a magnetometer (like the MPU9255). It's around 10$ and would give you the information you need. </p>

ContentLicense: CC BY-SA 4.0

Body:
Asking for the cheapest sensor does not make much sense without specifying a maximal error. Otherwise I propose to add a small rock, guess a zero-roll angle and you have a 'sensor' for free with a maximal error of 180deg.

A real solution would rather be any IMU with a magnetometer (like the MPU9255). It's around 10$ and would give you the information you need.


问:
What is the degree of freedom of the following drone?
This might be a stupid question to ask here .i am confused whether the dof of this drone is 3 or 4?

答:
In general i would say there is not enough information on this drawing, so we all ASSUME.

If you look at this and assume it is a multicopter with 2 counter rotating propellers (can not fly in a normal fashion without a pivoting mechanism, like a Chinook) you can only have yaw, roll and up down control which makes for 3-DoF. For the arm it give you 2 DoF (assuming no other pivot point exist that are not visible on the drawing)

From a practical point of view if the top is really a drone (multicopter) then it needs four propellers (which i can only see two of in the 2D picture)

A multicopter like i assumed moves like a ship 6-DoF (not an airplane 3-DoF)

I argue that as far as the drone is concerned it still has a 6-DoF. The attached arm has 2-DoF. wikipedia

Whether it serves any purpose to count the additional movement the arm can make as additional DoF is in my view debatable because you can not move in any more ways than before (i look at the maneuverability from the drones perspective and the arm endpoint Pe). You achieve the same result for the endpoint of the arm when you move the drone or when you move the arm.

I could of course be completely wrong being human.


问:
Compensation for IMU mounting misalignment
I have an MPU6050 IMU and I would like to mount it on an FSAE car and use it to measure the yaw, pitch, roll, and angular velocities as it drives. As it's impossible to mount it perfectly flat and align the IMU axes with the axes of the car, I am looking for a way to calibrate and compensate for the rotational offset of the car's frame and the IMU's frame.

From the IMU I can get quaternions, Euler angles, raw acceleration and angular velocity data, or yaw, pitch, and roll values. I imagine the solution will involve matrix and trig calculations, but I didn't pay nearly enough attention in multivariable calc to figure this out.

答:
I am going through a similar issue. Please check this link below for initial calibration in all the axis. This is not for MPU but a similar method could be followed. I am still working on it and, If I find a suitable solution, I will update. Hope this helps.

https://chionophilous.wordpress.com/2011/08/26/accelerometer-calibration-ii-simple-methods/

Also, refer to this pdf below. This is just for the accelerometer. But might be helpful.

https://www.st.com/resource/en/application_note/dm00119044.pdf

ContentLicense: CC BY-SA 3.0


问:
Value of ROS without real-time performance in robotics?
I have a general question about ROS - since it is NOT a real-time operating system(nor is Linux which it runs on), why can it be used for robotics applications which almost always have real time performance needs? </p>

<p>Basically unless you can put an upper bound on your perception and motion task times I don't understand how anything can actually work on a physical system - can someone explain? </p>

答:
Let's start with a pick and place robot (a robot arm with a camera and a suction cup that recognizes object in a bin and picks them individually). We can move the robot above the box, and simply wait until we have a captured an image, segmented the objects and computed grasping points and collision free trajectories.  We then move to robot to a grasping position, activate the pump and wait until we have grasped something. No need for any real-time in the perception and motion planning part. The motors however have to be controlled in a real-time loop so that they are moving synchronous and immediately stop as soon as a human comes to close to the robot. This part needs to be hard real time.
The whole system could for example be built by a ROS-part that does perception and motion planning and an ABB-Robot (with its own fast(!) realtime controller) that now and then gets new goal poses from the ROS-part and executes them while sending its current configuration back to ROS.

The most important issue here is that we can stop the robot while we are thinking. This does not work if your robot is a drone or a fast moving car. In the drone cases, we need at least a (fast) real time flight controller that keeps the drone flying while we for example send image data to a ground station to decide where to fly next.

In many applications, only small subsystems (mostly the motors) need to be controlled in real-time and the higher level tasks (perception, planning, reasoning, visualization, logging, multi-robot coordination) can take as long as they want. Trying to implement them in real time would be extremely difficult and completely unnecessary.

Update:

Another important point about real-time vs non-real-time is its definition.

It does NOT(!) mean that the system can process sensor data very quickly and can therefore react immediately to new sensor data (e.g. child running in front of car). It only means that the system guarantees to perform a computation within a certain time limit. It is perfectly possible that this time limit is in the range of seconds.
For a motor controller (as used above), you need a real-time system that has a guaranteed maximal computation duration in the ms-range. So even if you port ROS to real-time (which is currently done with ROS2), you don't magically are able to control fast moving robots.

So real-time is required, but not sufficient for controlling (the moving parts of) robots.


问:
Is there a specific way or module I can use to stream video data from a camera hooked to an Arduino Uno board?
I'm currently thinking about the feasibility of creating a robot which streams live video footage and other data such as temperature, humidity, etc. to a smartphone. Is it possible to do this on an Arduino Uno board? Or is a Raspberry Pi board needed?</p>

答:
You need more computing power than the Arduino Uno. Your question is needs more context, there is endless electronics that can do it, but if you want to find one that can handle your particular case, you need to think about the following:

What kind of data rates do i need to stream (it is a trade off between computation power, transmission distance, data rates)

RGB cameras have very different resolutions which influence data rates (compression needed?)

What are my sensors data rates wanted (compression needed?)

Does it need to be realtime (what delay is acceptable)

What should the electronic platform do else then streaming data?

Physical constraints your robot has (how big, heavy can your electronics be)

Physical pins you need to connect sensors (or what interfaces you want to use like i2c, rs232, usb, camera direct connection, ...)

For a project i did, i made a simple data-link for a drone, i needed a Raspberry Pi 2 to cope with the 1080p video compression and some sensor data and command and control link. Over a standard internet protocol (RTSP, TCP, UDP) and compression you will introduce delay i estimated around 300ms for the video (it used about 3 MBit for 1080p h264 compressed) for the transmission i used an ubiquity long range wifi with limited success (you never get the ranges they advertise, especially if you also move), with a 3g or 4g modem you may get better ranges but you will be dependent on the 3g/4g network coverage. As the project evolved they now changed to a Raspberry Pi 3 because they wanted also to stream LiDAR data (for LiDAR data rates needed are big for a usable data set, 4 MBit is not uncommon). But all of this things can be done in a completely different way.

For projects like this there are trade offs to be made, unless you define your functions properly and have some experience it is hard to know what to use in the end. The technology today will allow you to do what you describe but there will be a cost to it (time, money, learning).


问:
Why do we need coriolis and centrifugal forces when it comes to the dynamics of a robotic arm?
So we all know (and love) the typical dynamic equation of a robotic arm:

$$
M(q) \ddot{q}+C(q,\dot{q})\dot{q}+G(q)=\tau
$$

Where M is the mass matrix, G is gravity and C is Coriolis and Centrifugal forces.

Coriolis and Centrifugal forces are pseudo forces that are experienced only for the frame that is attached to the body that is rotating. But my understanding is that all calculations happen relative to the base frame, which is static. The need for Coriolis and Centrifugal forces would imply that the forces are actually expressed in the frame that is attached to each link.

To put my question simply, why do we need the coriolis and centrifugal forces in the dynamic equation of a robotic arm (since everything is done relative to the initial/base frame)?

(p.s. feel free to use a single or double pendulum robotic arm example if you would prefer).

答:
But my understanding is that all calculations happen relative to the
  base frame

This is incorrect. Take a look at this two-link arm manipulator. The point ($x_2,y_2$) is obviously expressed in a moving frame $y_1,x_1$. Another way to look at the problem is to use Lagrangian approach which free you from constraint forces.


问:
Sensor options for localization on linear rail
For a thesis project for ways to localize a slide on a linear rail with a length of ~1m. The slide in question is the seat of an indoor rowing machine: Concept2 Ergometer Price is definitely an issue as we want to built multiple sensor setups.

I need the location of the slide with an accuracy of around 1mm with a rate of 50-100Hz. Adding cables to the seat is something I want to avoid, so I'd like to have an external sensor (fixed to the rail) and at most a target (e.g. reflective surface) on the slide. Seat speed can be up to 2m/s.

I thought about Sharp triangulation sensors (like the GP2Y0A60SZ0F), but I have no experience with the accuracy and its behavior with fast moving objects. Even when operator with 5V, the output for 50cm and 1m only differs by 0.25V so I assume that there is a major accuracy degradation.

Ultrasonic is to slow and inaccurate, and commercial laser triangulation sensors are quickly at >200$.

Which sensor principles am I missing? As soon as I know what I'm looking for, I can find a sensor on my own (no shopping question!), but I can't search for a sensor if I have no starting point.

答:
Have you thought about a linear encoder system (wiki)?

I am not sure whether it is cheaper though.


问:
In EKF-SLAM, why do we even need odometry when there is a more reliable sensor?Also, are all SLAM algorithms feature-based?
In the book of SLAM for dummies, why do we even need the odometry when the robot would use the data retrieved from the laser scanner which is more accurate than odometry? Why not just rerly on the laser scanner and do away from the odometry? Is there any contribution by the odometry that the laser scanner does not have? Also, are all SLAM algorithms feature-based?</p>

答:
If you read about the principles of sensor fusion, you will always get a better estimate when you combine data in the right way. For example, if you are measuring temperature in a room with 3 different temperature sensors, it is not ideal to only use the best sensor. The ideal case would be to create a weighted combination of each sensor, where the sensor's weight is proportional to one over that sensor's variance. Not to mention, odometry data is VERY good. It's the extraction of landmarks that is noisy and will most likely have a higher variance.

If you think about it from a high level perspective it's also required that you have a motion update based on odometry. If you only used landmarks, then you would have ambiguous cases. Take for example, the case where you only identify one landmark. You'd have a distance z from your robot to the landmark, but this would map to an infinite number of points in a circle around the landmark. If you identify zero landmarks, then you can't do anything! By including odometry, we no longer have an ambiguity. Assuming we're localizing in a 2D plane (x,y), then you would have to guarantee you have readings for at least 3 landmarks to triangulate your position without odometry, and you cannot make that guarantee in normal environments.

Finally, an encoder can be sample on the order of 50Hz, whereas a LIDAR can only be sampled at around 6-7Hz (don't quote me on those frequencies). This means that you can update your current position much more frequently via odometry than you can from sensor readings. This isn't even taking into account how long it takes you to process your sensor reading to identify landmarks!


问:
/odom topics not matching ERROR
I have an existing ROS workspace which was built in C++. I am trying to implement a node built by The Construct in python which reads distance travelled from the /odom topic. I have successfully built a package within my existing work space containing their code and can run the node.

When I rosrun the node, I am receiving an error on the roscore saying:

[ERROR]: Client [/movement_detector_node] wants topic /odom to have datatype/md5sum [nav_msgs/Odometry], but our version has [geometry_msgs/PoseArray]. Dropping connection.

It looks like my existing work space uses Type: geometry_msgs/PoseArray
 messages to communicate.

Could I please get some help on the proper way to debug and fix this?

Node for distance collection below. All credit belongs to The Construct.

```<code>#!/usr/bin/env python

import rospy
import math
from nav_msgs.msg import Odometry
from geometry_msgs.msg import Point
from std_msgs.msg import Float64

class MovementDetector(object):
    def __init__(self):
        self._mved_distance = Float64()
        self._mved_distance.data = 0.0
        self.get_init_position()

        self.distance_moved_pub = rospy.Publisher('/moved_distance', Float64, queue_size=1)
        rospy.Subscriber("/odom", Odometry, self.odom_callback)

    def get_init_position(self):
        data_odom = None
        while data_odom is None:
            try:
                data_odom = rospy.wait_for_message("/odom", Odometry, timeout=1)
            except:
                rospy.loginfo("Current odom not ready yet, retrying for setting up init pose")

        self._current_position = Point()
        self._current_position.x = data_odom.pose.pose.position.x
        self._current_position.y = data_odom.pose.pose.position.y
        self._current_position.z = data_odom.pose.pose.position.z

    def odom_callback(self,msg):
        NewPosition = msg.pose.pose.position
        self._mved_distance.data += self.calculate_distance(NewPosition, self._current_position)
        self.updatecurrent_positin(NewPosition)
        if self._mved_distance.data < 0.000001:
            aux = Float64()
            aux.data = 0.0
            self.distance_moved_pub.publish(aux)
        else:
            self.distance_moved_pub.publish(self._mved_distance)

    def updatecurrent_positin(self, new_position):
        self._current_position.x = new_position.x
        self._current_position.y = new_position.y
        self._current_position.z = new_position.z

    def calculate_distance(self, new_position, old_position):
        x2 = new_position.x
        x1 = old_position.x
        y2 = new_position.y
        y1 = old_position.y
        dist = math.hypot(x2 - x1, y2 - y1)
        return dist

    def publish_moved_distance(self):
        """
        Loops untils closed, publishing moved distance
        """
        rospy.spin()

        # spin() simply keeps python from exiting until this node is stopped
        rospy.spin()

if __name__ == '__main__':
    rospy.init_node('movement_detector_node', anonymous=True)
    movement_obj = MovementDetector()
    movement_obj.publish_moved_distance()
</code>```

UPDATE:

I was able to fix this problem but now have an additional question. Basically the existing workspace was expecting the subscriber to use the geometry_msgs\PoseArray message. Once I imported that message and used it in the callback my error went away.

Looking at the geometry_msgs\PoseArray message, it's composed of position and orientation message. For the distance collection script to work, I need to only use the position message of geometry_msgs\PoseArray. I wrote a basic subscriber to practice isolating this data.

Pictures of both message types below. Could someone help me isolate the x, y, and z from the geometry_msgs\PoseArray message?

```<code>#!/usr/bin/env python

import rospy
import math
from nav_msgs.msg import Odometry
from geometry_msgs.msg import PoseArray
from std_msgs.msg import Float64

def callback(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data)

def listener():

    # In ROS, nodes are uniquely named. If two nodes with the same
    # name are launched, the previous one is kicked off. The
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'listener' node so that multiple listeners can
    # run simultaneously.
    rospy.init_node('listener', anonymous=True)

    rospy.Subscriber("odom", PoseArray, callback)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()

if __name__ == '__main__':
    listener()
</code>```

答:
As I understand your workspace send to the /odom topic geometry_msgs/PoseArray and you are trying to read it as nav_msgs/Odometry, As you can see they have totally different struct. I can imagine that you don't want to change the "The Construct" code, so my suggestion would be to create an intermediate topic in order to "translate" the poseArray to Odometry. This ros tutorial might help you.

It would be helpful if you post you workspace code too.

Title: /odom topics not matching ERROR


问:
What is the direction of current flowing through the freewheeling diodes in H-bridge if I use BJT?
I am new to electronics.the question is buzzing in my head since i first saw the H bridge configuration.please answer the question briefly

答:
q1 and q3 will never really turn on if the voltage applied to A or B is less than the motor supply voltage, NPN transistors require that the base voltage is greater than the emitter voltage by 0.6v, lets say without the motor running its emitter is sitting at a random value of 2v, when you apply say a 5v signal to it, the emitter will then only every rise to 4.4v

if motor supply is 12v then A or B will have to reach 12.6v to turn on q1 or q3, this is why q1 and q3 are usually pnp transistors. q1 and q3 are forming emitter followers(?) and its not a great way to use them in a circuit like this.
I'd also change the diodes to 1n4001 or 1n4007


问:
I want my stepper motor to switch speed while traveling (not acceleration wise)
I have this project I'm working on where I'll need the speed of the stepper motor to change set speed at a certain distance, I just can't figure out a way to do it. I'm using arduino and a stepper motor, this is the current code.

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

AccelStepper stepper1(AccelStepper::FULL4WIRE, 0, 1, 2, 3);

void setup()
{
    stepper1.setMaxSpeed(200.0);
    stepper1.setAcceleration(400.0);
    stepper1.moveTo(5000);

}

void loop()
{
    // Change direction at the limits
    if (stepper1.distanceToGo() == 0)
    stepper1.moveTo(-stepper1.currentPosition());
    stepper1.run();
</code>```

What I want it to do basically is to first moveTo(2500)  at the current speed 200 then after 2500 I want it to increase speed to 400. After it has moved 5000 it turns and moves back to position but that's implemented already.

答:
For this task; increase speed when a certain distance is reached.

I would use encoders on the wheels which will workout the distance travelled and when the target distance is reached then increase speed.


问:
Cannot get 3 DOF bicycle model to run correctly
I'm trying to simulate a vehicle using a dynamic bicycle model but I cannot seem to get it working. If I set a constant steering angle the lateral velocity grows exponentially and creates impossible results.

```<code>a = 0.34284
b = 0.40716
m = 155
I = 37.29

def f_DynBkMdl(x, y, delta, theta, dt, states):
    dtheta = states[0]
    vlat = states[1]
    vlon = states[2]

    if delta > math.radians(180):
        delta = delta - math.radians(360)

    if delta<0:
        j = 1
    else:
        j = 0
    if dtheta<0:
        q = 1
    else:
        q = 0

    dtheta = abs(dtheta)
    delta = abs(delta)

    sf = delta - (a*dtheta)/vlon
    ff = 30.77*math.degrees(sf)
    pf = 0

    sr = (b*dtheta)/vlon
    fr = 30.77*math.degrees(sr)
    pr = 0

    if j == 1:
        fr = -fr
        ff = -ff
    if q == 1:
        dtheta = -dtheta

    theta = theta%math.radians(360)

    ddtheta = (a*pf*delta + a*ff - b*fr)/I
    dvlat = (pf*delta + ff + fr)/m - vlon*dtheta
    dvlon = (pf + pr - ff*delta)/m - vlat*dtheta

    dx = -vlat*np.sin(theta) + vlon*np.cos(theta)
    dy = vlat*np.cos(theta) + vlon*np.sin(theta)

    theta = theta + dtheta*dt + (1/2)*ddtheta*dt**2
    dtheta = dtheta + ddtheta*dt
    vlat = vlat + dvlat*dt
    vlon = vlon + dvlon*dt
    vabs = np.sqrt(vlat**2 + vlon**2)
    x = x + dx*dt
    y = y + dy*dt

    states = [dtheta, vlat, vlon]

    array = np.array([x, y, theta, vabs, states])
    return array
</code>```

With a and b being the distance between the front and rear axle to the vehicle's centre of gravity, m being the mass and I the inertia.
x and y are the global position and theta is the heading with delta being the steering angle.

I obtained my equations from this document https://vtechworks.lib.vt.edu/bitstream/handle/10919/36615/Chapter2a.pdf under the headings 2.3.1, 2.3.2 and 2.3.3. I used a simplified tyre model and assumed infinite friction so the friction circle is not required.

Is there something I am missing to make this work?

答:
I think this question doesn't belong here, it is more suitable to the stackoverflow.
To the problem now, first of all I assume you are making a mistake by mixing degrees with radians.
In this part of the code

```<code> if delta > 180:
        delta = delta - math.radians(360)
</code>```

delta seems to be in degrees and then you are trying to normalize it by subtracting radians (hint you might get angles that are even bigger than 360 so you should make a loop to check it out).

While here:

```<code>  sf = delta - (a*dtheta)/vlon
</code>```

you are using it as a number(radians).

Please check it out, and upload the source where you got the equations from because it is realy hard to follow your code.

Body:
I think this question doesn't belong here, it is more suitable to the stackoverflow.
To the problem now, first of all I assume you are making a mistake by mixing degrees with radians.
In this part of the code

 if delta > 180:
        delta = delta - math.radians(360)

delta seems to be in degrees and then you are trying to normalize it by subtracting radians (hint you might get angles that are even bigger than 360 so you should make a loop to check it out).

While here:

  sf = delta - (a*dtheta)/vlon

you are using it as a number(radians).

Please check it out, and upload the source where you got the equations from because it is realy hard to follow your code.


问:
Meaning of Roomba's charging states
I added an Arduino to control a Roomba 615 (similar to iRobot Create 2).
The Arduino is communicating with Roomba through the Mini-DIN connector with the Open Interface.

While Roomba is docked and in Passive mode, I would like to know when the battery is fully charged in order to know when Roomba is ready to clean/travel. I am currently watching the Charging State (ID 21 in Open Interface, p.28).

Could you explain to me the meaning of each state?

Which state corresponds to « the battery is fully charged »?

The 6 states are:

0 Not charging

1 Reconditioning Charging

2 Full Charging

3 Trickle Charging

4 Waiting

5 Charging Fault Condition

答:
0 Not charging -- The robot is not on the dock

1 Reconditioning Charging -- This is a slow trickle meant for a battery that has been left uncharged for so long that its voltage has
become extremely low.

2 Full Charging -- Normal charging

3 Trickle Charging -- A top-up mode that keeps a fully charged battery fully charged.

4 Waiting -- Generally this is when the battery's temperature is too high to apply current. For example, after a full charge, the
battery is pretty hot, so we wait a little for it to cool off before
trickling. Very hot environments (eg, Arizona in the summer) can also trigger this state.

5 Charging Fault Condition -- Any problems with charging will land you here

For the purpose of waiting for Roomba to be ready to start a new mission, I would look for Trickle charging.

Title: Meaning of Roomba's charging states


问:
DC motor direct loading
I found many tutorials and online calculators for the selection of dc motor to drive wheel, I understood how the torque affect the driving of wheel.

But what happen when I change the orientation of motor and load? What is the main criteria for a dc motor to work when I want to rotate a plate which is vertically mounted on motor's shaft, when the motor is placed vertically also (as shown in the picture)?

I am not an engineering student so please provide me an answer as simple as possible.

答:
I would say that the main criteria for a motor mounted in this way would be to ensure that's it's balanced, equal to it's middle position and well supported and secured to it's base. </p>

<p>You will have centrifugal force wanting to pull the centre shaft outwards. This force will increase the faster you spin the plate. The torque calculation should be the same but you might need to take into account the weight (if any) acting down on the motor's shaft. Also make the plate as light as possible as this will reduce load bearing on the shaft and reduce the centrifugal force.  </p>

Title: DC motor direct loading

Body:
I would say that the main criteria for a motor mounted in this way would be to ensure that's it's balanced, equal to it's middle position and well supported and secured to it's base.

You will have centrifugal force wanting to pull the centre shaft outwards. This force will increase the faster you spin the plate. The torque calculation should be the same but you might need to take into account the weight (if any) acting down on the motor's shaft. Also make the plate as light as possible as this will reduce load bearing on the shaft and reduce the centrifugal force.


问:
differential drive PID controller
I have a differential drive robot that works fine (good PD parameters) driving at say 1 m/s. Now, if it speeds up (to 1.2 m/s) it starts wobbling again. What would be a good strategy for a controller that is able to cope with the whole speed range of 0 - 4 m/s?

edit 14th of April:

The robot is a line follow robot but I do not see how this would be related to my question since a robot following a trajectory would have the same problem.

I recently talked to other developers of differential drive robots and they are facing similar issues e.g. they told me that they need to adjust PID parameters once the battery is not fully charged hence the robot drives at a different speed.

I do not know if you guys are into youtube, but if your are really interested in my robot this link would be helpful: https://www.youtube.com/watch?v=vMedNPhXlEo

PID parameters are: P 0.31, D 0.59, I 0.00

PID controller programmed using C:

```<code>  // note: the inner wheel turns backwards for narrow curves
  // cte is -128..128 depending on the robots position
  // relative to a trajectory / black line
  /** Execute the PID controller and update motor speeds */
  void PID()
  {
    int32_t steer;
    int32_t cte;
    cte = 128 - get_segment_center(0);
    // Compute PID equation
    steer = (int)(
      -P * (float)cte
      -D * (float)(cte - diff_cte) / (float)PERIOD_MS
      -I * (float)int_cte
    );
    if (steer < -5)
    {
      // turn left
      turn = -1;
      uXbot_move(MAX_SPEED + steer, MAX_SPEED);
    }
    else if (steer > 5)
    {
      // turn right
      turn = 1;
      uXbot_move(MAX_SPEED, MAX_SPEED - steer);
    }
    else
    {
      // go straight
      turn = 0;
      uXbot_move(MAX_SPEED, MAX_SPEED);
    }
    diff_cte = cte;
    int_cte += cte;
  }
</code>```

答:
I see that his question is from a long time ago but, just in case it still gets attention, here are some thoughts based on running a small line follower:

Let's address the battery problem first:

I assume that the statement uXbot_move(MAX_SPEED + steer, MAX_SPEED); has parameters that map to PWM values - possibly by some scaling factor.

A fixed PWM value will produce a different drive voltage as the battery voltage sags. In your motor driver, measure the battery voltage with an ADC input. Use that value to adjust the actual PWM duty cycle so that the average voltage stays constant. Change the uxBot() to accept a Voltage rather than a PWM. Now you are able to command, say, 3 Volts to the motor and be confident that is what it gets regardless (within limits) of the actual battery voltage. If you had 8 bits of PWM resolution you might end up with code fragments like these:

```<code>void setLeftMotorVolts(float volts) {
  int motorPWM = (255 * volts) / batteryVolts;
  setLeftMotorPWM(motorPWM);
}

void setRightMotorVolts(float volts) {
  // reverse the right motor
  int motorPWM = (-255 * volts) / batteryVolts;
  setRightMotorPWM(motorPWM);
}
</code>```

How about the performance tuning with speed:

```<code>    if (steer < -5)
    {
      // turn left
      turn = -1;
      uXbot_move(MAX_SPEED + steer, MAX_SPEED);
    } else if (steer > 5)
    {
      // turn right
      turn = 1;
      uXbot_move(MAX_SPEED, MAX_SPEED - steer);
    } else {
      // go straight
      turn = 0;
      uXbot_move(MAX_SPEED, MAX_SPEED);
    }
</code>```

Part of the problem here is that the robot forward speed will change as it turns. Any turning motion will reduce the forward speed. The effect is clearly visible in the video you linked to. While this can help navigate sharp turns it messes with the dynamics somewhat.

If, instead, you make changes to BOTH wheel speeds together, the forward speed will remain constant. Clearly, there must be some headroom left for the outer wheel to be able to increase speed. With both wheels changing speed, the code fragment above would reduce to just:

```<code>uXbot_move(MAX_SPEED + steer, MAX_SPEED - steer);
</code>```

That will make the response consistent but the controller may still have trouble adapting to different speeds. To sort that out, consider scaling the steering correction with the current speed. That is, the correction will be larger at higher speeds.

Thinking about the controller, I have three observations.

First, it is important that the PID function is called at regular, constant intervals. It just does not work well unless that is true. Your code does not specify that so it may already be true. Indeed, the existence of the division by PERIOD_MS indicates that you are aware of this.

Second, for the specific line following task that you describe, you do not need an I term in the controller. In fact, because you do nothing to limit integral windup, it may be doing more harm than good.

Finally, unless you are seriously limited for processor power, do your calculations in floating point as much as possible. Only reduce to an int when you actually calculate the PWM duty cycle for the timer register.

Title: differential drive PID controller

Body:
I see that his question is from a long time ago but, just in case it still gets attention, here are some thoughts based on running a small line follower:

Let's address the battery problem first:

I assume that the statement uXbot_move(MAX_SPEED + steer, MAX_SPEED); has parameters that map to PWM values - possibly by some scaling factor.

A fixed PWM value will produce a different drive voltage as the battery voltage sags. In your motor driver, measure the battery voltage with an ADC input. Use that value to adjust the actual PWM duty cycle so that the average voltage stays constant. Change the uxBot() to accept a Voltage rather than a PWM. Now you are able to command, say, 3 Volts to the motor and be confident that is what it gets regardless (within limits) of the actual battery voltage. If you had 8 bits of PWM resolution you might end up with code fragments like these:

void setLeftMotorVolts(float volts) {
  int motorPWM = (255 * volts) / batteryVolts;
  setLeftMotorPWM(motorPWM);
}

void setRightMotorVolts(float volts) {
  // reverse the right motor
  int motorPWM = (-255 * volts) / batteryVolts;
  setRightMotorPWM(motorPWM);
}

How about the performance tuning with speed:

    if (steer < -5)
    {
      // turn left
      turn = -1;
      uXbot_move(MAX_SPEED + steer, MAX_SPEED);
    } else if (steer > 5)
    {
      // turn right
      turn = 1;
      uXbot_move(MAX_SPEED, MAX_SPEED - steer);
    } else {
      // go straight
      turn = 0;
      uXbot_move(MAX_SPEED, MAX_SPEED);
    }

Part of the problem here is that the robot forward speed will change as it turns. Any turning motion will reduce the forward speed. The effect is clearly visible in the video you linked to. While this can help navigate sharp turns it messes with the dynamics somewhat.

If, instead, you make changes to BOTH wheel speeds together, the forward speed will remain constant. Clearly, there must be some headroom left for the outer wheel to be able to increase speed. With both wheels changing speed, the code fragment above would reduce to just:

uXbot_move(MAX_SPEED + steer, MAX_SPEED - steer);

That will make the response consistent but the controller may still have trouble adapting to different speeds. To sort that out, consider scaling the steering correction with the current speed. That is, the correction will be larger at higher speeds.

Thinking about the controller, I have three observations.

First, it is important that the PID function is called at regular, constant intervals. It just does not work well unless that is true. Your code does not specify that so it may already be true. Indeed, the existence of the division by PERIOD_MS indicates that you are aware of this.

Second, for the specific line following task that you describe, you do not need an I term in the controller. In fact, because you do nothing to limit integral windup, it may be doing more harm than good.

Finally, unless you are seriously limited for processor power, do your calculations in floating point as much as possible. Only reduce to an int when you actually calculate the PWM duty cycle for the timer register.


问:
Is it to possible to measure a room exact with rplidar?
I want to measure a room using rp3+, rplidar, ROS and SLAM.

It should be easy possible to create mapping of the room. But how exact it would be? Is it possible to get less than 1 cm precision over 10m?

Regarding the rplidar specification its possible, but it is also applies for real environment?

答:
You don't say which RPLIDAR you are talking about, but looking at the spec of the RPLIDAR A2M8 (the first hit on google), it has a range of 0.15 m to 12 m, and an angular resolution of between 0.45 and 1.35 degrees.

LIDAR in a fixed position in the centre of the room

We can use trig to calculate the distance to the corners of the room and convert angular resolution to linear resolution:

$$a^2 +b^2 = c^2$$
$$\tan A = a/b$$

based on

If your room 10m x 10m then Pythagoras' Theorem gives us 707 cm from the centre of the room to the corners.

With $A$ as the angular resolution and $b$ as the range, then $a$ is the linear resolution:

$$ a = b \tan A$$

If we assume that this LIDAR can achieve 0.45 degrees at 707 cm then plugging these values into the equation we get an 5.55 cm linear resolution.

I suspect that angular resolution and range are linked however, so angular resolution at 707 cm will probably be closer to 1.35 than 0.45 degrees.

If we assume a more realistic 1 degree angular resolution (by linear interpolation), we get a 12.34 cm linear resolution.

Both of these are much larger than your desired 1 cm resolution, so no, this LADAR can't do what you want with a single 2D point cloud.

In order to get 1cm resolution over 10m with a LIDAR, you would need one with an angular resolution of just 0.08 degrees at 707 cm, which seems like quite a jump.

LIDAR on a movable platform

The maths change if you are able to move your LIDAR to any position within the room. Then you are limited by the number of point clouds you are prepared to measure, and some combination of the positional accuracy of your LIDAR and/or distribution of features.

If you take a point cloud every 100 cm (a 9x9 grid) then the maximum diagonal distance of each point cloud would be 141 cm which at 0.45 degrees is 1.11 cm, very close to your desired target.

The trouble is you now have 81 point clouds to fuse together.

The more point clouds you measure, the higher the resolution, but given the minimum distance of the LIDAR is 15cm, there is little point in taking a measurement more than every 30cm.

A 31x31 grid would have a separation of 31.25 cm and a maximum diagonal distance of 44.19 cm, which at 0.45 degrees would be 0.35 cm.

Data fusion uncertainty and accumulated errors

Once you have all of your point clouds, you then have to fuse them together, and this is where it starts to get tricky.

To fuse the data you start to become limited by the resolution of the positional data you have for your point clouds.

If your LIDAR is on a mobile robot, you might be limited by the encoders and the accumulated error in position tracking as your robot moves between all of your positions.

You could use the point clouds to correct any positional errors, but that means identifying common features, and the further apart these features are, the lower resolution they become. If your room is a featureless void, the best data you have might be from the one point cloud from the centre of the room. All of the others point clouds have better data for some edges, but worse data for others.


问:
Is there a straightforward 16bit microcontroller?
Background

Some of my sketches or ideas require a common data buss to all perph chips.

The issue

This way issue still lays before me, how then, if I am going for a common data buss. how do I address each chip via this microcontroller?

However, Using a microprocessor is a plus in that direction, but i rather not design something that takes more chips when i can  just handle with one central chip to work out the calculations and decisions.

Main idea

My question is. What is a good microcontroller that offers me

16 bit parallel ports.

easy adressing to perph chips

able to handle a wide variety of brands.

Documents and data sheets that are related

Here are some related documents that I intended to use.

8bit Atmel Atmega640 microcontroller

HS cmos ARING bus interface 16bit

AD5207 2 channel 256 position digital potentiometer

RIRWE416D4 series 4M high speed SRAM 256kbit × 16 bit

Finding a good microcontroller will be a step into finding a good 16 ADC.

Why this question

The intersil 80cxx platform is cringe worthy in my view because, the address and the data is share a common pin set and I need extra hardware to demux the data and the address. Also,  the platform they give is byte oriented I need word.

Replacement requirements.

I need something that gives me good high speed performance that I can use in a microcomputer esk layout.

My number one priority is finding something that is highly customizable with the requirement that I can use the standard 15 pin serial com ports or at least

The parallax propellor 8 core is close could go down to two core.

答: The propeller core is flexible to allow 16 bit ports and SPI, I2C or any data buss nterfacing protocol. Without the need for interrupts.</p>


问:
A powerful pull/rotate device that provides a certain (controllable) force?
I don't know how to call the device I'm looking for (or need to create), maybe you can help me with terminology too so I can at least search..

I want something that either rotates or pulls with a certain (controllable) force, i.e. not like a servo/stepper motor which control position, but on the contrary, it should be able to "catch up" to the moving load fast or stay still if the load is too heavy, but provide a steady pull of a certain force. Do these things exist and if so, what are they called? Do you know of any such thing that does it out of the box?

Btw I'm looking for something that pulls in the range of 100-200 lb, so the constant tension things from sewing machines won't work :)

答: I would use a stepper motor with a spring and dash pot connection to the output shaft and a variable resistor or optical feedback measuring the difference between the motor and the output shaft. </p>


问:
Is there a Java or mathematical algorithm for Pure Path Pursuit?
I was building a robot which I wanted to have smooth consistent motions and pathways. I am somewhat familiar with Pure Path Pursuit and wanted to know if someone could point me towards a mathematical or Java algorithm which I could implement or take a look at in order to better understand this concept. Any help is appreciated. Thanks!</p>

答:
Here's an example implementation in Java for FRC:

https://github.com/Team488/SeriouslyCommonLib/blob/master/src/main/java/xbot/common/subsystems/drive/PurePursuitCommand.java

Let us know if we can answer any more questions about it or the general framework.


问:
Beginner Sets for intermediate devs
For a longer time I'm looking for some kind of robotic set, which is programmable, but most things I've found are related to child education or involves a lot of putting all the hardware parts together by yourself.

I'm working as a Software engineer for a longer time, so I have a good knowledge of software languages also on c/c++ .

I've taken several steps in on the Raspberry pi which was very interesting but shortly it turns out I'm not that much interested in soldering hardware parts or something like that.

Can you guys give me some advice on where to start with robotic Programming for adults, without getting to deep into elektronics or hardware engineering, if possible, but to conenctrate on Programming?

Any advice would be great

Thanks

答: They are a little pricey, but you can do really cool things with the Lego Robotics stuff. You can run linux on the Ev3 bricks and then program it however you want. They have a lot of choices for motors/servos and sensors and everything plugs together pretty easily.</p>

Title: Beginner Sets for intermediate devs


问:
How to plot the 3D camera trajectory from a VSLAM output
I am totally new to VSLAM algorithms and would want to plot the path followed by the moving camera. I am using the open source implementation of ORB_SLAM2 for a rgb-d camera on benchmark dataset. The output of the algorithm produces a CameraTrajectory.txt file. The file is in the format : [time_stamp] [tx] [ty] [tz] [qx] [qy] [qz] [qw] . I am aware of that the rotations are in Quarternion form but cannot figure out how to plot the full 3D plot of the camera path from these seven values tx,ty,tz,qx,qy,qz,qw . I need a [time_stamp] [x] [y] [z] format.</p>

答:
That's simple.

If you use matlab or opengl what you need to do is just drawing 3 axis at (tx,ty,tz).
You need to convert quaternion to rotation matrix.

(qx,qy,qz,qw) -> R(3x3 matrix)

where each col of R is the axis you need. The axis just a line segment where it start from (tx,ty,tz) and end at (tx+rx,ty+ry,tz+rz).

There are libraries for quaternion to rotation conversion. You don't need to implement it yourself.


答:
In words, rather than code.  Assume you have the path defined as a dense list of points.

Find the point on the path closest to robot

Draw a circle of radius R about that point, then find the point on the path where the circle cuts (usually the circle will cut between two points).  The circle may cut the path multiple times, take the closest (along the path) point.

Moving at constant velocity, steer toward that point using some kind of proportional controller

Repeat

Title: Is there a Java or mathematical algorithm for Pure Path Pursuit?

Body: I was building a robot which I wanted to have smooth consistent motions and pathways. I am somewhat familiar with Pure Path Pursuit and wanted to know if someone could point me towards a mathematical or Java algorithm which I could implement or take a look at in order to better understand this concept. Any help is appreciated. Thanks!</p>


答:
You are reading it too narrowly.

You don't "need" odometery. SLAM is simply a way to fuse any sensor estimates into a consistent estimate of the robot's state.

"Feature-based" doesn't necessarily mean you need to have identifiable features everywhere in the environment.

First principal of sensor fusion: Two estimates are better than one!

Example

I haven't read the book "for dummies" but if they don't do the following numeric example, I'd set the book on fire and get a better one. And if they do have this example, then I wonder why you didn't mention it!

( you can follow along in the math here )

A robot is at position $x=0$, and is moving to the right (increasing $x$). In this perfect world, the dynamics and sensor modes are linear. (otherwise use EKF, PF, or some variant).

There's a wall at exactly $x=10$ which the robot can measure distance to.

The robot has a laser scanner to get distance with sensor variance $\sigma_l^2=.1$

The robot can measure it's distance travelled with odometers using sensor variance $\sigma_o^2 = .5$. Clearly the laser is more accurate than the odos.

Here's how the robot handles SLAM in this simple environment. (note this is actually localization since we aren't updating the position of the wall).

The robot tries to move one unit to the right.

Odometry measures $x=.9$

Laser scanner says you are $8.8$ units from the wall. (implying you are at 1.2)

Question: Where are you?

Do you choose the best sensor? In this case, the laser is the best right? So obviously I'm at $x=1.2$.

Do you choose the one "closest" to what you expect? Well in this case I think we should use odometry, since $.9$ is closer to what I intended, (moving one unit).

Maybe you could average the two? Well, that's better, but it is susceptible to outliers.

The shiny principals of sensor fusion tell you how to answer the question as follows:

Your minimum mean-squared estimate of the robot position is given by:

$$x_{mmse}=\frac{\sigma_l^2}{\sigma_o^2+\sigma_l^2}(.9) + \frac{\sigma_o^2}{\sigma_o^2+\sigma_l^2}(1.2)$$
$$x_{mmse}=\frac{.1}{.6}(.9) + \frac{.5}{.6}(1.2)$$
$$x_{mmse}=1.15$$

... unless I screwed up the algebra somewhere. People localize airplanes using math not much more complicated than that.

Title: In EKF-SLAM, why do we even need odometry when there is a more reliable sensor?Also, are all SLAM algorithms feature-based?

Body: In the book of SLAM for dummies, why do we even need the odometry when the robot would use the data retrieved from the laser scanner which is more accurate than odometry? Why not just rerly on the laser scanner and do away from the odometry? Is there any contribution by the odometry that the laser scanner does not have? Also, are all SLAM algorithms feature-based?</p>


问:
IK - 3dof - iterative
I want to solve for a 3dof planar arm using gradient descent to approximate end position. Now I am a little confused about the formula and was wondering if someone can help me out.

This is my thought process:

First start about using the forward kinematic solution mapping angles to euclidean space:

$x = l_1 * cos\theta_1 + l_2 * \cos(\theta_1 + \theta_2) + l_3 * \cos(\theta_1 + \theta_2 + \theta_3)$

$y = l_1 * sin\theta_1 + l_2 * \sin(\theta_1 + \theta_2) + l_3 * \sin(\theta_1 + \theta_2 + \theta_3)$

$\phi = (\theta_1 + \theta_2 + \theta_3)$

Now to I need to define a cost function ( that is where I get a little stuck), I know from a 2dof example, that I need to minimize the distance from the endpoint of my arm $x_{ep} $ to the target in euclidean space $x_{tg}$. defined as: $|| x_{ep} - x_{tg}||^2$ using gradient descent. Now, for a 3dof arm, obviously I would have an unlimited amount of solutions with this solution, so that I need to add one additional constraint, namely the angle $\phi$ for my endeffector too. Here I am not quite sure on how to add the angle to the cost function as a parameter.

Then I would find the gradient function $\nabla f_{cost} $ for each $\theta$, in respect to my cost function, specified above using partial derivatives.
$\frac{\partial f_{cost}}{\partial \theta_{1}}(|| \begin{bmatrix}
           x_{ep} \\
           y_{ep} \\
           \phi_{ep}
         \end{bmatrix} - \begin{bmatrix}
           x_{tg} \\
           y_{tg} \\
           \phi_{tg}
         \end{bmatrix}||^2)$, $\frac{\partial f_{cost}}{\partial \theta_{2}} ...$ , $\frac{\partial f_{cost}}{\partial \theta_{3}} ...$

Then we simply try to iteratively minimize the cost function until we are below a tolerance $tol$.

I know there is a missing piece, but I am not quite sure where, I believe it lies the cost function. Maybe I am wrong, thank you for your suggestions!

答:
It can be demonstrated that the Gradient Descent (GD) policy corresponds to the use of the classical Jacobian transposed method for solving IK problems in robotics.

This strategy does not suffer from singularities but turns out to be slow and can get stuck in particular circumstances. More importantly, GD does not offer a principled way to deal with multiple prioritized objectives as you are looking for, instead.

To this end, you ought to make use of the Jacobian pseudoinverse $\mathbf{J}^+$ that allows you to exploit kinematic redundancies to implement a hierarchy of tasks to be attained.

In particular, this policy can be represented by the following relation:

$$
\mathbf{\dot{q}} = \mathbf{J}^+ \cdot \left( \mathbf{x}_\text{tg} - \mathbf{x}_\text{ep} \right) + \left( \mathbf{I} - \mathbf{J}^+\mathbf{J} \right) \cdot \mathbf{\dot{q}_0},
$$

where:

$\mathbf{\dot{q}}$ is the direction where to convergence iteratively (or, equivalently, the velocity that you would send to the joints).

$\left( \mathbf{x}_{tg} - \mathbf{x}_{ep} \right)$ is the primary task that encodes the reaching in position.

$\mathbf{J}^+=\mathbf{J}^T\left(\mathbf{J}\mathbf{J}^T\right)^{-1}$ is the pseudoinverse of the Jacobian of the primary task $\mathbf{J}=\frac{\partial \left( \mathbf{x}_\text{tg} - \mathbf{x}_\text{ep} \right)}{\partial \mathbf{\theta}}$ (as $\mathbf{J}$ is not square).

$\mathbf{\dot{q}_0}$ is the Jacobian of the secondary task − not yet specified − that encodes the reaching in orientation.

$\left( \mathbf{I} - \mathbf{J}^+\mathbf{J} \right)$ is the Null Space projection ensuring that the secondary task won't interfere with the primary task. In essence, the algorithm will provide directions that will drive the system toward both the objectives, if possible; otherwise, the primary task will take over the secondary task. Therefore, the primary task acts as a constraint in a typical optimization setting.

In our context, the simplest secondary objective $q_0$ could be:

$$
q_0 = \left( \phi_\text{tg} - \phi \right)^2.
$$

Hence, it stems that:

$$
\mathbf{\dot{q}_0} = \frac{\partial q_0}{\partial \mathbf{\theta}}.
$$

Remarkably, $\mathbf{J}^+$ is prone to singularities, thus it can be replaced by the Damped Least-Squares version $\mathbf{J}_\text{DLS}^+$ that makes the policy work very similarly to a Jacobian transposed in the neighborhood of singularities:

$$
\mathbf{J}_\text{DLS}^+ = \mathbf{J}^T\left(\mathbf{J}\mathbf{J}^T + \mu^2\mathbf{I}\right)^{-1},
$$

where $\mu$ is a damping factor that can be chosen as a function of the smallest singular value of $\mathbf{J}$.

Interestingly enough, we challenge students with the same exact problem during our school on robot programming

References

https://www.dis.uniroma1.it/~deluca/rob2_en/02_KinematicRedundancy.pdf

Title: IK - 3dof - iterative


答: If I understand your question correctly, it seems to me that you are looking for a DC torque motor (brushed or brushless) with a suitable sensor attached to the load or to the output shaft. The sensor measures whatever it is what you want to control, you need a processor to implement the control system algorithms, and a power amplifier to deliver electrical power to the motor.</p>

Title: A powerful pull/rotate device that provides a certain (controllable) force?

Body:
I don't know how to call the device I'm looking for (or need to create), maybe you can help me with terminology too so I can at least search..

I want something that either rotates or pulls with a certain (controllable) force, i.e. not like a servo/stepper motor which control position, but on the contrary, it should be able to "catch up" to the moving load fast or stay still if the load is too heavy, but provide a steady pull of a certain force. Do these things exist and if so, what are they called? Do you know of any such thing that does it out of the box?

Btw I'm looking for something that pulls in the range of 100-200 lb, so the constant tension things from sewing machines won't work :)


问:
How to control the velocity of a mobile robot?
I have a differential drive robot whose linear velocity and angular velocity is to be controlled. The current strategy for doing that is:

A high level path tracking module spits out the reference velocities (linear and angular)

Using the kinematic equations of the differential drive robot, the rpm of each wheel is calculated.

A PID controller is run for each motor which achieves the desired RPM for that motor.

Is this a good strategy for controlling the linear and angular velocity?

It seems like an open loop controller because two separate PIDs are just maintaining the RPMs of individual motors. But the linear and angular velocities seem uncontrolled.

If I want to model a plant whose states are linear velocity and angular velocity, I don't know how to find the dynamics equation for the states (linear acceleration and angular acceleration)

Even if I refer to the data sheet of the motors and get the dynamics right would it make sense to implement such a controller?

What would be the best way to go about this problem of controlling linear and angular velocity of a mobile robot?

答:
The strategy you outlined is up to the task only if the high-level path planning will be undertaking every once in a while the required corrections to compensate for the unavoidable mismatches between the commanded velocities delivered to the system and the actual feedback that might be represented as current locations along a designed path within the map.

On the other hand, your goal of coming up with a complete state-space model of the differential drive system would be fruitful only if you can get measurements of the linear and angular velocities independently from the wheels kinematics, as for example by relying on an inertial unit and/or visual odometry. If you can only elaborate wheels feedback, then you are good to go with your policy.


问:
How does it get a bizarre term in triangle law of vector equation in a paper
I am reading the paper "Motion control of wheeled mobile robots"

at page 5, as we have the equation (34.7), i wonder how it contains $− dc(s)\dot s$ in side. As the triangle law of vector: $\vec{OP}=\vec{OP_s} +\vec{P_sP}$. that is enough. Taking derivative, we should get (34.7) without $− dc(s)\dot s$

答:
You made a simple mistake while calculating the derivative.The equation is:
$\vec{OP}= OP_s \vec {i_s} + P_sP \vec {j_s}$

The derivative should be $\partial \vec{OP}/ \partial t =\partial({OP_s}\vec {i_s})/\partial t + \partial (P_sP \vec {j_s})/\partial t  = \partial({OP_s}\vec {i_s})/\partial t $ but it's given that $d\vec{OP_s} / dt = \partial ({OP_s}\vec {i_s}) /\partial t = \dot s \vec {i_s}$.

Now for the second term:

$\partial (P_sP \vec {j_s})/\partial t = (\partial P_sP/ \partial t) \vec{j_s} + (P_sP) \partial \vec {j_s} / \partial t$

So you have $ (\partial P_sP/ \partial t) \vec{j_s} = \dot d \vec{j_s}$

And $ P_sP \partial \vec {j_s} / \partial t = d (\partial \vec {j_s} / \partial s) * \partial s/ \partial t = d \partial \vec {j_s} / \partial s * \dot s$. to calculate the derivative of  the normal vector at that point you can check out this book eq. (3.4) and (3.6), added to this you curve is planar and the vectors $\vec {i_s}, \vec {j_s}$ are in the same plane so you end up to eq. (4.1) which is the eq. you where searching for.


答:
In general, there are two options available. The first one is called model predictive control which means to simulate future states of the system and search in the game tree for a pleasant node. The second strategy is “direct control”, which can be realized as a pid controller. The idea is to implement if-then-statements without predicting the future.

To figure out which strategy is preferred the overall human-machine-interaction has to be investigated. The first step is, not to program a control loop but to create an event recorder who saves the human actions into a queue. New sensor/action measurements are replacing older ones, similar to a black box in a truck. In the second step, the recorded game log gets analyzed and then a decision is made which kind of control strategy will work.

The idea in the original post with a high level path tracking module make sense. The concept can be explored further into a qualitative simulation. That is a symbolic description of the system which leaves out the details. Sometimes it can help to handle complex differential equations more easily. Creating a qualitative simulation is similar to program a computer game for a low end computer like the Commodore 64. That means, the simulation is not working accurate, but it's a simplified description of the problem.

Title: How to control the velocity of a mobile robot?

Body:
I have a differential drive robot whose linear velocity and angular velocity is to be controlled. The current strategy for doing that is:

A high level path tracking module spits out the reference velocities (linear and angular)

Using the kinematic equations of the differential drive robot, the rpm of each wheel is calculated.

A PID controller is run for each motor which achieves the desired RPM for that motor.

Is this a good strategy for controlling the linear and angular velocity?

It seems like an open loop controller because two separate PIDs are just maintaining the RPMs of individual motors. But the linear and angular velocities seem uncontrolled.

If I want to model a plant whose states are linear velocity and angular velocity, I don't know how to find the dynamics equation for the states (linear acceleration and angular acceleration)

Even if I refer to the data sheet of the motors and get the dynamics right would it make sense to implement such a controller?

What would be the best way to go about this problem of controlling linear and angular velocity of a mobile robot?


问:
Convert Vehicle coordinates to World coordinates for positioning
I'm tracking the position of a vehicle along a certain trajectory using the Kalman filter and the idea is to check for improvements in position estimation through fusion of data from multiple sensors (We consider data from 2 inputs: GPS and Odometry)

GPS data is recorded through an app on the iPhone and gives information about the Latitude, Longitude, Elevation and Timestamp Information. This GPS data is in 3D spherical coordinates and is converted to 2D Cartesian using UTM (UTM is projected cartesian System). Thus, we have the position of the vehicle through GPS in world coordinates (in m).

Odometry data is recorded through measurement sensors on vehicle and gives the x-position of the vehicle, y-position of the vehicle and orientation of the vehicle. This is calculated based on the wheelticks and is relative to the inertial origin of coordinates. Thus, we have the position of the vehicle through Odometry in vehicle coordinates (in mm). The GPS data updates once every 1000ms and Odometry data is given once every 20ms.

How do we relate the position data from vehicle coordinates system with the data from world coordinates?

(Eg: If I check the data for some point, I see GPS data for the position (x,y) to be (661272.59, 1.517914e+06) and Odometry data for some point to be (414,6) and, both are measurements given to the Kalman. How do we relate the position given by odometry with the corresponding GPS point?)

What is meant by inertial origin of coordinates and inertial coordinate system? (I read about dead reckoning systems but, in this case, we do not have information about the accelerometer, gyroscopes, etc and only get information about positioning of vehicle from wheel ticks)

答: The GPS gives you the absolute position (in world coordinate system), while the encoders the relative position of the vehicle, according to the initial assumption that you made. To simplify from GPS you get the actual position, while from the encoders you get the path traveled between 2 measurements. In your position I would get the as initial position the one from the GPS and then when I would get measurement from the encoders I would just update the position, finally when I would get again both the measurements feed them to the filter.


问:
/odom topics not matching ERROR
I have an existing ROS workspace which was built in C++. I am trying to implement a node built by The Construct in python which reads distance travelled from the /odom topic. I have successfully built a package within my existing work space containing their code and can run the node.

When I rosrun the node, I am receiving an error on the roscore saying:

[ERROR]: Client [/movement_detector_node] wants topic /odom to have datatype/md5sum [nav_msgs/Odometry], but our version has [geometry_msgs/PoseArray]. Dropping connection.

It looks like my existing work space uses Type: geometry_msgs/PoseArray
 messages to communicate.

Could I please get some help on the proper way to debug and fix this?

Node for distance collection below. All credit belongs to The Construct.

```<code>#!/usr/bin/env python

import rospy
import math
from nav_msgs.msg import Odometry
from geometry_msgs.msg import Point
from std_msgs.msg import Float64

class MovementDetector(object):
    def __init__(self):
        self._mved_distance = Float64()
        self._mved_distance.data = 0.0
        self.get_init_position()

        self.distance_moved_pub = rospy.Publisher('/moved_distance', Float64, queue_size=1)
        rospy.Subscriber("/odom", Odometry, self.odom_callback)

    def get_init_position(self):
        data_odom = None
        while data_odom is None:
            try:
                data_odom = rospy.wait_for_message("/odom", Odometry, timeout=1)
            except:
                rospy.loginfo("Current odom not ready yet, retrying for setting up init pose")

        self._current_position = Point()
        self._current_position.x = data_odom.pose.pose.position.x
        self._current_position.y = data_odom.pose.pose.position.y
        self._current_position.z = data_odom.pose.pose.position.z

    def odom_callback(self,msg):
        NewPosition = msg.pose.pose.position
        self._mved_distance.data += self.calculate_distance(NewPosition, self._current_position)
        self.updatecurrent_positin(NewPosition)
        if self._mved_distance.data < 0.000001:
            aux = Float64()
            aux.data = 0.0
            self.distance_moved_pub.publish(aux)
        else:
            self.distance_moved_pub.publish(self._mved_distance)

    def updatecurrent_positin(self, new_position):
        self._current_position.x = new_position.x
        self._current_position.y = new_position.y
        self._current_position.z = new_position.z

    def calculate_distance(self, new_position, old_position):
        x2 = new_position.x
        x1 = old_position.x
        y2 = new_position.y
        y1 = old_position.y
        dist = math.hypot(x2 - x1, y2 - y1)
        return dist

    def publish_moved_distance(self):
        """
        Loops untils closed, publishing moved distance
        """
        rospy.spin()

        # spin() simply keeps python from exiting until this node is stopped
        rospy.spin()

if __name__ == '__main__':
    rospy.init_node('movement_detector_node', anonymous=True)
    movement_obj = MovementDetector()
    movement_obj.publish_moved_distance()
</code>```

UPDATE:

I was able to fix this problem but now have an additional question. Basically the existing workspace was expecting the subscriber to use the geometry_msgs\PoseArray message. Once I imported that message and used it in the callback my error went away.

Looking at the geometry_msgs\PoseArray message, it's composed of position and orientation message. For the distance collection script to work, I need to only use the position message of geometry_msgs\PoseArray. I wrote a basic subscriber to practice isolating this data.

Pictures of both message types below. Could someone help me isolate the x, y, and z from the geometry_msgs\PoseArray message?

```<code>#!/usr/bin/env python

import rospy
import math
from nav_msgs.msg import Odometry
from geometry_msgs.msg import PoseArray
from std_msgs.msg import Float64

def callback(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data)

def listener():

    # In ROS, nodes are uniquely named. If two nodes with the same
    # name are launched, the previous one is kicked off. The
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'listener' node so that multiple listeners can
    # run simultaneously.
    rospy.init_node('listener', anonymous=True)

    rospy.Subscriber("odom", PoseArray, callback)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()

if __name__ == '__main__':
    listener()
</code>```

答:
Could someone help me isolate the x, y, and z from the geometry_msgs/PoseArray message?

The code below is your solution as simple for the above question with geometry_msgs/PoseArray message:

```<code>import rospy
from geometry_msgs.msg import PoseArray

def callback(data):
    for pose in data.poses:
        print("X: {}".format(pose.position.x))
        print("Y: {}".format(pose.position.Y))
        print("Z: {}".format(pose.position.z))

def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("odom", PoseArray, callback)
    rospy.spin()

if __name__ == '__main__':
    listener()
</code>```

Title: /odom topics not matching ERROR

Body:
Could someone help me isolate the x, y, and z from the geometry_msgs/PoseArray message?

The code below is your solution as simple for the above question with geometry_msgs/PoseArray message:

import rospy
from geometry_msgs.msg import PoseArray

def callback(data):
    for pose in data.poses:
        print("X: {}".format(pose.position.x))
        print("Y: {}".format(pose.position.Y))
        print("Z: {}".format(pose.position.z))

def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("odom", PoseArray, callback)
    rospy.spin()

if __name__ == '__main__':
    listener()


问:
I want to activate a remote shock collar based on messages in a discord server
So, for starters - this is a kink thing and not an animal abuse thing. I have an introductory understanding of electrical engineering (the most complex thing I've done is make an oscilloscope from an old camp TV) so I'm confident i could create the hardware, but the code side is completely greek to me.

Like I don't even know what kind of board (Arduino?) I would use.

答:
This sounds like an interesting project, but in the current form it's too broad for this board.

This could be a path to follow, if you run into problems, just ask here, but make sure that it's a closed question that deals with a single problem ("How can I simulate a button press on a remote with my ESP32- Arduino"):

I found this: discord-arduino-simplest which is a chatbot that runs on an arduino and turns an led on or off depending on messages in the discord-server.

Other projects:
send discord-message on wifi-arduino

Board wise: the Adafruit HUZZAH32 – ESP32 Feather Board is a good starting point. It has wifi and a battery-connector so you could add it with a small LiPo to the collar. Should be the size of a matchbox.

As you have experience with electronics, you should be able to analyse the receiver on the shock collar. I guess it only sends a signal to the shock-generator which you can also to with the arduino. If you do it right, the normal remote will still work.


问:
iRobot Create2 Programmable Robot: what is already in the robot
I want to buy the programmable iRobot Create2 and I have some questions about:

The "autonomous navigation" with obstacle avoidance is just implemented in the robot when I'll buy it?

And what about the "come back home" in case of discharge? Is already disponible?

What are the sensors already inside the robot? Infrared and leds only?
Thanks in avance

答:
Create 2 has all of the same navigation features and sensors as our Roomba 600 series vacuum cleaning robots. That is to say, it does not have systematic navigation or obstacle avoidance. You may confine it using virtual walls. If your project requires automatic room coverage, such as a roving security bot, you can make use of the built-in coverage algorithm by starting a cleaning cycle through the Open Interface.

Create will return to the dock when its battery is low only if you have it running a cleaning cycle. If you are directly commanding the wheels yourself, it will not automatically return to the dock. You will need to monitor the battery state yourself, at which point you can command it to return to the dock.

Sensors available include wheel encoders, downward-facing IR cliff sensors, forward-facing IR light-touch and wall-follow sensors, the IR receiver for dock/virtual wall codes, the dirt-detect sensor, buttons, and the bumper. A number of internal variables such as battery state and motor current are also available. For actuators you have the two wheels, three cleaning motors, and LEDs.

Here is a link to the Create programming manual:
https://www.irobotweb.com/-/media/MainSite/Files/About/STEM/Create/2018-07-19_iRobot_Roomba_600_Open_Interface_Spec.pdf


答:
As nionios said, the GPS gives you latitude and longitude in global coordinates, while odometry gives the difference between two coordinates, normally using encoders in the motors and/or IMU.

You can use your initial position from the GPS data as your initial position for odometry.

However, as stated here, GPS data has a precision in meters and you won't necessarily increase your accurate position if you use it alongside IMU and encoder information in a Kalman Filter.

Title: Convert Vehicle coordinates to World coordinates for positioning

Body:
I'm tracking the position of a vehicle along a certain trajectory using the Kalman filter and the idea is to check for improvements in position estimation through fusion of data from multiple sensors (We consider data from 2 inputs: GPS and Odometry)

GPS data is recorded through an app on the iPhone and gives information about the Latitude, Longitude, Elevation and Timestamp Information. This GPS data is in 3D spherical coordinates and is converted to 2D Cartesian using UTM (UTM is projected cartesian System). Thus, we have the position of the vehicle through GPS in world coordinates (in m).

Odometry data is recorded through measurement sensors on vehicle and gives the x-position of the vehicle, y-position of the vehicle and orientation of the vehicle. This is calculated based on the wheelticks and is relative to the inertial origin of coordinates. Thus, we have the position of the vehicle through Odometry in vehicle coordinates (in mm). The GPS data updates once every 1000ms and Odometry data is given once every 20ms.

How do we relate the position data from vehicle coordinates system with the data from world coordinates?

(Eg: If I check the data for some point, I see GPS data for the position (x,y) to be (661272.59, 1.517914e+06) and Odometry data for some point to be (414,6) and, both are measurements given to the Kalman. How do we relate the position given by odometry with the corresponding GPS point?)

What is meant by inertial origin of coordinates and inertial coordinate system? (I read about dead reckoning systems but, in this case, we do not have information about the accelerometer, gyroscopes, etc and only get information about positioning of vehicle from wheel ticks)


答:
Modern motor control offerings are able to control position, velocity, and torque (force).
Stepper motors give you good position control, moderate velocity control, and really poor torque control since they pass between pole location and have highly variable torque output.

A brushed DC, brushless DC, AC induction, or best AC permanent magnet servos can offer extremely precise control in all of these areas.

Without knowing you application it is hard to recommend the "best" motor, but in general, DC brushed and brushless servo motors can be purchased relatively inexpensively and are easy to find in the 10W to 1kW range. AC induction motors (with a position control VFD) are very common and while they offer poor position control compared to other options, they are easily in power ranges from 100W to 1000+kW. AC servos are king when it comes to dynamic control, power density, and availability. They can be easily found in power ranges from 50W to 30kW.

Looking at torque, Stepper motors have very high stall torque at low speeds. DC motors offer little torque at very low speeds and are best mated with a gearbox or made significantly oversized for the application. AC servos offer nearly flat torque response for their entire speed range.

In terms of cost, expect a closed loop system to run 2-3x (or more) beyond the cost of open-loop motor control. Closed loop is really necessary if you want to accurately control position or velocity with anything other than a stepper motor.

Feel free to expand on your requirements so we can help you pick the best solution for your application.

Source: I am an industrial controls engineer with a focus in motion control. Hobby robotics guy.


问:
Having trouble getting correct homogeneous transformation matrices for my robotic arm
I am working on a project to build and program a robotic arm. And, no, this is not a HW problem. I have watched a ton of tutorials on the HTM, but its still not fully clicking. The image shows my attempt at the matrices and the robotic arm diagram. Are these correct? The robot will consist of a prismatic joint at the base and then two revolute joints. Thanks for the help.

答:
A quick partial answer to help move you forward:

1) Your axis are labeled for a left-handed coordinate system. Use right-handed (swap the x and y axis in your diagram)

2) There is no prismatic parameter in your diagram. Add it.

3) Frames (Transforms) are placed on the mathematical axis where things move and not necessarily on any body of your device. You are setting yourself up for potential confusion if you draw bodies over your frames as you have done there.

4) Until you have an intuitive understanding, draw 2 axis for each body to help visualize the parameter. You are missing $q_1$ (the prismatic motion) and it may help you become proficient quicker if you change $\theta_1$ and $\theta_2$ to $q_2$ and $q_3$

5) There are 2 standard sets of parameter->transform maths out there. Know which one you are using. The most common is to first do a parameterized transform about $z$ (rotation or linear) and then a constant transform to move the frame to where the next joint is. Until you are comfortable with the math, keep them separate.

6) You should be able to write the matrix for a static transform for any multiple of 90 degrees rotation directly. The first 3 columns of the transform matrix are the rotation component. In the picture below you can see that frame $B$ has it's $x$ axis pointing in the negative $y$ direction, so the $x$ axis direction column is $<0_x,-1_y,0_z>$. The $y$ and $z$ axis of $B$ are written in a similar way. The position column is just the position of the frame. $<0_x,3_y,-1_z>$

So in the end you should have the following transforms (assuming you separate out the parameterized motion as suggested).

Note that frames $1$ and $2q$ as well as frames $2$ and $3q$ share the same z axis. Also I guessed at which direction the prismatic joint pointed.

$H_w^0$ - Transform from origin to where the prismatic axis starts.

$H_0^{1q}$ - Parameterized transform along z axis

$H_{1q}^1$ - Transform to end of Link 1 where the first rotation axis starts

$H_1^{2q}$ - Parameterized rotation around z axis

$H_{2q}^2$ - Transform to end of Link 2 where the second rotation axis starts

$H_2^{3q}$ - Parameterized rotation around z axis

$H_{3q}^{eef}$ - Transform to end of Link 3 where the end effector frame is

The forward kinematics will be the composition of these matrices.

$H_0^{eef} = H_w^0 H_0^{1q} H_{1q}^1 H_1^{2q} H_{2q}^2 H_2^{3q} H_{3q}^{eef} $


问:
In path planning, what kind of path is feasible for a nonholonomic robot?
For a car-like nonholonomic robot, What kind of path is feasible?

Is it right that a path is feasible for a car-like robot if it's curvature continuous, and the curvature on any point doesn't exceed the turning limit of the robot?

I'm not quite sure about this because I noticed some paper said their path planning algorithms deal with the differential constraint of the vehicle. I don't understand what this means. I think if a path is smooth enough, the vehicle should be able to track this path exactly (ignoring the dynamic model).

So what kind of path satisfies the differential constraints of vehicles? Or what kind of path doesn't satisfy the differential constraints of vehicles? I really need some help here.  Thanks!

答:
A non-holonomic vehicle is constrained in 3 degrees of freedom (x, y, theta) where y_dot = 0. A non-holonomic vehicle can therefore only translate along a curved path governed by its kinematics (skid steer differential is different from Ackerman differential). You are correct in saying that a non-holonomic vehicle can only have a feasible path that lies on a curved path from the robots current pose.

When a paper says deal with the differential constraint of the vehicle they mean that the robot cannot, for example, rotate on the spot (skid steer) or actuate in the y or z direction. This is important in path planning because there is no point in considering paths the robot cannot achieve.


问:
Variables that Improve SLAM
I have a general question regarding SLAM as I am not an expert on the topic. What are the variables that can improve map generation?

The ones I can think of are:

A higher resolution camera

Consistent lighting conditions

A room with plenty of high confidence landmarks

A lot of processing power on the robot

Could someone help elaborate this list for me or tell me if I'm completely wrong?

答:
Your Question is in generall so the answers will be, too. What is your application? It is in Indoor or Outdoor? Do you have a specific SLAM in you mind to use?
However, in general, I propose you do not limit your self to monocular cameras. If you are in an indoor environment I propose you RGBD cameras and in an outdoor environment, stereo cameras would be a better fit. Aso do not forget to calibrate your camera, see these two link for calibrating the camera by OpenCV and ROS.
The next stepps will be odometry fusion. Using IMU, wheel encoders, LIDAR, Sonar and so on will be helpful. The robot pose EKF can help you with odometry fusion.     </p>

Title: Variables that Improve SLAM


问:
Are all drone propellers compatible with all brushless motors?
I want to build a drone using these motors

SunnySky X2212 KV1400 Brushless Motor For RC Drone FPV Racing Multi Rotor

and these propellers

DYNAM 2X RC Model Airplanes 9x5 Inch Nylon Propellers DYP-1003

Are all propellers compatible with all brushless motors? If not, how do I know if mine are compatible with each other?

答:
Not at all. It is about efficiency, agility, and maneuverability of your drone.

Just like wheels on a car, the size of the propeller needs to be matched to the rest of the power system. For example, putting 3” props on a motor designed for 5” propellers will result in extremely high RPM and power draw and will create very little thrust. Likewise, putting large props on a small motor will likely be too much for the motor to spin, this will create very little thrust, lots of heat and excessive current draw. Extreme mismatches can damage motors and ESC’s.

The same propeller on two different motors can have vastly different performance. Even in the worst-case scenario it is possible that by a bad chose of your propeller, the drone could not take off or on the other hand, they will break when the robot is flying!

Read more at All about Multirotor Drone FPV Propellers


答: For a skid-steered vehicle, the constraint has this form:  xdot * sin(th) - ydot * cos(th) = 0.  All trajectories must satisfy this equation.  The robot can in fact spin on a dime because such motion has (xdot,ydot)=0.  It can also parallel-park, which is not a smooth path in the (x,y) plane.</p>

Title: In path planning, what kind of path is feasible for a nonholonomic robot?

Body:
For a car-like nonholonomic robot, What kind of path is feasible?

Is it right that a path is feasible for a car-like robot if it's curvature continuous, and the curvature on any point doesn't exceed the turning limit of the robot?

I'm not quite sure about this because I noticed some paper said their path planning algorithms deal with the differential constraint of the vehicle. I don't understand what this means. I think if a path is smooth enough, the vehicle should be able to track this path exactly (ignoring the dynamic model).

So what kind of path satisfies the differential constraints of vehicles? Or what kind of path doesn't satisfy the differential constraints of vehicles? I really need some help here.  Thanks!


问:
Is there a table of DC motors in relation to weight/mass? I want to find the fastest for my build
I am building a line follower robot for a science competition, i have the weight of the components but i don't know what would be the fastest motor i could use to reach the best avg speed of the robot...

Is there some kind of calculator or table of reference for most common dc motors available, weight capacity and avg speed?

Thanks for the attention and sorry if i made the mistake of asking something that was already answered here... i wasn't able to find...

答:
I beleive you’re looking for Power Density

How you utilize said power of course is up to your design. You generally want the most wattage in the smallest package, and you should get something as to what you’re looking for..but for such a small robot, the speed boost may not be as helpful as being able to accurately and quickly accelerate around/past corners.

Engineering is of course a careful balance between optimal choices. Which is not as trivial as one would think. Good luck on your choice!


问:
Choosing path planning and obstacle avoidance algorithm for 2D space
I am working on a 2D space where my robot needs to follow a trajectory while avoiding some obstacles.

I've read recently about methods for path planning as "Vector Field Histogram" and the "Dynamic window approach".

Is it worth to use these kind of algorithms for a 2D space or should I go with something as Potential Fields or Rapidly-Exploring Random Trees?

答:
In a 2D space, you could probably get away with something much simpler to begin with like Breadth-first search, Dijkstra's or A-Star. Combine it with an occupancy grid as a map based on LIDAR data and you'd be good to go. RRT's work well and I've used them in the past, but for much higher dimensional search spaces. In general I would recommend starting out with the simplest solution. If it turns out it doesn't perform fast/well enough, then you upgrade to something more complicated. There's no need to build a formula-1 car to drive to the grocery store XD.

It really depends on your application, and since I know nothing about it, it's hard to give you the best answer.

Edit: RRT* (read: RRT star) is also very nice.


问:
How to convert serial data to sensor_msgs/Range Message
I have a ROS node which manipulates a serial frame, the frame contains ultrasonic measurements, I have to extract this measurement and publish it as sensor_msgs/Range Message, and I am using the following code:

```<code>ros::Rate loop_rate(5);
    while(ros::ok()){
        ros::spinOnce();

        if(ser.available())//serial::Serial ser;
        {
            std::string stringRange = ser.read(ser.available());
            //ROS_INFO_STREAM("Read: " << result.data);
            sonar_msg.range = ::atof(stringRange.c_str());
            sonar_msg.header.stamp = ros::Time::now();
            pub_sonar.publish(&sonar_msg);
        }
        loop_rate.sleep();
    }
</code>```

When I try to build using catkin, the terminal fails and give me an error message:

```<code>error: request for member ‘serialize’ in ‘t’, which is of pointer type
‘boost::call_traits<sensor_msgs::Range_<std::allocator<void>>*>::param_type
               {aka sensor_msgs::Range_<std::allocator<void>>* const}’
 (maybe you meant to use ‘->’ ?)
     t.serialize(stream.getData(), 0);
</code>```

I thing the problem in converting to float data.

How can I solve this?

答:
First of all, You must completely consider all of the parameters in your topic. For example in your case by a simple search, you will find the parameters in sensor_msgs/Range. As you can see it comprise of different parameters like min_range, max_range and so on which is depend on your sensor. Maybe these parameters do not have any important for you but surely it is important when you are using others packages. fill all the parameters step by step.

About your code, please show us a more complete part of the code, how did you define sonar_msg?


问:
Odometry heading and laser scan heading not point to same direction
please help, after so much research still cant find a single solution from google.
some say offset, but there is no offset in the configuration.

problem: odom direction and laser scan heading didnt match

let say the grid with x,y line
positive y is 0 degree and
positive x is 90 degree

im using gmapping to do slam,
and after running gmapping what i get was
the laser scan is facing to 0 degree while
my odom is facing to 90 degree in rviz

i had try to find a solution or similar problem.. but seem there is none like this case out there.

so how can i rotate my odom to match my laser scan?

答: Ros tf will solve your problem. In your case, you can use a static tf in which the translation vector is zero and a 90-degree Rotation matrix.</p>


问:
Localize a Mobile Robot on a Mirror
I am currently busy with a project which requires me to construct a robot capable of cleaning a heliostat (movable mirror used to redirect sunlight). Heliostats are basically large flat mirrors that track and reflect the sun. In order to be cleaned, the heliostats would be stowed in a horizontal position so that the robot may drive over its surface.

My question is then how or what sensors would i use to localize the robot on the mirror. From what i have seen many robotic sensors are unable to effectively detect glass, which seems to be a problem as the systems only real reference is the mirror. I am considering using a type of cliff sensor similar to the ones on robotic vacuum cleaners, but how would i localize the robot when its in the middle region of the mirror? Will the cliff sensors and wheel odometers be enough to fully localize this robot or not? i.e. What sensors would work?

I have attached both a basic image of the robot as well as an image of a typical heliostat the robot will need to clean. Mirror sizes may vary but this size is roughly 1m x 2m Please let me know if i must provide more information to clarify the question.

答: I don’t think you need any complex sensing device.  You could extend the body of your robot to include a housing which holds an LED, aimed toward the mirror and tilted slightly to the interior of your robot.  The extended body would block outside light from interfering with the LED signal.  You could place a photodiode in your robot to give a binary signal for detecting the presence of the LED signal.  When the edge of the mirror is encountered, the LED signal would cease to be reflected to the photodiode. </p>

Title: Localize a Mobile Robot on a Mirror


问:
Regarding kalman filter implementation
I think I might have originally posted this in the wrong stack exchange forum, link. I think this might be the right place, I am not sure if posting again is considered "bad style", I apologize if this is the case.

My questions is regarding the implementation of a discrete time Kalman filter assuming the time update occurs much more often than measurement update. I'll be specifically looking at the covariance propagation and Kalman gain equations.

Given a D.T. KF with the following state space model:
$$
\hat{x}_{k+1} = F \hat{x}_k + G \omega_k
$$
$$
\hat{y}_k = C \hat{x}_k + \upsilon_k
$$
and assuming $\hat{x}^-(0)$ and $P^-(0)$ are known as well as the process and measurement noise intensities (Q and R respectively) the relevant equations are:

Gain update:
$$
K = P^-C^T (CP^- C^T + R)^{-1}
$$
Measurement update
$$
P^- = F P^+ F^T + Q
$$
Time Update:
$$
P^+ = (I-KC)P^-
$$

The difficulty I am having is with respect to implementation and how to properly initialize. A pseudo code example of what I think should be done is the following:

```<code>% Assume P0 is given
Pp = P0;                                       % Initializing P-
for i=1:N                                      % N = number of measurement updates
    for j=1:m                                  % m = number of time updates in one measurement update
        Pp = F*Pu*F' + Qd;                     % covariance prop
    end
    K = Pp*C'*(R + C*Pp*C')^(-1)        % update gain
    Pu = (eye(nx) - K*C)*Pp;            % measurement update
end
</code>```

But this has the problem that the first iteration Pp cannot compute because there has yet to be a measurement update. This is easily solved by forcing a measurement update before any time updates. Maybe it's just me but it seems kind of incorrect to NEED a measurement update before any time updates.

答:
I believe you are misunderstanding some of the Kalman filter equations. There is no such thing as a time update.

What you have shown here

Time Update:

$$P^+ = (I-KC)P^-$$

is the updating of the uncertainty/covariance from the measurement update. You can see this labeled properly on the wikipedia article on the kalman filter.

In your code your initial value of Pu should be set to the uncertainty of your initial value. If you don't know this then usually Identity will work and it will update itself accordingly.

Also in general I don't really see how your code is going to work. You shouldn't really have two for loops. You should have 1 for loop and and an if state for the measurement update. Generally I would also separate the update and prediction into two functions.

I don't know your application and this is an EKF but try to structure your code similarly to this example.

Title: Regarding kalman filter implementation


问:
Is it possible to use HC-SR04 ultrasonic range sensor to indicate thickness of a material
The HC-SR04 is directly connected to an Arduino board with the receiver end(echo) connected to analog pin 2 and the transmitter (trigger) connected to digital pin 4.

I am wondering if I can use the sensor to sense the change in saturation from when object block its path. The receiver and transmitter will be positioned like this

The line in the middle is supposed to be a paper. I'll be using it to see the difference between one paper and two paper when they travel trough the two.

Now I'm not sure if this is possible but the way I see it working is kind of similar to an IR LED Arduino program connected to an LED, where when one paper passes trough the light gets a little bit weaker and with two it takes a heavier hit.

Is this possible?

答:
The short answer is "no, a sonic range sensor can't do it".

It might "work" under very controlled conditions, but relying on only the attenuation of the returned signal to determine thickness may leave you open to incorrect results due to multipath propagation effects.

The more traditional way to measure thickness with sound is called profiling.  The following is excerpted from a USGS Woods Hole Science Center page on Seismic Profiling systems:

reflection profiling is accomplished by [emitting] acoustic energy in timed intervals [...]. The transmitted acoustic energy is reflected from boundaries between various layers with different acoustic impedances [i.e. the air and the paper]. Acoustic impedance is defined by the bulk density of the medium times the velocity of the sound within that medium. The reflected acoustic signal is received [by one or more microphones]. The receiver converts the reflected signal to an analog signal [which is digitized and heavily processed to determine the makeup of the materials].

Rather than just measuring the time of the incoming pulse, you'd need to analyze both the time and frequency domain of the recovered signal to solve for the acoustic properties necessary to transform your transmitted pulse into the received pulse.

So the long answer is that it can be done sonically, although a sonic range sensor is generally insufficient for this purpose.


问:
Moving clock arms individually
I have as project to build something like this ( using arduino if possible ): http://clockclock.com

The one modelization that came across my mind is to take 2 sticks ( as clock arms ) and command them manually using one ( or two ) motors that will be under them.
However, I fail to find the adequate motor. Basic motors have just one axis in the center that i can control; This would perfectly move ONE clock arm, but the second will just have to follow it...

As solution to create the mechanism will be a great help, I'm still so new at this.

答:
In the linked page, the arms of the clocks move pretty much independently. It means that you cannot use some simple gear mechanisms to generate that kind of movement using only one motor.

Therefore, using two motors is a must.

Title: Moving clock arms individually


问:
SLAM and navigation
I have a question about SLAM. Is it common for SLAM to be used for mere map generation? For instance, have a map generated using ORB-SLAM and then freeze the map for future path planning where future updates are prohibited. I suppose, the map becomes a static map. However, is the common application to constantly update the map?</p>

答:
From my point of view, the answer really depends on the context you are working in.

For example, in most industrial applications when people refer to SLAM navigation, they incorrectly mean Lidar based localization. In fact, SLAM is only applied in the first step, when creating the map. Then, the map is saved as you said and used for the localization. This has to be done this way since the precision needed in those applications is quite challenging, and remapping might cause precision loses.

In other contexts, the approach might be different (autonomous navigation, cartography, etc.), and the maps might be updated in runtime.

Title: SLAM and navigation