问:
Modelling Point Clouds for Collision Detection in Gazebo
I am currently applying path planning to my robotic arm (in Gazebo) and have chosen to use an RRT. In order to detect points of collision, I was thinking of getting a Point Cloud from a Kinect subscriber and feeding it to something like an Octomap to have a collision map I could import into Gazebo. However, there is no Gazebo plugin to import Octomap files and I do not have enough experience to write my own. The next idea would be to instead feed this point cloud to a mesh generator (like Meshlab) and turn that into a URDF, but before starting I'd rather get the input of somebody far more experienced. Is this the right way to go? Keep in mind the environment is static, and the only things moving are the arms. Thank you. Below is just a picture of an octomap.

答:
For the most part I was able to get this done. The only difference I chose was to use the Point Cloud library's triangular mesh generator instead of Meshlab's mesh generator mainly because Meshlab's generator is interactive. Below is the image of the Kinect (on top of the Baxter) taking a picture of the shelf, and a picture of the STL put together from the PointCloud the Kinect took.

The code I used is as below:

```<code>#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>
#include <pcl/io/vtk_io.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/io/io.h>
int n = 0;
void
cloud_cb ()
{
 // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PCLPointCloud2 cloud_blob;
  pcl::io::loadPCDFile ("mesh.pcd", cloud_blob);
  pcl::fromPCLPointCloud2 (cloud_blob, *cloud);
  //* the data should be available in cloud

  // Normal estimation*
  pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
  pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
  tree->setInputCloud (cloud);
  n.setInputCloud (cloud);
  n.setSearchMethod (tree);
  n.setKSearch (20);
  n.compute (*normals);
  //* normals should not contain the point normals + surface curvatures

  // Concatenate the XYZ and normal fields*
  pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::PointNormal>);
  pcl::concatenateFields (*cloud, *normals, *cloud_with_normals);
  //* cloud_with_normals = cloud + normals

  // Create search tree*
  pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>);
  tree2->setInputCloud (cloud_with_normals);

  // Initialize objects
  pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
  pcl::PolygonMesh triangles;

  // Set the maximum distance between connected points (maximum edge length)
  gp3.setSearchRadius (0.025);

  // Set typical values for the parameters
  gp3.setMu (2.5);
  gp3.setMaximumNearestNeighbors (100);
  gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees
  gp3.setMinimumAngle(M_PI/18); // 10 degrees
  gp3.setMaximumAngle(2*M_PI/3); // 120 degrees
  gp3.setNormalConsistency(false);

  // Get result
  gp3.setInputCloud (cloud_with_normals);
  gp3.setSearchMethod (tree2);
  gp3.reconstruct (triangles);

  // Additional vertex information
  std::vector<int> parts = gp3.getPartIDs();
  std::vector<int> states = gp3.getPointStates();
pcl::io::savePolygonFileSTL("mesh.stl", triangles);
}

void saveFile(const sensor_msgs::PointCloud2::ConstPtr& input)
{
if(n <= 1)
{
 pcl::PCLPointCloud2::Ptr pcl_input_cloud(new pcl::PCLPointCloud2);
     pcl_conversions::toPCL(*input, *pcl_input_cloud);
    pcl::io::savePCDFile("mesh.pcd", *pcl_input_cloud);
n++;
    cloud_cb();
    }

    return;
}

int
main (int argc, char** argv)
{
  // Initialize ROS
  ros::init (argc, argv, "my_pcl_tutorial");
  ros::NodeHandle nh;
    ros::Rate loop_late(1);
  // Create a ROS subscriber for the input point cloud
  ros::Subscriber sub = nh.subscribe("/cameras/kinect/depth/points", 1, saveFile);

    while(n<=1)
    {
    ros::spinOnce();
    loop_late.sleep();
    }
return 0;
}
</code>```

Most of the code is copied exactly from http://pointclouds.org/documentation/tutorials/greedy_projection.php . I'll have to find a way to get a better 3D reconstruction of the shelf considering there are gaps in the levels.

Body:
For the most part I was able to get this done. The only difference I chose was to use the Point Cloud library's triangular mesh generator instead of Meshlab's mesh generator mainly because Meshlab's generator is interactive. Below is the image of the Kinect (on top of the Baxter) taking a picture of the shelf, and a picture of the STL put together from the PointCloud the Kinect took.

The code I used is as below:

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>
#include <pcl/io/vtk_io.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/io/io.h>
int n = 0;
void
cloud_cb ()
{
 // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PCLPointCloud2 cloud_blob;
  pcl::io::loadPCDFile ("mesh.pcd", cloud_blob);
  pcl::fromPCLPointCloud2 (cloud_blob, *cloud);
  //* the data should be available in cloud

  // Normal estimation*
  pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
  pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
  tree->setInputCloud (cloud);
  n.setInputCloud (cloud);
  n.setSearchMethod (tree);
  n.setKSearch (20);
  n.compute (*normals);
  //* normals should not contain the point normals + surface curvatures

  // Concatenate the XYZ and normal fields*
  pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::PointNormal>);
  pcl::concatenateFields (*cloud, *normals, *cloud_with_normals);
  //* cloud_with_normals = cloud + normals

  // Create search tree*
  pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>);
  tree2->setInputCloud (cloud_with_normals);

  // Initialize objects
  pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
  pcl::PolygonMesh triangles;

  // Set the maximum distance between connected points (maximum edge length)
  gp3.setSearchRadius (0.025);

  // Set typical values for the parameters
  gp3.setMu (2.5);
  gp3.setMaximumNearestNeighbors (100);
  gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees
  gp3.setMinimumAngle(M_PI/18); // 10 degrees
  gp3.setMaximumAngle(2*M_PI/3); // 120 degrees
  gp3.setNormalConsistency(false);

  // Get result
  gp3.setInputCloud (cloud_with_normals);
  gp3.setSearchMethod (tree2);
  gp3.reconstruct (triangles);

  // Additional vertex information
  std::vector<int> parts = gp3.getPartIDs();
  std::vector<int> states = gp3.getPointStates();
pcl::io::savePolygonFileSTL("mesh.stl", triangles);
}

void saveFile(const sensor_msgs::PointCloud2::ConstPtr& input)
{
if(n <= 1)
{
 pcl::PCLPointCloud2::Ptr pcl_input_cloud(new pcl::PCLPointCloud2);
     pcl_conversions::toPCL(*input, *pcl_input_cloud);
    pcl::io::savePCDFile("mesh.pcd", *pcl_input_cloud);
n++;
    cloud_cb();
    }

    return;
}

int
main (int argc, char** argv)
{
  // Initialize ROS
  ros::init (argc, argv, "my_pcl_tutorial");
  ros::NodeHandle nh;
    ros::Rate loop_late(1);
  // Create a ROS subscriber for the input point cloud
  ros::Subscriber sub = nh.subscribe("/cameras/kinect/depth/points", 1, saveFile);

    while(n<=1)
    {
    ros::spinOnce();
    loop_late.sleep();
    }
return 0;
}

Most of the code is copied exactly from http://pointclouds.org/documentation/tutorials/greedy_projection.php . I'll have to find a way to get a better 3D reconstruction of the shelf considering there are gaps in the levels.


问:
Which trajectory planning algorithm for minimizing jerk
In order to perform a cyclic task, I need a trajectory planning algorithm. This trajectory should minimize jerk and jounce.

When I search for trajectory planning algorithms, I get many different options, but I haven't found one which satisfies my requirements in terms of which values I can specify. An extra complicating factor is that the algorithm should be used online in a system without too much computing power, so mpc algorithms are not possible...

The trajectory I am planning is 2D, but this can be stripped down to 2 trajectories of 1 dimention each. There are no obstacles in the field, just bounds on the field itself (minimum and maximum values for x and y)

Values that I should be able to specify:

Total time needed (it should reach its destination at this specific
time)

Starting and end position

Starting and end velocity

Starting and end acceleration

Maximum values for the position.

Ideally, I would also be able to specify the bounds for the velocity, acceleration, jerk and jounce, but I am comfortable with just generating the trajectory, and then checking if those values are exceeded.

Which algorithm can do that?

So far I have used fifth order polynomials, and checking for limits on velocity, acceleration, jerk and jounce afterwards, but I cannot set the maximum values for the position, and that is a problem...

Thank you in advance!

答:
This might not be the right answer for your problem, but it may give you some idea how you might solve this problem:
 At the company, I'm working for, we have lot of issues concerning jerk and acceleration of rotary arms. Our approach is we use motion specified by a position-velocity diagram (User-Input). According to this profiles we calculate an acceleration (assuming infinite jerk). Next step is to calculate a jerk according to a so-called jerk-percentage. This is parameter we use to say how much time of the acceleration there is jerk. See this link where this concept is explained more in detail (only the first 3 paragraphs are related to this topic).
 Anyway at the moment we have still infinite jounce (this has no influence on our application anymore). I suggest go a step further. Use the same concept, call it jounce percentage, and minize it this way.
 At the end you have a simple path finding process, where you only need to identify position, time and velocity. The rest is simple calculation, which can be performed even on a 30year old 8-bit PIC

ContentLicense: CC BY-SA 3.0


问:
Length and Width of a Line Following Robot
I'm building a line following robot. I have made different chassis designs. The main prototype I'm using is a rectangle base. At one side motors are placed. On the other side of the rectangle caster wheel is placed in the middle. Look at the following image.

By varying the values of distance, I have seen that the stability of the robot is varying rapidly.

I'm driving the robot using PID. I have seen that for some chassis designs it is very hard(sometimes impossible) to calculate correct constant values. And for some chassis it is very easy. By the word stability I meant this. I have a feeling that the robot dimensions, distance values and that stability has a relationship..

Is there an equation or something that can be used to estimate the value of the distance when the width of the robot is known..?

Other than that is there a relationship between robot weight and diameter of the wheel or robot dimensions and the diameter..?

Thanks for the attention!!

答:
Actually, the caster wheel has ideally no effect on the kinematics of the vehicle. In reality there will be some resistance from the caster wheel that does impact the vehicle motion, but we can still ignore it for the sake of designing a control law.

