问:
Error during mavros Multi-Vehicle Simulation with px4 in Gazebo | Invalid <param> tag
I followed the instruction as mentioned here. Everything worked fine but at last stage when I try to run:-

```<code>roslaunch px4 multi_uav_mavros_sitl.launch
</code>```

I get following:-

```<code>... logging to /home/yograj/.ros/log/40d4394e-0a3d-11e8-a1f1-3c77e68de09b/roslaunch-yograj-Inspiron-5537-12334.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Usage: xacro.py [options] <input>

xacro.py: error: expected exactly one input file as argument
while processing /home/yograj/src/Firmware/launch/single_vehcile_spawn.launch:
Invalid <param> tag: Cannot load command parameter [iris_1_sdf]: command [/opt/ros/kinetic/share/xacro/xacro.py /home/yograj/src/Firmware/Tools/sitl_gazebo/models/rotors_description/urdf/iris_base.xacro rotors_description_dir:=/home/yograj/src/Firmware/Tools/sitl_gazebo/models/rotors_description mavlink_udp_port:=14560 > iris_1.urdf ; 'gz sdf -p iris_1.urdf'] returned with code [2].

Param xml is <param command="$(arg cmd)" name="$(arg vehicle)_$(arg ID)_sdf"/>
The traceback for the exception was written to the log file
</code>```

Launch file

```<code><launch>

    <!-- Posix SITL environment launch script -->
    <arg name="x" default="0"/>
    <arg name="y" default="0"/>
    <arg name="z" default="0"/>
    <arg name="R" default="0"/>
    <arg name="P" default="0"/>
    <arg name="Y" default="0"/>
    <arg name="est" default="ekf2"/>
    <arg name="vehicle" default="iris"/>
    <arg name="ID" default="1"/>
    <arg name="rcS" default="$(find px4)/posix-configs/SITL/init/$(arg est)/$(arg vehicle)_$(arg ID)"/>
    <arg name="mavlink_udp_port" default="14560" />

    <arg name="cmd" default="$(find xacro)/xacro.py $(find px4)/Tools/sitl_gazebo/models/rotors_description/urdf/$(arg vehicle)_base.xacro rotors_description_dir:=$(find px4)/Tools/sitl_gazebo/models/rotors_description mavlink_udp_port:=$(arg mavlink_udp_port) > $(arg vehicle)_$(arg ID).urdf ; 'gz sdf -p $(arg vehicle)_$(arg ID).urdf'" />

    <param command="$(arg cmd)" name="$(arg vehicle)_$(arg ID)_sdf" />

    <node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen"
        args="$(find px4) $(arg rcS)">
    </node>

    <node name="$(arg vehicle)_$(arg ID)_spawn" output="screen" pkg="gazebo_ros" type="spawn_model"
        args="-sdf -param $(arg vehicle)_$(arg ID)_sdf -model $(arg vehicle)_$(arg ID) -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg R) -P $(arg P) -Y $(arg Y)" respawn="false"/>

</launch>

<!-- vim: set et ft=xml fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : -->
</code>```

答:
If you are using old version of px4 firmware. There was some problem with launch file (single_vehcile_spawn.launch). Correcting

```<code> <arg name="cmd" default="$(find xacro)/xacro.py $(find px4)/Tools/sitl_gazebo/models/rotors_description/urdf/$(arg vehicle)_base.xacro rotors_description_dir:=$(find px4)/Tools/sitl_gazebo/models/rotors_description mavlink_udp_port:=$(arg mavlink_udp_port) > $(arg vehicle)_$(arg ID).urdf ; 'gz sdf -p $(arg vehicle)_$(arg ID).urdf'" />
</code>```

in single_vehcile_spawn.launch with

```<code><arg name="cmd" default="$(find xacro)/xacro.py $(find px4)/Tools/sitl_gazebo/models/rotors_description/urdf/$(arg vehicle)_base.xacro rotors_description_dir:=$(find px4)/Tools/sitl_gazebo/models/rotors_description mavlink_udp_port:=$(arg mavlink_udp_port)" />
</code>```

Body:
If you are using old version of px4 firmware. There was some problem with launch file (single_vehcile_spawn.launch). Correcting

 <arg name="cmd" default="$(find xacro)/xacro.py $(find px4)/Tools/sitl_gazebo/models/rotors_description/urdf/$(arg vehicle)_base.xacro rotors_description_dir:=$(find px4)/Tools/sitl_gazebo/models/rotors_description mavlink_udp_port:=$(arg mavlink_udp_port) > $(arg vehicle)_$(arg ID).urdf ; 'gz sdf -p $(arg vehicle)_$(arg ID).urdf'" />

in single_vehcile_spawn.launch with

<arg name="cmd" default="$(find xacro)/xacro.py $(find px4)/Tools/sitl_gazebo/models/rotors_description/urdf/$(arg vehicle)_base.xacro rotors_description_dir:=$(find px4)/Tools/sitl_gazebo/models/rotors_description mavlink_udp_port:=$(arg mavlink_udp_port)" />


问:
3D mapping using only a 2D Lidar
How can I map a 3D environment using only a 2D lidar? The lidar would be hand held and it would have 6 DoF. So if I move it in arbitrary motion in all 6DoF, I expect my algorithm to generate a 3D map of whatever part of the environment was visible to the lidar.

I've come across ways to use IMU, monocular camera or encoder motor for state estimation that is required for mapping, but I want a solution that doesn't require any other sensor except a 2D lidar like RPLidar.

答:
If it was fixed:
- You can place it vertically and define a rotating mechanism so it spins on itself and the 2D beam eventually maps the 3D surroundings.

If it is hand-held:
- You will have to compute the transformation matrix from the origin to the new position of the camera (lidar in your case) and apply it to perform an image/laserScan registration, such that the sensed data gets mapped on the correct spatial coordinates.

If you are working with ROS and have an IMU, I am pretty sure there is a package that will be able to do the registration for you.

You can check the laser_geometry package in the ROS wiki:
http://wiki.ros.org/laser_geometry

If not you will have to implement the registration by yourself and it is a task that requires time.

ContentLicense: CC BY-SA 3.0

Title: 3D mapping using only a 2D Lidar


问:
What is an "actuation state"
The paper A Feedforward Control Approach to the Local Navigation Problem for Autonomous Vehicles by Alonzo Kelly uses the term actuation space.

Feedforward solves the historically significant clothoid generation problem trivially. C space combinatoric explosion is solved by planning in actuation space.

I have attempted to search for this term via Google. However, I can only find applications of actuation spaces—not what an actual space actually is.

A definition or source for further investigation would be greatly appreciated.

答:
after reading this ... there are mentions of task-space, state-space, configuration-space, etc

https://www.researchgate.net/publication/282198949_Fuzzy_logic_control_of_a_continuum_manipulator_for_surgical_applications

then this link ...

https://helgewurdemann.files.wordpress.com/2014/10/embc-2015-embedded-electro-conductive-yarn-for-shape-sensing-of-soft-manipulators-wurdemann-sareh-shafti-noh-faragasso-chathuranga-liu-hirai-althoefer.pdf

contains this text ...

As explained in the previous section, the shape sensing system
  consists of a set of three electro-conductive yarn threads with the
  resistances [R1(s1), R2(s2), R3(s3)]. As a linear function can be
  defined describing the relation between the resistance and the length
  of the yarn thread within the elongation interval [0;156%], it is
  possible to continuously calculate and update the length of the three
  threads [s1, s2, s3]. These actuation space variables are now used to
  obtain the arc parameters as shown in Figure 5 and Equations 1-3 [16].

I may very well be wrong about this, but to me it implies that "actuation space" is collection of entities or variables that relate to the physical world in which the robot operates and includes the robot itself. (there is probably a better way to word it though)

Title: What is an "actuation state"


答:
I don't think what you're asking is possible with the state of the art sadly. You cannot, AFAIK, generate a 3D map from a hand held 2D LIDAR without any other sensors. It's a very interesting question you're raising but I think it's a research question :)

A LIDAR is going to give you a 2D laserscan/Pointcloud. That 2D data will not possible to extrapolate to 3D, at least not in a straight forward way:

Let say you want to something like ICP and match the laser scan onto each other building the map. Now you rotate your 2D laserscan by x degree along the yaw axis. Assuming in your environment walls are straight and vertical, the 2D laser scan will be slightly larger than the original 2D laser scan. How will ICP be able to tell you that this laser scan is the same as the one before but tilted since they do not have overlapping regions. And that's where lies the whole problem of using a 2D laser scan to build a 3D map. You wont have enough of those overlaping areas.

That said, not everything is lost and you can still make it. Here is my take on this:

Start the lidar with a horizontal scan.

Use the first scan and start building a 2D map.

Extrapolate the map assuming all walls are verticals and infinite.

Using ICP or other algorithms to match incoming scans to your virtual walls. Correct the walls if needed.

To detect roofs, progressively match incoming scans to walls until you find a scan that can't be match onto your walls.

Using those scan to build fake walls that are perpendicular to the closest walls in the environment, but passes by a certain number of laser points. Note on scan can create multiple fake walls.

Start again using ICP against your artificial walls.

After a lot of scans, you should have a 3D map of the environment.

See how this algo "fakes" overlapping regions and use the incoming scans to figure out which overlapping regions are the correct ones.

If this ends up being a research paper, please contact me :P. Good luck to you.

Title: 3D mapping using only a 2D Lidar

Body:
How can I map a 3D environment using only a 2D lidar? The lidar would be hand held and it would have 6 DoF. So if I move it in arbitrary motion in all 6DoF, I expect my algorithm to generate a 3D map of whatever part of the environment was visible to the lidar.

I've come across ways to use IMU, monocular camera or encoder motor for state estimation that is required for mapping, but I want a solution that doesn't require any other sensor except a 2D lidar like RPLidar.


问:
Metrics for rigid body motions in SE(3)
As SE(3) does not have any bi-invariant metric, what are the available pseudo metrics for comparing two homogeneous matrices for rigid body motions ? In other words, how to compare two dual quaternions ? </p>

答:
You can use

$$d(T_1, T_2) = \sqrt{a\left\Vert \log(R_1^{T}R_2) \right\Vert^{2} + b\Vert p_2 - p_1 \Vert^{2}},$$

where $T = \begin{bmatrix}R & p\\0 & 1\end{bmatrix}$, $a$ and $b$ are some (arbitrary) scaling factors (scalars), and $\Vert \cdot \Vert$ denotes the Euclidean norm. This metric is left-invariant. (See also papers by Prof. Frank Park, for example. He has a number of works in this area.)

