问:
Discontinuity in device orientation
Why is there a discontinuity in the quaternion representation of my device orientation?

I'm using a SENtral+PNI RM3100+ST LSM330 to track orientation. I performed the following test:

Place the device in the center of a horizontal rotating plate ("lazy susan").

Pause for a few seconds.

Rotate the plate 360° clockwise.

Pause for a few seconds.

Rotate the plate 360° clockwise again.

I got this output, which appears discontinuous at sample #1288-1289.

Sample #1288 has  (Qx,Qy,Qz,Qw) = (0.5837, 0.8038, 0.0931, 0.0675), but sample #1289 has (Qx,Qy,Qz,Qw) = (0.7079, -0.6969, -0.0807, 0.0818).

Plugging in the formulas on page 32 of this document, this corresponds to a change in orientation from (Heading, Pitch, Roll) = (108°, 0°, 142°) to (Heading, Pitch, Roll) = (-89°, 0°, 83°).

The graph of (Heading, Pitch, Roll) is also not continuous mod 90°.

Does this output make sense? I did not expect a discontinuity in the first plot, since the unit quaternions are a covering space of SO(3). Is there a hardware problem, or am I interpreting the data incorrectly?

Edit: The sensor code is in central.c and main.c. It is read with this Python script.

答: yaw has a range of +/- 180 degrees. There is going to be a discontinuity when you reach that limit. </p>

Title: Discontinuity in device orientation


问:
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?

答:
I'm not familiar with your device, but here are a few tips that might help...

Since the device is using a quaternion to describe an orientation, they must also specify some base coordinate frame against which that rotation applies.

The w term in a quaternion is the cosine of the half-angle of desired rotation around the (x,y,z) vector component. If you don't care about the angle of rotation, then w can be anything (subject to normalization requirements), including 0.

ContentLicense: CC BY-SA 3.0


问:
Real-time camera localisation in known environment
I am young researcher/developer coming from different (non-robotic) background and I did some research on camera localisation and I came to the point, where I can say that I am lost and I would need some of your help.

I have discovered that there is a lot of SLAM algorithms which are used for robots etc. As far as I know they are all in unknown environments. But my situation is different.

My problems and idea at the same time is:

I will be placed in an known room/indoor environment (dimensions would be known)

I would like to use handheld camera

I can use predefined landmarks if they would help. In my case, I can put some " unique stickers" on the walls at predefined positions if that would help in any way for faster localisation.

I would like to get my camera position (with its orientation etc) in realtime(30 Hz or faster).

For beginning I would like to ask which SLAM algorithm is the right one for my situation or where to start. Or do you have any other suggestions how to get real time camera positions inside of the known room/environment. It must be really fast and must allow fast camera movements. Camera would be on person and not on robot.

thank you in advance.

答:
The problem you want to solve is definitely a SLAM problem and not just simply localization (or maybe we can consider it SLAm since the mapping part is not as heavy). The reason for this is that you will need to do some kind of mapping for initialization when you set up the environment. Of course you could set up the environment with markers or known features and carefully position them so that you know the map immediately, but that process is a lot harder than most people imagine.

Based on your question and the comments you've provided in CroCo's answer (which, by the way, is still a decent answer but I would like to expand), I see two paths that you can take which shouldn't be too difficult given all the resources available out there:

Vision-based: Use fiduciary markers (QR codes or typical black and white checker patterns like you see on crash-test dummies), then locate these markers using computer vision feature recognition algorithms (OpenCV can do this easily using something like SURF). You can perform the initial mapping by using a graph-based SLAM approach (not real-time, record a bunch of data and crunch it all at once), then do localization only in real-time using a simplified bundle adjustment approach (with just one single image and enough visible features).

LiDAR-based: Rely generally on ICP registration with your reference point cloud (pre-built map) and a fresh scan from the sensor. Note that to do this you need to use a scanner on your stick instead of a camera. It will be almost impossible to build the map with laser scan data and then localize inside it with a camera. I say "almost" because there does exist a body of research that relies on monocular cameras for generating 3D data from 2D images (shape from shading, for example), but that is going to be a much bigger challenge than I suspect you want to tackle.

Another interesting option is to use something like the X-Box Kinect (v1 or v2) so that you can get both 2D camera data and 3D scanning at the same time. With that approach you can then identify features in the camera images but have them linked to 3D coordinates in the scan data. Here is an example of the Kinect being used for indoor SLAM.

Some of the challenges you will encounter will be motion blur and even rolling shutter issues if you are using a fast-moving camera point-of-view. Your problem could be solved simply by considering a new image, identifying the features in that image, and then simple camera 3D reconstruction (again using OpenCV's camera reconstruction tools would be recommended).

I also suggest checking into using ROS, which provides a lot of the components for solving your problem already built and ready for implementation using a variety of different sensors.

Another thing that you haven't mentioned (and is alluded to in CroCo's answer) is that you can use an IMU (integrated accelerometer, gyroscope, and possibly magnetometer) to provide motion estimates of the camera itself. This is not sufficient alone but can make real-time pose estimation much easier (actually, most of us would consider it crucial). With the use of an IMU and camera/scanner data, you can then use an EKF or particle filter as has been suggested.


答:
You are right, the quaternion should be without discontinuities.

It could be a bad implementation of your algorithm, but I believe your discontinuity may come from the magnetometer in your setup. Magnetometers have to be calibrated properly in order to map the magnetic field reading to an orientation. If it is not, it can lead to effects where small changes in the actual orientation of the device lead to large changes in the interpretation of the orientation from the magnetic reading.

Title: Discontinuity in device orientation

Body:
Why is there a discontinuity in the quaternion representation of my device orientation?

I'm using a SENtral+PNI RM3100+ST LSM330 to track orientation. I performed the following test:

Place the device in the center of a horizontal rotating plate ("lazy susan").

Pause for a few seconds.

Rotate the plate 360° clockwise.

Pause for a few seconds.

Rotate the plate 360° clockwise again.

I got this output, which appears discontinuous at sample #1288-1289.

Sample #1288 has  (Qx,Qy,Qz,Qw) = (0.5837, 0.8038, 0.0931, 0.0675), but sample #1289 has (Qx,Qy,Qz,Qw) = (0.7079, -0.6969, -0.0807, 0.0818).

Plugging in the formulas on page 32 of this document, this corresponds to a change in orientation from (Heading, Pitch, Roll) = (108°, 0°, 142°) to (Heading, Pitch, Roll) = (-89°, 0°, 83°).

The graph of (Heading, Pitch, Roll) is also not continuous mod 90°.

Does this output make sense? I did not expect a discontinuity in the first plot, since the unit quaternions are a covering space of SO(3). Is there a hardware problem, or am I interpreting the data incorrectly?

Edit: The sensor code is in central.c and main.c. It is read with this Python script.


问:
Is RobotBASIC outdated?
I found this website http://robotbasic.org/ and it talks about a language used for programming things related to robotics, and I want to make sure whether or not it's worth investing any time or energy into compared to other languages before I just wipe it from my browser bookmarks for good. Nowadays, are there better languages and methods for going about the same things that it talks about?

I mean, the site looks pretty old, like something from the late 90s or pre-2010, plus I never heard of it anywhere except for this site, so I wonder if it's just not relevant any more if it ever was.

答:
In an ideal case always the right tool is used for the right job. In many cases however the best among the accessible/known tools is used.

There has to be a purpose why robotbasic was created, and it might still be the best tool for that specific niche purpose. After taking a short look at the website, this purpose was not to me clearly described. It seems as a general tool for everithing, but for that purpuse it is, to my knowledge, not generally used or known.

I find it a bit confusing that it uses an operating system called RROS, which it not the well known ROS, however the names are very similar.

Title: Is RobotBASIC outdated?


答:
Something's not right, either with your test, your conversion, or with the device itself. If you look at your graph of heading, pitch, and roll, you can see that heading rotates through 360 degrees, which is expected, but roll changes almost 180 degrees in one direction, then 180 degrees back. If your device is loose and rolling around on the turntable then maybe that's correct, but otherwise you've got something else going on.

Can you provide your initialization code? Notice that you can't just power-on this device an use it - from page 16 of the manual:

Note: It is necessary to set the MagRate, AccelRate, AND GyroRate registers to non-zero values for the SENtral algorithm to function properly and to obtain reliable orientation and scaled sensor data. If a [Sensor]Rate register is left as 0x00 after power-up, or is changed to 0x00, this effectively disablesthat sensor within the SENtral algorithm. Also, the CalStatus, MagTransient, and AlgorithmSlow bits become undefined.

Are you getting any errors? Page 17, step (d) states you are to read the event register and then process the bits in the priority order specified in Figure 4-3 (at the top of that page), which means you are to check and act on an error bit before checking the sensor data available bits.

Finally, Can you provide your sensor read code? Your sample data with the discontinuity shows values in the range of -1 to 1, but Page 19 clearly states that Full Scale Output for the quaternions are 0-1, or $\pm \pi$. All of your data appears to be bounded at +1 on the high end, which makes me believe that you are not operating at the $\pm \pi$ band, so maybe you are reconstructing the bytes incorrectly upon receipt.

Title: Discontinuity in device orientation


问:
Developing a Quadrotor using ROS
I
 suppose who know ROS and how it works (at least most of you)
I have some question regarding the implementation of a quadrotor in that
 framework.

3D movements: A quadrotor has 6DOF and moves in a 3D
environment. Looking at the various ROS packages I could not find any
package that allows to drive a "robot" in the 3D space. The package
/move_base for instance allows only 2D. Make sense to use this
package for such a project? I thought to use 2D navigation projecting
the "shadow" of a quadrotor on the ground...

MoveIt: it seems a real interesting and promising package, but I
read that it is for robotic arms and not expressly indicate for
quadrotor. Maybe one can use the possibility to create a virtual
floating joints in MoveIt to let the quadrotor any movement in a 3D
environment...that's ok, but I cannot understand whether is "too much"
and not useful for a flying robot.

Trajectories: The possibility to create a 3D trajectory in the
space seems to be not a standard package of ROS. I found Octomap
which allows the creation of 3D maps from sensor datas. Very interesting
and for sure very useful. But...I don't think it could be useful for
creating 3D trajectories.  Should I in that case create an extra package
to compute 3D trajectories to be feed into the quadrotor? Or there
already something like that?

There is already an existing project hector_quadrotor which seems to
acclaim a good success ans it is very considered in the field. Most
people refer to that project when speaking or answering question
regarding quadrotors in ROS. I saw many times that project...since
weeks. And due to the total lack of documentation I didn't try anymore
to understand how it works. Really too difficult.
Another interesting project, ArDrone, has comments in the source
code...in Russian!!! @_@