Based on the extended discussion in the comments, your sensor can be used to measure the lateral error of the robot with respect to the line it is following. Consider the diagram below, where the robot position is depicted with a dark blue circle and its direction of motion is the red arrow (with constant speed $v$). The lateral error is $e$ (perpendicular distance to the line), while the heading error is $\alpha$ (angle of the velocity with respect to the line).

What you care about is having a control law that controls the robot heading so that an appropriate value of $\alpha$ causes $e$ to be minimized. To do that, consider the error dynamics of $e$:

$\dot{e} = v \sin \alpha$

Which can be extended to:

$\ddot{e} = v \dot{\alpha} \cos \alpha$

If we ignore the fact that the line direction may be changing (valid for most cases similar to roads), then the rate of change of the heading error is approximately the rate of change of the robot heading (turn rate $\omega$):

$\dot{\alpha} \approx \omega$

$\ddot{e} = v \omega \cos \alpha$

Now comes the tricky part. What we really want to do is minimize the error $e$ by controlling the turn rate $\omega$, but the above equation is non-linear and we prefer to design control laws with linear systems. So let's make up a new control input $\eta$ that is related to $\omega$:

$\eta = v \omega \cos \alpha$

Then we can make a feedback control law for $\eta$. I'll go straight to the answer and then follow it up with the details if you are interested...

The feedback controller can be a full PID as shown below:

$\eta = -K_p e - K_d \dot{e} - K_i \int e dt$

And then we calculate the necessary turn rate $\omega$:

$\omega = \frac{\eta}{v \cos \alpha}$

Normally you might do this by using a measurement of $\alpha$, but since you are only measuring $e$ you could just assume that term is constant and use:

$\omega = \frac{\eta}{v}$

Which is really just using a PID control law for $\omega$ based on $e$ but now with the factor $\frac{1}{v}$ in the gains.

With $\omega$ known, you can compute the necessary wheel speed differential as follows (based on your variable names, and where $b$ is the width between wheels):

midSpeed + value $ = \frac{1}{2} \omega b + v$

$v = $ midSpeed

value $= \frac{1}{2}\omega b$

Overall, you are computing $\omega$ using a PID control law as a function of lateral error $e$ (coming from your sensor). You then compute value from the value for $\omega$ and use it to determine the left and right wheel speeds.

Now, read on for more details regarding the error dynamics and linearized control system:

We can write out the system dynamics like this, where we consider $z$ to be the vector of the error states.

$z = \begin{bmatrix} \dot{e} \\ e \end{bmatrix}$

$\dot{z} = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} z + \begin{bmatrix} 1 \\ 0 \end{bmatrix} \eta$

If you are familiar with linear control theory then you can start to see how this is a convenient form where we can make a feedback control law with input $\eta$ as a function of the error:

$\eta = -\begin{bmatrix} K_d & K_p \end{bmatrix} z$

$\dot{z} = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} z - \begin{bmatrix} 1 \\ 0 \end{bmatrix} \begin{bmatrix} K_d & K_p \end{bmatrix} z$

$\dot{z} = \begin{bmatrix} -K_d & -K_p \\ 1 & 0 \end{bmatrix} z$

This closed-loop system has the following characteristic equation:

$s^2 + K_d s + K_p = 0$

Which results in the poles (this is a PD control law, not PID):

$p = -\frac{1}{2}K_d \pm \sqrt{\frac{1}{4}K_d^2 - Kp}$

So if you wanted a critically damped system with no oscillations around the line, you could choose one of the gains and use the following relationship to get the other (start with smaller gains and tune until you get the response you want):

$K_p = \frac{1}{4}K_d^2$


问:
Sensors for differential drive
I have the following chassis along with an Arduino and a motor shield.

I'm in the process of developing a tracking mechanism for use with differential drive.

Normally, a photo reflector can be placed adjacent to the wheel that will reflect when each spoke passes through therefore allowing code to be written that will accurately measure each wheels position.

The problem I have is that you cannot see the wheels from inside the chassis, only small holes for the driveshaft. Placing sensors on the outside would look ridiculous and a wall crash would cause havoc.

Would I be able to use a photo reflector on the gears (as shown) if I accurately placed it to count each spoke on the gear itself? I'm a bit hesitant though because even a small bump could misalign the sensor - again causing havoc.

So does any one have an idea on how to track the wheel movements?

答: One alternative to sensing the wheel movement is to actually track the vehicle movement over ground. I know that some people have done it using optical mouse sensors. The results will depend on the type of underground you are expecting. The upside is however that you track the actual vehicle movement, which is what you are really interested in.</p>

Title: Sensors for differential drive


问:
Is it possible to design robot software or AI to function in different devices?
so i'm really interested in robotics.. I'm not really a robot expert as i have no experience on creating one. I just like them.  Anyway, I am always wondering if its possible to build a robot that can transfer itself to different devices and still function. I mean, if you want that robot to transfer itself(THE DATA that making it function or whatever you call it) to your laptop so you can still use it while you are away or anything.. Does creating one require advanced computing and knowledge? Is it kind of creating a artificial intelligence?. When it think of this i would always thought of J.A.R.V.I.S since he can go to Stark Suit and communicate with him.

Translated into robotics terminology by a roboticist:

Is it possible to create software for controlling robot hardware that can transfer itself to different devices and still function. Could it transfer itself to your laptop and collaborate with you using information it gathered while it was in it's robot body?
  Does creating software like this require advanced knowledge and computing? Is software like this considered to be artificial intelligence?

I am serious about this question sorry to bother or if anyone will be annoyed./

答:
This already happens when a commercial robot product comes off of the assembly line! The robot software is the same for each robot and is copied over.

Some robots work using similar computer processors as your laptop so you could just copy the files over and use them in a simulator of some kind. Many of us use ROS (Robot Operating System), which is useful for code that works on multiple different robots.

However, you usually want a robot to perform very specific tasks, and the robot itself will typically have a physical configuration that doesn't change. That doesn't mean you can't develop systems that work with various configurations. There are examples of modular robots that can reconfigure themselves -- and this means software or AI that can handle varying configurations. Here is one example that builds new robots out of foam. This is kind of like the idea of cross-platform software that is intended to work on different devices.

It is just so much easier to make one reliable system for one robot such as a ground vehicle, and another entirely separate system that is reliable for flying a UAV. Trying to make one system that can control both of those vehicles equally well is very difficult, and in most cases it is not worth the risk and disadvantages.

Possibly what you are referring to is a general artificial intelligence that can "hack" into different systems and control them even though it is not designed for it. Otherwise it is just a matter of including various inputs and outputs as you want -- think of something like an automated building management system, controlling thermostats, elevators, door locks, etc., each one of those items is like a separate robot but they are all controlled by one central computer.


问:
Need help for a quadcopter PID
I'm trying to make a quadcopter with Arduino.
I already have the angles (roll pitch and yaw) thanks to an IMU. They are in degrees and filtered with a complementary filter.
I want to apply a PID algorithm for each axis but I dont know if the inputs should be angles (degrees) or angular velocities in degrees per second so as to calculate the errors with respect referencies.
Which will be the difference? Which will be the best way?

Finally, another question about a PID code: I have seen that many people don't include time in their codes. For example, their derivative term is kd×(last error-actual error) instead kd×(last error-actual error)/looptime and something similar with the integrative term. Which is the difference?

Thank you in advanced.

答: Making a quad with arduino is very difficult task. You will have to consider the delay taken by the reciever. For that you will have to use interupts to to collect the signals with out disturbing to process. And as you asked the input error will always be angles. You will have to change raw values to angles. And also before using pid, you will have to use the gyro values. You will have to use them in manner such that if angle of quad is disturbed in one axis then increase speed proportionaled to gyro out in that axis to react to the change. After that you will use pid. With out that. Its impossible. Ita my experience.</p>

Title: Need help for a quadcopter PID


问:
Is Venetian mirror possible in Autodesk Inventor?
I see there are things like glass and mirror in Autodesk Inventor Professional 2016 but is there a possibility to have Venetian mirror? So that from one side it would look like a mirror and from the other side it would look like a transparent glass?</p>

答:
Surface properties like that are really only for cosmetic purposes so it is unlikely any CAD program has that option. However, you may be able to get the appropriate effect by assigning particular faces either glass or mirror texture.

Based on your added comments, I think the best option is simply to capture images or animation frames with whatever proper surface setting is needed for the required view angle. Then you can stitch the separate animation frames together to make it seem as though the component has the look you want.


答:
The short answer is yes, totally possible, though not done that often in practice.