Note that here the logarithm map of a matrix $R \in SO(3), \text{Tr}(R) \neq 1$ is
$$\log(R) = \frac{\phi}{2\sin\phi}(R - R^T),$$

where $1 + 2\cos\phi = \text{Tr}(R)$. From the above expression, $\log(R)$ is actually a skew symmetric matrix so we can write
$$\log(R) = [r]_{\times},$$
where $r \in \mathbf{R}^3$, and $[\cdot]_\times$ denotes a cross-product matrix. In this sense, the norm of $\log(R_1^TR_2)$ in the first equation should be thought of as the norm of the corresponding vector $r \in \mathbf{R}^3$.

Also, the norm  $\left\Vert \log(R_1^{T}R_2) \right\Vert$ is actually the length of the minimal geodesic connecting $R_1$ and $R_2$ (see this paper).

Title: Metrics for rigid body motions in SE(3)


答:
As the previous answers stated: You need an additional source of information to reconstruct the orientation of the scanner. Even if only roughly.

Do a Google search for "Zebedee scanner". The researchers from CSIRO implemented the scan registration in the most elegant way, IMHO.
And they use a cheap IMU in their device.

Title: 3D mapping using only a 2D Lidar


问:
Strange phase case in Bode diagram of a transfer function
Please help me to solve my problem:
This is the transfer function: $G(s)=10\frac{(s^2+1)(s-10)}{s(s+0.1)(s^2+2s+100)}$

I calculated properly the whole Bode diagram apart from the phase of the complex zeros $(s^2+1)$. I would sum here at this point as usually: +180° and so does Wolfram's software in fact my result of the phase is equal to this one:

the problem is that my professor uses MATLAB which gives -180° and therefore this should be the right solution

I don't know which one is right and why, that's why I bother.

答: It's just a phase unwrapping case in MATLAB. Anyway when real parts of complex poles/zeros are null, phase jump could be +180 or -180, it's uknown therefore both diagrams are correct</p>


问:
What are good options for modifying drones?
I'm apart of a group at my University where we would like to build a drone/UAV and constantly add and modify parts on it.

We were thinking of using an Arduino or raspberry pi, but we really don't want to mess with PID loops. However, with these microcontrollers we can easily add multiple sensors and a GPS. We can build the frame, do soldering, and everything else, but we would like some type of pre-made PID loop or flight controller so we don't need to worry about the drone falling from the sky.

Would anybody have any recommendations for us? Maybe flight controllers that we can add anything else on top of, and then change the code. Or a pre-built drone where we can modify its code and add sensors.

Any help is extremely appreciated. Thanks!

答:
Seems like you're looking for a basic flight controller, for example, the PIXHAWK. It comes with onboard IMUs and GPS support, while being able to run two main types of firmware: PX4 and ArduCopter. Firmware like this contains PID loops, flight control algorithms, flight mode switching support etc. while being open source and easily customizable if you have some C++ experience. Also, PIXHAWK supports the widely used MAVLINK protocol for sending and receiving messages, which allows you to send offboard position, velocity commands etc. or write your own commands adhering to the MAVLINK protocol.

On the other hand, boards like this are only good for low level control: so for anything vision based or for other kinds of sensing, you'd need a companion computer. If you have a companion computer like the RPi, you can use MAVROS to interface with the PIXHAWK(https://github.com/mavlink/mavros).

If you want to make this whole process easier and get something off the shelf, there are some platforms like the 'ErleCopter': it already comes with the ArduPilot flight stack and a RPi computer installed on a multirotor platform. Or if you're still interested in the custom platform route, there are also certain boards like the NavIO: (RPi + PIXHAWK) combo which you can install on your own custom platform.

Hope this helps.


问:
Real time implementation of EtherCAT master with ros_control
I want to control a motor using EtherCAT protocol.

1. I used IgH ethercat master to control motor in hard real time (1 kHz).

2. Later I want to integrate this in ros_control with hard real-time control. The developer of ros_control are ensuring that ros_control is real time.

3. If I want to create other application using ros/moveit/ros-android on top of ros_control & ethercat(driver), Can we call the system hard realtime (ros_control + igh (both are hard realtime) and ros (not realtime)) ?

答:
You would confuse or mislead people if you called a non-realtime system with realtime subsystems a realtime system.

If your motor control is realtime, just say that. That you have realtime control of the motor position (or whatever feedback parameter is in the realtime domain).

Note that using realtime components incorrectly can result in non-realtime operation and the fact that you claim hard-realtime will make anyone that is evaluating your system look extra carefully to make sure this is true for the operating conditions they care about.


问:
Powering Off Main Processor Without Software shutdown
I am building a robot that uses an Intel NUC (running ArchLinux) as its main processing unit to run some machine learning and ROS programs scripts.  One of the requirements for the robot is that it must fully turn off and on by a single main power switch.  By doing so, it cuts power to the entire robot, including the NUC.  I am worried that doing so will damage the NUC.  Is there any safe way to shut down a computer without having to turn it off via software. </p>

<p>**One more requirement for the robot is that its electronics are sealed in in an airtight box, therefore the NUC cannot be accessed to turn off via the main power button.</p>

答:
The main two things I do for an a linux system for which I want to be able to kill power freely are:

Choose appropriate filesystems and configure them to recover cleanly on restart. The choice depends on your storage hardware, most journaling filesystems work fine for this. Mounting as much as you can read-only also helps.

Make sure that all processes needed for operation clean up their environments and automatically started cleanly. (Clean up temp files, rotate log files, etc)

Searching linux filesystem power loss will get you started with selection and configuration recommendations.

Note that providing too high a voltage to the NUC can damage it and an improperly designed robot electrical system might spike high in a poorly sequenced shutdown from one of the energy storage elements (usually kinetic from the moving mass of the robot or inductive from the motor or power supply coils).


问:
Navigation of a ground vehicle towards target without map
I have the following setup:

RC car chassis which can turn, go back and forward; both the turn rate and the acceleration can be controlled smoothly

Raspberry Pi 3

Two cameras so that depth map can be calculated on the fly for obstacle avoidance

Several microphones so that direction of the voice can be determined

Intertial measurement unit to keep heading at the direction of the voice

Several infrared distance sensors

What I want to acompilish is a robot that will drive towards me when called. Voice recognition, structure from motion and handling the IMU are not a problem for me because I've done it before. What I find really problematic is how do I actively avoid obstacles, while trying to follow the voice? I assume that I can call the robot multiple times - i.e. when it gets confused. The robot will stop when a face is recognized from one of the cameras, therefore the distance to target is initially unknown. In theory I could try to create a 3d point cloud using structure from motion and determine the robot's location within the pre-built map and use it for navigation, however as far as I know, the determination of robot location within the map is a costly and uncertain computation (especially when its initial position is unknown).

What I would like to learn is - are there some algorithms that allow the robot to stick to given heading while avoiding obstacles, but without a map? I would be very grateful for scientific papers, blog posts or simply algorithm names if there are any avalible.

I recently read about bug algorithms - especially dist bug. This sounds like most promising solution for me so far.

答:
I know you said without maps but bear with me :).

Would something like the A* algorithm principle, but with a unknown map in which you add obstacles work for you ?

You could start with an empty map and use A* to go to the target. Each time you encounter an obstacle you had it to the empty map and recalculate A*. Using you IMU you can get odometry so building that simple map should be feasible. And by starting with an empty map you don't "need" that expensive localization initialization since you know where you start.

Another strategy I can think of is that of simple organisms. Just go toward the (light) sound in a straight line and if you encounter an obstacle just use a "wall follower" behavior, always trying to get closer to the sound, and pray it was the right direction. Simple but effective.

As you've pointed in the comment another interesting direction is to copy insect behaviors. You can look at the work done by this lab on desert ant navigation. I haven't read this paper but I saw a presentation of it and it sounded quite interesting.


问:
Delayed Kalman navigation based on two way ranges
I am interested to know the basic principle of the "Delayed KF" when considering an underwater robot aiming to localize it self using a LBL system.

More practically, in order to calculate the distance to each anchor,   the robot transmits a PING to and waits for the RESPONSE from the anchor. This is time consuming as the sound velocity is very  low (1500m/s). Lets say it will take order of 5/10 seconds to complete such iteration (large distances).

If the robot is static (during this operation, or the anchors are very close), I can recover the two travel time,  TWTT, and after that the distance (knowing the sound velocity, divide by two etc). In that case i can include the range to my EKF navigation filter.

Assuming that the robots moves (1 m/s) this assumption does not hold anymore as I can not divide the TWTT by a factor of 2.

Searching online i found talking about the delayed EKF in which (in my understanding) having a  measurements timestamped (the real time and the time when i got it) i re-run the filter at the right time when the measurements was/or should have been done.

Does this hold also for this case and how can be integrated with the navigation filter of the robot?

Geometrically to find the right distance based on the TWTT and considering the movement done during that time seems hard to me to model. At least i have not found any paper in the literature.

Regards,

答:
I believe you're not taking the problem with the right angle in mind.

Your ping measurements are not delayed measurements, they are wrong. The problem is not that you are receiving them late but that, by receiving them late, you lost the actual information that they were providing you. That is because you are calculating the position this way :

Image shamelessly taken from this paper by Rui Almeida

But this relationship is not 100% correct when you are moving. You could try to model this error as either a bias or a Gaussian noise but, since the error is due to the vessel movement, I believe your system is not suffering from a Gaussian noise or bias, and that would not be very effective.

From my point of view, you would have a better chance by using an EKF on the odometry model of your robot and using it to find the right TTWT from there. But i'm not a Kalman filter wizard at all so I hope someone will pass by and prove me wrong.


问:
Making a tunnel follower robot with 2 IR side sensors and 1 ultrasonic sensor
We have a tunnel and the distance from the walls to the robot is about 30cm when the robot is centered, the tunnel curves to the right. The robot has an infrared sensor on its left and one on its right and has an ultrasonic sensor at its front (so basically its eyes). How can I make the robot turn appropriately while its moving so that it's centered in the tunnel. I just need an idea for this algorithm because I can't find any. All what the infrared sensors can do is measure the distance to the walls.</p>

答: One possible method is to find the width of your robot, subtract that from 30 cm, then half the remaining distance and if one of the IR sensors reads less than that number, turn in the other direction.</p>


问:
Transforming Point Cloud to get Top Down Image
My task:

I have a task where I am asked to track parcels(carton boxes) of different dimensions moving on a conveyor. I am using Asus Xtion pro camera mounted on top of a conveyor in any inclined angle. I am looking for a model free object tracker that will detect boxes in the scene, track them & gives their 6 DOF? My target object is just a box and I want to eliminate all other things in the scene.