Could you me give any good suggestions? Or point me in the right direction
please?
It would help me to understand how to focus my searches and which
package I can/cannot use.

UPDATE: my goal is to let the quadrotor flying and using gmapping to localize itself. I've heard and read al lot of stuff about that but I found all this tutorials very hard to understand. I cannot get a global vision of the software and sometime I run in problems like: "is there a package for this task, or should I invent it from scratch?"

Thanks!

答: To control the UAV Quadrotor, you can use MAVROS y you have any autopilot which support MAVLink protocol (i.e AR. parrot, navio+, etc). I'm working to control the uav in a simulatior in mavproxy and now I can takeoff, arming, change mode and move it, the issue I found is rotation on yaw angle. I hope this help you.</p>

Title: Developing a Quadrotor using ROS


问:
Finding cubic polynomial equation for 3 joints
My professor gave us an assignment in which we have to find the cubic equation for a 3-DOF manipulator. The end effector is resting at A(1.5,1.5,1) and moves and stops at B(1,1,2) in 10 seconds. How would I go about this? Would I use the Jacobian matrix or would I use path planning and the coefficient matrix to solve my problem. I'm assuming coefficient matrix but I am not given the original position in angle form. I was only taught how to use path planing when the original angles are given.</p>

答:
I guess you want to find a cubic polynomial for the end effector. You have 3 coordinates for your points A and B, from your question is not clear if they are $x,y,z$ or $x,y,\theta$. Anyway, I'll show here the procedure for $x$, and you can repeat it for the other two coordinates.

Given the cubic parametric form $x = a_0+a_1 t + a_2 t^2 + a_3 t^3$ ($*$), you want to find the parameters $a_i$.

At $t=0$ you know that $x = 1.5$, so from ($*$) $a_0 = 1.5$.

At $t=10$ you know that $x = 1$, so from ($*$) $a_0+10a_1 + 100a_2 + 1000a_3 = 1$.

Let's differentiate the polynomial: $\dot{x} = a_1 + 2a_2 t + 3a_3 t^2$ ($**$).

At $t=0$ you know that $\dot{x} = 0$ (rest condition), so from ($**$) $a_1 = 0$.

At $t=10$ you know that $\dot{x} = 0$ (stop condition), so from ($**$) $a_1 + 20a_2 + 300a_3 = 0$.

So you have:

$a_0 = 1.5$

$a_1 = 0$

$a_0+10a_1 + 100a_2 + 1000a_3 = 1 \Rightarrow 1.5 + 100a_2 + 1000a_3 = 1$

$a_1 + 20a_2 + 300a_3 = 0 \Rightarrow 20a_2 + 300a_3 = 0$

From the last equation you get $a_2 = -15a_3$, substituting in the second last you get $a_3 = 0.001$, and substituting $a_3$ back you get $a_2 = -0.015$.

So you have all the $a_i$ coefficients to replace in $(*)$ and you can get the solution $x(t) = 1.5 - 0.015t^2 + 0.001t^3$. You can do the same for the other 2 coordinates changing the initial and final conditions.


问:
Should I switch my servo system from brushed to brushless motors?
I have a robot that uses brushed motors in its servo system. These are Maxon 3W motors, with 131:1 planetary gearboxes. The motors are controlled by a PIC microcontroller, running a 1kHz PID controller. The servos are for a low speed high torque application. There is significant backlash between the sensor and the motor.

Maxon offer 12W brushless motors which are the same size. These are better in many ways: double the torque, better heat dissipation, higher efficiency.

The problem, obviously, is that they require more complex drive electronics. Also, I have heard a couple of people mention that brushed motors are better for servo applications, though they never explained why.

Has anyone else implemented this kind of system?

Are there any gotchas when using brushed motors for servos?

Is it possible to servo it at low speeds if I only have the 3 integral digital Hall sensors, and no encoder? (I would prefer not to add an encoder because of the money and space cost)

It torque ripple likely to be a problem?

答:
In industry, there is a strong preference for low maintenance brush-less motors over relatively high maintenance brushed motors. While the former may me more expensive in terms of the motor itself and the drive electronics, the reduction in the term long cost of maintenance usually out weighs the extra capital cost.

As user65 suggests, you may need sinusoidal commutation to avoid torque ripple at low speeds, depending on precisely how you design your system and how fine you need your velocity control to be.

The paper A Comparison Study of the Commutation Methods for ... has some interesting information commutation methods, which might be of use.

Ultimately though, I think that avoiding using encoders is a false economy.

Unlike halls, they have the distinct advantage that they aren't tied to the motor rotation - i.e. they don't have to go on the motor shaft. You could place them on the load side of the gearbox, which will allow you to quantify the precise effects of the backlash in your gearbox.

This would allow you to to perform backlash compensation in software, run dual servo loops (one for position tracking with backlash compensation and another for more immediate velocity control) and generally take much more precise control of your system both at high and low speeds.


问:
P gain tuning for quadcopter (Is my perception for a P-gain too high correct?)
Good day,

I am currently working on a project using Complementary filter for Sensor fusion and PID algorithm for motor control. I viewed a lot of videos in youtube as well as consulted various blogs and papers with what to expect with setting the P gain to high or too low.

P Gain too low

easy over correction and easy to turn by hand

P Gain too high

oscillates rapidly

I have a sample video of what I think a high P gain (3 in my case) looks like. Do this look like the P gain is too high?  https://youtu.be/8rBqkcmVS1k

From the video:

I noticed that the quad sometimes corrects its orientation immediately after turning few degrees (4-5 deg). However, it does not do so in a consitent manner.

It also overcorrects.

The reason behind my doubt is because the quadcopter doesn't react immediately to changes. I checked the complementary filter. It updates (fast) the filtered angle reading from sudden angular acceleration from the gyro as well as updates the long term filtered angle changes from the accelerometer (albeit slowly). If I am right, is the the P gain is responsible for compensating the "delay"?

The formula I used in the complementary filter is the following:

```<code>float alpha = 0.98;
float pitchAngleCF=(alpha)*pitchAngleCF+gyroAngleVelocityArray.Pitch*deltaTime)+(1-alpha)*(accelAngleArray.Pitch);
</code>```

Here is a video for a P gain of 1: https://youtu.be/rSBrwULKun4

Your help would be very appreciated :)

答:
:EDIT:

I've edited out most of the content I had previously written because your code does work (except for the mis-matched parenthesis), but it threw me off because this is not really a complimentary filter. You have a hodge-podge here that is confusing to look at initially.

First you have a lag filter on the accelerometer output:

```<code>alpha = 0.98;
filteredAccelerometer = alpha*filteredAccelerometer + (1-alpha)*rawAccelerometer;
</code>```

Then, instead of doing proper numeric integration on the gyro, which would look something like:

```<code>gyroAngle = gyroAngle + gyroAngleVelocityArray.Pitch*deltaTime;
</code>```

You instead are substituting in the filtered accelerometer measurement as the "accumulated" angle:

```<code>gyroAngle = filteredAccelerometer + gyroAngleVelocityArray.Pitch*deltaTime;
</code>```

and you are calling all of this a "complimentary filter", such that:

```<code>pitchAngleCF = alpha*pitchAngleCF + (1-alpha)*angleAccelArray.Pitch + gyroAngleVelocityArray.Pitch*deltaTime;
</code>```

However, this isn't really a complimentary filter because there's "option" or "setting" to blend the gyro and accelerometer outputs. I would suggest converting both sensors to a common unit (degres, for instance), then using the complimentary filter to combine the two measurements, then filter that if you find that anything needs filtering.

So, following your schema:

```<code>accelVelocityArray.Pitch = accelVelocityArray.Pitch + accelAccelArray.Pitch*deltaTime;
accelAngleArray.Pitch = accelAngleArray.Pitch + accelVelocityArray.Pitch*deltaTime;

gyroAngleArray.Pitch = gryoVelocityArray.Pitch*deltaTime;

alpha = 0.95;
pitchCF = alpha*gyroAngleArray.Pitch + (1-alpha)*accelAngleArray.Pitch;
</code>```

THIS is the output of a complimentary filter. Now if you find that your craft is not responsive enough you can increase alpha (take more of the reading from the gyro), or if you find that there is too much drift you can decrease alpha (take more of the reading from the accelerometer). If you find that the reading is too noisy, then you can put this through a lag filter:

```<code>beta = 0.9;
filteredPitch = beta*pitchCF + (1-beta)*filteredPitch;
</code>```

NOW you adjust beta to determine how smooth you want the combined pitch reading to be.

I hope this clarifies things for you.

Now, regarding your actual question, I don't think it's possible to give a quality answer with the (lack of) data you have provided.

It is true that, for a real system with inertia, if you set the proportional gain too high the system will oscillate. However, it is not clear if you are only using a proportional gain (if you have kI and kD set to zero). Also, because the craft is tethered and you are holding it, it's not clear if the craft is responding to its own controller or if it's responding to the external forces (you and the tether).

I'm also not sure how stable your control loop timing is and/or how you are determining what deltaTime should be. If you're interested in manual tuning of a PID controller, first be sure that you are processing your sensor output correctly (see my above comments regarding sensor fusion and filtering), then give the Ziegler-Nichols tuning method a try:

Set kP, kI, and kD to zero.

Increase kP until the system achieves consistent oscillations.

Record kP (as the "ultimate" gain, kU), and the oscillation period.

Set kP, kI, and kD to values based on the ultimate gain and oscillation period.

Body:
:EDIT:

I've edited out most of the content I had previously written because your code does work (except for the mis-matched parenthesis), but it threw me off because this is not really a complimentary filter. You have a hodge-podge here that is confusing to look at initially.

First you have a lag filter on the accelerometer output:

alpha = 0.98;
filteredAccelerometer = alpha*filteredAccelerometer + (1-alpha)*rawAccelerometer;

Then, instead of doing proper numeric integration on the gyro, which would look something like:

gyroAngle = gyroAngle + gyroAngleVelocityArray.Pitch*deltaTime;

You instead are substituting in the filtered accelerometer measurement as the "accumulated" angle:

gyroAngle = filteredAccelerometer + gyroAngleVelocityArray.Pitch*deltaTime;

and you are calling all of this a "complimentary filter", such that:

pitchAngleCF = alpha*pitchAngleCF + (1-alpha)*angleAccelArray.Pitch + gyroAngleVelocityArray.Pitch*deltaTime;