Creating an AI that thinks like a human (and does what it's human partners or masters want like J.A.R.V.I.S) is something we can't do yet. The current research in that direction does require advanced knowledge and skills.

If you want to know more about some detail add a comment about what you are curious about and I'll try to answer.

Title: Is it possible to design robot software or AI to function in different devices?

Body:
so i'm really interested in robotics.. I'm not really a robot expert as i have no experience on creating one. I just like them.  Anyway, I am always wondering if its possible to build a robot that can transfer itself to different devices and still function. I mean, if you want that robot to transfer itself(THE DATA that making it function or whatever you call it) to your laptop so you can still use it while you are away or anything.. Does creating one require advanced computing and knowledge? Is it kind of creating a artificial intelligence?. When it think of this i would always thought of J.A.R.V.I.S since he can go to Stark Suit and communicate with him.

Translated into robotics terminology by a roboticist:

Is it possible to create software for controlling robot hardware that can transfer itself to different devices and still function. Could it transfer itself to your laptop and collaborate with you using information it gathered while it was in it's robot body?
  Does creating software like this require advanced knowledge and computing? Is software like this considered to be artificial intelligence?

I am serious about this question sorry to bother or if anyone will be annoyed./


问:
Humanoid balancing
I'm currently working on Humanoid robot. I've solved the Forward & Inverse Kinematic relations of the robot, and they turn out to be fine. Now I want to move onto Walking. I've seen tons of algorithms & research papers but none of them make the idea clear. I understand the concept of ZMP & what the method tries to do, but I simply can't get my head around all the details that are required to implement it in a real robot. Do I have to plan my gait & generate the trajectories beforehand, solve the joint angles, store them somewhere & feed it to the motors in real-time? or Do I generate everything at run-time(a bad Idea IMO)? Is there a step-by-step procedure that I can follow to get the job done? or Do I have to crawl all my way through those Research papers, which never make sense(at least for me).</p>

答:
Keep in mind that the ZMP is a simplification. In practice with walking robots the support polygon is constantly changing so it can be tough to keep the ZMP inside.

Pregenerated (offline) trajectories will only work in very specific conditions (flat ground, no disturbances), and only if you can model your support polygon well.

That said, everything you learn as you try to make your robot walk with offline trajectories will be useful going forward.

Title: Humanoid balancing


问:
Torque / Current control for BLDC motors
I am working on a robotic application, and I want to control the torque (or current) of brushless DC motors. There are many BLDC speed controllers but I could not find anything related to torque or current.

Instead of continuously spinning, the motor is actuating a robotic joint, which means I need to control the torque at steady-state, or low-speed, finite rotation.

I am looking for a low-cost, low weight solution, similar to what Texas Instruments DRV8833C Dual
H-Bridge Motor Drivers does for brushed DC motors.

答:
You did not exactly specify the application you are working on, however, the fact that you have limited angular displacement range, and not continuous rotations, does not necessarily mean that you need torque control. If you are interested in positions instead of velocity, you will need position control, and you do not necessarily need also torque control. (e.g. if you want to do gravity compensation though a torque feed forward method, you will need a torque controller, but you would not need something like that for hobby applications)

If your application is simple and does not require high speed precise trajectories, because of simplicity, I would recommend trying position control without a torque control. For this, you could use the velocity controllers well known for BLDCs (as the ones you mentioned, might also come with overload protection) and add an external position loop around it. Your COTS velocity controller will get an input from the outer position controller, implemented on a microcontroller (or similar device, depending on what you use).

The position controller will have to get position feedback of some kind.There are more ways to get angular position feedback, depending on budget and application. Encoders are commonly used, but if high precision is not needed, you might be able to get away with using a potentiometer.

The control rule can be a simple proportional controller at first (PID later), generating the input for the velocity controller. If the difference between the desired position and the actual position (measured by the angular displacement sensor of your choice) is large the velocity controller will get a large input (the said difference multiplied by a constant, which you have to play around with). If there is no difference between the actual and the desired angle then zero velocity is required. Your position controller will generate an output, compatible with your velocity controller (e.g. PWM signals to the velocity controller), that tells the velocity controller how fast and in which direction should the motor move to reach the desired position.  Depending on your application this simple approach could be enough.

If you want to start from scratch, you can build your own position/velocity/torque controller, here is an example of how it can be implemented on Atmel micro controllers, here for Microchip. Both documentations recommend motor driver ICs, I think all IC can be considered light weight.

If this is a hobby like project, you might be interested in R/C servos e.g. Dynamixel which have all the functionality you require, position control, built in. The ones I linked are quire capable (incl. torque control, modifiable PID gains), but be aware of their stall torque limitations.


答:
I don't think I have heard of an algorithm specifically for minimizing jerk and definitely none for jounce.  However, here are some semi-recent academic articles and papers that may be of interest to you.  They all minimize acceleration in different ways, and you may be able to be extend for jerk and jounce.

IEEE SPECTRUM article: Robots With Smooth Moves Are Up to 40% More Efficient profiling the AREUS project.

RSS 2012: Time-Optimal Trajectory Generation for Path Following with Bounded Acceleration and Velocity by Tobias Kunz and Mike Stilman.  Video here.

HUMANOIDS 2015: Kinematically Constrained Workspace Control via Linear Optimization by Zachary K. Kingston, Neil T. Dantam, and Lydia E. Kavraki.

Title: Which trajectory planning algorithm for minimizing jerk

Body:
In order to perform a cyclic task, I need a trajectory planning algorithm. This trajectory should minimize jerk and jounce.

When I search for trajectory planning algorithms, I get many different options, but I haven't found one which satisfies my requirements in terms of which values I can specify. An extra complicating factor is that the algorithm should be used online in a system without too much computing power, so mpc algorithms are not possible...

The trajectory I am planning is 2D, but this can be stripped down to 2 trajectories of 1 dimention each. There are no obstacles in the field, just bounds on the field itself (minimum and maximum values for x and y)

Values that I should be able to specify:

Total time needed (it should reach its destination at this specific
time)

Starting and end position

Starting and end velocity

Starting and end acceleration

Maximum values for the position.

Ideally, I would also be able to specify the bounds for the velocity, acceleration, jerk and jounce, but I am comfortable with just generating the trajectory, and then checking if those values are exceeded.

Which algorithm can do that?

So far I have used fifth order polynomials, and checking for limits on velocity, acceleration, jerk and jounce afterwards, but I cannot set the maximum values for the position, and that is a problem...

Thank you in advance!


问:
PID tuning for 6 dof robotic arm
I'm currently developing a 6 dof robotic arm. The arm is vibrating when it stop moving and I want to reduce it. Another thing is that arm is so heavy (because there is a projector inside it, lol) and I have to use spring between joints. So, can anyone tell me 1. how to select springs because my supervisor told me that proper selection of springs can reduce vibration? 2. how do I tune the PID parameters? All the joints are dynamixel servos and their PID parameters are tunable. I read article about tuning for a single servo. How do I tune these parameters for the whole arm?</p>

答:
Springs (no matter the combination) are not going to reduce the vibration. (there are exceptions because real springs lose energy but I don't think it applies to your case.) Damping could reduce the vibration, but that means you are throwing away energy and it sounds like you need all you can get to move that heavy projector.

Keep in mind that PID does not work as well when the load on the joints change, which is what happens in an arm. Depending on the angle of the joints, sometimes gravity will increase or decrease the apparent load in a way that makes the PID gains not work well at that angle.

Increasing the D gain of your PID will help. However for an arm you should be using a trajectory generator to set the target position to intermediate points between the start and end position.

Another issue you might be having is that you probably have the extra projector support springs arranged to help lift the projector to the position you will use most often. This means you will have asymmetric force gradients on the arm with gravity creating one force and the spring creating another.

So...

Use the single servo PID tuning approach for each servo, one at a time, with the joint axis of the servo of interest vertical and the other joints in a position that puts the projector closest to where you normally want it. Leave the projector support spring on. (the goal is to eliminate the influence of gravity when tuning the PID)

Set up the arm for normal use and increase the D gain on the joints that are vibrating too much until it's ok (or until you get a high frequency vibration). I predict that the arm performance will not be good when you do this and you should do the next step.

Add a trajectory generator to your control. With this you should be able to set an accelleration that gives you better performance than step 2 but might be a little slow.

Switch to torque control, do your own PID calculaton and add feedforward control for gravity compensation and support spring compensation.

All of the above should help regardless if the vibration is from motor, mechanism, or control.

Starting with actuators that are properly sized for the application would be best but it sounds like that is not an option for you.

Title: PID tuning for 6 dof robotic arm


问:
Can you seed a Kalman filter with a particle filter?
Is there a way of initializing a Kalman filter using a population of particles that belong to the same "cluster"? How can you determine a good estimate for the mean value (compute weighted average ?) and the covariance matrix ? Each particle is represented as $[ x , y , θ , weight]$.</p>

答:
While this can be done it will be problematic. The issue comes from the fact that particle filters are a method for dealing with multi-modal probability distributions (PD) while Kalman filters assume your PD can be well represented with a Gaussian distribution.

I can conceive of a few methods for doing so if you really must. The most naive would be to calculate the mean and covariance of each $[x, y, \theta]$ vector. This neglects the weights and as such will be impacted by outliers (in this case particles of low weights).

It may be better to calculate the mean and covariance of each $[x, y, \theta]$ vector using the normalized weight values as the probability of the vector. This may be what you were driving at in your question.

Another naive approach would be select the largest mode and calculate its mean and covariance. Doing so requires that you select which particles belong to the mode and which don't which you could do with something like K-means.

Yet another alternative would be to use K-means to find the centers for K clusters and then calculate the mean and covariance of of these centers. I suspect this will work out pretty close to the same things as the second option I offered but not having done the math I cannot say so for certain.


问:
Change PWM values according to encoder output
I have a motor with an encoder. When I set the speed of the motor it should change its speed so that encoder readings per second should fit an equation $y = ax^2 + bx + c$ where x is speed value that is given to the motor and y is the encoder readings per second that should get with motor.

Encoder reading is counted in every 1ms and if it is not equal to the value of the encoder output should get from motor (it is calculated using the equation), the PWM input to the motor should vary in-order to get desired encoder output.

I want to control this value using a PID controller but I'm confused in writing equations. Any help would be appreciated..

答:
$$y_d = a x^2 + b x + c$$ is your model, where I am using $y_d$ to represent the desired value of your control variable.

Using the measured value of your encoder $y_m$, define an error value $y_e$  $$y_e = y_d - y_m$$

Your PID controller can then be implemented as

$${PWM}_{dc} = k_p y_e + k_i \int y_e dt + k_d \frac{dy_e}{dt}$$

Here I am using ${PWM}_{dc}$ to be the duty cycle of your PWM signal.

So if you have a mapping showing what PWM duty cycles will achieve which $x$ speeds (perhaps a lookup table?) you can use ${PWM}_{dc}$ to find the value of $x$ to command.  Otherwise, go ahead and substitute your $x$ in place of my ${PWM}_{dc}$ and assume the mapping between these two variables is linear.


问:
Arduino Power Adapters
I'm shopping for my first Arduino with a specific goal in mind. I need to attach 3 standard servo motors, an ArduCam Mini 2MP camera, and several LEDs. I'm trying to figure out power requirements. I assume that USB power won't be sufficient. I'm looking at 12V AC-to-DC outlet adapters and I noticed that Amps vary from ~500MA to 5A. I don't want to use batteries.

What would you recommend as minimum amperage for this setup? Is there a maximum amperage for Arduino boards? I don't want to plug it in and burn it out. If I plug in both the USB cable and a power adapter at the same time, is power drawn from both cables?

Thanks!

答:
The three “standard servo motors” – presumably standard-size hobby RC servos – will be the main load on your power supply, unless your LEDs are high-power devices.  Pololu.com's electrical characteristics of servos... web page has some guidelines you probably should read.  Some excerpts:

... A standard servo will have a stall current around one amp, a micro servo will need a few hundred milliamps, and a giant servo can draw ten amps or more. ... quiescent currents are tricker to estimate ... typically, the current should be in the few dozen to one or two hundred milliamp range

For your three servos, a 5V 2A power supply is reasonable, supposing you never stall more than one servo at once and that stall times are brief (a few seconds at most).  If you were to stall all three servos at the same time on a 2A PS, and the Uno were powered by the same supply, it probably would reset or otherwise misbehave.

Figure 35 to 50 mA for the Uno, and perhaps 50 mA for the ArduCam Mini 2MP camera (125 mW at 3V, IIUC), and 15 to 25 mA per LED.  Note, for indicator LEDs (vs illumination) many high brightness LEDs work ok at sub-milliamp currents; for example, on some of my Arduino nano boards I've replaced the PWR indicator's 1KΩ dropping resistor with 20KΩ and it's adequately bright.

In brief, allow two to three amps for the servos and perhaps a fourth of an amp for the rest.

The Arduino will draw only the current it needs, as long as it's powered via USB or its Vin pin or DC socket.  Several Arduino models (eg Uno, Mega2560, Nano) have a FET or diode automatic power-selection network, typically allowing them to be powered by USB at the same time as by Vin pin or DC socket.

If you wish to connect a 5V PS to an Arduino's +5V line (which can be done), first review the “gotcha's” at 10 ways to destroy an arduino  at rugged-circuits.com.

Edit:

For a 12V adapter, hook into the Vin pin or DC socket.  On an Uno, there's a diode after the DC socket and in this case using the socket is preferable to using Vin.

With 12V into the Uno's +5V regulator (typically a NCP1117ST50T3G), you probably won't draw more than 0.3–0.5 A from the  +5V line without overheating the regulator.  A 9V supply, dropping 3V less across the regulator, dissipates 1.5 W less power in it at 0.5 A than does a 12V supply, with consequently less heating.

An Uno page at arduino.cc says:

The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

Note that hooking a 5V PS to the +5V bypasses the regulator entirely.  The earlier link (10 ways...) recommends against this in certain cases.  The Uno page at arduino.cc advises against it:

5V. This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

Options include:

Power Arduino and low-current devices via USB or via a 9V 3-5 W adapter; use a higher-current, eg 2A or 10 W,  5V adapter for servos.

With a 5 A or 60 W, 12V adapter, connect +12 to Vin or DC socket; also attach one or more inexpensive adjustable 2-amp LM2596-based buck regulators like 1, 2, or 3 to the +12, dial the outputs in to +5, and use them to power the servos, with the Arduino ground common with the regulator grounds.

Title: Arduino Power Adapters


问:
Calculate robot heading to follow wall and avoid obstacles
I have a task that involves implementing robot behaviour that will follow wall and avoid obstacles along it's path. The robot must stay at desired distance from the wall but also stick to it so it should not loose sight of it. Robot is sensing it's surrounding with ultrasonic sensor that is oscillating from left to right and filling an array of small length (10 values) with detected distances (every 10 degrees). From this reading I would like to calculate heading vector that will result in robot path similar to one shown in bottom picture:

Black(walls), red(obstacles), blue(robot), green(desired path)

答:
It sounds like you want some sort of bug algorithm.

But the pseudo-code for what you want is simple:

```<code>while not at goal:
    if there is a wall in front:
        turn right a little
    else if there is a wall on the left:
        drive straight a little
    else:
        turn left a little
stop
</code>```

Of course tuning this thing can be tricky.  For example, you probably don't want to turn in place when you see no wall.  You should drive forward and left in an arc.  The specifics of which depend on your robot and environment.

Also, because you have a spinning ultrasonic sensor, you should not drive the robot too fast.

Note that the pseudo code really only needs a single sensor on the left of the robot and in front of the robot.  But since you have an array of range values, you can potentially do something more sophisticated, although more complicated.   For example, use the few range readings on the left side of the robot to determine the distance and angle of the wall relative to the robot, and act accordingly.

Body:
It sounds like you want some sort of bug algorithm.

But the pseudo-code for what you want is simple:

while not at goal:
    if there is a wall in front:
        turn right a little
    else if there is a wall on the left:
        drive straight a little
    else:
        turn left a little
stop

Of course tuning this thing can be tricky.  For example, you probably don't want to turn in place when you see no wall.  You should drive forward and left in an arc.  The specifics of which depend on your robot and environment.

Also, because you have a spinning ultrasonic sensor, you should not drive the robot too fast.

Note that the pseudo code really only needs a single sensor on the left of the robot and in front of the robot.  But since you have an array of range values, you can potentially do something more sophisticated, although more complicated.   For example, use the few range readings on the left side of the robot to determine the distance and angle of the wall relative to the robot, and act accordingly.


问:
ROS and Kinect data without callbacks
I'd like to get rgb and depth data from a kinect, and I found a little tutorial here: http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython. It's fine, but what I'd like is to be able to get the data on demand, and not as whenever the callback is triggered, assuming I won't try to get the data faster than it can be available. I'd appreciate any help - do go easy on the ROS jargon, I'm still learning...Thanks.</p>

答:
You should simply use the callback method since you can have an object in your code that is always updated with the latest measurement. Then you can simply poll the measurement in that object whenever you want (say in some while loop running at a given rate). I notice you are linking to help related to using Python, whereas I am more familiar with coding ROS nodes in C++. If you were doing that then your code might look something like:

```<code>#include...

class KinectSubscriber {
 ...
}

int main(...) {
 ...
 KinectSubscriber MyKinectSub;
 ...
 while (ros::ok()) {
  ...
  data = MyKinectSub.data;
  ...
 }
}
</code>```

Of course you don't have to access the data at each iteration of the loop, you could use some conditional statements so that the data is polled only under certain circumstances.

Title: ROS and Kinect data without callbacks

Body:
You should simply use the callback method since you can have an object in your code that is always updated with the latest measurement. Then you can simply poll the measurement in that object whenever you want (say in some while loop running at a given rate). I notice you are linking to help related to using Python, whereas I am more familiar with coding ROS nodes in C++. If you were doing that then your code might look something like:

#include...

class KinectSubscriber {
 ...
}

int main(...) {
 ...
 KinectSubscriber MyKinectSub;
 ...
 while (ros::ok()) {
  ...
  data = MyKinectSub.data;
  ...
 }
}

Of course you don't have to access the data at each iteration of the loop, you could use some conditional statements so that the data is polled only under certain circumstances.


问:
How can I measure the actual speed and distance traveled of the robot with an external setup?
Good day to all.

First of all, I'd like to clarify that the intention of this question is not to solve the localization problem that is so popular in robotics. However, the purpose is to gather feedbacks on how we can actually measure the speed of the robot with external setup. The purpose is to be able to compare the speed of the robot detected by the encoder and the actual speed, detected by the external setup.

I am trying to measure the distance traveled and the speed of the robot, but the problem is it occasionally experiences slippage. Therefore encoder is not accurate for this kind of application.

I could mark the distance and measure the time for the robot to reach the specified point, but then I would have to work with a stopwatch and then transfer all these data to Excel to be analyzed.

Are there other ways to do it? It would be great if the external setup will allow data to be automatically sent directly to a software like Matlab. My concern is more on the hardware side. Any external setup or sensors or devices that can help to achieve this?

Thanks.

答:
There are a couple good options depending on the scale of your project for capturing a ground truth.

For large scale outside (cars or agricultural vehicles) RTK GPS can be had for a very reasonable price.

For small scale you can probably make a poor-mans motion capture with OpenCV, ping-pong balls, and a few global shutter cameras (preferred if you can afford it) or even webcams.

If you have both no time and no money, make a grid on the floor with a builders chalk line, attach a marker (ping-pong ball on a stick) near to the floor (avoid abbe error), and take a video from above. Your pose estimates will be more precise than the stopwatch estimates you were thinking of.

Make sure to estimate and include the measurement error of your ground truth in the report.


答:
Until you learn more about ROS the best approach is to use a callback. You can copy the data to a global variable and use that in your main program if it helps you reason about the data flow better.

If you are trying to do this to reduce network congestion, your best bet is to change the driver parameters to reduce the framerate or resolution. For the openni_camera package the parameters are here. Other solutions exist but require either modifying the ROS drivers or not using ROS at all.

As a side note; if you don't have a specific reason to use ROS, don't use it. It will save some headaches and your program will be faster and simpler besides.

Title: ROS and Kinect data without callbacks

Body: I'd like to get rgb and depth data from a kinect, and I found a little tutorial here: http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython. It's fine, but what I'd like is to be able to get the data on demand, and not as whenever the callback is triggered, assuming I won't try to get the data faster than it can be available. I'd appreciate any help - do go easy on the ROS jargon, I'm still learning...Thanks.</p>


答:
Typically, tracking the position and orientation of a vehicle is not accomplished by looking at the wheels — it's done with navigation sensors.  If you were attempting to have closed-loop control (i.e. servo control) of your motors then wheel-mounted position sensors might be appropriate.  But if the goal is to support "autonomous driving", then I don't think position sensors will suffice.

Put simply, any non-flat terrain or slippage of the tracks would ruin your accuracy.

Instead, I would suggest one or more of the following navigation sensors:

Compass

GPS

Inertial navigation system

Acoustic or laser rangefinder

Acoustic beacons and triangulation

Title: Sensors for differential drive

Body:
I have the following chassis along with an Arduino and a motor shield.

I'm in the process of developing a tracking mechanism for use with differential drive.

Normally, a photo reflector can be placed adjacent to the wheel that will reflect when each spoke passes through therefore allowing code to be written that will accurately measure each wheels position.

The problem I have is that you cannot see the wheels from inside the chassis, only small holes for the driveshaft. Placing sensors on the outside would look ridiculous and a wall crash would cause havoc.

Would I be able to use a photo reflector on the gears (as shown) if I accurately placed it to count each spoke on the gear itself? I'm a bit hesitant though because even a small bump could misalign the sensor - again causing havoc.

So does any one have an idea on how to track the wheel movements?


问:
How can I measure the height of an object with a single sharp sensor (GP2Y0A21YK0F)?
I have one sharp sensor and I have to use it to measure the height of a block (6cm - 12 cm). How can I accomplish this ?
Actually it is to be connected to a robot which will move near the box and determine its height.

About GP2Y0A21YK0F:
http://www.sharpsma.com/webfm_send/1489

The robot is like this: http://i.imgur.com/8qT8zeQ.jpg

If possible please suggest a solution that doesn't require moving the sensor.
But any method will do fine.

答:
Can you explain more about how the robot is to measure the height?

It would seem to me like you could put the sensor at the top of a mast of known height $h$, looking down. Then the robot drives up to the block until the sensor feedback registers some distance other than $h$ (plus or minus some margin for noise, etc.)

Once you are in position, the height of the block is

$$
h_{\mbox{block}} = h_{\mbox{mast}} - \mbox{sensor output}
$$


答:
I think the vibrations of the mechanical structure are due to the mechanical structures natural frequency. The dynamixel servos you mentioned are quite performant and have a acceleration and deceleration. This means that it has an abrupt stop when it reaches its setpoint, and this "shock" excites the mechanical structure at its natural frequency.

You could set the PID controller of the dynamixel servos softer with a large settling time without any overshot. This might help.

To tune the PID you can follow the Ziegler-Nichols method. The order of tuning should be backwards, from end-effector to base.

Another solution (and actually this would be my recommendation):
You can leave the PID controllers of the servos as they are and do a trajectory planning. Instead of reducing the performance of the controllers (i.e. instead of making them soft), generate the reference values, the setpoints of the controllers, in a smooth manner, where you control the changes in position, velocity and acceleration, and those are not implicitly set by the controller. They will still be influenced by the controllers, but their effect will be greatly reduced. If you plan the trajectories smoothly (continuous acceleration, no sudden changes) the mechanical structure (at its natural frequency) will not be excited anymore. You will lose some dynamical performance but you will gain smooth motions.

The spring can help your servos if they do not have enough torque. It may effect the frequency of the vibrations but will not eliminate these in most cases. Dampers can be used to reduce vibrations, if your spring is actually a spring-damper it can eliminate vibrations.

To dimension a spring you have to determine what is the maximum torque required by the mechanical system in one given axis. You compare that with the maximum torque of your motor. if it is larger, so you need more torque than you have, you can use this difference to dimension a spring. The spring exerts a force, which is then converted to a torque using the perpendicular distance. This perpendicular however changes with the motion of the joint. So the design variables, spring constant, perpendicular distance (distance and angle of attack) will effect how much torque the spring will exert for every position of the joint. The same way the mechanical torque requirements of the robot will change for every position of the joint. The motor torque will not change. So...the torque coming form the spring plus the torque coming from the motor will have to be smaller than the required torque for every possible position of the joint.

Since you mentioned a projector:
Please keep in mind that a small motion at the projector level will produce a large motion at the projected image. So you will have to have very smooth motions in order to not excite the mechanical structure. Or you could use a more robust mechanical structure, which is not that easy to excite.

Backlash can also be compensated to some degree. You can find more about it here.

Title: PID tuning for 6 dof robotic arm

Body: I'm currently developing a 6 dof robotic arm. The arm is vibrating when it stop moving and I want to reduce it. Another thing is that arm is so heavy (because there is a projector inside it, lol) and I have to use spring between joints. So, can anyone tell me 1. how to select springs because my supervisor told me that proper selection of springs can reduce vibration? 2. how do I tune the PID parameters? All the joints are dynamixel servos and their PID parameters are tunable. I read article about tuning for a single servo. How do I tune these parameters for the whole arm?</p>


问:
Manipulator end-effector orientation with quaternions
I have the following problem:

Given 3 points on a surface, I have to adjust a manipulator end-effector (i.e. pen) on a Baxter Robot, normal to that surface.

From the three points I easily get the coordinate frame, as well as the normal vector. My question is now, how can I use those to tell the manipulator its supposed orientation.

The Baxter Inverse Kinematics solver takes a $(x,y,z)$-tuple of Cartesian coordinates for the desired position, as well as a $(x,y,z,w)$-quaternion for the desired orientation. What do I set the orientation to? My feeling would be to just use the normal vector $(n_1,n_2,n_3)$ and a $0$, or do I have to do some calculation?

答:
As Brian indicated in a comment, you simply need to convert your rotation matrix (or Euler angles) into a quaternion.  Maths - Conversion Matrix to Quaternion is my favorite site for geometric conversions.

Quaternions are a great representation and have a number of benefits over other representations, so you should definitely read up on them.


问:
What can this picture/data tell?
I've implemented a model of a ball-on-plate plant and am controlling it over a network. Below is the open loop output when excited by successive sinusoidal inputs with increasing frequencies. I know that the plant is open loop unstable, and it is cool that this figure so nicely captures the instability.

What I'd like to know is if there is other information that I can glean about the plant from the relationship between the input and the output state.

(The state is clipped at 3.1 units.)

答: The natural frequency of your system is obvious from your graph.  From that you can get a relationship between mass and stiffness (using a second order model).  If you look at the growth in amplitude of your natural frequency (use a high-pass filter to remove the input signal) you should see the rate of growth in the characteristic frequency.  That is related to the system damping ratio.  A text on vibration (e.g., http://www.newport.com/Fundamentals-of-Vibration/140234/1033/content.aspx) can help with the specific parameters.

Title: What can this picture/data tell?


问:
Comparison of lifting systems
What kind of systems can be used to make a torso lifting system like the one used by this robot (the black part) :

Rack and pinion

lead screw

scissor lift

can a triple tree help ?

What are the pro and cons of each system ?
How do they ensure stability ?
And finally, is there a way to draw current when lowering instead of drawing current when lifting ?

答:
So this is summary...Open to discussions or edits...

```<code>| Mechanism          | Precision | Friction | Max length | Max force |
|--------------------| ----------|----------|------------|-----------|
| rack and pinion    | low       | high     | unlimited  | high      |
| lead screw         | high      | mid      | limited    | high      |
| ball screw         | high      | low      | limited    | high      |
| scissor lift       | mid       | low      | limited    | high      |
| linear direct drive| high      | low      | unlimited  | mid       |
| 4-bar mechanism    | high      | low      | limited    | high      |
|--------------------|-----------|----------|------------|-----------|
</code>```

It may worth noting:

that the scissor and 4-bar mechanisms have a non-linear dependency between input and output velocity

not all 4 bar mechanism's motions are linear

the scissor mechanism (if designed like this) provides a good lateral stiffness, all others would need some form of linear motion guide to cope with lateral forces that bend the structure.

You can use a spring (mech/pneu/hydro) to invert the direction of effort, or a simple counterweight.

You may want to use a non-backdrivable gearbox to drive these (not the linear direct drive of course)...

Title: Comparison of lifting systems

Body:
So this is summary...Open to discussions or edits...

| Mechanism          | Precision | Friction | Max length | Max force |
|--------------------| ----------|----------|------------|-----------|
| rack and pinion    | low       | high     | unlimited  | high      |
| lead screw         | high      | mid      | limited    | high      |
| ball screw         | high      | low      | limited    | high      |
| scissor lift       | mid       | low      | limited    | high      |
| linear direct drive| high      | low      | unlimited  | mid       |
| 4-bar mechanism    | high      | low      | limited    | high      |
|--------------------|-----------|----------|------------|-----------|

It may worth noting:

that the scissor and 4-bar mechanisms have a non-linear dependency between input and output velocity

not all 4 bar mechanism's motions are linear

the scissor mechanism (if designed like this) provides a good lateral stiffness, all others would need some form of linear motion guide to cope with lateral forces that bend the structure.

You can use a spring (mech/pneu/hydro) to invert the direction of effort, or a simple counterweight.

You may want to use a non-backdrivable gearbox to drive these (not the linear direct drive of course)...


问:
Sensors for differential drive
I have the following chassis along with an Arduino and a motor shield.

I'm in the process of developing a tracking mechanism for use with differential drive.

Normally, a photo reflector can be placed adjacent to the wheel that will reflect when each spoke passes through therefore allowing code to be written that will accurately measure each wheels position.

The problem I have is that you cannot see the wheels from inside the chassis, only small holes for the driveshaft. Placing sensors on the outside would look ridiculous and a wall crash would cause havoc.

Would I be able to use a photo reflector on the gears (as shown) if I accurately placed it to count each spoke on the gear itself? I'm a bit hesitant though because even a small bump could misalign the sensor - again causing havoc.

So does any one have an idea on how to track the wheel movements?

答:
I put together encoders for this exact chassis.  Rather than reflecting ones, I used slot ones.  I thought I could work off the hole in the white gear, but it turns out the plastic is pretty transparent to IR, so I ended up using some black electical tape (high tech, I know) to make opaque regions on the gear.

After building two encoders, I discovered there's a similar product online: LightBeam OptoInterrupter Module

For my first robot, I’m just using a rough encoder, with 4 counts per wheel revolution.  Here's my description from my blog:

In looking in the chassis, there’s not a lot of room. As a result, I decided I’d use a small transmissive sensor, rather than a reflective sensor.  Both have an IR emitter and an IR photo detector.  For reflective units, they both face the same direction, and the detector measure IR reflected back to the sensor.  For a transmissive or interrupt sensor, the two units are separated by a gap, and the detector picks up IR passing through the gap. So far, so good.

I ended up using Vishay transmissive optical sensors (model TCST1202) I purchased from DigiKey.  I wired them up based on the circuit posted by Aniss1001 in the “Homemade wheel encoder“ thread on the Arduino forum.

I built the circuit on a prototyping breadboard for testing and got a surprise.  The circuit worked fine, but the gear is transparent to IR!  It turns out that nylon and most plastics used for inexpensive gears are pretty transparent to IR.  I first tried creating an opaque section with a black marker, but while that worked on paper, it didn’t adhere well enough to the gear.  I ended up using a piece of black tape.  Once that worked, I cut some small circuit boards down to size and built the encoders, practicing my soldering skills.

I just used hot glue to mount the encoders.  The encoder boards stick up above the chassis base, so I’m using standoffs to raise the plastic plate with the Romeo controller and other devices.  Here’s a picture of one of the encoders before mounting,, and then mounted on the chassis:

Hope this helps!

Title: Sensors for differential drive


问:
ROS + kinect depth data duplication
I am trying to get depth data from a Kinect in a ROS project. It currently looks like this:

To arrive at this, I've done:

```<code>depth_sub = rospy.Subscriber("/camera/depth/image", Image, depth_cb)
...
def depth_cb(data):
    img = bridge.imgmsg_to_cv2(data, "32FC1")
    img = np.array(img, dtype=np.float32)
    img = cv2.normalize(img, img, 0, 1, cv2.NORM_MINMAX)
    cv2.imshow("Depth", img)
    cv2.waitKey(5)
</code>```

I also launch openni.launch from the openni_launch package, which publishes the depth data.

I also get this weird warning from the node (can be seen in the image):
    ComplexWarning: Casting complex values to real discards the imaginary part.

But as I understand it the data type is an array of 32-bit floats. Yet some of the values appear as nan.

I would like a depth image that directly corresponds to a RGB image array of the same size. I will be doing some tracking in the RGB space, and using the tracked coordinates (X,Y) from that to index into the depth array. Thanks.

edit:
Turns out, /camera/depth/image is published as an array of uint8s, but the actual data is 32bit floats (which is not listed anywhere, had to hunt it down in other people's code). Thus an array of 480x640 uint8s, interpreted as 32bit floats, in effectively "quartered" in the number of data points. Which could explain how the image is 4 times smaller (and hence accessing datapoints out of bounds = nan?), but not why there are two of them.

答:
I hope I am understanding your issue right.

The "complex" error looks like an encoding issue: depth data does not contain any complex numbers. Try removing the CV_32FC1, let it fallback to "passthrough" mode, i.e., it will use whatever the default type is. OpenCV constructs its matrices in a weird way sometimes.

Are you using the Kinect V1 or V2? Neither Kinect has the same resolution on both color and depth camera, so can you tell me a little bit more about what issue you're having when you say "I would like a depth image that directly corresponds to a RGB image array of the same size"?

Title: ROS + kinect depth data duplication


问:
Choosing a proper sampling time for a PID controller
I have a robotic system I'm controlling with Arduino, is there an heuristic way to determine a proper sampling time for my PID controller? Considering I have some other things to compute on my sketch that require time, but of course a good sampling time is crucial.

Basically I have a distance sensor that needs to detect at a constant rate an object that is moving, sometimes slow, sometimes fast. I don't have a good model of my system so I can't actually tell the physical frequency of the system.

答:
In order to properly sample a system you need to be sampling at least as fast as the Nyquist rate, which is twice as fast as the response rate of the system, preferably faster. You can do a lot of math to find out how fast is fast enough (I suggest Ogata), or go with the rule of thumb, 5-10x the system frequency.

Since you are detecting the rate that an object is moving, you need to sample it fast enough to see it move no more than the minimum you care about.

As an example, lets say your maximum rate is 100mm/s, and you want an accuracy of 1mm.

In this case, to see the object move no more than 1mm, you would need to sample at 2 x (max speed / accuracy) = 2 x (100mm/s / 1mm) or 200Hz minimum, and preferably you would be sampling at 500-1000Hz per the rule of thumb.

OwnerDisplayName: Gian Mauro Musso


答:
Regarding the lift mechanism, I suggest you look at the semiconductor wafer-handling robots.  You can see the insides of one version here:  https://www.ifixit.com/Teardown/Hine+Design+Inc.+Automated+Wafer+Handling+Unit+Teardown/1651

In that robot they used a lead screw vertical drive mechanism along with (it looks like) two cylindrical shafts for stability and linearity.  When I've built systems using parallel rails or shafts, it is very difficult to keep them collinear, so we would usually fix both ends of one rail, and only one end of the second rail.  The other end could float over a small range.  That way we would prevent binding due to misalignment issues.

That industry has made vertical lift mechanisms for robots out of everything from pneumatics, to linear motors, to ball screws, and more.  All of their designs require compactness and cleanliness, so some of the designs are very clever.  You can search for patents by companies such as Genmark, PRI Automation, Brooks Automation, Applied Materials, KLA Tencor, Hine Design, and Adept to find good examples.

Title: Comparison of lifting systems

Body:
What kind of systems can be used to make a torso lifting system like the one used by this robot (the black part) :

Rack and pinion

lead screw

scissor lift

can a triple tree help ?

What are the pro and cons of each system ?
How do they ensure stability ?
And finally, is there a way to draw current when lowering instead of drawing current when lifting ?


问:
Mechanical robustness/shock resistance LiPo batteries
How mechanically robust are LiPo batteries? How much force or acceleration can they maximally withstand before failure? What is their (mechanical) shock resistance?

For some electrical components used in robots, such as IMU's, it can be found in datasheets that they can suffer mechanical failure if accelerated or loaded beyond given values. For IMU's, this is typically somewhere between $2000g$ and $10000g$ (where $1g = 9.81 m/s^2$).

I'm wondering if similar values are known for LiPo batteries, since they are known to be vulnerable components. But, is there any quantification known for their claimed vulnerability?

答:
Typically, with LiPo batteries, they don't have a hard case. The hazard comes when the battery internals get dented, which causes the battery to short out internally. LiPo batteries can dump enough current when shorted  to cause a fire and/or explode when shorted.

The deformation that causes a dent in the battery is generally caused by a high local pressure, the same way you might crack the screen of your phone if your car keys press against it in your pocket. Actually, I would bet this is the reason that a lot of cell phones catch fire in people's pants.

So anyways, pressure is force over some area ($P = F/A$). The force may be cause by acceleration or shock, as $F=ma$. In this instance, then, catastrophic damage would depend on how the battery hit more so than the actual shock rating.

That is, if the battery hit on the corner, then the contact area is small, so the pressure is high, so the battery may deform. If the battery hits on its face/back/etc., then the area is large, so the pressure is low, so the battery may not deform. Again, this is how you could drop your phone on its back on the floor and the screen is fine, or you drop it on its corner and the screen cracks.

All of this is to say that I would imagine battery manufacturers would probably not shock rate a LiPo battery because the outside of a typical LiPo cell is so soft that the impact orientation would play a very large role in whether or not  the battery fails.

If you're concerned about battery damage then I would consider packing the battery in a hard shell.


问:
Open source implementations for GPS+IMU sensor fusion?
Are there any Open source implementations of GPS+IMU sensor fusion (loosely coupled; i.e. using GPS module output and 9 degree of freedom IMU sensors)? -- kalman filtering based or otherwise.

I did find some open source implementations of IMU sensor fusion that merge accel/gyro/magneto to provide the raw-pitch-yaw, but haven't found anything that includes GPS data to provide filtered location and speed info.

答:
ROS has a package called robot_localization that can be used to fuse IMU and GPS data. This package implements Extended and Unscented Kalman filter algorithms.
The package can be found here.</p>


问:
Building a controllable "knob"
I am trying to build a semi-analog timer. Something like those old egg timers that you rotate the face of. I want a knob that I can turn that can be read by a microcontroller, and I also want the microcontroller to be able to position the knob. I'd like to implement "stops" by letting the microcontroller push the knob towards certain positions. As it runs down, the knob should turn. This is my first project of this kind; I've built small robots in the past, but it's been many years.

I've considered hacking a servo motor to read its position, but the small hobby servos I've tried are too hard to turn, very noisy, and pick up too much momentum when turned. They don't act like a good knob.

I'm now considering a rotary encoder connected to a motor, but after hunting at several sites (SparkFun, ServoCity, DigiKey, Trossen, and some others), I haven't been able to find anything that seemed appropriate. I'm not certain how to find a motor that's going to have the right kind of low torque.

This seems like it shouldn't be a really uncommon problem. Is there a fairly normal approach to creating a knob that can be adjusted both by the user and a microcontroller?

答:
The industry standard for solving this problem is with moving faders.

They are readily available inexpensive components that do exactly what you ask for, except the being round part.

Title: Building a controllable "knob"


答:
as @Chuck points out, LiPo cell are sensitive to thermal runaway triggered by mechanical rupture or deformation.

An example of a manufactures shock spec can be found here. (They test for a drop onto concrete).

Mechanical failure from impact depends on so many factors that I don't think you will find specifications more specific than the one above.

For pure acceleration (vibration in a rocket launch or a sensor in a centrifuge for instance) they should perform pretty well. The electrolyte is a paste...

Title: Mechanical robustness/shock resistance LiPo batteries

Body:
How mechanically robust are LiPo batteries? How much force or acceleration can they maximally withstand before failure? What is their (mechanical) shock resistance?

For some electrical components used in robots, such as IMU's, it can be found in datasheets that they can suffer mechanical failure if accelerated or loaded beyond given values. For IMU's, this is typically somewhere between $2000g$ and $10000g$ (where $1g = 9.81 m/s^2$).

I'm wondering if similar values are known for LiPo batteries, since they are known to be vulnerable components. But, is there any quantification known for their claimed vulnerability?


问:
Combustion engine controlled with a remote
How can one control a combustion engine using a remote control.
Or how would you make a car controlled using a remote.</p>

答:
I will assume that you going to make everything from scratch.

For computing unit I would recomend to use STM32 microcontroller (use Discovery or Nucleo  board) however if you have never programmed before Arduino would be simple but a bit less powerful.
For testing when transmiter with big range is needless you can use bluetooth module (HC-05) this will allow you to control from your laptop and see all needed feedback.

Depending on mechanical steering system you have choosen you need different solutions but assuming that you going to use Ackermann steering geometry you need one servomotor for controlling stering weels.

In my projects always i've been using electrical engines but according to my general knowledge about combustion engines, you have to control throttle so this give you need for one more servomotor. Encoder on shaft could give good feedback information. If you want know speed of your car you need encoder on at least one wheel

For start this is good idea to build it with full remote control but later if you become more aware of sotware and mechanics you can implement sensors and algorythms for better sterability or some autonomous maneuvers.


答:
Yes. The px4 software for the pixhawk autopilot has an extended kalman filter that uses an accelerometer, a gyroscope, gps, and mag.

A paper describing the a smaller ekf which only estimates attitude can be found on archive.org and code for the full ekf can be found on github with further information on archive.org.

Title: Open source implementations for GPS+IMU sensor fusion?

Body:
Are there any Open source implementations of GPS+IMU sensor fusion (loosely coupled; i.e. using GPS module output and 9 degree of freedom IMU sensors)? -- kalman filtering based or otherwise.

I did find some open source implementations of IMU sensor fusion that merge accel/gyro/magneto to provide the raw-pitch-yaw, but haven't found anything that includes GPS data to provide filtered location and speed info.

ContentLicense: CC BY-SA 4.0


问:
What is $\alpha \sin(\theta) + \beta \frac{d \theta}{d t}$ in the inverted pendulum problem?
I am preparing for an exam in neural networks. As an example for self-organizing maps they showed the inverted pendulum problem where you want to keep the pole vertical:

Now the part which I don't understand:

$$f(\theta) = \alpha \sin(\theta) + \beta \frac{\mathrm{d} \theta}{\mathrm{d} t}$$
  Let $x= \theta$, $y=\frac{\mathrm{d} \theta}{\mathrm{d} t}$, $z=f$.

Solution with SOM:

three-dimensional surface in $(x,y,z)$

adapt two-dimensional SOM to surface

Method of control

For a given $(x,y)$ find neuron $k$ for wich $w_k = [w_{k1}, w_{k2}, w_{k2}, w_{k3}]$

$f(\theta)$ is then $w_{k3}$

I guess we use the SOM to learn the function $f$. However, I would like to understand where $f$ comes from / what it means in this model.

答:
The function $f$ comes from the equation of motion for the inverted pendulum problem (inverted pendulum alone, not including the motion of the wheeled platform). If you consider your figure but ignore the side-to-side motion of the cart, then the equilibrium of moments about the hinge is:

$\sum M = m g l \sin \theta - b\frac{d \theta}{dt} $

Where $m$ is the mass of the black point mass at the tip of the pendulum and $b$ is the linear damping coefficient (due to friction at the hinge).

The sum of moments is equal to the inertial reaction (equivalent of $F = ma$):

$\sum M = m l^2 \frac{d^2 \theta}{dt^2}$

Equating these two leads to the equation of motion for the inverted pendulum:

$\frac{d^2 \theta}{dt^2} = \frac{g}{l} \sin \theta - \frac{b}{m l^2} \frac{d \theta}{dt}$

Substituting $\alpha = \frac{g}{l}$ and $\beta = -\frac{b}{m l^2}$, we then recover the form of the function $f$ in your question:

$\frac{d^2 \theta}{dt^2} = \alpha \sin \theta + \beta \frac{d \theta}{dt}$

(It should again be stressed that this analysis does not include the side-to-side motion of the cart.)


问:
Forward kinematic computing the transformation matrix
I am the moment trying to compute the transformation matrix for robot arm, that is made of 2 joints (serial robot arm), with which I am having some issues. L = 3, L1 = L2 = 2, and q = ($q_1$,$q_2$,$q_3$) = $(0 , \frac{-\Pi}{6},\frac{\Pi}{6})$

Based on this information I have to compute the forward kinematic, and calculate the position of each joint.

Problem here is though, how do I compute the angle around x,y,z.. for the transformation matrix.  Using sin,cos,tan is of course possible, but what do their angle corresponds? which axis do they correspond to?

I tried using @SteveO answer to compute the $P_0^{tool}$ using the method he provided in his answer, but I somehow mess up something, as the value doesn't resemble the answer given in the example..

答:
Start with coordinate systems.  I've drawn one example.

In my analysis, if all $q_i = 0$ then the manipulator would point straight up.  You can choose other coordinate frames to get the same result.  Build your rotation matrices from the coordinate systems you set up.

The rotation matrix from coordinate system $0$ to coordinate system $1$ is
$$_0^1R = \begin{bmatrix}
\cos q_1&-\sin q_1&0\\
\sin q_1&\cos q_1&0\\
0&0&1
\end{bmatrix}
$$

The mapping from coordinate system $1$ to coordinate system $2$ is

$$_1^2R = \begin{bmatrix}
-\sin q_2&-\cos q_2&0\\
\cos q_2&-\sin q_2&0\\
0&0&1
\end{bmatrix}
$$

And the mapping from system $2$ to $3$ is

$$_2^3R = \begin{bmatrix}
\cos q_3&-\sin q_3&0\\
\sin q_3&\cos q_3&0\\
0&0&1
\end{bmatrix}
$$

Notice that all of the joint angles are taken as positive rotations around the $z$ axis.  I'm not sure from your problem statement or drawing if that is your intention.

So to compute the position of point $p$ with respect to the global $0$ coordinate system, apply the vector loop

$$ \vec p = L \vec y_1 + L_1 \vec x_2 + L_3 \vec x_3$$

$\vec y_1$ is the second column from $_0^1R$.  $\vec x_2$ is the first column from $_0^2R$, and $\vec x_3$ is the first column from $_0^3R$.

You compute $_0^2R$ by multiplying $_0^1R _1^2R$, and $_0^3R$ is $_0^2R _2^3R$.


问:
Does C have advantages over C++ in robotics?
I want to build robots, and right now I aim to work with Arduino boards
I know that they are compatible with c and c++, so was wondering which language is better for robotics in general?

I know how to write in java, and the fact that c++ is object oriented makes it look like a better choice for me

does c have any advantages over c++?

答:
As the comments indicate, the answer is really based on what you want to do with the programs you write.  There are a lot of benefits to the object oriented capabilities of C++.  But the inheritance, overloading, etc., does come with a performance penalty.  C++ compilers optimize quite well, and for most tasks you will be fine with that - especially since you already know java.  But if you need to do fast, low-level tasks, you will never beat the efficiency of pure C unless you write assembly code directly.

Do you want to write low-level communication, data acquisition, or control code?  Then choose C.  Do you want to write user applications that run on top of the low-level driver stuff?  Then C++ would be easier for a java programmer.


答:
Most microcontrollers have good C++ compilers now.

Most C idioms can be written in C++.

Templates, function overloading, and structure member functions allow one to write modular, readable code without classes.

Interfacing to other libraries can be done with extern "C".

Much high-level software (image processing, ROS, etc) is written in C++.

If you pick one systems language for robotics work, pick C++.

If you are working close to the metal, you must learn and understand what C++ is doing behind the scenes.

The only advantage C has is that there's lots of legacy code using C, especially OS code, and occasionally there is obscure or old hardware without a C++ compiler.

Title: Does C have advantages over C++ in robotics?

Body:
I want to build robots, and right now I aim to work with Arduino boards
I know that they are compatible with c and c++, so was wondering which language is better for robotics in general?

I know how to write in java, and the fact that c++ is object oriented makes it look like a better choice for me

does c have any advantages over c++?


问:
Camera Calibration fails to run on ROS
I am running ROS Indigo on Ubuntu 14.04. I am doing a mono-camera calibration and trying to follow the camera calibration tutorial on the ROS Wiki.

I give the following command:

rosrun camera_calibration cameracalibrator.py --size 8x6 --square
  0.108 image:=/my_camera/image camera:=/my_camera

I get the following error:

ImportError: numpy.core.multiarray failed to import Traceback (most
  recent call last): File
  "/opt/ros/indigo/lib/camera_calibration/cameracalibrator.py", line 47,
  in  import cv2 ImportError: numpy.core.multiarray failed to
  import

I thought it was to do with updating numpy and did a rosdep update but no difference.

What is a possible way to solve this problem?

UPDATE:
I uninstalled and reinstalled ROS completely from scratch. I still get the same error. Should I have to look somewhere outside ROS?

答:
Did you try updating numpy directly? rosdep does not care about pip packages.</p>

```<code>sudo pip install numpy -U
</code>```

Title: Camera Calibration fails to run on ROS

Body:
Did you try updating numpy directly? rosdep does not care about pip packages.

sudo pip install numpy -U


答:
In your forward kinematics transformation matrix (4x4, incl. also translation, of just 3x3) the orientation of the end-effector is expressed relative to the base (or world) coordinate system.

SteveO described very well how to obtain the 3x3 rotation matrix, similarly you can obtain also the 4x4 transformation matrix

If you have the matrix you have to choose how do you want to express the coordinates. Commonly in robotics euler angles are used, with successive rotations about the axes of a coordinate system. After choosing the Euler angles, you also have to choose which is the succession of the rotation. In robotics in many cases the rotations are successive (intrinsic) rotations.

After choosing hwo do you want to express the orientation you can build up the orientation matrix from your rotations(e.g. X-Y-Z, then you multiply $R_{TCP} = R(\phi_x) * R(\phi_y) * R(\phi_z) $).

The orientation of your TCP expressed in function of your joints is $R_{joints}=R_{joints}(q1, q2, q3)$ or $^3_0R$ in the notation used by SteveO. Both of the matrices express the same orientation but in a different way, so $R_{TCP}=R_{joints}$ the joint angles are known in forward kinematics, so you can calculate the orientation angles. Please note that if you are using Matlab the dcm2angle() function does exactly this.

Title: Forward kinematic computing the transformation matrix

Body:
I am the moment trying to compute the transformation matrix for robot arm, that is made of 2 joints (serial robot arm), with which I am having some issues. L = 3, L1 = L2 = 2, and q = ($q_1$,$q_2$,$q_3$) = $(0 , \frac{-\Pi}{6},\frac{\Pi}{6})$

Based on this information I have to compute the forward kinematic, and calculate the position of each joint.

Problem here is though, how do I compute the angle around x,y,z.. for the transformation matrix.  Using sin,cos,tan is of course possible, but what do their angle corresponds? which axis do they correspond to?

I tried using @SteveO answer to compute the $P_0^{tool}$ using the method he provided in his answer, but I somehow mess up something, as the value doesn't resemble the answer given in the example..


问:
IPhone controlled RC car
I have an R.C car and there is a program in my computer in which I can code the car to perform movements.I would like to have an application with a visual design.Where it shows the cars path.

Is there available software code for this? Saves me lots of time.

答: You'd probably have more success with Android, i.e. NXT Remote Control took me 30 seconds to find.</p>

Title: IPhone controlled RC car


问:
IMU sensor and compensation
Hi I'm using "minImu 9" 9 DOF IMU (gyro, accelerometer and compass) sensor and it gives pitch roll and yaw values with a slope on desktop (no touch, no vibration, steady). Y axis is angle in degree and X axis is time in second. X axis length is 60 seconds. How can fix this?

Pitch

Roll

Yaw

Note1: minIMU code

答:
if you're using a complementary filter, it's likely you have a bias in your gyroscope. take an average of 100 measurements when the imu isn't moving and subtract that from future measurements.

How does removing the average change the behavior of the complimentary filter?

What do the measurements look like before and after the biases have been removed?

Title: IMU sensor and compensation


答:
MEMS gyros all have a problem with drift due to temperature. This can be worked around using several techniques, and higher cost parts generally have some amount of compensation built in. However, in my experience even the most expensive gyros need some individual calibration or sensor fusion techniques to deal with drift.

Taking a look at this sensor package, the 3 axis gyro is not calibrated for temperature, but does include a temperature sensor. This is pretty common in low cost gyros.

As an aside, I would not consider this part an IMU since it does no sensor fusion or calibration between the gyro, temperature sensor, accelerometer and magnetometer. This is reflected in its price.

Anyway, what that means is you will need to come up with a way to deal with the gyro drift yourself.

The best technique is going to depend on your application and budget, but here are some approaches to look at:

Buy a better IMU: Depending on your budget, this may be the simplest solution. Expect to spend between $50-$100.00 for such a device.

Have an operational calibration process: In this case, you would measure the drift rate of each axis every time you knew it was not in motion, keeping it updated in a moving average and apply that as an offset to the measured rate. This is a simple solution if you have a way of knowing that the sensor is not moving and that will happen regularly during operation.

Calibrate the offset for temperature: If you have access to a precision thermal chamber, you can pre-calculate the drift rate vs temperature function and update it on the fly. This works best if combined with an occasional stopped calibration.

Implement a Complementary or Kalman filter to process the data. This is described in the answers to https://stackoverflow.com/questions/1586658/combine-gyroscope-and-accelerometer-data and can be combined with 2 and 3.

Title: IMU sensor and compensation

Body:
Hi I'm using "minImu 9" 9 DOF IMU (gyro, accelerometer and compass) sensor and it gives pitch roll and yaw values with a slope on desktop (no touch, no vibration, steady). Y axis is angle in degree and X axis is time in second. X axis length is 60 seconds. How can fix this?

Pitch

Roll

Yaw

Note1: minIMU code


问:
What is the difference between motion planning and trajectory generation?
What are the major differences between motion planning and trajectory generation in robotics? Can the terms be used interchangeably?</p>

答:
you can referred to this link, it is useful:
http://www.ene.ttu.ee/elektriajamid/oppeinfo/materjal/AAR0040/03_Robotics.pdf</p>


答:
In many contexts these terms can be interchangeable, however they can also refer to specific things. Here's a glossary to help figure that out:

State (rigid body mechanics) - Position and velocity at a given moment in time.

Motion - The change of state at any instant in time of a body (or bodies).

Trajectory - The state of a body or bodies over a period of time.

Path - The position of a body or bodies over a period of time without worrying about velocity or higher order terms.

Planning - Calculating how to compose and sequence a set of primitives in a way that takes a body from an initial state to a final state while respecting a set of constraints (avoiding obstacles or burning minimal fuel for instance).

Generation - Used generically but can often refer to the phase of planning when you know all the variables and are just calculating the trajectory.

So motion planning and trajectory planning are interchanged a lot. Trajectory generation can be a sub-task of motion planning in some contexts.

Title: What is the difference between motion planning and trajectory generation?

Body: What are the major differences between motion planning and trajectory generation in robotics? Can the terms be used interchangeably?</p>


问:
sum_error in PID controller
I'm trying to implement a PID controller by myself and I've a question about the sum_error in I control. Here is a short code based on the PID theory.

```<code>void pid()
{
  error = target - current;

  pTerm = Kp * error;

  sum_error = sum_error + error * deltaT ;
  iTerm = Ki * sum_error;

  dTerm = Kd * (error - last_error) / deltaT;
  last_error = error;

  Term = K*(pTerm + iTerm + dTerm);
}
</code>```

Now, I start my commands:

Phase 1, If at t=0, I set target=1.0, and the controller begins to drive motor to go to the target=1.0,
Phase 2, and then, at t=N, I set target=2.0, and the controller begins to drive motor to go to the target=2.0

My question is, in the beginning of phase 1, the error=1.0, the sum_error=0, and after the phase 1, the sum_error is not zero anymore, it's positive. And in the beginning of phase 2, the error=1.0 (it is also the same with above), but the sum_error is positive. So, the iTerm at t=N is much greater than iTerm at t=0.

It means, the curves between phase 2 and phase 1 are different!!!

But to end-user, the command 1, and the command 2 is almost the same, and it should drive the same effort.

Should I set the sum_error to zero or bound it? Can anyone tell me how to handle the sum_error in typical?

Any comment will be much appreciated!!

Kevin Kuei

答:
I would recommend implementing

anti-windup

an averaging (or other) filter for the derivative term (spanning across 2-3-4 timesteps

Here is a referece implementation from Atmel in C with integrator reset.

EDIT:
Please consider Chucks questions in the comments and his answer, since anti windup prevents unwanted error accumulation only in the case when the system is not able to execute the desired set-point.

Title: sum_error in PID controller


答:
First, please respond to the questions I ask in the comments on your question.

You mention that the device to be controlled is a motor. Bear in mind that rotating power is $P = \tau \omega$, or torque times speed, so you won't get the same response at high speed that you get at low speed because motor torque typically declines with increasing speed.

I'm not sure if this is the cause of your differing responses or not, but I believe it would have a large impact unless you're just using "1.0" and "2.0" as placeholders for some other value, or they are literally 1 and 2 and are very close together percentage-wise in terms of the entire speed band of the motor.

Regarding wind-up, mentioned in 50k4's answer, I wouldn't think it would be an issue unless your process is saturating, which is to say that it shouldn't be an issue unless your motor is hitting some physical limits that would prevent it from responding, like a current limit or something similar. Note however that if you are getting to the point where your response is saturating that you are also likely operating at a point where motor power is limited and thus you are unlikely to get the same response curves no matter what actions you take to tune a standard PID controller.

Ultimately, if I were you, I would evaluate the errors and determine if there is a problem with your error accounting or if you are realizing the physical limitations of a motor. Keep in mind that the entire point of the integral term is to accumulate error - this will speed control response if it is "taking too long". Accumulated error before settling is both normal and desirable as long as the controller output is still able to effect change in the system. Only when the system becomes unresponsive: linear actuators at an end stop; motors at top speed; motor drivers at a current limit; etc., will wind-up become an issue.

I would output integral error, set the motor setpoint to 1.0, then wait until integral error is (effectively) zero, then change the setpoint to 2.0. If the output response is still inconsistent, then you have a problem with the physical limitations of the system (increasing torque required at higher speeds). If you get consistent responses then you are entering "Phase 2" at time "t=N', which is still inside the response time for Phase 1. As the controller is still actively responding it will naturally generate a different response. At that point, consider waiting longer to enter Phase 2 or increasing the gains on your controller to achieve a settled response by time "t=N".

As a final comment, the last line of your code has "Term = k * (error terms)". If you are doing everything else correctly (generally, have your sampling time correct), then you should leave $k=1$, or just use the sum of the PID terms as the controller output.

Title: sum_error in PID controller

Body:
I'm trying to implement a PID controller by myself and I've a question about the sum_error in I control. Here is a short code based on the PID theory.

```<code>void pid()
{
  error = target - current;

  pTerm = Kp * error;

  sum_error = sum_error + error * deltaT ;
  iTerm = Ki * sum_error;

  dTerm = Kd * (error - last_error) / deltaT;
  last_error = error;

  Term = K*(pTerm + iTerm + dTerm);
}
</code>```

Now, I start my commands:

Phase 1, If at t=0, I set target=1.0, and the controller begins to drive motor to go to the target=1.0,
Phase 2, and then, at t=N, I set target=2.0, and the controller begins to drive motor to go to the target=2.0

My question is, in the beginning of phase 1, the error=1.0, the sum_error=0, and after the phase 1, the sum_error is not zero anymore, it's positive. And in the beginning of phase 2, the error=1.0 (it is also the same with above), but the sum_error is positive. So, the iTerm at t=N is much greater than iTerm at t=0.

It means, the curves between phase 2 and phase 1 are different!!!

But to end-user, the command 1, and the command 2 is almost the same, and it should drive the same effort.

Should I set the sum_error to zero or bound it? Can anyone tell me how to handle the sum_error in typical?

Any comment will be much appreciated!!

Kevin Kuei


问:
How do I simulate an assembly line?
I need to simulate a stream of vehicles, such as on an assembly line. Automatons are performing operations on the vehicles when they come within reach.  The automatons do not keep track of the individual vehicles, they simply collect data.

We need to choose a method of matching the data gathered by each automaton with the vehicle it belongs to.  For example, we could guess the identity of a vehicle using its timing when arriving in the operation range (sensors) of an automaton.

I have to check the possible problems we will face, so I would like a little (hopefully simple) video/simulation tool that I could play with.

vehicles could be symbolized has moving black squares

automatons/sensors could be static points or circles.

it should be possible to change the time interval between two vehicles, and their speed, and add some random delays.

What kind of software should I search for, or where should I look?

Should I consider to developing it from scratch?

答:
This is a great question and has come up a couple of times already (see Quadruped Learning Simulator and See Standalone (or capable of being) Robotics Simulator).

In short, the de facto standard simulators for all things robotic are Stage (for 2D) and Gazebo (for 3D). ROS is another option for what you are trying to do. Not only because it is highly compatible with the aforementioned simulators but because it has it's own simple visualization tool called RViz which excels at displaying primitives as you describe.

Title: How do I simulate an assembly line?