My approach:

I do Point cloud pre-processing like down-sampling, pass through filtering and segmentation. All these should give me a final point cloud containing only the objects on the conveyor.

I planned to make the "z" values in each point(depth value) as zero, thereby making the point cloud of the box to be flat on the ground.

I planned to transfer the view of the camera from any inclined position to a top down view so that I can view any number of carton boxes moving on the conveyor from a top down view. I feel the top down view will prevent perspective viewing problems

The process flow of step 2 and 3 is shown below.

After the top down view of the point cloud is achieved, I need to convert the 3rd point cloud to 2nd image, so that I can perform object tracking with so many OpenCV based tracking algorithms available.

A Sample point cloud is shown below in different views

Original View from camera:

Point Cloud View 1:

Point Cloud View 2:

Point Cloud Target/Desired View for converting to 2nd: (The box is the target. All the ground plane and unnecessary points would be eliminated)

Is my approach correct? How will I achieve steps 2,3 and 4?

答:
It looks like you're using ROS which will make some of these tasks easier. To start, you will need to define some coordinate frames. If you're only using the coordinate frame of the lidar, that's fine, just make sure you know the location and orientation of your origin. It's important to be able to define the coordinate frames of other objects (like the boxes) in terms of relative transforms from other frames (like the lidar origin).

My first step in this process would be to eliminate all points which are irrelevant by knowledge of the physical system rather than through software processing. How high is the lidar off the ground? How high is the conveyor off the ground? You know that no points below the conveyor belt (or off to the sides for that matter) are going to be relevant and you know the location of the belt relative to the lidar - crop the field of view to match.

Next, consider what "flattening" the point cloud will actually gain you. Since the lidar seems to be above the plane of the top of the objects that you're looking to find, you will get a large number of points returned from both the sides and top of the objects. This means that things like edge detection won't work on just a 2D representation of that dataset. I would recommend going down another path of "known object" filtering. Something like volumetric estimation or plane detection/tracking might be your best bet. Hope this helps!


问:
Technology behind Kiva Systems mobile robots
What kind of sensors and algorithms are the mobile robots of Kiva Systems equipped with? </p>

答:
Kiva uses a multi-agent system to control its fleet of robots and movable shells. Their website provides a high-level overview of their system architecture and there's also a presentation online that goes into more detail. The A* algorithm is used for wayfinding and a heuristic algorithm decides on the order of things to pick up (travelling salesman problem) and which shelves to move where (more frequently used shelves are put nearer the packing stations to reduce travel time).

According to this paper, the whole system is implemented in Java and MySQL.

I couldn't find any direct quote about the sensors in their mobile platforms, but from the picture I'd be guessing a number of sonars and IRs


问:
Light pattern is flashing intermittently using RVIZ/OpenNI with two Kinects
I have two Kinects (each on its own USB card) whose cameras I'm watching in RVIZ through OpenNI, and the structured light pattern of one is flashing intermittently - it's only there for a short flash every two seconds. Obviously, the structured light depth calculations only work if the pattern is always projected when the camera is looking at it.

What causes this, and how do I fix it?

EDIT: I was also having this issue with a single Kinect, for which I discovered the issue, as detailed in my own answer. However, the problem persists when two Kinects are plugged in, with one Kinect flashing and the other functioning normally.

答: Apparent partial issue was a conflict with the VM running Windows (on my Linux box) attempting to grab the XnSensorServer resource. Running the VM and then the setup specified in the question produced the observed Kinect disfunctionality, whereas running the setup and then opening the VM crashed the XnSensorServer, freezing the Kinect altogether.</p>


问:
How to become proficient in software development for an aspiring roboticist?
I am a masters student specializing in Robotics. I have a bachelors degree in Mechanical engineering and hence a bit sloppy with programming languages. MATLAB is one thing I am proficient in. But robotics requires extensive programming, especially in C++ and Python.

From a career point of view, software development is one of the major skills to have. I have started learning C++ and OOP concepts mainly from EdX. However, I do not know how much to learn and what exactly to be proficient in terms of coding. I have talked to various professors and peers who suggest me take courses in programming and take online challenges in Hackerrank and Leetcode. I have looked at many of these sources and most of them approach coding from a software engineering point of view. I am not sure if that is the right way to learn to code from a robotics perspective.

I would really appreciate some pointers and directions on how to be proficient in software development for robotics. Working on projects is one thing and I have already begun working on ROS-Indigo. However, I would like a solid foundation in software development rather than half-baked knowledge.

The main thing that confuses me there are too many sources and I am not able to pin down which is the best source to learn and exactly how much to learn. From a roboticist career point of view, some guidance in this aspect would be really helpful. Thanks.

答:
If you make a career of robotics, you will come in contact with a lot of languages, a lot of libraries, and a lot of systems.

The more you know about the fundamentals, the easier it will be to adjust to something new. Likewise, if you focus your learning on whatever project or context is relevant to you at any given moment, it's more likely to stick with you.

In general if you learn only what you need to do the project in front of you, and then take a small amount of time to drill down and understand something about the foundation of what you are doing, you will constantly be leveling up in your robotics knowledge.

Since you're coming from a ME background, I'll assume you are interested in the hardware side of things as well as software.

You should have a basic knowledge of algorithms and numerical analysis. You should know for which calculations you computer will give you erroneous results and how to mitigate them.

You should know that each language has it's own idioms. Many of which come in to, and go out of, fashion with each passing decade. So you need to take the extra step of learning the appropriate idiom for whatever algorithm you are using if you want others to be able to collaborate with you.

You should understand that microcontrollers, processors, homogeneous multi-processor architectures, and heterogeneous multi-processor architectures all require different approaches for solving the same equation or problem. I think it's easiest to start with a microcontroller like an 8 bit Atmel AVR (Arduino's use these), then ARM, x86, GPU's, (maybe OpenCL), and finally distributed systems (ROS middleware is one, limited, example). It all comes down to computation speed vs communication speed vs problem granularity. FPGA's are another style of computing you should know about. Software runs on hardware and roboticists often need to select the right hardware for their software.

You should learn a bit about the internals of operating systems. Start with a small one, preferably a real-time one. They tend to be more modular and digestable. Then dig into at least one big one, Linux or Windows for instance. Learn what an OS does to actually load and run a program, and how to inspect and manage processes.

You should learn a bit about IPC and middleware. It's kind of silly to use ROS if you don't know which situations it's bad for.

You should learn at least one full C/C++ toolchain on the command line. Command lines are more similar across operating systems than graphical environments or IDEs. Most languages and toolchains will touch or interface somehow with a C/C++ one in one way on another.

C is still the dominant low-level language, and C++ is often used in computation intensive (robotics) code. You should know that C and C++ are different languages and that there are different versions.

For C, it's worth reading old code, before the advent of java, when men were men and pointers were an elegant weapon of a more civilized age. The idioms of the time (1980 +/-) led to clear and clean code.

For C++, my favorite robotics code to read is Simbody.

Know that there are different programming paradigms. Learning functional programming is very useful. It's the best/fastest approach for some problems. You can use functional programming in imperative languages, and you can torture your CS friends using imperative programming in a functional language.

There is more that can go in this list. Beyond pointing out that C/C++ is used a lot, I did not recommend languages or libraries or frameworks on purpose. I've learned and used 10's of each, and will continue to learn them on an as needed basis.

This knowledge is fun to apply but its real power is when you are working and interfacing with domain experts. The same way you might use your tribology knowledge figure out what type of bearing to use and specify what you need for a custom one to be made, you can use the above knowledge to read through the kernels of the different physics engines Gazebo can interface with and choose one appropriate for the scenario your are trying to simulate.

Don't stress too much. Be pragmatic. Learn what you need to for the project at hand and then learn a little bit of the foundation or why of what you are doing.


问:
Is a virtual machine with ros-kinetic available anywhere?
I want to learn ros-kinetic from a virtual machine. I found that ros-indigo  is available from nootrix; similarly, is there a virtual machine with ros-kinetic version available anywhere?

答:
Hey I was wondering this same thing.. After some research there are some docker containers that you can look at https://hub.docker.com/_/ros/ . If you want a virtual machine im actually working on a vagrant file that does exactly this as we speak. https://github.com/joepuzzo/vagrant-turtlebot
You could fork that and tweak it to your needs.


问:
Python3 Modules for motor movement
Are there any Python3 modules used to program robotic movement by declaring a device or component and then providing the instructions? I am not looking for modules that test the components.</p>

答:
This is an extremely general question. What code you will use will depend on the type of "robotic movement" you are attempting to achieve, and what platform you are running the code on.

Let's say you want to control a stepper motor from python running on a Raspberry Pi. Stephen Phillips has written a nice python class for this purpose. The code was for Python 2.x, but the only changes you need to make to port it to python 3 are to add parenthesis to the print statements and change the backticks to repr() because python 3 has cleaned up the print syntax. See the output of python's 2to3 command below:

```<code>@@ -41,10 +41,10 @@
         steps = (steps % self.steps_per_rev)
         if steps > self.steps_per_rev / 2:
             steps -= self.steps_per_rev
-            print "moving " + `steps` + " steps"
+            print("moving " + repr(steps) + " steps")
             self._move_acw(-steps / 8)
         else:
-            print "moving " + `steps` + " steps"
+            print("moving " + repr(steps) + " steps")
             self._move_cw(steps / 8)
         self.step_angle = target_step_angle

@@ -98,7 +98,7 @@
     GPIO.setmode(GPIO.BOARD)
     m = Motor([18,22,24,26])
     m.rpm = 5
-    print "Pause in seconds: " + `m._T`
+    print("Pause in seconds: " + repr(m._T))
     m.move_to(90)
     sleep(1)
     m.move_to(0)
</code>```

Title: Python3 Modules for motor movement

Body:
This is an extremely general question. What code you will use will depend on the type of "robotic movement" you are attempting to achieve, and what platform you are running the code on.

Let's say you want to control a stepper motor from python running on a Raspberry Pi. Stephen Phillips has written a nice python class for this purpose. The code was for Python 2.x, but the only changes you need to make to port it to python 3 are to add parenthesis to the print statements and change the backticks to repr() because python 3 has cleaned up the print syntax. See the output of python's 2to3 command below:

@@ -41,10 +41,10 @@
         steps = (steps % self.steps_per_rev)
         if steps > self.steps_per_rev / 2:
             steps -= self.steps_per_rev
-            print "moving " + `steps` + " steps"
+            print("moving " + repr(steps) + " steps")
             self._move_acw(-steps / 8)
         else:
-            print "moving " + `steps` + " steps"
+            print("moving " + repr(steps) + " steps")
             self._move_cw(steps / 8)
         self.step_angle = target_step_angle

@@ -98,7 +98,7 @@
     GPIO.setmode(GPIO.BOARD)
     m = Motor([18,22,24,26])
     m.rpm = 5
-    print "Pause in seconds: " + `m._T`
+    print("Pause in seconds: " + repr(m._T))
     m.move_to(90)
     sleep(1)
     m.move_to(0)


问:
How to maximize stall torque of a motor
I'm looking to use 3-phase motor without gearbox for robotics application. It will always work at near stall situation never rotating more than 360deg. I'm looking for arrangement that will produce max stall torque while drawing min current.

I tried both gimbal (high resistance) and BLDC (low resistance) motors and yes I could achieve high torque, but only at cost of too high current and overheating.

My question is both practical and theoretical: what motor or mode of operation should I choose to maximize stall torque? and what in principle can be done? Imagine I had my motor factory - how would I approach building stall torque motor?

答:
So, you want to use a servo? Why not just buy a servo?

Three things are required for "motor action" -

A current carrying conductor

A magnetic field

An applied voltage

The result is relative motion between the conductor and the magnetic field.

Three things are also required for "generator action" -
1.  A current carrying conductor
2.  A magnetic field
3.  Relative motion

The result is a voltage developed across the conductor.

This is important because once a motor starts it also becomes a generator of sorts, because it meets the criteria required for generator action.

The generator action in a motor will develop what is referred to as "back EMF". It is a voltage that acts against the applied voltage. The back EMF "fights" the applied voltage, which reduces the net voltage applied to the motor, which reduces the current draw.

The torque a motor can produce will always be directly related to the strength of the magnetic field inside the motor. The strength of the magnetic field is directly related to the current in the motor windings.

You make more torque in a motor by passing more current to the motor.

As you have noticed, more current leads to more heat in the motor, because of "I squared R losses." This term comes from the formula for electric power, $P = IV$, combined with Ohm's Law, $V = IR$, to give a formula for electric power in terms of current and resistance:

$$
P = I^2 R \\
$$

The $I^2R$ losses are the reason why high voltage electric lines are used for power transmission - higher voltages reduce current. Power losses increase with current squared, so it's important to get current as low as possible to reduce the power losses.

So, in order to get a high stall torque, you need a high applied current. As you have seen, you cannot take a "standard" or general purpose motor and use it at stall conditions because most motors are designed with back EMF in mind. The back EMF protects the motor by reducing current draw, which reduces the heat generated ($I^2R$ losses) inside the motor.

To operate predominately in the stall region of a motor requires more cooling to dissipate the heat generated, and/or different wire insulation that is capable of withstanding higher winding temperatures.

A motor spec sheet should list the "nominal" or operating current for the motor. The alternative to buying a specialized motor might be to operate the motor in conjunction with a current-regulated power supply instead of a voltage-regulated power supply. Throttle the motor to no more than the specified  operating current and the heat generated in the motor should be manageable.

I say this might be acceptable because most higher-power motors feature an integrated fan. If the motor has a fan, then the rated current for the motor likely depends on the fan rotating at the nominal motor speed.

You can meet the requirement by creating a blower for the motor - this is a common practice where slow speed, high torque motors are used, as in cranes. Essentially, you disconnect the fan from the motor you want to operate at stall condition and attach it to the output shaft of a second motor. Any time you apply power to the first motor, you spin the second motor at whatever speed the fan is supposed to turn.

Now you get all the design cooling for the first motor and, assuming you're operating at or below the rated current for the first motor, you should be able to operate at or near stall torque for as long as you want.

Title: How to maximize stall torque of a motor


问:
Scale estimation in datasets for monocular odometry
Suppose I've developed a monocular SLAM or odometry algorithm. Then I want to test it on some dataset, for example KITTI, TUM etc. How should I deal with the absolute scale in this way? Thanks.

答:
Assume something, then adjust your guess based on your measured distance traversed versus actual distance traversed. </p>

<p>If you can get data from a vehicle that drove down a road, and you know the path taken, you can map that route and determine the actual distance travelled. If you assumed some arbitrary distance, and your path turned out to be 340 km, but you know from a map the actual distance traveled is 100 km, then scale your original assumed value to (1/3.4) of whatever your original guess was. Repeat until results match. </p>

Body:
Assume something, then adjust your guess based on your measured distance traversed versus actual distance traversed.

If you can get data from a vehicle that drove down a road, and you know the path taken, you can map that route and determine the actual distance travelled. If you assumed some arbitrary distance, and your path turned out to be 340 km, but you know from a map the actual distance traveled is 100 km, then scale your original assumed value to (1/3.4) of whatever your original guess was. Repeat until results match.


答:
One relevant equation is the lorentz force equation. which suggests that if you want to reduce current then you need to increase the magnetic field.

The magnetic circuit is complex, with different materials moving relative to each other. As the rotor of the motor rotates, the magnetic field within the stator changes direction and there are losses. Choosing optimum materials and geometry is the subject of many books and scientific papers. In most motor design, rotation is expected and materials and geometry that is optimum for a rotating magnetic field are used. If you have a mostly non-rotating application, you may be able to select different materials and geometry that is better.

If you don't want to design your own motors, the type of industrial motor that is most likely to be a bit optimized towards your requirements is called a direct drive motor.

The gimbals motor you linked claims to have 6Kg/cm of torque. Assuming they really mean 6 Kg*cm*9.81*m/s^2, that's about 0.6 Newton meters (Nm) of torque. A good motor that would fit the same volume could be the Kollmorgen TBM(S)-7615-X, which has about 3 Nm of stall torque, but also approximately 3 times the mass. That's a rough idea of what good design and optimization can do. About double the torque per kilogram of motor.

Considering your ~$100 per motor budget, it depends on how motivated you are. If you are really motivated and like to build things, you could learn a bit of how motors are made and make your own motors (which are just some iron sheet cut out (by waterjet for instance), glued in a stack, wound with copper wire, and magnets glued to a rotor) for roughly your budget, assuming your robot has 3 or 6 motors.

However you may want to keep in mind that there are very few direct drive serial chain (arm or leg like) robots. The ones that exist are usually oriented horizontally so that the motors don't have to resist gravity.

Or you could do a bit of searching for motor (+ gears) that fits what you want to do best at your price range. You will probably have to make some compromises, but with a bit of calculation, you can be reasonably sure of the performance of the robot before you buy the motors.

Title: How to maximize stall torque of a motor

Body:
I'm looking to use 3-phase motor without gearbox for robotics application. It will always work at near stall situation never rotating more than 360deg. I'm looking for arrangement that will produce max stall torque while drawing min current.

I tried both gimbal (high resistance) and BLDC (low resistance) motors and yes I could achieve high torque, but only at cost of too high current and overheating.

My question is both practical and theoretical: what motor or mode of operation should I choose to maximize stall torque? and what in principle can be done? Imagine I had my motor factory - how would I approach building stall torque motor?


问:
Correct Fish eye camera radial distortion and blurry stretch at the image edges
There are a lot of questions regarding this topic, but I am trying to get a more clear picture from these questions.

I am trying to calibrate a fish eye camera and I am using OpenCV cv::omnidir class functions to find the camera intrinsics.

I am getting fair results. The problem is, at the image edges, the objects get stretched and I am, also, losing some information at the edges.

Here is my input image:

Here is my output image:

As you can see, I am losing some information at the edges (left and right) and also the images start stretching at the edges.

My questions are as follows:

How I can I include more FOV in the corrected image at the edges, where the information is lost?

How can I reduce the blur effect at the edges?

During calibration, should I cover the entire FOV of the camera so that the corners are present at the edges also?

What is the correct way of showing the patterns while calibration?

Are there any online tool boxes which provides fish eye calibration.

Here is my code snippet for calibration and testing:

```<code>//Calibration
Mat K, xi, D, idx;
int flags=0|omnidir::CALIB_FIX_SKEW | omnidir::CALIB_FIX_K1 |
 omnidir::CALIB_FIX_K2;

TermCriteria critia(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 200,
0.0001);

vector<cv::Mat> rvecs, tvecs;

double rms = cv::omnidir::calibrate(obj_points, image_points, image_size, K,
xi, D, rvecs, tvecs, flags, critia, idx);

//Testing
Mat R = Mat::eye(3, 3, CV_32F);
Mat Mapx, Mapy;
Mat New_camera_mat(3,3,CV_32F);

//New_camera_mat tries to get entire FOV,but it is losing some information
  at edges

New_camera_mat.at<float>(0, 0) = 100; New_camera_mat.at<float>(0, 1) = 0;
New_camera_mat.at<float>(0, 2) = 1280/2;

New_camera_mat.at<float>(1, 0) = 0; New_camera_mat.at<float>(1, 1) = 100;
New_camera_mat.at<float>(1, 2) = 720/2 ;

New_camera_mat.at<float>(2, 0) = 0; New_camera_mat.at<float>(2, 1) = 0;
New_camera_mat.at<float>(2, 2) = 1;

cv::omnidir::initUndistortRectifyMap(K, D, xi_Right, R, New_camera_mat,
image_size, CV_32F, Mapx, Mapy, cv::omnidir::RECTIFY_PERSPECTIVE);

remap(distorted_frame, undistorted_out_frame, Mapx, Mapy, INTER_CUBIC);
</code>```

答:
How I can I include more FOV in the corrected image at the edges, where the information is lost?

-> Just try to modify fx and fy of your intrinsic matrix. Maybe, multiplying a scalar to K(0,0) and K(1,1) will work.

How can I reduce the blur effect at the edges?

-> Generally, it is not possible unless you create a specialized DNN. All the blurry area is because you are stretching small areas in the original image. It is an inevitable side effect when you undistort a fish-eye image.

During calibration, should I cover the entire FOV of the camera so that the corners are present at the edges also?
-> Yes

What is the correct way of showing the patterns while calibration?
Are there any online tool boxes which provides fish eye calibration.

-> To fully observe the lens distortion characteristic you should show the pattern everywhere in the image. Try to show your board around the circular border of the image. But not too much as blurry corners will decrease the accuracy.

-> No open source online one as far as I know. If need one you should build one.


问:
3D mapping using only a 2D Lidar
How can I map a 3D environment using only a 2D lidar? The lidar would be hand held and it would have 6 DoF. So if I move it in arbitrary motion in all 6DoF, I expect my algorithm to generate a 3D map of whatever part of the environment was visible to the lidar.