However, this isn't really a complimentary filter because there's "option" or "setting" to blend the gyro and accelerometer outputs. I would suggest converting both sensors to a common unit (degres, for instance), then using the complimentary filter to combine the two measurements, then filter that if you find that anything needs filtering.

So, following your schema:

accelVelocityArray.Pitch = accelVelocityArray.Pitch + accelAccelArray.Pitch*deltaTime;
accelAngleArray.Pitch = accelAngleArray.Pitch + accelVelocityArray.Pitch*deltaTime;

gyroAngleArray.Pitch = gryoVelocityArray.Pitch*deltaTime;

alpha = 0.95;
pitchCF = alpha*gyroAngleArray.Pitch + (1-alpha)*accelAngleArray.Pitch;

THIS is the output of a complimentary filter. Now if you find that your craft is not responsive enough you can increase alpha (take more of the reading from the gyro), or if you find that there is too much drift you can decrease alpha (take more of the reading from the accelerometer). If you find that the reading is too noisy, then you can put this through a lag filter:

beta = 0.9;
filteredPitch = beta*pitchCF + (1-beta)*filteredPitch;

NOW you adjust beta to determine how smooth you want the combined pitch reading to be.

I hope this clarifies things for you.

Now, regarding your actual question, I don't think it's possible to give a quality answer with the (lack of) data you have provided.

It is true that, for a real system with inertia, if you set the proportional gain too high the system will oscillate. However, it is not clear if you are only using a proportional gain (if you have kI and kD set to zero). Also, because the craft is tethered and you are holding it, it's not clear if the craft is responding to its own controller or if it's responding to the external forces (you and the tether).

I'm also not sure how stable your control loop timing is and/or how you are determining what deltaTime should be. If you're interested in manual tuning of a PID controller, first be sure that you are processing your sensor output correctly (see my above comments regarding sensor fusion and filtering), then give the Ziegler-Nichols tuning method a try:

Set kP, kI, and kD to zero.

Increase kP until the system achieves consistent oscillations.

Record kP (as the "ultimate" gain, kU), and the oscillation period.

Set kP, kI, and kD to values based on the ultimate gain and oscillation period.


问:
Calculating required torques for a given trajectory using Lagrange-Euler
I have a 2DOF robot with 2 revolute joints, as shown in the diagram below. I'm trying to calculate (using MATLAB) the torque required to move it but my answers don't match up with what I'm expecting.

Denavit-Hartenberg parameters:
$$
\begin{array}{c|cccc}
joint & a & \alpha & d & \theta \\
\hline
1 & 0 & \pi/2 & 0 & \theta_1 \\
2 & 1 & 0 & 0 & \theta_2 \\
\end{array}
$$

I'm trying to calculate the torques required to produce a given acceleration, using the Euler-Lagrange techniques as described on pages 5/6 in this paper.
Particularly,
$$ T_i(inertial) = \sum_{j=0}^nD_{ij}\ddot q_i$$
where
$$ D_{ij} = \sum_{p=max(i,j)}^n Trace(U_{pj}J_pU_{pi}^T) $$
and
$$
J_i = \begin{bmatrix}
{(-I_{xx}+I_{yy}+I_{zz}) \over 2} & I_{xy} & I_{xz} & m_i\bar x_i \\
I_{xy} & {(I_{xx}-I_{yy}+I_{zz}) \over 2} & I_{yz} & m_i\bar y_i \\
I_{xz} & I_{yz} & {(I_{xx}+I_{yy}-I_{zz}) \over 2} & m_i\bar z_i \\
 m_i\bar x_i & m_i\bar y_i & m_i\bar z_i & m_i \end{bmatrix}
$$

As I was having trouble I've tried to create the simplest example that I'm still getting wrong. For this I'm attempting to calculate the inertial torque required to accelerate $\theta_1$ at a constant 1 ${rad\over s^2}$. As $\theta_2$ is constant at 0, I believe this should remove any gyroscopic/Coriolis forces. I've made link 1 weightless so its pseudo-inertia matrix is 0. I've calculated my pseudo-inertia matrix for link 2:
$$
I_{xx} = {mr^2 \over 2} = 0.0025\\ I_{yy} = I_{zz} = {ml^2 \over 3} = 2/3
$$
$$
J_2 =\begin{bmatrix}
1.3308 & 0 & 0 & -1 \\
0 & 0.0025 & 0 & 0 \\
0 & 0 & 0.0025 & 0 \\
-1 & 0 & 0 & 2 \\
\end{bmatrix}
$$

My expected torque for joint 1:
$$
T_1 = I\ddot \omega \\
T_1 = {ml^2 \over 3} \times \ddot \omega \\
T_1 = {2\times1\over3}\times1 \\
T_1= {2\over3}Nm
$$

The torque calculated by my code for joint 1:

```<code>q = [0 0];
qdd = [1 0];
T = calcT(q);
calc_inertial_torque(1, T, J, qdd)
</code>```

$$
T_1={4\over3}Nm
$$

So this is my problem, my code $T_1$ doesn't match up with my simple mechanics $T_1$.

The key functions called are shown below.

```<code>function inertial_torque_n = calc_inertial_torque(n, T, J, qdd)
    inertial_torque_n = 0;
    for j = 1:2
        Mnj = 0;
        joint_accel = qdd(j);
        for i = 1:2
            Uij = calcUij(T, i, j);
            Ji = J(:,:,i);
            Uin = calcUij(T, i, n);
            Mnj = Mnj + trace(Uin*Ji*transpose(Uij));
        end
        inertial_torque_n = inertial_torque_n + Mnj * joint_accel;
    end
end

function U=calcUij(T,i,j)
    T(:,:,j) = derivative(T(:,:,j));

    U = eye(4,4);
    for x = 1:i
        U = U*T(:,:,x);
    end
end

function T = derivative(T)
    dt_by_dtheta = [0 -1  0  0
                    1  0  0  0
                    0  0  0  0
                    0  0  0  0];

    T = dt_by_dtheta*T;
end
</code>```

I realise this is a fairly simple robot, and a complicated process - but I'm hoping to scale it up to more DOF once I'm happy it works.

答:
You don't have axes shown, so the math is a little hard to follow, but based on the bottom row of $ J_2$ it looks like y is along the length of link 2. If this is the case, then I would expect rotation and x and z to have the same moment of inertia, because each would be rotating the cylinder about the end instead about its longitudinal axis.

This means that Ixx and Izz should cancel where their signs are different, as in J11 and J33, leaving only Iyy/2, but instead of that I see zeros as the entries there. As this is (a model of) a real link,  Iyy must be something; I would assume $ mr^2/2$, or 0.0025. This should be in J11 and J33. I haven't checked your math on J22, but given that Iyy doesn't cancel out there and you end give a very "round" 2/3 as an answer I suspect it is incorrect as well.

Check your math on your J2 matrix and/or provide drawings of link 2 with a set of datums (dati?) (side note: the plural of datum is data, but I think it would be confusing to ask for "drawings with a set of data" when I mean graphical reference points, so I'll leave it as datums) I think this is where your problem lies.


问:
Color sensor alternatives
I am making a white line follower. I am using an IR sensor module based on TCRT5000. I am directly taking the 8bit ADC reading from Arduino Uno and printing the values on serial monitor. I observe that the values for white are around 25-35, which is ok. The problem arises when I try detecting an Orange (158C) surface. The sensor gives me values very close to that of white which is around 25-40.

I can use a color sensor but they are bulky and I am not sure how I can get readings faster with them since they take a finite time for sampling 'R','G' and 'B' pulses. Can someone please tell me an alternate approach to detecting the colours or any other possible solution to my problem.

EDIT: I would like to add that the line I wish to follow is 3cm in width. Hence I plan to use three sensors. Two just outside the line on either sides and one exactly at the centre. The sampling frequency of Arduino UNO is around 125KHz. Sampling IR is not an issue because it is quick but using a color sensor takes a lot of time.

答:
With computer-based vision, the solution often depends greatly on the environment in which the camera is operating.  You may have situations where bright light and shadows result in a very difficult sensing scenario.  Or you may have aspects of your targets which affect the light characteristics (diffusing, polarizing, etc.).  So the solution may not be easy to determine without knowing more about the environment.

For the issue you describe, I would first be certain of your measurements.  It doesn't make sense that some of your sensed values for orange are higher than you are getting for white - unless there is an additional difference besides the color difference.  Also, verify that orange is the only surface that gives you readings that come close to the white readings - ideally you would want the very lowest reading for white to be more than the very highest reading for any other color, plus a margin for error (such as measurement noise).

If you find that orange is indeed the only color that interferes with detection of white, you can use an optical filter that absorbs the orange spectrum but passes the other optical frequencies.  You can find them at Edmund Scientific, Kodak, Schott, and the like.  You can also find optical filters at many camera stores.

If you also find that there are other factors in play (I'm thinking about why the orange reading is higher than some of the white readings), you might be able to apply polarizers to defeat some of the specular returns from orange.  This would need to be designed carefully, since there are many types of polarizers that could be applied, depending on the reflected light characteristics.

Title: Color sensor alternatives


问:
Visual servoing - tracking a point
I am trying resolve some issues i am having with some inverse kinematics.

the robot arm i am using has a camera at the end of it, at which an object is being tracked. I can from the the camera frame retrieve a position, relative to that that frame but how do i convert that position in that frame, to an robot state, that set all the joint in a manner that  the camera keep the object at the center of the frame?...

-- My approach --

From my image analysis i retrieve a position of where the object i am tracking is positioned => (x,y) - coordinate.

I know at all the time the position (a) of the end tool by the T_base^tool - matrix, and from the image analysis i know the position (b) of the object relative to the camera frame for which i compute the difference as such c = b - a.

I then compute the image jacobian, given the C, the distance to the object and the focal length of the camera.

So... thats where i am at the moment.. I am not sure whether the position change retrieved from the cam frame will be seen as position of the tool point, at which  the equation will become un undetermined as the length of the state vector would become 7 instead of 6.

The equation that i have must be
$$J_{image}(q)dq = dp$$

J_image(q)[2x6]: being the image jacobian of the robot at current
state q

dq[6x1]: wanted change in q-state

dp[2x1]: computed positional change...

Solution would be found using linear least square..
but what i don't get is why the robot itself is not appearing the equation, which let me doubt my approach..

答:
For a 6 degree of freedom manipulator there are an infinite number of (positions + orientations) which will keep a point object centered in the frame.

When you determine the position of the object relative to the camera frame, is it allowable to ignore orientation changes and move the camera (keeping its current orientation) to track the object?  Or alternately, could you keep the origin of the camera frame constant and use rotations only to track the object?  You could do either of these given the object location relative to the camera frame through the inverse kinematics computations.

You may consider including in your image analysis algorithm the computation of the object's position AND orientation relative to the camera frame.  Then you will have a countable number of possible inverse kinematic solutions.

Once you determine which method (above) you are going to use, the inverse kinematics can be position-based, or velocity-based.  For small relative motions like I think you're describing, I would use velocity control to keep the object centered.  This involves computing the Jacobian matrix, and using it to set joint speeds to move the camera in the desired direction.  The concept is simple: it is a mapping of $$\dot{ \vec x} = J \dot{ \vec q}$$
where $\vec q$ is your vector of joint angles, and $\vec x$ is your vector of Cartesian positions and orientations.   However, the terms in $J$ can be rather complicated.

So your solution, using velocity control, requires you to determine the desired change in camera position/orientation, which is then applied to the equation above to compute the required changes in joint position.

Title: Visual servoing - tracking a point


问:
How to tell a stepper motor's position, or detect slippage
I am creating a CNC machine on a budget, using old motors out of printers/scanners/etc.

I am limited to about 650mA for the whole system, so my fear is that when the cutting bit touches the material, the stepper might be moving too quickly and won't have enough torque.  This would mean it will become one rotation behind, which could really mess up a CNC project.

Detecting when the motor "misses" a step would allow me to readjust the motor speed until it reaches a balance between working quickly and having adequate torque.  How can I achieve this?

答:
The ONLY difference between a stepper and a servo is that a Servo monitors its position with an encoder, and may increase power if it gets behind, or reduce power if it gets ahead, or generates a 'fault' condition if it is unable to move to the proper position in a predetermined time frame.

There is no difference in power requirements. Any stepper can be a servo by the addition of encoders and closed loop electronics. Any Servo can be a stepper by bypassing the closed loop.

As long as power requirements are planned, a less expensive stepper is a good choice, like moving a print head on a rail. Servo's are more appropriate when there may be some unknown power requirement, like on a CNC cutting machine.


问:
Filtering angular velocity spikes of a cheap Gyroscope
I would like to filter angular velocity data from a "cheap" gyroscope (60$). These values are used as an input of a nonlinear controller in a quadcopter application. I am not interested in removing the bias from the readings.

Edit:
I'm using a
 l2g4200d gyroscope connected via i2c with an Arduino uno. The following samples are acquired with the arduino, sent via serial and plotted using matlab.

When the sensor is steady, the plot shows several undesired spikes.

How can I filter these spikes?

1st approach: Spikes are attenuated but still present...

Let's consider the following samples in which a couple of fast rotations are performed. Let's assume that the frequency components of the "fast movement" are the ones I will deal with in the final application.

Below, the discrete Fourier transform of the signal in a normalized frequency scale and the second order ButterWorth low pass filter.

With this filter, the main components of the signal are preserved.

Although the undesired spikes are attenuated by a factor of three the plot shows a slight phase shift...

And the spikes are still present. How can I improve this result?
Thanks.

EDIT 2:

1./2. I am using a breakout board from Sparkfun. You can find the circuit with the Arduino and the gyro in this post: Can you roll with a L3G4200D gyroscope, Arduino and Matlab?
    I have added pullup resistors to the circuit. I would exclude this option because other sensors are connected via the i2c interface and they are working correctly.
    I haven't any decoupling capacitors installed near the integrated circuit of the gyro. The breakout board I'm using has them (0.1 uF). Please check the left side of the schematic below, maybe I am wrong.

Motors have a separate circuit and I have soldered all the components on a protoboard.

The gyro is in the quadcopter body but during the test the motors were turned off.

That is interesting. The sampling frequency used in the test was 200Hz.  Increasing the update freq from 200 to 400 hz doubled the glitching.

I found other comments on the web about the same breakout board and topic. Open the comments at the bottom of the page and Ctrl-F virtual1

答:
One of the options is to utilize  the exponential moving average. The below picture shows data corrupted by Gaussian noise with zero mean and 0.4 variance and how the filter does a good job to remove the spiky noisy data.

```<code>x = -pi:0.01:2*pi;
perfectY = cos(x); % generate data
noisyY = perfectY + .4 * randn(1, length(perfectY)); % corrupt data by noise

a = 0.13; % tuning parameter
preSmoothY = cos(-pi); % arbitrary initial value

for i = 1:length(noisyY)
    Smooth = (1-a)*preSmoothY + a*noisyY(i);
    preSmoothY = Smooth;
    expY(i) = Smooth;
end

plot( x,noisyY,'g', x, expY,'r', 'LineWidth', 2)
hold on
plot(x, perfectY, 'b','LineWidth', 2)
grid on
legend('noisy  data', 'filtered  data', 'data')
</code>```

Another choice is using Kalman filter. It is an optimal filter if you meet the requirements which means no filter can perform better than the Kalman. Unfortunately, the filter imposes some constraints on the signal such as linearity and Gaussianity. Moreover, the system must be described precisely.

Body:
One of the options is to utilize  the exponential moving average. The below picture shows data corrupted by Gaussian noise with zero mean and 0.4 variance and how the filter does a good job to remove the spiky noisy data.

x = -pi:0.01:2*pi;
perfectY = cos(x); % generate data
noisyY = perfectY + .4 * randn(1, length(perfectY)); % corrupt data by noise

a = 0.13; % tuning parameter
preSmoothY = cos(-pi); % arbitrary initial value

for i = 1:length(noisyY)
    Smooth = (1-a)*preSmoothY + a*noisyY(i);
    preSmoothY = Smooth;
    expY(i) = Smooth;
end

plot( x,noisyY,'g', x, expY,'r', 'LineWidth', 2)
hold on
plot(x, perfectY, 'b','LineWidth', 2)
grid on
legend('noisy  data', 'filtered  data', 'data')

Another choice is using Kalman filter. It is an optimal filter if you meet the requirements which means no filter can perform better than the Kalman. Unfortunately, the filter imposes some constraints on the signal such as linearity and Gaussianity. Moreover, the system must be described precisely.


问:
Robotic Manipulator
I have started working on robotic manipulators and got into a project which deals with control of robotic manipulator using artificial neural networks (solution of inverse kinematics and trajectory generation, to be precise!).
Can someone please suggest me where to start as I have no prior knowledge about robotic manipulator and ANN and how to code them?</p>

答:
If you have no prior experience in robotics, I would recommend one well known book, Craig - Introduction of Robotics: Mechanics and Control. This should explain well the basics of robotic manipulators.

For artificial intelligence (AI), I would recommend Russel, Norvig - Artificial Intelligence, a Modern Approach, although ANNs are not the central topic of the book, it is a very good and well known book on AI in general. It is always good to know what AI is about an what are the problem categories that can be solved with AI and what methods are recommended for the problem types.

There are scientific publications dealing explicitly with ANN for Inverse Kinematics,  e.g. this one:

Jha, Panchanand, and B. B. Biswal. "A Neural Network Approach for Inverse Kinematic of a SCARA Manipulator." IAES International Journal of Robotics and Automation (IJRA) 3.1 (2014): 52-61.

However trajectory generation is somewhat different in nature. I would recommend reading up generally on AI and machine learning to see which method is best suited for which class of problems.

Title: Robotic Manipulator


问:
Is there a .NET library for conveyor belt automation?
I'm a software developer and I work for a company that I think could use some automation in its warehouse. I thought it would be fun to put together a prototype of a conveyor system that automates a manual sorting process that we do on our warehouses. I'm primarily a .NET developer so I'm wondering if there is an .NET SDK for conveyor automation. </p>

<p>Any other information on where to start would be helpful but is not my main question here. </p>

答:
Software for industrial automation is somewhat different then "general purpose" software.

Your software controlling the conveyor belts will have to interact with the conveyor belts. This is through sensors (probably inductive and/or capacitive proximity sensors, maybe mechanical switches, cameras with image processing etc.). The software you write will most likely be reactive to the information coming from the sensors and will act using actuators (electrical pneumatic or maybe hydraulic motors, which stop the line, move a piece from A to B, etc.)

The trick is to interface your software to hardware. In industrial automation this is normally done with PLC-s. We can very generally define them as the hardware platfrom of automation for running sofware. The programming of these is done in 5 standardized languages. For porgramming PLC-s in .net I would like to redirect you here.

If it is not a serial product, just an experiment, you might want to take a look at DAQ boards, with .net compatibility like this one. The DAQ board will be your interface to phyisical signals and the software will run on a PC in .NET.


问:
Which is model is best for feedback control of robotic manipulators: MIMO or parallel SISO?
I'm currently designing a robotic arm with 6-DOF, and my goal is to be able to give setpoints for 3d position, velocity and orientation ($x,y,z,\dot{x},\dot{y},\dot{z},\theta,\alpha,\gamma$).

I only had feedback-control for SISO systems so far in College, so, taking the learning curve of multivariable control in consideration, should I approach this problem trying to model the system as a MIMO or multiple SISOs?

If possible please mention possible disadvantages and advantages in each strategy.

答:
The set of Parallel SISO controllers is a is a subset of MIMO controllers so MIMO is at least as powerful and possibly more powerful.  As for pros and cons I see no reason to use parallel SISO except that you may be more comfortable for it so it may be easier to get done.

That said the system may be separable by actuator in which case it can pop out as being several SISO problems.  Although control systems is my area I don't work on robots so I can't say if that's the case for your problem.

Another thing that is often done, as georgebrindeiro pointed out, is to break the problem into inner and outer control loops, where the inner loops allow you to ignore much of the


问:
calculating position based on accelerometer data
Please help me with the following task. I have MPU 9150 from which I get acceleration/gyro and magnetometer data. What I'm currently interested in is to get the orientation and position of the robot. I can get the position using quaternions. Its quite stable. Rarely changes when staying still.
But the problem is in converting accelerometer data to calculate the displacement.

As I know its required to to integrate twice the accel. data to get position.
Using quaternion I can rotate the vector of acceleration and then sum it's axises to get velocity then do the same again to get position. But it doesn't work that way. First of all moving the sensor to some position and then moving it back doesn't give me the same position as before. The problem is that after I put the sensor back and it stays without any movement the velocity doesn't change to zero though the acceleration data coming from sensors are zeros.

Here is an example (initially its like this):
the gravity: -0.10  -0.00   1.00

raw accel: -785 -28 8135

accel after scaling to +-g: -0.10   -0.00   0.99

the result after rotating accel vector using quaternion: 0.00   -0.00   -0.00

After moving the sensor and putting it back it's acceleration becomes as:
 0.00   -0.00   -0.01
 0.00   -0.00   -0.01
 0.00   -0.00   -0.00
 0.00   -0.00   -0.01
and so on.
If I'm integrating it then I get slowly increasing position of Z.

But the worst problem is that the velocity doesn't come back to zero

For example if I move sensor once and put it back the velocity will be at:
-0.089 for vx and
0.15 for vy

After several such movements it becomes:
-1.22 for vx
1.08 for vy
-8.63 for vz

and after another such movement:

vx -1.43
vy 1.23
vz -9.7

The x and y doesnt change if sensor is not moving but Z is changing slowly.
Though the quaternion is not changing at all.

What should be the correct way to do that task?

Here is the part of code for integrations:

```<code>vX += wX * speed;
vY += wY * speed;
vZ += wZ * speed;

posX += vX * speed;
posY += vY * speed;
posZ += vZ * speed;
</code>```

Currently set speed to 1 just to test how it works.

EDIT 1: Here is the code to retrieve quaternion and accel data, rotate and compensate gravity and get final accel data.

```<code>        // display initial world-frame acceleration, adjusted to remove gravity
        // and rotated based on known orientation from quaternion
        mpu.dmpGetQuaternion(&q, fifoBuffer);
        mpu.dmpGetAccel(&aaReal, fifoBuffer);
        mpu.dmpGetGravity(&gravity, &q);

        //Serial.print("gravity\t");
        Serial.print(gravity.x);
        Serial.print("\t");
        Serial.print(gravity.y);
        Serial.print("\t");
        Serial.print(gravity.z);
        Serial.print("\t");

        //Serial.print("accell\t");
        Serial.print(aaReal.x);
        Serial.print("\t");
        Serial.print(aaReal.y);
        Serial.print("\t");
        Serial.print(aaReal.z);
        Serial.print("\t");

        float val = 4.0f;
        float ax = val * (float)aaReal.x / 32768.0f;
        float ay = val * (float)aaReal.y / 32768.0f;
        float az = val * (float)aaReal.z / 32768.0f;

        theWorldF.x = ax;
        theWorldF.y = ay;
        theWorldF.z = az;

        //Serial.print("scaled_accel\t");
        Serial.print(ax);
        Serial.print("\t");
        Serial.print(ay);
        Serial.print("\t");
        Serial.print(az);
        Serial.print("\t");

        theWorldF.x -= gravity.x;
        theWorldF.y -= gravity.y;
        theWorldF.z -= gravity.z;

        theWorldF.rotate(&q);
        //gravity.rotate(&q);
        //Serial.print("gravity_compensated_accel\t");
        Serial.print(theWorldF.x);
        Serial.print("\t");
        Serial.print(theWorldF.y);
        Serial.print("\t");
        Serial.print(theWorldF.z);
        Serial.print("\t");
        Serial.print(deltaTime);
        Serial.println();
</code>```

EDIT 2:

dmpGetQuaternion, dmpGetAccel functions are just reading from the FIFO buffer of MPU.

dmpGetGravity is:

```<code>uint8_t MPU6050::dmpGetGravity(VectorFloat *v, Quaternion *q) {
    v -> x = 2 * (q -> x*q -> z - q -> w*q -> y);
    v -> y = 2 * (q -> w*q -> x + q -> y*q -> z);
    v -> z = q -> w*q -> w - q -> x*q -> x - q -> y*q -> y + q -> z*q -> z;
    return 0;
}
</code>```

EDIT 3:
the library for using MPU 9150:
https://github.com/sparkfun/MPU-9150_Breakout

EDIT 4: Another example

gravity vector: -1.00   -0.02   0.02

raw accel data: -8459   -141    125
accel data scaled (+-2g range): -1.03   -0.02   0.02

gravity compensation and rotation of accel data: -0.01  0.00    0.33

答:
You're trying to do numeric integration, which takes the form:

$$
\mbox{integrated value } +=\mbox{derivative} * \mbox{elapsed time}
$$

What you have instead of elapsed time is some value called speed. Try setting up your numeric integration code on an interrupt, where the interrupt timing is what you would use in place of elapsed time.

I'm not sure what method you're using to get from quaternions to the rotated acceleration vector, but I would like to point out that you can't just do numeric integration on quaternions like you can with accelerations or velocities. See page 11 of this document for more detail, but briefly, take your gyroscope angular accelerations $\omega_x \omega_y \omega_z$ and the existing quaternion $q(t)$ and calculate the quaternion derivative:

$$
\dot{q}(t) = \frac{1}{2} \left[ \begin{array}{cccc}
0 & \omega_z & -\omega_y & \omega_x \\
-\omega_z & 0 & \omega_x & \omega_y \\
\omega_y & -\omega_x & 0 & \omega_z \\
-\omega_x & -\omega_y & -\omega_z & 0 \end{array} \right] q(t)
$$

Then you numerically integrate that, such that, for a discrete system,

$$
q_k = q_{k-1} + \dot{q}_k * dT
$$

You do not provide any code on how you're updating your acceleration vector, no code on how you're getting a quaternion, etc., so it's not possible to give you any more specific feedback than this.


答:
I think you took a wrong turn in your approach.

I know at all the time the position (a) of the end tool by the T_base^tool - matrix, and from the image analysis i know the position (b) of the object relative to the camera frame for which i compute the difference as such c = b - a.

You don't care about position (a).  You care about the position in the center of the camera frame, which you can think of as an imaginary end tool.  Let's call it position (i).  Just like your real end tool, this point will always occupy the same spot in the camera frame (which happens to be the center, in this case).

So, given position (b) and position (i), you can compute the distance between the two points.  Your state vector will be 6 points -- replace the data for the "real" tool with the data for the "imaginary" tool in your inverse kinematics equation.

Title: Visual servoing - tracking a point

Body:
I am trying resolve some issues i am having with some inverse kinematics.

the robot arm i am using has a camera at the end of it, at which an object is being tracked. I can from the the camera frame retrieve a position, relative to that that frame but how do i convert that position in that frame, to an robot state, that set all the joint in a manner that  the camera keep the object at the center of the frame?...

-- My approach --

From my image analysis i retrieve a position of where the object i am tracking is positioned => (x,y) - coordinate.

I know at all the time the position (a) of the end tool by the T_base^tool - matrix, and from the image analysis i know the position (b) of the object relative to the camera frame for which i compute the difference as such c = b - a.

I then compute the image jacobian, given the C, the distance to the object and the focal length of the camera.

So... thats where i am at the moment.. I am not sure whether the position change retrieved from the cam frame will be seen as position of the tool point, at which  the equation will become un undetermined as the length of the state vector would become 7 instead of 6.

The equation that i have must be
$$J_{image}(q)dq = dp$$

J_image(q)[2x6]: being the image jacobian of the robot at current
state q

dq[6x1]: wanted change in q-state

dp[2x1]: computed positional change...

Solution would be found using linear least square..
but what i don't get is why the robot itself is not appearing the equation, which let me doubt my approach..


问:
Is there a way to use a stress-ball-like device as acceleration control interface
I am thinking of a project proposal for my robotics course and we are required to make one that has a potential application on physical therapy or medical fields. One thing that came across my mind is a motorized wheelchair that moves when a stress ball control is squeezed by the user. As a robotics novice, I wonder if I could integrate a sensor circuit with a rubber ball so that when it is pressed, perhaps by a stroke patient, it triggers some driver circuit. is this possible? if so, how? My experience with robotics is limited to arduino, servo motors and basic sensors.</p>

答:
You could try to insert a piezo-element into the stress ball, or coat a piezo element with rubber, which can be squeezed by the user.

This element will give a voltage peak on the on- and off ramps of the squeezing. You can find the proper schematics for the electronics online. Now you just need to detect this pulse with a computer system (possibly an arduino) and off you go.

Is this what you mean?

Edit: I am no expert on which element to use, but try to find one with the right output voltage for your detection element. Since they are passive elements, most of them are fairly cheap and robust.


答: Barometers are cheap, easy to use, and very sensitive.  They can be placed inside a sealed rubber ball and detect changes in pressure.  See for example these sensors: www.takktile.com.  (The makers of these sensors encase them in rubber, which you may or may not want to do).</p>

Title: Is there a way to use a stress-ball-like device as acceleration control interface

Body: I am thinking of a project proposal for my robotics course and we are required to make one that has a potential application on physical therapy or medical fields. One thing that came across my mind is a motorized wheelchair that moves when a stress ball control is squeezed by the user. As a robotics novice, I wonder if I could integrate a sensor circuit with a rubber ball so that when it is pressed, perhaps by a stroke patient, it triggers some driver circuit. is this possible? if so, how? My experience with robotics is limited to arduino, servo motors and basic sensors.</p>


问:
4dof or 5dof robot arm with stepper motors tool-chain for an hobbyist
In the past I built some simple robot arms at home, using RC servo motors or stepper motors (till 3dof). I would like to build a new arm with 4dof or 5dof with the steppers. Until now I used Arduino and A4988 stepper drivers and Gcode.
For calculating inverse kinematics in real time for a 4dof or 5dof I think the Arduino is not enough powerful. So I'm searching for a new tool-chain Gcode Interpreter + inverse kinematics calculation + stepper controller.
I see LinuxCNC + beaglebone black + cnc cape. Not too expensive for an hobbyist.
But this is the only possibility I found. There are other possibilities for an hobbyist to implement a 4dof or 5dof robot arm working with the stepper motors?</p>

答:
Yes, I doubt you will be able to do much inverse kinematics on an Arduino.  You will probably want a 32 bit processor that can handle floating point math a little easier.

As JJM pointed out, depending on what you are doing, you might not need IK.  Nevertheless, for a fast IK library, check out ikfast.


问:
How to perform odometry on an arduino for a differential wheeled robot?
I am using a differential wheel robot for my project. I need to know the current coordinates of the robot with respect to it's initial position taken as the origin. I m doing the computation on an Arduino UNO and the only sensory input that I get is from the two encoders. I have the function updateOdomenty() called in the loop() and this is it's corresponding code:

```<code>void updateOdometry()
{

  static int encoderRPosPrev = 0;
  static int encoderLPosPrev = 0;

  float SR = distancePerCount * (encoderRPos - encoderRPosPrev);
  float SL = distancePerCount * (encoderLPos - encoderLPosPrev);

  encoderRPosPrev = encoderRPos;
  encoderLPosPrev = encoderLPos;

  x += SR * cos(theta);
  y += SL * sin(theta);
  theta += (SR - SL) / wheelDistance;

  if(theta > 6.28)
    theta -= 6.28;
  else if(theta < -6.28)
    theta += 6.28;
}
</code>```

This is the code that me and my team mates made after reading this paper. I am wondering if this is the best possible way to solve this problem with an Arduino. If not, how is odometry done in differential wheeled systems?

答:
I would add a few lines after you check that theta is between +/- 2pi:

```<code>meanDistance = (SL + SR)/2;
posX = posX + meanDistance*cos (theta);
posY = posY + meanDistance*sin(theta);
</code>```

This of course assumes theta is positive CCW starting from the +x-axis.  This is similar but not the same as your code for X and Y, but your code appears to put the X origin on the right wheel and Y origin on the left, and I'm not sure why you would do that.

Additionally, your code for theta uses a small angle sine approximation, sin(theta) = theta = dy/dL. You could use a true asin for this instead.

Otherwise, taking my comments above into account, this is how I would do differential-drive dead reckoning. Your next, least-expensive upgrade would be a compass or magnetometer, but that would probably come with a decent IMU, which would be your second upgrade, with GPS being the last. But, as I said, if all you need is dead reckoning, you've basically got it.

Body:
I would add a few lines after you check that theta is between +/- 2pi:

meanDistance = (SL + SR)/2;
posX = posX + meanDistance*cos (theta);
posY = posY + meanDistance*sin(theta);

This of course assumes theta is positive CCW starting from the +x-axis.  This is similar but not the same as your code for X and Y, but your code appears to put the X origin on the right wheel and Y origin on the left, and I'm not sure why you would do that.

Additionally, your code for theta uses a small angle sine approximation, sin(theta) = theta = dy/dL. You could use a true asin for this instead.

Otherwise, taking my comments above into account, this is how I would do differential-drive dead reckoning. Your next, least-expensive upgrade would be a compass or magnetometer, but that would probably come with a decent IMU, which would be your second upgrade, with GPS being the last. But, as I said, if all you need is dead reckoning, you've basically got it.


问:
How to use an IMU to hover at a fixed location in a quadcopter in the presence of gravity?
There's an accelerometer in the IMU. The output can then be integrated to estimate the position, at least in theory.

But in practice, there's a huge acceleration from gravity, which varies rather randomly across locations. Vibrations etc can be filtered out with low-pass filters, but how do you filter out gravity? Is it simply the case that the vertical vector is ignored when doing any calculations?

My application is, I want to build a quadcopter that could hover in one place even in the presence of (reasonable) winds: the quadcopter ideally would tilt towards random gusts to maintain a certain position. Every single tutorial I could find on the Internet only uses the accelerometer to estimate where down is when stationary, and simply assumes that using the gyroscope to hold the quadcopter level is enough.

I also want to use the IMU to estimate altitude if possible, of course as an input to something like a Kalman filter in conjunction with a sonar system.

Obviously, for my application GPS is far too slow.

答: To "filter" out gravity is not necessarily the correct terminology. The accelerometer measures all forces acting on it, so when it is stationary the only force is gravity. However, because the accelerometer may not be level, the gravity force might not be directly on the Z-axis (assuming Z axis is representing the vertical). Usually a gyroscope is used along with the accelerometer to level the acceleromter, this way the gravity force can be directly subtracted from the accelerometer readings. </p>


答:
You could use the Arduino for the input/output to your motors and sensors, but do the actual calculation on a raspberry pi. They can communicate trough the I2C bus.

For the raspberry pi this I2C bus is implementend on the gpio pins. How to communicate trough this bus from the os i do not know (I haven't tried) but I am sure that others have, so you should be able to find resources for that. This will give you the extra computer power you need to do your IK calculations.

Or do you really want to keep your calculations on your arduino?

Title: 4dof or 5dof robot arm with stepper motors tool-chain for an hobbyist

Body:
In the past I built some simple robot arms at home, using RC servo motors or stepper motors (till 3dof). I would like to build a new arm with 4dof or 5dof with the steppers. Until now I used Arduino and A4988 stepper drivers and Gcode.
For calculating inverse kinematics in real time for a 4dof or 5dof I think the Arduino is not enough powerful. So I'm searching for a new tool-chain Gcode Interpreter + inverse kinematics calculation + stepper controller.
I see LinuxCNC + beaglebone black + cnc cape. Not too expensive for an hobbyist.
But this is the only possibility I found. There are other possibilities for an hobbyist to implement a 4dof or 5dof robot arm working with the stepper motors?</p>


问:
What exactly are PPM controlled ESCs? Are most ESCs available to build quadcopters PPM Controlled?
First, I don't see any manufacturer or online store telling whether an ESC is PPM controlled or not. Second, I have also been Googling and asking comments in all about ESCs youtube videos for long, but I couldn't find anything useful.

Why do I need PPM controlled ESCs?

I'm doing a project based on AndroCopter and its clearly mentioned that it specifically requires the use of PPM controlled ESCs.

Can I use any ESCs available in the market for this project?

It's also mentioned in the Github repo that PPM controlled ESCs are the most common ones. However from some who explained ESCs in Youtube video has commented back for my doubt telling that most common ESCs are PWM controlled which is contradicting the previous statement.

PS: I need to use Arduino Mega to control the four ESCs. And Arduino Mega is programmed to send out PPM signals which is exactly why I need PPM controlled ESCs. Correct me if I made any mistakes.

答:
I'm not an expert re: PPM communications but, from what I can tell, PPM signals contain pulses which are interpreted by the receiving microprocessor (or speed controller) as position commands.  If the pulse is the smallest acceptable width, then the position of the servo will be commanded to go completely to one side; if the pulse is the largest acceptable width, then the position of the servo will be commanded to go completely to the other side.  The PPM pulse is essentially a position setpoint, and the control of the power to achieve this position is up to the device that receives this signal.

On the other hand, a PWM signal will often directly regulate the amount of power that is transmitted to the motor.  Consider the per cent that the PWM is ON - if it is ON 100% of the time, the motor will receive the highest possible amount of power.  If the PWM signal is on at a 50% duty cycle, the motor will receive 50% of the available power.

Essentially a PWM signal is part of a lower-level control loop, as compared to the PPM signal.  With the PPM signal, the speed controller takes care of the lower loops for you.


答:
I've never seen MIMO used in this context before, but I can see how SISO might apply.

Most robotic systems I've seen have been aggregation's of single axis motor controllers (your multiple SISO) each of which only had a single encoder for sensing and a single motor for actuation. So each axis was SISO, but the robot as a whole was MIMO.

Some systems I have worked on had significant backlash between motor/rotary encoder and load/linear encoder, so implemented a dual feedback loops, with one motor control output, but two encoders. The rotary encoder on the motor was primarily used to track velocity accurately, while the linear encoder on the load was used to compensate for backlash in the (worm) gear and provide accurate position information and tracking.

I believe that for most control systems, these traditional control methods are the most you will ever need, however there are exceptions.

I have only seen one system which might have benefited from a truly MIMO control system and that was one with similar characteristics to your own, but also needed to control the force applied by the tool-point of the robot. We did implement this with a traditional multiple SISO approach, but it required exceptionally careful tuning, and I'm not convinced that trying to use some form of computed torque technique would have been any easier anyway.

I would suggest that you start off with a multiple SISO approach and if that fails to give you the performance or characteristics you require, research into more advanced methods. At the very least you will have learn a lot more about the kinematics and dynamics of your system by that point.

Title: Which is model is best for feedback control of robotic manipulators: MIMO or parallel SISO?

Body:
I'm currently designing a robotic arm with 6-DOF, and my goal is to be able to give setpoints for 3d position, velocity and orientation ($x,y,z,\dot{x},\dot{y},\dot{z},\theta,\alpha,\gamma$).

I only had feedback-control for SISO systems so far in College, so, taking the learning curve of multivariable control in consideration, should I approach this problem trying to model the system as a MIMO or multiple SISOs?

If possible please mention possible disadvantages and advantages in each strategy.


问:
inverse kinematics osciliations..
I am the moment having some issues with an Jacobian going towards a singularity (i think)as some of its values becomes close to zero, and my robot oscillates, and therefore thought that some form of optimization of the linear least square solution is needed.

I have heard about the interior point method, but I am not sure on how i can apply it here.

My equation is as this..

J(q)dq = du

How would i have to implement the optimization, and would be needed?

答:
As your Jacobian matrix approaches a singularity, one or more of your joints will be required to reach an excessive velocity in order for the end effector to remain on the path.  This is a problem when you want the end effector to continue with a non-zero speed along its path.  Otherwise, the singularity could cause the end effector to dwell while the nullspace motion of the robot eventually resulted in it being able to continue along the path, and you wouldn't have to implement any optimal control algorithms.

When the configuration becomes close enough to a singularity, any control approach will either cause the end effector to reduce below the desire speed, or else will cause the end effector to deviate from its desired path.  If you think of the desired trajectory as a set of differential motions (or speeds), you can see that the two problems above are really the same thing:  the end effector is unable to continue with nonzero speed along a desired path.

Systems have been controlled which attempt to optimize the motion in the neighborhood of singularities.  Often they will use a gradient technique to minimize the error from the desired trajectory (the path/speed combination).  The interior point method is one of these approaches.

You would need to set up your objective function (or constraint) to be optimized to be related to the error between the desired trajectory and the achievable trajectory.  I have seen pretty simple optimization functions such as minimize the sum of the square of the joint velocities, all the way through very complex optimizations that trade off between speed and positional deviations.

I think the answers to this question will help you get started:  With a 6-axis robot, given end-effector position and range of orientations, how to find optimal joint values

Title: inverse kinematics osciliations..


答: See also this question for some info on how accelerometers handle gravity versus an external force.</p>

Title: How to use an IMU to hover at a fixed location in a quadcopter in the presence of gravity?

Body:
There's an accelerometer in the IMU. The output can then be integrated to estimate the position, at least in theory.

But in practice, there's a huge acceleration from gravity, which varies rather randomly across locations. Vibrations etc can be filtered out with low-pass filters, but how do you filter out gravity? Is it simply the case that the vertical vector is ignored when doing any calculations?

My application is, I want to build a quadcopter that could hover in one place even in the presence of (reasonable) winds: the quadcopter ideally would tilt towards random gusts to maintain a certain position. Every single tutorial I could find on the Internet only uses the accelerometer to estimate where down is when stationary, and simply assumes that using the gyroscope to hold the quadcopter level is enough.

I also want to use the IMU to estimate altitude if possible, of course as an input to something like a Kalman filter in conjunction with a sonar system.

Obviously, for my application GPS is far too slow.


问:
Problem with HC-SR04 sensor
I have three HC-SR04 sensors connected to a PIC18F4431 with the schematic provided below. Before building the PCB I've tried testing all three sensors with a bread board and they worked fine. But now I have my PCB and when I connect them to that and tried testing, they work only for a few seconds and then stop working.

I set timers and a set of LEDs to lit if an item is in between 40cm from each sensor. As I've tried from the bread board, when I cross my arm withing that range, the appropriate bulbs are lit and when I take my arm off the other bulbs are lit. But using the PCB, when I upload the code through a PICKIT2 they work fine for a few seconds and then they freeze. If I reset the MCLR pin it works again for another few seconds and freeze again. And sometimes randomly if I touch the receiving part of the sensor it works but that happens randomly. Not always working. What could be the issue?

Is my oscillator burnt while I was soldering it? Once I connected two 0.33uF polar capacitors and found out that for one second, it takes one minute or more to blink a bulb.

答:
In the PCB copper-side picture and the board layout picture, three pins have been left unconnected.  If your code has those set as inputs you are likely to get random inputs.  Check what your program does with those pins.  You can set them to low outputs and leave them low if they are causing problems.

For the other pins (ie those with with traces) if there is nothing yet connected to an input pin that you are reading, you may get intermittent problems like those mentioned in the question.  As an interim measure you might tie such pins high or low through 10 KΩ to 40 KΩ resistors.

Title: Problem with HC-SR04 sensor


问:
Hector SLAM, Matching algorithm
I'm trying to understand the scan-matching part of Hector SLAM (PPT summary). It seems a little difficult to understand, in some cases, how is it possible to actually perform the alignment of the scans. Can anyone explain about it?

In my case, I'm working with a simulation. I'm moving my robot in a corridor-like featureless environment (only two walls) and I don't get a map. Nevertheless, if I move in a sinewave motion, I'm able to get a map. Moreover, if I have an additional feature, the algorithm even shows the real path as long as this feature is seen (right part of the image), otherwise it shows a very weird-looking oscillatory path which does not resemble a sinewave at all. Something important to notice is that the width of the map is pretty accurate (real=4m, map's=4.014m), and the length of the movement is also somehow accurate (real=15m, map's= 15.47). I'm using a Hokuyo URG-04LX laser range finder, no odometry, no IMU. I'm running in Ubuntu 14.04 and using ROS Indigo.

I more or less understand how Hector works, but I have no idea about why I'm getting this map and specially trajectory.

Thank you.

答:
So your path starts out perfect because of the back wall, however because of the lack of features afterward & poor sinusoidal path planned spatial parameters i.e. (amplitude, frequency) w.r.t. speed (wait... speed).

Have you tried increasing the speed of the motors?

Title: Hector SLAM, Matching algorithm


问:
How to convert rotation matrix in to equivalent Quaternion using Eigen Library.
Eigen library (http://goo.gl/cV5LY), which is used extensively in ROS and PCL.

Thank you.

答:
https://stackoverflow.com/questions/21761909/eigen-convert-matrix3d-rotation-to-quaternion

Welcome neel, please take the time to look around and contribute to other questions.


问:
Kinematics of a 4 wheeled differential drive robots
I have a 4 wheeled differential drive robot, like the Pioneer 3-AT. There are only two motors, one for left wheels and one for right wheels.

I want to send velocity commands to the robot, I'm using ROS and the standard commands are: [linear_velocity, angular_velocity].

I need to convert them into left and right velocities, from literature if I had 2 wheels I should do this:

$v_l = linear_v - \omega * |r|$

$v_r = linear_v + \omega * |r|$

where |r| is the absolute value of the distance from the wheels to the robot "center".

How should I take into account that I have 4 wheels?

答:
This is an old question but I see it repeated without a real answer.
Sticking with a kinematic model only, here's what I would do:

The linear velocity of the robot is $\upsilon$ and the angular velocity of the robot is $\omega$.

The distance to the ICR (not shown in the diagram) is
$$
\frac{\upsilon}{\omega}
$$
The velocity of the wheel about the ICR is
$$
\omega \sqrt{ d^2+s^2}
$$
The angle between our wheel and the ICR is
$$
\alpha = \arctan\frac{s}{d}
$$
We assume our wheels are the only thing creating motion about the ICR. $\upsilon_r$ is the linear velocity of the wheel.
$$
\upsilon_r=\frac{\omega \sqrt{ d^2+s^2}}{\cos \alpha}
$$

When the Instantaneous Center of Rotation (ICR) is far from the vehicle, the model is the same as the differential drive model. When the ICR is near the center of the vehicle this model is more accurate.

Just like the kinematic model for differential drives, this works well when friction is high and equal at all wheels. Rubber on concrete or hard floor for instance.


问:
How do I if know my quad is powerful enough to take off vertically smoothly and how do I calculate max Thrust(g) for given current(A) and voltage(V)?
If I build my quadcopter with the following components, will it take off vertically smoothly?

Frame: F450 glass fiber and polyamide nylon [280g]

Landing Gear: High Landing Gear for F450 [90g]

Battery: 3000mAh 20C (30C burst) 3s/1p [260g]

Motor: XXD A2212 1400KV brushless outrunner motor [4x50g]

ESC: 30A (40A burst) Brushless with BEC - 2A/5V [4x25g]

Prop: 1045 Propeller set

Assume that the total weight of the quad is ~1.1Kg and I would like to have payload upto 400g, making the quad weigh ~1.5Kg

From all that I've learnt, the Thrust:Weight ratio should never fall below 1.7:1 (and a 2:1 is recommended to have better control) which if does creates problems in lifting my quad vertically smoothly. I'm neither planning to have very high maneuverability nor cruise the sky pushing my quad's limits. I just want it to fly.

Here's the motors pull(g)-amps(A)-voltage(V)-power(W)-specificThrust(g/W) information for A2212 1400kv with 10 x 4.5 Props

Since my battery's discharge rate is limited to 20C, if I'm not wrong, it can give out only 60A (since its 3000mAh) for the entire circuit with four motors, each of which can take 15A max, which from the above table would produce ~600g thrust, which is 2400g from all four motors.

Does this mean I can get 1.6:1 Thrust:Weight at 100% throttle? Can my quad still take off vertically smoothly?

I'm also confused about the efficacy of my motor, meaning if I buy a bigger motor, can get more than 600g thrust at 15A/11.1V with same/bigger props? If not, is this the most efficient combination of motor and prop?

If yes, what is the maximum thrust (practical pulling force in g, not in N) I can get outta 15A/11.1V? Which equation tells defines that exact relation, provided I fly my quad at usual conditions (1013hPa/25degC extTemp/80%-90% relHumidity/max15mAlti)?

PS: I tried ecalc, Prop Power Thrust and Efficiency Calculations, and a few other online stuff.

Update: Will replacing the 3000mAh-20c/30c battery with the 5000mAh-20c/30c 3s1p keeping everything same solve some problems and increase the flight time, provided I keep everything else the same?

答:
You're really asking two questions here:

Will the motors and propellers be able to provide enough thrust to lift the weight of the quadcopter?

There's no substitute for measurement here.  Get one motor, one propeller, and measure it for yourself using a benchtop power supply.  Then multiply that by 4 (scaling it by the ratios you posted, as appropriate) and compare it to the total weight of the components you plan to buy.

The second question supports the first:

Will my power system be able to drive the motors at full speed?

Since you will already have the motors, you can measure their input current at full speed.  Then multiply by 4, and see if that total power matches your calculations for the equipment.


答: Eigen has a Quaternion constructor that takes a rotation matrix. </p>

Title: How to convert rotation matrix in to equivalent Quaternion using Eigen Library.

Body:
Eigen library (http://goo.gl/cV5LY), which is used extensively in ROS and PCL.

Thank you.


问:
What are human-friendly terms for mobile-robot orientation and relative direction of non-robot objects?
Within robotics programming, orientation is primarily given in terms of x, y, & z coordinates, from some central location.  However x, y, z coordinates aren't convenient for rapid human understanding if there are many locations from which to select (e.g., {23, 34, 45}, {34, 23, 45}, {34, 32, 45}, {23, 43, 45} is not particularly human friendly, and is highly prone to human error).  Yet more common English orientation descriptors are frequently either too wordy or too imprecise for rapid selection (e.g.,  "front-facing camera on robot 1's right front shoulder" is too wordy; but "front"/ "forward" is too imprecise - is the camera on the leading edge or is it pointing forward?)

In the naval and aeronautical fields vehicle locations are generically talked about as fore, aft (or stern), port, and starboard. While, direction of movement that is relative to the vehicle is frequently given in reference to a clockface (e.g., forward of the the fore would be "at 12", rear of the aft would be "at 6", while right of starboard and left of port would be "at 3" and "at 9", respectively).  This language supports rapid human communication that is more precise than terms such as "front" and "forward".  Are there equivalent terms within mobile robotics?

答:
I prefer to use anatomical terms for this. I'm slightly biased because I often do biomimetic and rehabilitation work. However, there are a few nice things about using them discussing or describing a (vehicle) body.

The terminology is rich. There are unambiguous terms for location (left right anterior posterior dorsal ventral), the cross section planes (sagital transverse coronal), and relative positioning on the body (proximal distal).

The terminology is shared. Roboticists doing medical, walking, and manipulation use these terms and the fact that biologists and medical scientists can instantly understand you creates opportunities for scientific cross-pollination.


问:
3 degrees of freedom analytical solution

I have got a robot that exactly looks like as shown in the figure above. I have worked out the inverse kinematics analytical solution without the base rotation (considering 2 dof alone) but I am not able to find the analytical solution including the base(3 dof). How do I find the anlytical solution for this robot ??

答:
You can find many examples for this type of robot arm online.  It is kinematically similar to the first three joints of a Puma 560, which was used extensively as an example when robot kinematics and controls algorithms were being developed in academia.

Try section 4.2 of this paper:

http://deepblue.lib.umich.edu/bitstream/handle/2027.42/6192/bac6709.0001.001.pdf


问:
Which algorithms are used in autonomous robot
I am working on proposal of autonomous fire fight robots but I'm little bit confused about its sensor and algorithms. My friend suggested there are some path finding AI algorithms like BFS, DFS, A*, and Dijkstra's Algorithm which are used in robots, but I didn't believe it.

I want to ask: Are these algorithms used in real world robots or some other genetic algorithms? How does a robot discover path to detect, and differentiate, a human from fire?  I only want some explanation that gives knowledge.

答: in my opinion one possibility on how the robot could find people with fire is by using image processing. You can obtain a real time Infra red image of the outside world and then check for levels of heat measured. Using recognition alogirthms the robot could decide whether a particular figure is a human or not and if it is a human then by checking the heat generated it could decide whether the person is in danger or not. The source of heat could be the main setpoint that the robot wants to reach.</p>


问:
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?

答:
Install OpenCV-Python, it will solve the import cv2 error.

You can refer the following link for installation, Install OpenCV-Python in Windows.

Title: Camera Calibration fails to run on ROS


问:
Using another device instead of RC transmitter
I want to make pc controlled quadrotor. All the tutorials/projects made with rc receiver. I want to use arduino or xbee instead of rc receiver for pc control of quadrotor. How can I do this. </p>

<p>Note: I have arduino, beaglebone, xbee, hc-05, KK2 and multiwii parts. </p>

答:
The input to the autopilot is a 50Hz PWM signal with pulse width varying from 1000 µs to 2000 µs (this is with APM, it should be same with KK2).  In case of a RC transmitter this signal is modulated on a 2.4GHz channel and the PWM values are mapped to the output of a potentiometer on the remote.
Now, you can keep an Arduino on your quadrotor with an XBee, and generate the same signal using the 'Servo' library (it also generates a signal of the same frequency).  And on your PC you can write a python script to transmit PWM values through an XBee connected on your serial port.</p>


问:
Microcontroller flashing itself
Can a micro controller flash itself?
What i mean to say is, I have an STM32F103RG with 1Mb Flash Size.
I have a UART Communication modem connected to it. Can i send a firmware (.HEX or .BIN) to the microcontroller via the radio verify checksums, on sucess the microcontroller saves the file into a SD Card ( via SPI ) and then restarts itself and start flashing itself reading from the file ( in the sD card )?

Can something like this be done or an external MCU is required to carry out the flashing?

The purpose is the microcontroller and radio will be sitting at a remote location and i need a way to change the microcontroller's firmware by sending it a firmware update file remotely.

答:
Yes this is entirely possible, and as FuaZe said, it's called a bootloader.

You essentially have two programs on your chip, each with their own memory area; the bootloader and the application. Preferably, the bootloader area is write-protected to make sure you don't accidentally destroy it.

With the bootloader, you can use any algorithm you want. If you have enough space, the bootloader could be large enough to communicate with the outside world, get the hex file and program the application. If not, the older application can do the communication, write the hex file somewhere (external SD card for example as you said), restart to enter the bootloader and then it would read the hex file and write to flash.

The bootloader is naturally the first program to run on restart, and it usually either has a timeout, where if there is no communication it would jump to the application, waits for an "exit bootloader" command, or with your example, checks if there is something to bootload and if not immediately jumps to the application.

Note that with the bootloader, you need to be careful! You need to think about all cases where there could be power cuts in the middle of programming, or corruption of the program during write etc. In short, you need to make it bullet proof, or you may find yourself in a situation where your microcontroller is bricked. This is similar to how windows 10 bricks computers.

If your bootloader communicates directly with the outside world to download the new firmware, you have the lowest risks. You just need to protect the bootloader itself and you should be able to recover from errors.

If your bootloader reads the program from somewhere on the board, where the firmware is written by the application itself, you need to be sure that the application is always capable of writing new firmware to that somewhere on the board. This may not always be the case, for example because there could be bugs among other reasons. In such a case, I suggest having a read-only firmware on the board which contains the original well-tested application. A button for example could tell the bootloader that you have messed up and would like to have the original application bootloaded.

The case with your external SD card fits better in the first case, since you can always recover with removing the SD card, writing the correct firmware on it with a computer and plugging it for bootload.

Title: Microcontroller flashing itself


问:
How to have a 'Auto Go Home' feature, like the DJI Phantom 3, on a project built quadcopter?
What should a quadcopter have, or have access to, in order to make this 'return home' feature work? Is GPS enough? What is the approach needed to make this happen?

I used a Arduino Mega 2560 with IMU to stable my quadcopter.

答:
I would go with one of two-ish methods to do this, but both methods require the craft to know its own position. You could do this with GPS, or an IMU, or any other means or combination of position tracking.

Method 1 - Only track where you are and where "home" is. Use sensors to detect obstacles along your path and navigate around them as applicable.

Method 2 - Leave "breadcrumbs". Set your first waypoint where "home" is. Every time you get X meters away from the last waypoint, set a new waypoint. Assume there is no obstacles between waypoints (set the waypoint distance small enough that this should always be true), then just follow the waypoints back.

Note that Method 1 is just Method 2 with a very large distance setpoint.


问:
Where to make changes for simulation project Bullet/Gazebo/ROS/Orocos
I am starting to develop robotics project which involves simulation (and maybe real world programs) of soft-body dynamics (for food processing) and clothes/garment handling (for textile industry or home service robots). It is known that soft-body dynamics and garment handling are two less explored areas of robotics and simulation, therefore I hope to make some development of (contribution to) projects that are involved. The following projects are involed:

Bullet physics engine - for dynamics

Gazebo - simulation environment

ROS - robot OS, I hope to use Universal Robot UR5 or UR10 arms and some grippers (not decided yet)

Orocos - for control algorithms

Initially I hope use "ROS INDIGO IGLOO PREINSTALLED VIRTUAL MACHINE" (from nootrix.com), but apparently I will have to make updates to the Bullet, Gazeboo, add new ROS stacks and so on.

The question is - how to organize such project? E.g. If I am updating Bullet physics engine with the new soft-body dynamics algorithm then what executable (so) files should I produce and where to put them into virtual machine? The similar question can be asked if I need to update Gazebo.

There seems to be incredibly large number of files. Is it right to change only some of them.

Sorry about such questions, but the sofware stack seems to be more complex than the robotics itself.

答:
You are right, it is a lot of files to deal with...

ROS, among other things, is a convention for developing large software systems. They say Robot Operating System but what they mean is Robot Software Build, Packaging, and Network Transparent Interprocess Communication System. RSBPNTICS does not roll off the tongue though...

ROS is not the best build and packaging system but it's got a decent amount of documentation and it's got 'robot' in the name. Read the ROS docs, do the tutorials, and after a little while you will start learning how to make small changes to large systems of software.

The basic process is that you grab the source code for the library or process that you want to modify and build it. You replace the system version with your version (there are lots of ways to do this, but what you don't do is delete the system version). And then you make the changes you want to the source code. Most source code libraries are managed with version control software like git or subversion and you will have the opportunity to use them to contribute your changes back to the original authors.

Understand that it will take learning and practice to develop enough experience where things start making sense. In the mean time, make friends with people that already have some experience to learn from and help you out along the way.

If you have time to look around at other things for a little bit before starting, check out rock-robotics, another robot software build & packaging system. Rock is arguably more closely integrated with Orocos. There are also several other frameworks devoted to robotics that you will find with a little searching.

You are correct in your assesment that the software stack is more complex than the robotics. But this is only because of the stack you've chosen. Depending on what exactly you are doing, it might be quicker and easier to just write it all from scratch.

I recommend against using a virtual machine unless you have to. It just adds a layer of stuff to deal with. Installing ROS on a machine, even building ROS from source, is easy enough. Ubuntu 14.04 for ROS Indigo. I prefer developing on a faster moving distro and use Archlinux where ROS is well supported via the AUR repository.

A comment on your list of tools... I don't think you've found the right simulation combination yet.

Bullet (a video game physics simulator by Sony where looks and speed are more important than accuracy) is not something I'd use. Bullet does have soft body support but check the equations and integration functions for accuracy before you use it.

As you look for a suitable simulator to build on, take a look at simbody. I don't think it has what you need but it is some of the most beautifully organized and commented code I've seen. Use it for inspiration.

Gazebo is only a (nice and useful) wrapper that actually prevents a lot of features of the underlying simulators to be used. Don't be afraid to use the simulators without gazebo.


问:
DC motor shaft and gear installation
I'm hoping to use a DC motor to drive a cog bar horizontally along a track. AFAIK, I'd need to install a (plastic) cog on the motor shaft, which itself grips on the (plastic) cog bar. Does anyone know how to prevent the cog from shifting on the shaft? The shaft is 10mm long and I'd like to make sure the cog cog sits at 5mm, where the cog bar is.

Any help will be appreciated.

Thanks

答:
The term I'd use for cog-bar and cog is rack and pinion.

Plastic pinions are usually press-fit if they are very small or use set screws if they are just small.

I assume you are asking the question because the pinion is sliding on the motor shaft. Use epoxy. Use one that takes some time to cure so that you can position the pinion without worry.

Title: DC motor shaft and gear installation


问:
Weird magnetometer values
I bought a 3-axis magnetometer (Similar to this one ) And plugged into an Arduino in order to read the heading value.
I mounted it on my robot and I drove with the robot for around 30 meters, turned 180 degrees and drove back to my starting position. I plotted the heading value and it shows inconsistent values. The 180 degrees turn started at sec 55, the rest is driving in one direction using a joystick and following a wall as reference so small deviations are expected but not that big as in the image.

When the robot is turning in-place, there is no such problem and the heading variation follows the rotation of the robot. The robot (Turtlebot) is a little bit shaky such that the magnetometer doesn't always have the x and y axes parallel to the floor but I don't think few degrees of offset can cause such a huge difference. I calculate the heading as follows:

heading = atan2(y field intensity, x field intensity)

Why does this happen? Could it be form some metals or electric wires under the floor?
Can you suggest a more robust method/sensor for estimating the heading in indoor environments?

EDIT:

I drove the same path again and the pattern similarity is making it even weirder

答:
Everything looks fine to me.

Imagine if you kept driving in clockwise circles. Would you want your heading to be 18064? Would that mean anything to you? Which direction are you facing?

No, instead whenever you would go below 0 it puts you up to 359, because counter clockwise of North is North-Northwest.

Similarly, clockwise of North is North-Northeast, so instead of going from 359 to 361 you go to 1 instead.

All you are seeing is the output giving you a useful heading, which means "wrapping" from 0 to 360 because these are actually the same values. Similar to how a clock "jumps" from 12 to 1 (or 23 to 1, depending on your background).

Title: Weird magnetometer values