I've come across ways to use IMU, monocular camera or encoder motor for state estimation that is required for mapping, but I want a solution that doesn't require any other sensor except a 2D lidar like RPLidar.

答:
That is an already solved problem. As Squelsh mentioned CSIRO released its initial version in 2009 and their work is commercialized by GEOSLAM already.

One of a CMU student released a open source version of CSIRO's work, called LOAM.
Unfortunately, he also commercialized his work and closed the original git. Good news is that many people have a copy of that already:)
CSIRO's recent work combines IMU,2D LiDAR, camera, encoder and the related paper will be released soon at RAL.

This category of SLAM is called Continuous-time SLAM.
If you are writing a paper, here is one of the latest CT-SLAM paper. Please, cite this:)

Also, check these videos 1, 2.

Title: 3D mapping using only a 2D Lidar


问:
Reducing motor speed without jamming up
So I built three little bots so far.

One with a raspberry-pi, (6V motors), one with an arduino (12V motors), and another with an arduino but a hacked remote car (7ish, volt motors):

The problem I have with all these is that the motors spin so fast the car just bumps into something in a few seconds. (I have a small house)

I tried to use PWM to control the speed, but at a little less than full throttle (255) they jam up and they can't take the weight I put on them.

Should I buy one of these chassis that slow the motor down and give it torque with a gearbox, or is there anything else I can do?

答:
Gearboxes are probably your best bet if you never want to go fast.

You may be able to make it work better if you give it pulsed power (PWM in a way, but pulsed at a speed low enough that the motor actually gets going and then slows down each time.  See Controlling Motors in the Presence of Friction and Backlash for details on the technique.

You can almost certainly make it better if you put some sort of closed-loop speed control on the motors.  Encoders are best, but you can do amazing things using back-EMF speed sensing.  Either of these techniques require you to work with a closed-loop system which isn't trivial, and neither of them will overcome all the problems unless you use a gearbox (but, with closed-loop speed control you can have a much higher ratio of top to bottom speed while keeping things smooth).

Title: Reducing motor speed without jamming up


问:
Calculating the covariance matrix of a measurement
I want to estimate the covariance matrix of a measurement for a robot evolving on plane and having the following state vector.
$$
X
=
\begin{bmatrix}
x\\
y\\
\theta
\end{bmatrix}
$$
$x$ and $y$ are the coordinates in $XY$ plane et $\theta$ the heading angle.

The measurement is taken from a place recognition algorithm which returns an pose
         $$z=
      \begin{bmatrix}
         x_{m}\\
         y_{m}\\
        \theta_{m}
      \end{bmatrix}
       $$

The covariance matrix of the measurement should have the following form

$$
\Sigma
=
\begin{bmatrix}
\sigma_{x}^2 & 0 & 0 \\
0 & \sigma_{y}^2 & 0 \\
0 & 0 & \sigma_{\theta }^2 \\
\end{bmatrix}
$$

How to calculate $\sigma_{x}$ for example given that I have the ground truth pose  $$ground_{truth}=
      \begin{bmatrix}
         x_{gt}\\
         y_{gt}\\
        \theta_{gt}
      \end{bmatrix}
       $$
and the measurement $z$

答:
Correct me if I'm wrong, but it sounds like you're looking for an estimate of the noise in the measurement, which is usually called 'R' in the Kalman filter (https://en.wikipedia.org/wiki/Kalman_filter#Underlying_dynamical_system_model).  If you have the ground truth and you assume that the measurements have Gaussian noise (which is assumed in the Kalman filter) and are distributed about the ground truth measurements, you can get the MLE by doing

$ \hat{\sigma_{x}}^{2} = \frac{1}{n}\sum_{i=0}^{i=n} (x_{gt}^{i} - x_{m}^{i})^{2} $

To get $\sigma{x}$ you would just take the square root.  You can do the same for the other variables of course.  If you are keeping $\theta$ in a bounded range make sure you are careful about subtraction when doing this.

This would assume that all of the measurements come from a $\mathcal{N}(x_{gt}^{i}, \sigma_{x}^{2})$ distribution, where $x_{gt}^{i}$ is the ground truth measurement for the $i$-th measurement and $x_{m}^{i}$ is the noisy measured value.  This probably won't be strictly true in practice because the variance will likely depend on the number/type of visual features in your environment and details in your place recognition module, but you'll at least be able to smooth out the measurements a bit.  If you want to check how well this assumption holds, you can look at a histogram of the residuals $r_{i}$

$r_{i} = x_{gt}^{i} - x_{m}^{i}$

If the assumption is correct it should look roughly normal.

If you want to get into the weeds a bit more and do this a bit more 'properly', you can get estimates of the uncertainty in the transformation from your place recognition module by examining the fit that the module does.  I won't go into it here since you didn't ask, but see Chapter 6.1.4 in Szeliski (Computer Vision: Algorithms and Applications) on 'uncertainty modeling' if you want to know more.


问:
Why is a3 (link length) present in the DH parameter table?Shouldn't it be 0?

```<code>The figure shows an articulated arm kinematic model having 3 degrees of
freedom.**Theta** represents **joint angle**, **d** represents **joint
distance**, **alpha** represents **link twist angle** and **a** represents
**link length**
</code>```

答:
There is no unique DH parametrization but a couple of variations of DH parametrization out there in textbooks. Basically they all agree on the systematic way to describe the "center" of robots but diverge on the way the base and end-effector are treated. This is because often the the simplest mathematical representation of the representation (i.e. with the less frame and parameters) is not matching the more intuitive one for the user/application.

For you given example, I think you got confused as of where the frames for the DH parametrization are lying on the robot. Based on your table the center point of frame 0 and 1 are the same (which do not appear in your drawing). Then in your drawing you seem to have chosen to put the frame 3 at the end-effector, which makes logically the distance a3 appear, another solution would have been to have the center of frame 3 located on joint 3, then a3 should not appear in your DH table. The later solution is valid but less intuitive in my view (e.g. if you start to think about reaching location in space with your robot it's more intuitive to consider the end-effector than the joint  3 position to describe it)


问:
How to start as a control system engineer and to make advanced projects using PID
I am new to the field of control systems, PID and robotics and I want to enhance my knowledge in the field. Can you recommend me books where I can start learning about control system engineering (with mathematical and practical examples) so I can finally finish my project. (I am working on quad copter and I can find all codes online but can't understand it because some people here told me that I should start reading on these subjects first).</p>

答:
I can see two parts to this question!

You need to learn the math needed to develop such control systems in an advance manner.

Look for Author: Norman S. Nice - Control Systems Engineering. Sixth Edition I found this PDF online and was used in my course.

the programming skills needed to convert this math into a usable system.

Warning - Controlling a quadcopter is not beginner level task and requires at the least.

Good calibration and a Kaman filter on the accelerometer(acc) data.

The ability to transpose the the filtered acc data to a real world coordinate frame.

Power algorithm to determine the needed PWM output at a given motor to achieve flight.

PID control that uses the filtered acc data to determine error between set-point and actual data.

A good PID tune to make the system function as intended.

Programming skills in data manipulation and math.

Assuming you would be using Arduino or C/C++ you could simply google "quad*copter PID Arduino" and you would get 100's of matches.


答:
Making advanced projects with PID control is easy. At first, a uav-testbed is needed. This consists of two UAVs at the same time. The left UAV is controlled by the human operator with a joystick. And the right UAV is controlled by the pid-tracking controller. The idea is, that the pid-controller follows the human-demonstration in realtime and reduces the error. Such a set-up results not to the Artificial Intelligence itself, but it is only a development platform for testing out different kinds of pid-controllers. A more advanced form is model-predictive control, in which the error between the demonstration and the autonomous controlled vehicle is reduced by a dedicated model which can be a physics-engine, a transfer function or a neural network.

Finding good books about the topic is indeed a problem. I can only provide a link to paper which is not very useful Real-Time Predictive Control of an UR5 Robotic Arm Through Human Upper Limb Motion Tracking because it has nothing to do with UAV control. Another problematic source Designing Interactive Blimps as Puppets is unscientific because it is from the area of animatronics.

Title: How to start as a control system engineer and to make advanced projects using PID

Body: I am new to the field of control systems, PID and robotics and I want to enhance my knowledge in the field. Can you recommend me books where I can start learning about control system engineering (with mathematical and practical examples) so I can finally finish my project. (I am working on quad copter and I can find all codes online but can't understand it because some people here told me that I should start reading on these subjects first).</p>


问:
Places for the up-to-date topics in robotics
Are there specific places/websites where you guys read about the topics that are being searched in Robotics, specially, for the most newest researches. I would like to know the places where the most hottest topics in Robotics are studied for both theoretical and experimental studies. The only place I know is IEEE community. They are doing great specially their magazine but I'm curious if there are any alternatives for  robotics scientists. Please include journals. </p>

答: The IEEE society has a paywall infront of their papers. To read the information, somebody has to choose between paying 30 US$ per paper, or become a member which costs hundreds of dollar per year. Additionally, the quality of the papers is in doubt, because most of the journals of IEEE have no public peer-review. In contrast, the stackoverflow and stackexchange website are a good place for discuss new developments. The quality of the postings is high, and the content is available as fulltext. If you have any questions about current robotics, for example how to win the robocup challange, feel free to ask.</p>


问:
Controlling a servocity planetary motor?
I know this might sound like a stupid question, but I actually need help with this. So, I'm looking at this motor: https://www.servocity.com/2737-rpm-premium-planetary-gear-motor.

I have a raspberry pi, and was wondering how exactly I was supposed to control this. I know that I need a motor controller to drive this thing at a reasonable speed, but I need someone to point me in the right direction as to what type of motor controller I need. Thanks!

答:
The one I'd suggest for your motors is the RoboClaw 2x7 Motor Controller.

This takes control signals from the Raspberry Pi and powers the motor from a separate battery. The board should be able to power your Raspberry PI because it has a 5v 3amp BEC (battery eliminator circuit). You would need a battery of no more than 12 volts to power the motors.


答:
This is just a standard brushed DC motor.

What you use to control it (how you control it) depends most on your application.

The Motor Specs are:

Voltage = 3V-12V

Speed = 2737 rpm (12V, No Load)

Current = 0.18A  (12V, No Load)

Current = 4.9A (12V, Stall)

Torque = 9.72 oz-in (12V, Stall)

Some things to consider from this:

If you want to run at 2737 rpm, you better make sure you have a 12V supply and a driver than can drive 12V.  If slower is fine, lower voltage would be OK,  The rpm will scale pretty linearly with the voltage

If you need to be able to support a stall condition, you should make sure the driver can support 5A (or at least as much as you supply can).

Since this is a brushed DC motor, the speed is unregulated.  The speed will result from a balance between input power (V X A) and output power (rpm X torque).  You can add a separate control loop (like using an encoder) if you want to regulate speed.  Some controllers support encoders.

I assume you want to regulate the motor's power.  If so, something has to do the PWM.  This can be done by the Pi or a separate controller.

Title: Controlling a servocity planetary motor?

Body:
I know this might sound like a stupid question, but I actually need help with this. So, I'm looking at this motor: https://www.servocity.com/2737-rpm-premium-planetary-gear-motor.

I have a raspberry pi, and was wondering how exactly I was supposed to control this. I know that I need a motor controller to drive this thing at a reasonable speed, but I need someone to point me in the right direction as to what type of motor controller I need. Thanks!


答:
The absolute scale cannot be estimated if you are utilizing a monocular camera. Either you add an additional sensor information such as IMU or you need a size known object to be in your dataset.

As KITTI dataset has 3D LiDAR scan data as well, you can initially utilize them for finding the absolute scale.

Title: Scale estimation in datasets for monocular odometry

Body: Suppose I've developed a monocular SLAM or odometry algorithm. Then I want to test it on some dataset, for example KITTI, TUM etc. How should I deal with the absolute scale in this way? Thanks.


问:
Potential field algorithm in a predefined trajectory
I am currently working on collision avoidance using Potential fields and I have visualized the same in winfom.

Now, I need to test the algorithm in predefined trajectory say a spline(or in a lane).

My question is:
Is it possible to do collision avoidance considering potential field method in a predefined trajectory?

Say the model car avoids the obstacle and returns back on its trajectory to reach the goal, created in windows form.
If, so what are the parameters and contraints should be considered?

答:
This is not any more a pure potential field type of problem, since you already have a global trjectory which you then alter locally.

This is a hybrid approach. A good example for a hybrid approach is the Elastic Bands method, can be found here. It models the path as elastic bands which are deformed by virtual (mechanical) forces (due to the presence of obstacles). Furthermore, it also includes virtual forces which deform the path back to its original shape if no obstacles are present anymore, similarly to an elastic material.

Later
this method has been alterd to include robot geometry also. The Elastic Strips Method can be found here.


问:
Controlling digital servos
Many websites say that analog servo motors work on 50Hz and digital servo motors work on 300Hz. My question is, does this difference apply only to the inner control loop of the servo or does the user of the digital servo actually provide 300Hz PWM signal? To rephrase, are all (most) servos including digital ones controlled with 50Hz PWM, or are digital ones specifically controlled with 300Hz PWM? Thanks</p>

答:
I think people are getting their mS and uS mixed up! Generally it was always between 1mS and 2mS but to get the full range or extended range its said to be 0.8mS and 2.2mS (or 800uS to 2200uS) not 800 to 2200mS (I'm sure it was just a typo but to save confusion).
Obviously there needs to be a gap between the pulses so at 300Hz you would have a pulse of 2.2mS followed by a gap of 1.13mS, this is known as the Mark and the Space and can be written as a ratio or Mark/Space ratio although here it is irrelevant as I will explain.
(  300x(0.0022+0.00113)=1Second   ).
The old servos always want 50Hz which means as the Mark changed in duration (desired servo position) the Space must also change in duration to keep the frequency always at 50Hz (longer Mark needs a shorter Space to maintain the overall length of the signal and vice versa).
The new servos are quite happy to receive a position signal at 50Hz but will happily accept 300Hz so the only importance is to send the correct Mark duration for the required position and make no change to the Space in between, this makes basic interfacing with microprocessors and program writing that little bit easier for beginners as for instance you could always place a set 2.6mS Space between the Marks giving a position update frequency of between 294Hz and 208Hz(2.6mS+0.8mS and 2.6mS+2.2mS) which for many uses is more than fast enough and also makes the importance of the mark/space ratio redundant. Of course a constant update of 300Hz could be better in some cases requiring better more consistent performance but then a simple calculation is required in the program to set the space accordingly. </p>

Title: Controlling digital servos


问:
Singular configurations of a 7-dof robotic arm
I want to check for singular configurations of a 7-dof robotic arm (RRRRRRR). I have found the geometric Jacobian and it is a 6x7 matrix. If my theoretical background is solid when the Jacobian loses a rank (in this case <6) the robot is at a singularity.

So one should check when the determinant of the Jacobian equals zero.In this case since it is not a square matrix i multiplied the Jacobian by its transpose and calculated that determinant in matlab.

My problem is that the elements of the matrix,well those that are not equal to zero or 1, are terrible to look at.I mean, you can see a lot of cosine and sine terms which make the computation really complicated.

Is there a way to make things easier?

I appreciate all the help,
Victor

答:
Think of those "terrible to look at" terms as diamonds in the rough.  Yes, they look complicated at first.  But you will find an amazing number of them will combine using basic trigonometric identities. For example, look for repeating patterns of squares of the sines and cosines of the various angles, and use those to factor out terms and combine them to equal one, or zero, or twice theta_n, or some other simplification.  I have done this for an 8R arm.  It might take a day or two, but it is achievable.

If the last three (or four) joints of your manipulator have axes which intersect at a point, then you can simplify the equations quite a bit.  If this is the case, your manipulator has a spherical wrist geometry.  Robot manipulators with this feature can be analyzed in a partitioned fashion.  You can define the task as two related subtasks - position the center of the wrist at a certain point in space, and rotate the end effector to achieve the desired Euler angles for that pose.  The singularities of positioning the center of the wrist will be independent of the wrist joint angles, and can be found by a 3x3 $JJ^J$ instead of the 6x6 you are dealing with now.  The singularities of the end effector rotation might have terms that include all of the joint angles, but will still be calculable with a 3x3 matrix instead of a 6x6.


问:
Motion Profiling for Decreasing Energy Consumption
I am attempting to minimize the energy consumption used by an electric-motor-powered car given the speed restrictions:
$$\text{speed}: [v_{\text{min}},v_{\text{max}}]$$
Currently, we are utilizing a bang-bang controller where we tell the motor to run at full voltage until $v_\text{max}$ is reached. After this, the motor is cut. Once the speed approaches $v_\text{min}$ due to energy losses in the system, we will repeat this cycle.

We are striving to achieve the least energy consumption per unit distance. Is it worth while to implement some motion profiling system, or would this just increase energy consumption?

答:
How much energy are you using now with this strategy? You can't minimize if you can't measure or estimate with equations.

It appears that kinetic and potential energy both start and end at zero in your scenario. So all energy expenditure is from losses. If you make a list of your losses you will see by looking at the variables which ones are influenced by a motion profile and which are not.

Air friction and wheel contact friction are only some of the losses and whether they are significant depends. You need to list the equations, assumptions, and estimates of physical parameters you are using.

As a hint, battery internal losses, motor losses, gear losses and motor driver switching losses all are potentially significant depending on the size of your vehicle, the technology used, and the operating environment.

This can be solved mathematically or experimentally. Experimental requires less math but takes a lot longer to do. (In truth, a mathematical  approach would end with experimental validation but take less time because your experiments would start closer to the solution). I'll expand this answer if you add details on your own progress towards a solution.


答:
To paraphrase your question, you are using "bang-bang" control to keep the velocity of your vehicle within a desired range, and want to know if there is a better way to minimize energy consumption per distance traveled.

The answer is almost definitely "yes," with one exception: IF $v_{min}$ and $v_{max}$ values are very close together, and IF the system contains sufficient damping so that the velocity does not overshoot the target $v$, and IF the bang-bang controller is implemented efficiently, and IF the target $v$ is at the most efficient operating point for your vehicle, then no, there would likely not be a more efficient algorithm.  But all of these conditions are probably not true.

To implement a controller that minimizes energy consumption, you really need to know the efficiency of your vehicle for the universe of operating conditions the vehicle will be subjected to.  I would map this out (experimentally or algorithmically, as @hauptmech describes), then determine the optimal operating points.  Since your vehicle probably starts from rest, you will need to integrate the energy used for various acceleration profiles when speeding up to the desired operating point in order to reduce losses at the beginning of travel, then use the optimal acceleration profile to define the velocity setpoints for the controller during a journey.  Repeat this for the deceleration period when ending a journey.  Finally, the system stability (or its ability to remain at a target $v$ over time) will determine whether or not you need to implement a more advanced controller than bang-bang.  I would start with a proportional-plus-derivative controller attempting to servo around a specific velocity target, rather than a velocity range as you have implemented.  That way you can minimize the variance from the target $v$ without allowing it to vary by an arbitrary amount.

Title: Motion Profiling for Decreasing Energy Consumption

Body:
I am attempting to minimize the energy consumption used by an electric-motor-powered car given the speed restrictions:
$$\text{speed}: [v_{\text{min}},v_{\text{max}}]$$
Currently, we are utilizing a bang-bang controller where we tell the motor to run at full voltage until $v_\text{max}$ is reached. After this, the motor is cut. Once the speed approaches $v_\text{min}$ due to energy losses in the system, we will repeat this cycle.

We are striving to achieve the least energy consumption per unit distance. Is it worth while to implement some motion profiling system, or would this just increase energy consumption?


问:
Balancing robot - How to control the velocity and angle
We are currently making a balancing robot as a school project.

The robot has a gyroscope and an encoder to get the angle of the robot and the rpm of the wheels. By using the current angle of the robot and defining a target angle we are able to make the robot stand still and not fall over.

We don't understand how to incorporate the encoder (that measures the angular velocity of the wheels) to make the robot stand still when he motor speed is changing. The robot only knows the angle it is at so it won't compensate for the speed. Could one perhaps use the encoder in such a way that dictates the target angle and keep the robot still or even better control it?

We would also like to know if there is a way to automatically adjust TargetAngle to the needed one, like if the floor angle were to change.

Here is a sample of our code:

```<code>error = TargetAngle - CurrentAngle;
integral = integral + error*ki;
derivative = (error - lastError)*kd;

lastError = error;

pidsum = derivative+error*kp+integral;//this is what is used for throttling the engines
</code>```

答:
First of all, well done on getting your robot to balance! If you’ve got this far the rest should be easy.
A cascading PI loop (no D) works very well for this. You have an outer loop to control the speed and an inner loop to control the stability. In the outer PI loop, you set the speed and the necessary angle is calculated (hint: angular velocity can be calculated simply from the conversion of PE to KE). This is then passed down as the angle set point for the inner PI loop. This is what has been used here. I hope this helps.</p>


问:
Quadcopter stabilisation
I recently built a quadcopter and programmed a code to stabilise itself.
The copter takes the hight from a distancesensors and the angle from a MPU 6050 gyro and accelerometer with a complementary filter.
I currently face two Problems:

Altough the MPU 6050 is mounted to a vibrationabsorbing platform the angle is really bad. Some ideas to lessen the vibrations would be good.

The program never worked satisfactionally: I check every Milisecond, if the Copter is stabilised and at the right height or not. If not it spinns up the motors to correct. This should start the drone and let it hover at a certain height.

However, is the drone starting up well but shortly before take-off one side tilts up at an angle of apprximately 45° and the drone drifts of. The program could never compensate this.
Have you an idea? Or some other thoughts. (This is my first electrical Project so very basic stuff could be wrong)

Thanks for your help.

答:
It sounds like your control system is too basic for the task. Are you just firing up the motors if there is error? That is too simplistic. You should start by implementing PID control, that is not even too complicated, especially since you are using the mpu6050 where you can just read angles without doing sensor fusion yourself.

Regarding the sensor: is the angle so much better without motors on? You might try calibrating the sensor:
https://github.com/kkpoon/CalibrateMPU6050

You will later need to read not only the angles but also the angular rate from your sensor. A function for that can be found in Joop Brokkings flight controller, or in mine (although I do not use the mpu6050 anymore).
I am just finishing my own controller, first test flight I hope soon. If you want to see it: https://github.com/barafael/raPID
There is also a blog post linked in the readme where I try to keep an up to date description of my system.
Feel free to ask questions here or to me in case you get stuck. Good luck!

Title: Quadcopter stabilisation


问:
MPU6050 inconsistent Gyro data
I'm using an MPU6050 for a custom flight controller and I am facing an issue when reading the values from the IMU. The data shown below represents the angular velocity in the y-axis. When the angular velocity is increasing or decreasing the overall trend seems to be increasing/decreasing but there are random drops to 0 degrees / second. The end goal is to read from the accelerometer and gyroscope and calculate the current angular position of the device but the inconsistent data may produce garbage angles.

The data below is taken when I am rotating the MPU6050 about its x-axis.

Is this behaviour normal for a gyroscope or am I doing something wrong. If this is normal, is there a filter that I can apply to get more accurate values?

MPU6050 Datasheet: https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf

MPU6050 Register Map: https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf

Specs:

Clock speed: 16MHz internal

Communication: I2C (100KHz)

MCU: Nucleo 64 STM32f446RE

Data:

Sample of Data

```<code>#    DPS
223 -6.442748
224 -2.076336
225 0.732824
226 1.664122
227 1.832061
228 -1.740458
229 -0.549618
230 5.679389
231 8.351145
232 -0.442748
233 12.045801
234 15.78626
235 19.725191
236 28.106871
237 -0.473282
238 31.709925
239 31.450382
240 -0.70229
241 -1.526718
242 29.007633
243 -1.862595
244 32.152672
245 -0.580153
246 -1.725191
247 40.229008
248 -0.687023
249 -1.587786
250 48.580154
251 51.61832
252 -0.381679
253 -0.183206
254 63.343513
</code>```

Code:

```<code>while (1){
    MPU_config();
    MPU_getData();
}

void MPU_config(){
    //turns off SLEEP and CYCLE mode (register 0x6B)
    i2c_txData = 0x0;
    HAL_I2C_Mem_Write(&hi2c1,i2c_devAddr,
    (uint16_t)PWR_MGMT_1,1,&i2c_txData,1,HAL_MAX_DELAY);
    // Gyro Configuration register (0x1B)
    i2c_txData = 0x08; // fullscale +-500dps (0x08)
    HAL_I2C_Mem_Write(&hi2c1,i2c_devAddr,
    (uint16_t)GYRO_CONFIG,1,&i2c_txData,1,HAL_MAX_DELAY);
    // Accelerometer Configuration (0x1C)
    i2c_txData = 0x08; // fullscale +-4g
    HAL_I2C_Mem_Write(&hi2c1,i2c_devAddr,
    (uint16_t)ACCEL_CONFIG,1,&i2c_txData,1,HAL_MAX_DELAY);
}

void MPU_getData(){
    uint8_t ugyrox_h=0, ugyrox_l=0;
    signed char gyrox_h=0, gyrox_l=0;

    //0x0064 (100) random delay value
   HAL_I2C_Mem_Read(&hi2c1,i2c_devAddr|0x1,GYRO_XOUT_H,1,&ugyrox_h,1,0x0064);
   HAL_I2C_Mem_Read(&hi2c1,i2c_devAddr|0x1,GYRO_XOUT_L,1,&ugyrox_l,1,0x0064);

    // gyro data in MPU is in 2s complement
    gyrox_h = (signed char) ugyrox_h;
    gyrox_l = (signed char) ugyrox_l;

    //gyro_500 = 1.0f/65.5f (gyro_sensitivity: 500dps)
    gyroData = ((float) ((gyrox_h<<8) | gyrox_l))*gyro_500;

    printf("%x \t %x \t %f \n ",gyrox_h,gyrox_l,gyroData);
}
</code>```

Gyro Configuration

FS_SEL = 1, for 500dps (page 14 of register map PDF)

Sensitivity factor is 65.5, "gyro_500" is 1/65.5 in the code (page 12 of datasheet)

答:
So I found a way around the issue by filtering the data. Since there are random dips to 0, I replace a 0 with the previous value which was valid. This works out since it is safe to assume that the actual value when the gyro outputted 0 was close to the previous value which was valid. So its more accurate to keep that previous value instead of using 0.

In addition to this, I also used the average of the last 15 samples of data as the output.

Code:

I need to clean up the code, but here it is...
WINDOW_SIZE is set to 15 for the graph below

```<code>void MPU_getData(){
    uint8_t ugyrox_h=0, ugyrox_l=0, i;
    signed char gyrox_h=0, gyrox_l=0;
    int16_t tot=0;

    if(run == WINDOW_SIZE) run = 0;

    //0x0064 (100) random delay value

    HAL_I2C_Mem_Read(&hi2c1,i2c_devAddr|0x1,GYRO_XOUT_H,1,&ugyrox_h,1,0x0064);

  HAL_I2C_Mem_Read(&hi2c1,i2c_devAddr|0x1,GYRO_XOUT_L,1,&ugyrox_l,1,0x0064);

    // gyro data in MPU is in 2s complement
    gyrox_h = (signed char) ugyrox_h;
    gyrox_l = (signed char) ugyrox_l;

    //gyro_500 = 1.0f/65.5f (gyro_sensitivity: 500dps)
    gyroData = ((float) ((gyrox_h<<8) | gyrox_l))*gyro_2000;

    if( (gyroData < 2) && (gyroData > -2) ){
        gyroData = prevGyro;
    }

    window[run] = (int)gyroData;

    for(i=0; i<WINDOW_SIZE; i++){
        tot += window[i];
    }

    ++run;
    prevGyro = gyroData;
    printf("%x \t %x \t %d \n ",gyrox_h,gyrox_l,(tot/WINDOW_SIZE));
}
</code>```

Data:

Title: MPU6050 inconsistent Gyro data

Body:
So I found a way around the issue by filtering the data. Since there are random dips to 0, I replace a 0 with the previous value which was valid. This works out since it is safe to assume that the actual value when the gyro outputted 0 was close to the previous value which was valid. So its more accurate to keep that previous value instead of using 0.

In addition to this, I also used the average of the last 15 samples of data as the output.

Code:

I need to clean up the code, but here it is...
WINDOW_SIZE is set to 15 for the graph below

void MPU_getData(){
    uint8_t ugyrox_h=0, ugyrox_l=0, i;
    signed char gyrox_h=0, gyrox_l=0;
    int16_t tot=0;

    if(run == WINDOW_SIZE) run = 0;

    //0x0064 (100) random delay value

    HAL_I2C_Mem_Read(&hi2c1,i2c_devAddr|0x1,GYRO_XOUT_H,1,&ugyrox_h,1,0x0064);

  HAL_I2C_Mem_Read(&hi2c1,i2c_devAddr|0x1,GYRO_XOUT_L,1,&ugyrox_l,1,0x0064);

    // gyro data in MPU is in 2s complement
    gyrox_h = (signed char) ugyrox_h;
    gyrox_l = (signed char) ugyrox_l;

    //gyro_500 = 1.0f/65.5f (gyro_sensitivity: 500dps)
    gyroData = ((float) ((gyrox_h<<8) | gyrox_l))*gyro_2000;

    if( (gyroData < 2) && (gyroData > -2) ){
        gyroData = prevGyro;
    }

    window[run] = (int)gyroData;

    for(i=0; i<WINDOW_SIZE; i++){
        tot += window[i];
    }

    ++run;
    prevGyro = gyroData;
    printf("%x \t %x \t %d \n ",gyrox_h,gyrox_l,(tot/WINDOW_SIZE));
}

Data:


问:
How to implement Bounded Angle Vision in Particle Filter?
I have built a Particles Filter simulator and I wanted to add the following functionalities.

Limited Range Vision (Robot can see up to 50 meters)

Limited Angle Vision (Robot can see within a certain angle w.r.t its current orientation.  e.g. If the current orientation is 30 degree then it can see in the range from 0 to 60 degree.)

I have managed to add the Limited Range Vision functionality but unable to add Limited Angle Vision.

Method to Sense the landmarks distance within the range

```<code>public double[] sense(boolean addNoise) {
    double[] z = new double[World.getLandmark().getLandmarks().size()];
    for (int i = 0; i < z.length; i++) {
        Point lm = World.getLandmark().getLandmarks().get(i);
        double dx = x - lm.getX();
        double dy = y - lm.getY();
        double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
        if (addNoise) {
            dist += Util.nextGaussian(0, sense_noise);
        }
        if (isBoundedVision()) {
            // TODO Limited angle vision
            // if robot can see within 60 degree angle w.r.t its orientation
            if (dist <= laserRange) {
                z[i] = dist;
            }
        } else {
            z[i] = dist;
        }
    }
    return z;
}
</code>```

Method to calculate the probability of this particle

```<code>@Override
public double measurement_prob(double[] measurements) {
    double prob = 1.0;
    int c = 0;
    double[] myMeasurements = sense(false);
    for (int j = 0; j < measurements.length; j++) {
        if (measurements[j] != 0) {
            prob *= Util.gaussian(myMeasurements[j], sense_noise, measurements[j]);
            c++;
        }
    }
    if (isBoundedVision()) {
        if (c > 0) {
            // increase the probability if this particle can see more landmarks
            prob = Math.pow(prob, 1.0 / c);
        } else {
            prob = 0.0;
        }
    }
    return prob;
}
</code>```

Coordinates are relative to the robot and for distance calculation I am using the Euclidean Distance method and my Robot gets localized correctly.

答:
It looks like you're missing the angle that the robot is currently looking, e.g. robot_angle_radians.

Once you know where the robot is looking, you just use the atan2 function (see also: example usage) on each point:

```<code>point_angle = Math.atan2(dy, dx); // in radians
</code>```

Then you want to check whether the angle is not more than 30° off of the robot's angle:

```<code>offset = Math.abs(robot_angle_radians - point_angle) % (2 * Math.PI);
if (Math.toRadians(30) < offset) // then it's out of +/- 30 degree range
</code>```

Make sure you are consistent between a polar coordinate system and a compass rose coordinate system.

Body:
It looks like you're missing the angle that the robot is currently looking, e.g. robot_angle_radians.

Once you know where the robot is looking, you just use the atan2 function (see also: example usage) on each point:

point_angle = Math.atan2(dy, dx); // in radians

Then you want to check whether the angle is not more than 30° off of the robot's angle:

offset = Math.abs(robot_angle_radians - point_angle) % (2 * Math.PI);
if (Math.toRadians(30) < offset) // then it's out of +/- 30 degree range

Make sure you are consistent between a polar coordinate system and a compass rose coordinate system.


问:
What's the difference between a holonomic and a nonholonomic system?
I was wondering if a 1D point mass (a mass which can only move on a line, accelerated by an external time-varying force, see Wikipedia - Double integrator) is a holonomic or a nonholonomic system? Why?

I think that it is nonholonomic since it cannot move in any direction in its configuration space (which is 1D, just the $x$ axis). E.g. if the point mass is moving at $$x=10$$ with a velocity of 100 m/s in positive $x$-direction it cannot immediately go to $$x=9.9$$ due to its inertia. However, I have the feeling that my thoughts are wrong...

The background is the following:

I am trying to understand what holonomic and nonholonomic systems are. What I found so far:

Mathematically:

Holonomic system are systems for which all constraints are integrable into positional constraints.

Nonholonomic systems are systems which have constraints that are nonintegrable into positional constraints.

Intuitively:

Holonomic system where a robot can move in any direction in the configuration space.

Nonholonomic systems are systems where the velocities (magnitude and or direction) and other derivatives of the position are constraint.

答:
Holonomic constraints are constraints that can be expressed in the form of an equation relating the coordinate of the system and time

Non-holonomic are constraints that cannot be expressed in the form of equations but it is expressed in the form of inequality.


问:
How do I tune the cascaded PID controller in my flight controller?
there is a lot of information out there on how to tune quad PID parameters. However, they mostly regard only the master loop that takes user input and fused absolute angles. How and in which order do I tune my cascaded PID loops? Do I first do the rate loop? How can I tell if it's tuned correctly? I can cause it to spin the drone 2 times a second around itself, and that with low throttle. It stops quickly when I reset the stick position.

I feel stupid because I cannot tune the controller I built myself, but maybe you can explain it to me.

答:
In general, a cascade controller is nothing more than two independent controllers in series. With independent I mean that they do not intend to control the same value (= measurment, plant output). I.e. One controls the rate and the other  the position (or what ever is the case in your specific issue). Nevertheless, you still have only one output from both the controller combined to stabilize both values of interest.

Therefore you have to identify how the input to the plant $u_f$ - i.e. the output of the controllers - influence the outputs ($y_s$ and $y_f$!) of the plant. If you have a ruff idea about the crossover frequencies of these individual systems ($u_f \rightarrow y_f$ and $u_f \rightarrow y_s$) you can separate them into one fast and one slow subsystem. For example, you should have a look at the poles of both subsystems. The pole of the fast and slow system have to be different from each other, i.e.:
$$
\pi_{s,slowest} \neq \pi_{f,slowest}
$$
Otherwise you won't be able to tune the controllers individually!

Take this chart as a reference.

TUNE FAST CONTROLLER

So if you have identified your faster subsystem - i.e. the value that response faster to input changes - you can start tuning the corresponding controller (Fast controller $C_f$) with the help of the 'fast output' $y_f$. This can be done with the common methods like Ziegler-Nichols or whatever other P(ID) tuning method you prefer (best practice is to leave the integrator part - it only reduces the bandwidth of the controller - for this controller and use P(D) at most but this depends strongly on your system).

TUNE SLOW CONTROLLER

Now you have to shape the outer, 'slower' controller $C_s$. For that you have to have a look at the combined closed loop system of the fast control system you just tuned. I.e:

$$
P_s = \frac{P\cdot C_f}{1+P\cdot C_f}
$$

$P_s$ is your new plant. Therefore, you tune your controller on the basis of $P_s$, $r_s$ and $y_s$ as you know it. Here a PI(D) controller is recommended.


问:
Is a virtual machine with ros-kinetic available anywhere?
I want to learn ros-kinetic from a virtual machine. I found that ros-indigo  is available from nootrix; similarly, is there a virtual machine with ros-kinetic version available anywhere?

答: There is an online resource I have come across that is geared towards learning. It is a paid subscription and I have not personally used the online environment. I have used some of their tutorials and it seems helpful. </p>


问:
install ROS on ubuntu 17
which distribution of ROS should I install on Ubuntu 17
I have searched in ros distributions wiki but couldn't find any specification
and I also found that ROS Kinetic Kame is not suitable for ubuntu 17 </p>

答: ROS Lunar would be geared towards that distro I believe. I ran into this issue and just rolled back to 16.04 and Kinetic.</p>

ContentLicense: CC BY-SA 4.0

Title: install ROS on ubuntu 17


问:
Line Follower optimization
I'm working on building a line follower robot and want to optimize its performance. It was suggested that I use a PID algorithm. I read a lot about PID but am confused a bit regarding following:

I've calculated the error_value using $k_p * proportional + ...$
But regarding the change in the motor speed I'm confused as to what to use during comparison the difference (i.e. currentposition - setpoint) or the errorvalue. That is should I use

```<code>if (difference > 0)
{ //code for changing appropriate motor's speed using error_value }
</code>```

or

```<code>if (error_value > 0)
{ //code for changing appropriate motor's speed using error_value }
</code>```

Also is there any specified range for the values of the constants $k_p$, $k_i$ and $k_d$?
I'm using a differential wheeled robot for my line follower.

Also I would be happy if someone suggests me any other advanced optimization algorithm for improving the line follower robot.

答:
When using a PID loop to steer using line following, then your set point will always be the same. You will always want the line to be in the same position with respect to the robot, for instance in the centre of your sensor.

So if your line sensor outputs a value from -1 to 1 with 0 being the centre of the sensor, then you will want your set point to be zero (and sensor read back and difference will be the same). If your line sensor outputs a value of 0 to 10, then you will want your set point to be 5 (and your sensor read back and difference will be different).

Since you are steering by setting the wheels to turn at different speeds, then to smoothly follow a line at a constant velocity, you will probably want to adjust the speeds for both wheels based on the error. For example, if you need to turn left to stay on the line, you will slow down the left wheel and speed up the right wheel. The more you need to turn, the more you will need to slow down the inside wheel and the more you will need to speed up the outside wheel.

Consider the situation where you need to turn $\theta$ radians to the left to correct for error $e$ and your current speed is $S_0$:

So your left wheel needs to travel at $S_L = r\theta$ and your right wheel needs to travel at $S_R = (r+b)\theta$.

To maintain the same overall speed $S_0$, you need $S_0 = (r+b/2)\theta$,
so the left wheel will need to travel at $S_L = S_0 - (b/2)\theta$
while the right wheel will need to travel at $S_R = S_0 + (b/2)\theta$.

As your error tends towards zero, the speeds of each motor will also tend towards each other. As the error grows, the speed differentials will grow too.

You may even need your inside wheel to rotate backwards if your sensor is telling you that the line is curving more tightly than the distance between your wheels. These are complications which you can work through step by step as your control gets more sophisticated though.

Also, since your error will have both positive and negative values (to represent the continuum from off the scale left ... too far left ... on the line ... too far right ... off the scale right then you should never need to ask if the error is positive or negative, you should just calculate new values based on the error value, since a positive value and a negative value should have opposite and symmetric effects on the motors.

Note that for line following, you may be able to get away with just the proportional gain term (i.e. leaving the other terms at zero). Implementing a Derivative term may well allow you to push up the proportional gain term higher to get a more responsive system, but an integral term is unlikely to help. The fact that if you robot goes in the wrong direction the error will get larger means that your robots physical movements will act like an integral term anyway.

The specific values of P, D and I will be determined by the responsiveness of your system. For general advice about tuning PID parameters, see my answer and others on What are good strategies for tuning PID loops?

Title: Line Follower optimization


问:
Smart camera image processing on embedded GPU vs. in the cloud
I'm working on a smart camera that does key point prediction (predicting locations of wrists, elbow, shoulder, ears, eyes, nose, etc.) for gesture recognition.

Right now, the neural net is running on the embedded GPU (a Jetson TX2) and performance isn't ideal (<3 FPS). So I'm exploring whether it makes more sense to constantly upload images to the cloud, doing the predictions there, and sending the results back to the device.

I'm curious what approach others would recommend for a smart camera. Specifically:

Performance differences between using an embedded GPU vs. the cloud?

Cost differences between using an embedded GPU vs. the cloud?

What other smart cameras are doing (Nest, Lighthouse, etc.)?

If there is an alternative better than the Jetson TX2 if going the embedded path?

Any advice for any of the questions would be great.

答:
Performance differences between using an embedded GPU vs. the cloud?

For your context (to my mind, gesture recognition would ideally be realtime), the latency of going over the cloud would push me towards hardware.

Cost differences between using an embedded GPU vs. the cloud?

Depends on your volume. The cloud is not necessarily cheaper than hardware in the long run, although in some ways it's less headache especially in the short run. For gesture tracking, though, the latency would be too annoying to put up with forever.

What other smart cameras are doing (Nest, Lighthouse, etc.)?

If you're considering a Lighthouse - we use a lot of Realsense here, and find it quite satisfactory. Looking at getting one of the new ones any day now.

If there is an alternative better than the Jetson TX2 if going the embedded path?

I'm not sure it's the TX2 that's the problem - 3fps, what sensor are you using? The TX2 is a beast, and given a half-decent sensor (say, Realsense R200) you almost don't need one. That stated, have you looked into incorporating a Movidius?

HTH.