问:
Does RRT* guarantee asymptotic optimality for a minimum clearance cost metric?
The optimal sampling-based motion planning algorithm $\text{RRT}^*$ (described in this paper) has been shown to yield collision-free paths which converge to the optimal path as planning time increases. However, as far as I can see, the optimality proofs and experiments have assumed that the path cost metric is Euclidean distance in configuration space. Can $\text{RRT}^*$ also yield optimality properties for other path quality metrics, such as maximizing minimum clearance from obstacles throughout the path?

To define minimum clearance: for simplicity, we can consider a point robot moving about in Euclidean space. For any configuration $q$ that is in the collision-free configuration space, define a function $d(q)$ which returns the distance between the robot and the nearest C-obstacle. For a path $\sigma$, the minimum clearance $\text{min_clear}(\sigma)$ is the minimum value of $d(q)$ for all $q \in \sigma$. In optimal motion planning, one might wish to maximize minimum clearance from obstacles along a path. This would mean defining some cost metric $c(\sigma)$ such that $c$ increases as the minimum clearance decreases. One simple function would be $c(\sigma) = \exp(-\text{min_clear}(\sigma))$.

In the first paper introducing $\text{RRT}^*$, several assumptions are made about the path cost metric so that the proofs hold; one of the assumptions concerned additivity of the cost metric, which doesn't hold for the above minimum clearance metric. However, in the more recent journal article describing the algorithm, several of the prior assumptions weren't listed, and it seemed that the minimum clearance cost metric might also be optimized by the algorithm.

Does anyone know if the proofs for the optimality of $\text{RRT}^*$ can hold for a minimum clearance cost metric (perhaps not the one I gave above, but another which has the same minimum), or if experiments have been performed to support the algorithm's usefulness for such a metric?

答:
In a previous answer, we came to agree that a cost function defined as

$c(\sigma) = \text{exp}(-\text{min_clear}(\sigma))$

would satisfy the properties required for RRT* to yield asymptotic optimality under this metric.

However, upon reviewing the IJRR article which describes RRT*, this cost function does not technically satisfy the assumptions made in the article. Specifically, this cost function violates the boundedness property, defined as:

$\exists k_c \quad c(\sigma) \leq k_c\text{TV}(\sigma), \forall \sigma \in \Sigma$

where $\text{TV}(\sigma)$ is the total variation of a path, which is essentially the path's Euclidean length. Under this boundedness assumption, a path of length 0 must also have a cost of 0.

Let's define a path $\sigma_0$ to consist of a single configuration $q$, meaning the length of $\sigma_0$ is 0. Our path cost is therefore $c(\sigma_0) = \text{exp}(-d(q)) > 0$, which violates the boundedness assumption. Therefore, this cost function does not meet the requirements set in the IJRR article to yield asymptotic optimality.

I wonder if RRT* simply will not yield asymptotically optimal solutions under such a cost function, or if it still might but perhaps those assumptions simplified the optimality proofs in the paper.


问:
Virtual model in PLC discrete / continuous
How does one implement virtual model (continuous) while control system itself is discrete (PLC)?

I've done this in practice but what about theory, how does one explain this topic to a stranger? (lets say myself)

答:
You have to discretize the model. This is typically done with a z-transform, where

$$
z = e^{sT}
$$
or
$$
s \approx \frac{2}{T} \frac{z-1}{z+1}
$$

where $T$ is the sample period. Make the substitution in your CT model, replacing $s$ with the above, then solve it like you would for an ordinary transfer function.

Once you've done this, divide everything by the highest order of $z$ in the transfer function. Now $z^{-n}$ represents a delay of $n$ samples, so:

$$
Y(z) = X(z) + X(z) z^{-1}
$$

becomes
$$
Y_n = X_n + X_{n-1}
$$

This is very much akin to the Laplace transform, where you get functions of $s$, where $\frac{1}{s}$ is the integrator and $s$ is the differentiator. Here $z^n$ represents $n$ samples in the future where $z^{-n}$ represents $n$ samples in the past; this is why you must divide by the highest order of z - you can't get future samples.

$$
Y(s) = X(s) + sX(s)
$$
becomes
$$
y = x + \dot{x}
$$
So, regarding how to explain to someone how to implement a continuous model on a discrete controller, this is it. The Z-transform. Why this works the subject of many text books and much too long of an answer to cover here.

ContentLicense: CC BY-SA 3.0


问:
Arm to disassemble and assemble notebook at home?
Suppose I have perfect AI to control robotic arm.

What characteristics should it fulfill to be able to take such common tools as screwdriver and linesman's and disassemble and then assemble conventional notebook computer?

Are there such models available?

Is seems to me, that such arms as OWI-535 are only toys, i.e. they can just relocate lightweight objects and that's all. Am I right?

UPDATE

Also suppose that my AI can look at assembly area with multiple HD cameras and can perfectly "understand" what is sees.

答:
Yes, the OWI Robot arm is just a toy and doesn't have nearly enough accuracy, repeatability, sensor feedback, etc. to be able to do any sort of "real" assembly task.  I'm sure you are aware of industrial arm like Kuka, ABB, etc.  However, these arms are not suited to fine assembly either.  A new class of robot arm is becoming more popular, one that is "human safe" and designed for assembly tasks with some human involvement.  These are things like Universal Robotics, Rethink Robotics Sawyer, and ABB YuMi.

Also, even with "perfect AI control", a robotic arm needs a certain about of good sensor feedback to do anything useful.  One example of this is demonstrated in an old experiment where a woman's hand was completely numbed and she was asked to light a match.  It took about 45 seconds of fumbling with the match before she was successful.  With an un-numbed hand she can light the match in just a few seconds on the first try.  The point being that even with arguably the most powerful computer on the planet (the human brain), without good tactile sensing we are unable to do fine manipulation.  (I was unable to locate the video of said experiment, but it is also mentioned in this article.)


问:
Raspberry Pi Hexapod 18DOF, Best servo control board?
Recently I've bought a hexapod kit and 18 TowerPro MG995 servos.

My objective is to apply also the Pi camera, sensors and perhaps a claw...
So I've been researching and I haven't found a clear answer when comes to the servo control board.

Which servo controller board shall I choose to complete my project?

答: Servo's are controlled by Pulse Width Modulation (PWM) so you need a PWM controller that has enough pins and power to drive Servos. I'd go with 2 of Adafruit's I2C-based controller but Pololu has a USB one that is rather popular.</p>


问:
what are methods to compare PID controller performance?
If there are input and the sensor measured outputs. What are the objective methods to compare performance besides looking at inputs and outputs matching or not?</p>

答:
Controllers in general are judged typically by 3 criteria -

Rise time, or how quickly the output gets to the input,

Percent overshoot, or how much the output oscillates around the input, and

Settling time, or how long it takes the output to stabilize at the same value as the input.

Typically you measure these with a step test - from an initial condition of zero, give an input of 1. The time it takes to get from 10 percent to 90 percent is rise time, settling time is generally how long it takes the output to stay within 2% or 5% of the input value, and percent overshoot is the farthest beyond the input that the output got.

Allowing some overshoot improves rise time, which means the system responds faster, but at the expense of a longer selling time.

Some more explanation,

Because of inertia, rise time and percent overshot are competing goals. What is the fastest way to drive 1000 feet? Go full throttle, of course. If you start slowing down to stop right at 1000 feet, you won't get to the mark as quickly as the person that is still going full throttle with no braking.

Conversely, while the person who doesn't start braking until they hit 1000 feet may have got there first, it will take time, some distance, to stop. They have overshot the 1000 foot mark. If they overshoot by 10 feet then go in reverse as quickly as they can, they get back to the mark, but will probably overshoot again, but not as much as the first time because they travel a shorter distance and thus can't get to the same top speed. This process repeats and is called oscillation.

This trade off, getting there quickly vs not overshooting, is typical. All of engineering is defining criteria and then finding the best trade off to meet the established criteria.


问:
Quadcopter: Stabilization along the z-axis (for holding altitude)
I recently spent some work on my quadcopter firmware.
The model is stabilizing its attitude relatively well now.
However I noticed, that it is changing its altitude sometimes (maybe pressure changes, wind or turbulence).
Now I want to get rid of these altitude drops and found not much literature.
My approach is using the accelerometer:

Calculates the current g-force of the z-axis

if the g-force is > 0.25 g and longer than 25 ms, then I feed the accelerometer term (cm per s²) into the pid

the output is sent to the motors

The model now reacts when it is falling down with an up-regulation of the motors.
However, I am not sure, whether it is smart to feed the current acceleration into the regulator and I currently wonder, whether there is a smarter method to deal with sudden and smaller changes in altitude.

Current code:

```<code># define HLD_ALTITUDE_ZGBIAS 0.25f
# define HLD_ALTITUDE_ZTBIAS 25

const float fScaleF_g2cmss = 100.f * INERT_G_CONST;
int_fast16_t iAccZOutput = 0; // Accelerometer

// Calc current g-force
bool bOK_G;
float fAccel_g = Device::get_accel_z_g(m_pHalBoard, bOK_G); // Get the acceleration in g

// Small & fast stabilization using the accelerometer
static short iLAccSign = 0;
if(fabs(fAccel_g) >= HLD_ALTITUDE_ZGBIAS) {
  if(iLAccSign == 0) {
    iLAccSign = sign_f(fAccel_g);
  }

  // The g-force must act for a minimum time interval before the PID can be used
  uint_fast32_t iAccZTime = m_pHalBoard->m_pHAL->scheduler->millis() - m_iAccZTimer;
  if(iAccZTime < HLD_ALTITUDE_ZTBIAS) {
     return;
  }

  // Check whether the direction of acceleration changed suddenly
  // If so: reset the timer
  short iCAccSign = sign_f(fAccel_g);
  if(iCAccSign != iLAccSign) {
    // Reset the switch if acceleration becomes normal again
    m_iAccZTimer = m_pHalBoard->m_pHAL->scheduler->millis();
    // Reset the PID integrator
    m_pHalBoard->get_pid(PID_ACC_RATE).reset_I();
    // Save last sign
    iLAccSign = iCAccSign;
    return;
  }

  // Feed the current acceleration into the PID regulator
  float fAccZ_cmss = sign_f(fAccel_g) * (fabs(fAccel_g) - HLD_ALTITUDE_ZGBIAS) * fScaleF_g2cmss;
  iAccZOutput = static_cast<int_fast16_t>(constrain_float(m_pHalBoard->get_pid(PID_ACC_RATE).get_pid(-fAccZ_cmss, 1), -250, 250) );
} else {
  // Reset the switch if acceleration becomes normal again
  m_iAccZTimer = m_pHalBoard->m_pHAL->scheduler->millis();
  // Reset the PID integrator
  m_pHalBoard->get_pid(PID_ACC_RATE).reset_I();
}
</code>```

答:
Two approaches are possible:

Combine the altitude (GPS or pressure) and vertical acceleration sensors' data to calculate a better geometric altitude, and tune your vertical controller using this feedback in your loop.

Employ a stability augmentation loop for the z-acceleration (in body frame). In this case, if your vehicle swings, as shown on Jon's answer, your vehicle will sense a z-acceleration and will try to correct that. This may not be best practice to work on the z-acceleration in body frame, as it will couple the roll with altitude as the aircraft rolls and moves around. So a trigonometric conversion can be done to convert the a_z data (in body frame) into a_z_inertial (in Inertial frame, e.g. in gravity). It's best to work this on paper (you have both roll and pitch, affecting the result).

About the current algorithm:

Filter your accelerations. Try a running average (low pass filter) of your accelerations, to get rid of the noise. It will probably be OK to have a running average of the last 0.2 second, for example.

Do not use cut-off, at all. It makes life non-linear, and it's not good. Let the controller handle all the events, and let it react to the small errors, before they grow high.


问:
Brushless DC motor - Electronic Speed Control - Quadcopter
I'm a student who is doing electrical and electronics engineering. I'm currently doing my final project which is a quadcopter. One of my objectives in that is to make a Electronic Speed Controller (ESC) for the brushless motors that are being used.

I made a design for the ESC using proteus and I made the PCB also. I have attached the schematic. I used PIC16F628A for the ESC and wrote a small code in mikroC for the ESC to work when powered up. Unfortunately it didn't work properly. I tried sensorless control of brushless motors without getting any feedback.

Can I know how much of current that I should provide for the motor? According to some articles that I read the brushless DC (BLDC) motor requires around 10A at the startup for around 20 ms. I have posted the code also. I used two codes to run the motor. One with PWM and other without PWM (100% duty cycle).

I am a rookie to the subject of BLDC motor controlling. I am very grateful if anybody can help me to clear out the doubts and figure out the mistakes in my design to make it work properly.

Below given is the code that I tried. Please help me to figure out the right way to program the chip.

```<code>    const delay = 7000;

void main() {
 TRISB = 0x00;
 PORTB = 0x00;

 while(1)
 {
   PORTB = 0x24;
  delay_us(delay);

  PORTB = 0x36;
  delay_us(delay);

  PORTB = 0x12;
  delay_us(delay);

  PORTB = 0x1B;
  delay_us(delay);

  PORTB = 0x09;
  delay_us(delay);

  PORTB = 0x2D;
  delay_us(delay);
 }

}
</code>```

When I uploaded the above given code and when I set the delay to around 3000 μs, the motor spun but at each time one of the MOSFETs got heated up until I cannot touch it anymore. Here is the video of this scenario.

This is the other code (PWM);

```<code>const delay1 = 2000;
const delay2 = 1000;
int count = 0;
int cnt;
int arr[6] = {0x24, 0x36, 0x12, 0x1B, 0x09, 0x2D};
int i = 0;
int x =  0x32;

 void init(void)
 {
  TRISB = 0x00;
 PORTB = 0x00;
 //OPTION_REG = 0x87;
 //INTCON = 0xA0;
 CCP1CON = 0;
 CMCON = 0x07;
 }

void main() {
   init();
   while(1){

   for (cnt = 0; cnt < 10; cnt++)
       {
         PORTB = arr[i];
         delay_us(2);
         PORTB = 0x07;
         delay_us(2);

        }

     i++;

         if (i == 6)
         {
         i =0;
         }

   };

 }
</code>```

答:
First thing first: you can't observe your rotor's location at 0 speed, because at 0 speed, you've got no back EMF. You must make your motor ramp to a speed that allows you to observe it electronically. This is done open-loop.

To perform your ramp, you need to generate a voltage slightly above the BEMF at the ramping speed. Slightly above means that you probably don't need 100% duty cycle. Using 100% duty cycle on a stalled motor means that you put one phase (10 mOhms) on the output of your power supply (12V ?), so you basically try to put 1000A in your motor. You'll just make either or both your ESC and/or your motor burn.

Your motor supplier should indicate the characteristics of your motor. Look for one called Kv (in RPM/V). It allows you to know what duty cycle you should use at each step of your ramp.


问:
Conceptual problem regarding electronic shutters
I have been looking at CCD and CMOS sensors and cameras to decide which one to use in the process of automatic control of a printing process. By now I am getting the grips on almost all the essential numbers and abbreviations but there remains a problem with shutters.

I understand that there are different types of shutters, both mechanical and electronic, and I can understand how they work. My problem concerns shutter speed. If I use a mechanical shutter, well then the maximum shutter speed depends on that particular element in the assembly, but how does it work for electronic shutters? I have never read "Max shutter speed" in any specs. The only thing I usually see floating around are frames per second. But those do usally not pass a limit of about 120 fps. Depending on how the sensor it is built one could think that the maximum shutter speed therefore is 1/120 or 1/240 if it uses half frames.

Can this be right? It seems really slow. I will be faced with the task of recording crisp and clear images of paper which moves at about 17 m/s. That is never possible with shutter speeds that slow. Will I be forced to use a mechanical shutter or am I misunderstanding something?

答:
Shutter speed is a synonym for exposure time. Exposure time is linked to the frames per second (FPS):

$t_{exposure} + t_{readout} \leq 1 / {FPS}$

So the answer to your question is: no. FPS is usually the more limiting factor because of the readout speed and the bandwidth to transmit the data.
The FPS you select provides an upper limit for the exposure time, but not a lower limit. You can make your exposure time much shorter. How short depends on your camera model, but usually much shorter than a millisecond.


问:
ROS Calibration Camera Problems
I am trying to calibrate a monocular camera using ROS with the help of this website: How to Calibrate a Monocular Camera. When I run rostopic list, I get:

```<code>/left
/right
/rosout
/rosout_agg
/usb_cam/image
</code>```

When I run rosservice list, I get:

```<code>/cameracalibrator/get_loggers
/cameracalibrator/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level
</code>```

Finally, when I run:

```<code>rosrun camera_calibration cameracalibrator.py --size 10x7 --square 0.025 image:=/usb_cam/image camera:=/usb_cam
</code>```

It says:

```<code>('Waiting for service', '/usb_cam/set_camera_info', '...')
Service not found
</code>```

I even added the parameter at the end, --no-service-check, but that just makes the terminal stall indefinitely.

Could someone please help me figure out what is going wrong and how I can fix it? Also if it is important, usb_cam is saved at catkin_ws/src/usb_cam.

答:
It looks the answer you seek may have already been answered on the ROS website.

Specifically, a bug in the camera driver in that it is not advertising the proper service.

Title: ROS Calibration Camera Problems


问:
Arduino original or generic for a beginner?
I'm new to the robotics and electronics world, but I'm willing to dive into it. I'm a software developer and I want to create a project that uses GPS and Accelerometer data to show as a layer on Google Maps after transferred to PC.

My doubt is about which controller to get. In my country, there are generic controllers based on the Atmega328 that are being sold with a massive difference of price from the original Arduino (talking about the UNO model).

Should I start with an original model?

Should I expect to break the controller, fry it, or break any components by connecting them wrong?

Would the experience with a generic controller be less exciting than with the original Arduino one?

答:
If you're just starting out, you should probably use the original Arduino instead of a generic.

Let's say you follow an Arduino example using a generic, and things don't work the way you expect.  How will you know whether your Arduino code (or circuit) is the problem, and not the generic board?

In all actuality, a generic board will probably work fine.  The best choice for you will come down to how confident you can be in troubleshooting.


答: I got the problem fixed, apparently my camera was not "on", and it only turned on after I ran the .launch test file right before I do the calibration. Also it should be image_raw, not image in the command. </p>

Title: ROS Calibration Camera Problems

Body:
I am trying to calibrate a monocular camera using ROS with the help of this website: How to Calibrate a Monocular Camera. When I run rostopic list, I get:

```<code>/left
/right
/rosout
/rosout_agg
/usb_cam/image
</code>```

When I run rosservice list, I get:

```<code>/cameracalibrator/get_loggers
/cameracalibrator/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level
</code>```

Finally, when I run:

```<code>rosrun camera_calibration cameracalibrator.py --size 10x7 --square 0.025 image:=/usb_cam/image camera:=/usb_cam
</code>```

It says:

```<code>('Waiting for service', '/usb_cam/set_camera_info', '...')
Service not found
</code>```

I even added the parameter at the end, --no-service-check, but that just makes the terminal stall indefinitely.

Could someone please help me figure out what is going wrong and how I can fix it? Also if it is important, usb_cam is saved at catkin_ws/src/usb_cam.


问:
How do I choose the best filter for dead reckoning with an IMU?
I'm searching filter to reduce noise and smooth the signal while dead reckoning with an IMU (6dof gyro+accelerometer). What are the differences/advantages/disadvantages of the following filters:

Kalman

Complementary

moving average

Mahony

I applied kalman and complementary filters to an IMU and both of them gives time lag to actions with respect to filter parameters. Also kalman filter works slower than moving average and complementary. How can I choose right filter and filter parameters?

答:
I have had much better success with Kalman filters than any other, that is where it can be run fast enough, as the matrix transformations are very resource intensive.

I use the MPU 6000 (it is integrated into the Pixhawk my favourite FC) in conjunction with the Extended Kalman Filter, due to the linear nature of the systems I work with (quadcopters/planes).

But as holmeski pointed out, just using dead reckoning will not work out so well for any length of time, you will need some more accurate positioning.


问:
Mapping formats for small autonomous robots
I have some robot software I'm working on (Java on Android) which needs to store a pre-designed map of a playing field to be able to navigate around. The field's not got any fancy 3d structure, the map can be 2d.

I've been trying to find a good format to store the maps in.
I've looked into SVGs and DXFs, but neither one is really designed for the purpose.

Is there any file format specifically designed for small, geometric, robotics-oriented maps?

The field I'd be modelling is this one:

答:
I really don't think the format matters, so I'd suggest you go for what's most convenient to you.  You might want something that can be displayed easily on screen, any bit map format will do.

You could even use a simple text file with occupied grid squares marked, a really simple example below:

```<code>1111111
1000001
1110001
1000001
1111111
</code>```

Body:
I really don't think the format matters, so I'd suggest you go for what's most convenient to you.  You might want something that can be displayed easily on screen, any bit map format will do.

You could even use a simple text file with occupied grid squares marked, a really simple example below:

1111111
1000001
1110001
1000001
1111111


答:
Some type of Kalman filter is almost always the best solution to an estimation problem involving a dynamic system given your computer can handle the matrix inversion. Generally, Kalman filters optimally combine the previous estimate, the confidence of the previous estimate, sensor measurements, and sensor confidence together for the new state estimate.

The advantage of the complementary filter is its simplicity and ease of implementation.  The complementary filter's disadvantage is its accuracy; it will never behave better than a well tuned Kalman filter.

I am unfamiliar with the other filters you've listed :/

For your system, I would recommend using an extended Kalman filter or an unscented Kalman filter, both are capable of handling the nonlinear equations that you'll need for dead reckoning.

Choosing filter parameters will vary depending on the filter you end up using. I would recommend looking at Optimal State Estimation by Dan Simon which goes over linear and nonlinear Kalman filters as well as choosing filter parameters.

side note: Dead reckoning is an unobservable system. Your state estimate will slowly drift from truth no matter how accurate your sensors are. This may not be a problem if you're just trying to track motion over a couple of seconds. However, if you're trying to navigate a map using only the two sensors you've listed, you're bound to run into trouble.

Title: How do I choose the best filter for dead reckoning with an IMU?

Body:
I'm searching filter to reduce noise and smooth the signal while dead reckoning with an IMU (6dof gyro+accelerometer). What are the differences/advantages/disadvantages of the following filters:

Kalman

Complementary

moving average

Mahony

I applied kalman and complementary filters to an IMU and both of them gives time lag to actions with respect to filter parameters. Also kalman filter works slower than moving average and complementary. How can I choose right filter and filter parameters?


问:
How do I control the robotic arm motion?
I have a Robotic arm mounted on a car. There's a camera attached to it. Suppose the camera takes the image of a room, and finds that there's something, say an object, that has to be picked up. Say it's 50 feet away from the robot. My question is that how will the robot reach the object in the first place, and secondly, when it has reached the object, how will it know the real world co-ordinates of the object, to pick the object up, using inverse kinematic equations. Any help would be appreciated. Thanks</p>

答:
With your question, i assume that you are new to this field. This cannot be solved with one concept.

The mentioned objective requires SLAM technique - Simultaneous localization and mapping .

Using SLAM, the robot can be navigated to any location. A camera is not enough to map an area or a room in your case. You also require depth sensors such as kinect or Zed.
You need to develop a program to reach the object for your robot, depending on the architecture that you are using. Here comes the role of a platform.
A typical arduino, or a raspberry pi single board computer is enough for your project. You should be very familiar with these platforms to integrate your sensors and play with them.

Finally, once the location is reached and the object is recognized by the sensors, Here comes the Inverse kinematics into the action.
There is no such thing called "real-world co-ordinates", until and unless you are dealing with GPS for long range SLAM.

In your case,  the co-ordinates of the object are measured in the context of the location of the sensor mounted on your car.

Once the parameters of the object are known, you can use IK(inverse kinematics) for your robotic arm to grab it from its position. (Assuming that you know about IK, as you have mentioned in the question)


问:
iRobot Create 2 sensors
Can someone please provide me with a list of sensors on the create 2?  I am hoping to get one soon, but want to be sure it has ultrasonic sensors and not just bump sensors before I do.</p>

答:
The Roomba does not have ultrasonic sensors, but it does have quite a few infrared proximity sensors.  The Open Interface Spec calls it the "light bumper".

Package IDs 46-51 (pages 30 and 31) describe the different light bumper IR sensors.  They return a 12 bit number (0-4095) which will roughly correspond to distance to an object.  However it is highly dependent on the object's material.  The "light bumper" packet (45) contains a binary version of all the light bumper sensors together.  I don't know what threshold is used for this.

Title: iRobot Create 2 sensors


问:
Differences between Ackermann steering and standard bi/tricycles concerning kinematics?
I got the following homework question:

What are the general differences between robots with Ackermann steering and standard bicycles or tricycles concerning the kinematics?

But, I don't see what differences there should be, because a car-like robot (with 2 fixed rear wheels and 2 dependent adjustable front wheels) can be seen as a tricycle-like robot (with a single adjustable front wheel in the middle).

Then, if you let the distance between the two rear wheels approach zero, you get the bicycle.

So, I can't see any difference between those three mobile robots. Is there something I am missing?

答:
You're making two mistakes that I can see, both related to the idea of "shrinking" the set of front or back wheels into a single wheel.

Rather than thinking of Ackermann steering as (conceptually) a single wheel, imagine expanding the single front wheel of a tricycle into 2 wheels.  At first, the tire gets wider, then splits into two tires, then they get further apart — but the axles of the two wheels remain on the same line.  In other words, you end up with a "steerable front beam axle" like you'd find on a toy wagon — not an Ackermann system:

You could think of an Ackermann system as two bicycles welded together side by side, noting that connecting the front wheels is not solved by simply forcing their steering angles to be equal.  Instead, you might look at techniques like Burmester's theory to design the proper kinematic linkage between them.  (In the Ackermann solution, it's a 4-bar linkage.)

For the rear wheels, you're ignoring the ability to lean. In other words, a bicycle is not simply a tricycle with zero spacing between its back wheels; leaning is an integral part of maintaining stability with only two contact points.

(shifting weight to remain stable, via "Tricycle Steering"), (leaning to turn, via The stability of the bicycle)

Leaning is more of a dynamic discussion than a kinematic one, but worth noting since it affects the tires — bicycle/motorcycle tires have a rounded cross section to accomodate that lean, while car/motor-trike tires have a flatter cross section.


问:
Do magnets affect IMU values?
Im in the process of making a robot which requires 12 3x10mm cylindric magnets for the construction. They are 30mm from the center of the robot where I plan to have the IMU.

I was thinking about using MPU-6050. Do magnets affect the values? If yes, is there a solution for it? like maybe I could have a shield or something around the IMU?

答: On a semi related note, is there a possibly of permanent damage to the magnemometer and other chips if they are exposed to a magnetic field of between 1000-2000 uT from a stack of small rare earth magnets? I tried doing that to the 9-DOF IMU from adafruit today as a test and it seems to have permanently altered the bias of the magnetometer.</p>

Title: Do magnets affect IMU values?


问:
How does the cliff sensors on ROOMBA work through a glass wall?
I want to use IR sensors to detect whether my dustbin is full but I want to protect it from outside dust. I am planning to use the IR sensors on Roomba.

How are they working despite a plastic wall?

Also, what is the range of the sensor?

Can they detect obstacle at about 25 cm?

Why is there a wall between the IR sensors?

Is there a reason they are positioned at certain angle?

答: You should just use a Roomba 700 or 800 series robot.  These come with a bin full sensor already.  And the Open Interface spec works on Roomba versions 500, 600, 700, and 800.  </p>


问:
What actuator types exist that remain locked in their last position like hydraulic piston?
I would like to find an electronic actuator that mimics the characteristics of a hydraulic actuator, in that the position remains fixed without power drain when the actuator is not moving. Which actuators exist that match these criteria?</p>

答:
Actuators that use a worm gear can't generally be back-driven; these are the same gearing mechanisms that let you twist a guitar string to tune it without the tension being able to back-drive (and thus un-tune) the tuning mechanism.

Worm gears are nice in that they offer generally pretty huge reductions in speed, with a huge increase in torque. This leads to them being used in lots of things, one of them being linear actuators. The worm gear will typically be used to step down the motor from high speed to high torque, which is then used to turn the leadscrew that operates the linear actuator.

So, if you're looking for an actuator that's electric that can't be back-driven, you can search for worm gear actuators, or just look for linear actuators as most of them will expressly state if the can be back-driven.


问:
where to get this reference about Kalman filter, technical report
I'm sorry for this question that might not fit in here however, I would like to give it a shot. I've chosen this stack since the question is somehow related to mobile robots. I've came across a paper in Mobile Robot Localization that has cited the following reference,

C. Brown, H. Durrant-Whyte, J. Leonard, B. Rao, and B. Steer.  Kalman
  filter algorithms, applications, and utilities. Technical Report
  OUEL-1765/89, Oxford U. Robotics Research Group, 1989.

I couldn't find this reference. Nothing show up in Google not even in Google Scholar. In my university which allows me to access to a massive database, also nothing show up. Since this is a technical report, I'm interested to read it to have more appreciation about Kalman Filter. Has anyone came across this reference?

答:
If one of the named researchers is still at that Oxford University group, it can be reasonable to write/email to the researcher explaining your interest and ask if it is possible to obtain a copy - even though it's old. Or if you're shy ask your supervisor if this would be a good idea first.

However it is a very general sounding title, it's possible it doesn't have the precise thing that you're looking for... and many things have been written on the subject since.


答:
Another option is a motor which maintains position with a magnetic field.

Many stepper motors fall into a detent position when power is removed. If you only need whole step positional accuracy and the detent torque or cogging is large enough to hold your load in place, then this may be an option.

If the positional accuracy or detent torque is not high enough, then gearing can be applied to improve both at the expense of maximum speed (this is essentially what Chuck is suggesting, but a worm gear isn't the only option).

Title: What actuator types exist that remain locked in their last position like hydraulic piston?

Body: I would like to find an electronic actuator that mimics the characteristics of a hydraulic actuator, in that the position remains fixed without power drain when the actuator is not moving. Which actuators exist that match these criteria?</p>


答:
You are correct in that there is no Kinematic difference.

Kinematics do not consider why things happen - ie dynamic stability.

There are obvious physical differences, but when the math is worked out for kinematics, it should be the same. This of course implies a certain realistic cap on the level of kinematics. For example it has been pointed out a bicycle leans to steer, but that only occurs once a certain velocity is reached. Until then the kinematics are different. And once that velocity is reached Gyroscopic precession also becomes involved. One has to choose where reasonableness is satisfied. If you think all the physics can be modeled, I have some contacts at Yamaha motorcycle racing I'd like to introduce you to.

I found a PDF that describes the math in detail. The Kinematic math for ackerman is known as the bicycle model. Unless that's a crued joke, I would say it implies the correct answer to your question.

Title: Differences between Ackermann steering and standard bi/tricycles concerning kinematics?

Body:
I got the following homework question:

What are the general differences between robots with Ackermann steering and standard bicycles or tricycles concerning the kinematics?

But, I don't see what differences there should be, because a car-like robot (with 2 fixed rear wheels and 2 dependent adjustable front wheels) can be seen as a tricycle-like robot (with a single adjustable front wheel in the middle).

Then, if you let the distance between the two rear wheels approach zero, you get the bicycle.

So, I can't see any difference between those three mobile robots. Is there something I am missing?


问:
Kinect VS Stereo cameras
As I'm advancing in my project I realized I need better hardware, particularly for video input and processing.

From an intuitive feeling sounds like stereo cameras offers a more powerful and flexible solution, on the other hand the Kinect looks like a great out-of-the-box solution for depth sensing and it also takes away a lot of computational complexity as it output directly the depth.

So I would like to know what are the upsides and downsides of the 2 solutions and if they have any well known limitation and/or field of application and why.

Thank you

答:
Kinect:
Pro:

cheap

already calibrated

active system (works also on textureless surfaces)

dense stereo

Con:

defined range (low maximal range)

does not work good outdoors in direct sunlight

Stereo:

Pro:
- adjustable (different camera, different baseline possible for different ranges)

higher framerate possible

works outdoors

Cons:

hard to built right (cameras must not move at all)

higher computational load

no dense 3d (does rely on texture)

Title: Kinect VS Stereo cameras


问:
Kinect v1 VS Kinect v2
From a technical standpoint what are the differences between the Kinect v1 and the Kinect v2 ?

I'm interested both in the hardware equipment and the format of the data.

答:
Kinect 1 is a structured Light sensor, Kinect 2 is a Time of Flight camera.
Structured Light gives you better performance on edges where a ToF camera smoothes the data due to multipath-measurements.  ToF has less problems with ambient light.

What is your use case?

Title: Kinect v1 VS Kinect v2


答:
A latching relay remains fixed in its last position when power is disconnected.

A stepping switch is a specialized multi-position latching relay.

A circuit breaker, an earth leakage circuit breaker, a residual-current circuit breaker, etc. also remain fixed in its last position when power is disconnected.


问:
Extending iCreate battery power for auxilliary equipment
I plan to use the icreate as a platform to carry a tablet, or notebook PC and want to have power for some time so I need more than the 3000 mAh battery. I want all to be powered from same battery system and use same charging source. So I need info as to how to wire in additional 14.4V NiMH batteries in parallel with the existing and how to deal with the additional temperature sensors (I could ignore of course but...). Can the built in power control deal with this? Do I need to upgrade it somehow? I would appreciate suggestions as I do not want a completely separate power system for aux devices. Charging all from standard home base is the goal even though it will take longer. I can deal with adapting the 14.4V to whatever aux devices I add. Thanks.</p>

答: This project page describes many specifics of the Roomba power system.  I don't think it covers adding additional batteries in parallel, but probably has lots of other helpful information for you.</p>


问:
How to reduce battery power 10v 1.5A to 6v 1.5A
What's least complex way to reduce power from a 10V 1.5A battery to 6V 1.5A

Thank you!

答:
If your current requirements are indeed over an ampere,
use a buck converter, that is, switching DC-DC converter.  (For example, search for 6V 3A buck on ebay and you will see a lot of such converters for about $2.50 each, delivered.)  A buck converter's efficiency typically is 85 to 95%.  If you use resistors, your efficiency can be no better than 60%, and regulation will be quite poor:  you will get your desired voltage only at some certain current draw, and higher or lower voltages at other draws.

Here's a picture of a typical example.  It is labeled as 12V in, but it actually works with input voltages in the range from 8V to over 20V, ie, maintains close to 6V output for output currents up to 3A and input voltages from 8V to over 20V.


问:
Arduino compatible sensor for motion detection and positioning
I am working on a project that requires motion detection and positioning. I've worked substantially with a camera but the issue with this is that I need something sleek, small and not heavy at all. Cameras also tend to rely on luminosity and they don't work well in poorly lit spaces.

I need someone who's worked on something like this or who knows the best sensor for this purpose.

答:
"I am working on a project that requires motion detection and positioning"

Could a be bit more precise? In the title you just asked for motion detection, now you also want positioning.

What do you want to detect - a door or a fly? At which distance? With which accuracy? At which frame rate?

This would be something to at least detect motion and measure the distance to it: Infrared Sensor 4-30 cm - Sharp GP2Y0A41SK0F.


问:
How do I work out the specifications of motors and propellers for a quadcopter?
What will be the specifications of motors and propellers that can approx produce a thrust of 100kg in a quadcopter?

We are planning to lift a total weight of 50 Kg along with the 20 Kg weight of the quadcopter itself. So at 50% throttle the total thrust produced by it should be 150 Kg with a per motor total thrust of 37.5 kg.

I have looked at this answer to How to calculate quadcopter lift capabilities? but don't understand how to use this information to work out the specifications of motor and propeller required for my application.

The answer given in previous question is limited for small quad & I require the specifications of BLDC motor such as Kv,torque,Imax,V,Power,etc and of Propeller suitable for such motor.

答:
The other answer is perfectly adequate but I will run through the calculations for your quadcopter.

Normally the larger the load the lower the KVA (RPM per volt) of the motor required and the higher the voltage required, as lower KVA generally indicates more torque.

The larger the load the larger the prop required, a larger prop will produce more thrust at low RPMs but will require more torque to turn, choosing the right combination is key.

For large high performance motors, Tiger motor is my favorite (their are plenty of other venders but they are the one I am most familiar with)

For best performance in this size range I would choose the U10 range

For best controllability you want the quadrocopter to be able to hover at 50% or less of throttle, with your crafts total mass of 70kg and with a desired 4 motor configuration the motor thrust must be at least

70kg/4 = 17.5kg or 17400 grams at 50% throttle

Scrolling down you can see there thrust table and notice the largest thrust at 50% is 3254 grams (U10PLUS KV80@56v with a 30x10.5 prop), or 18% of what you need, you will need to go back to the drawing board, as in order to lift your load you would need 6 motors

Assuming your frame had to motos regularly spaced your frame would need to be 1.3m in diameter, at hover drawing 1.6kW and at peak over 10kW

This vehicle would be impracticable to build and fly, what are you hoping to do? 50kg is a tremendous amount of weight, can you tell us specifically what you're doing? we could then give better suggestions of how to accomplish it.


问:
Object Grasping Robot Arm Control
I have a 2 DOF Robot Arm with a camera attached to it. It takes an Image and there's an object in that image, say a glass. Of course, in order to move the arm to the required position to grasp the object, I have to solve the inverse kinematic equations. In order to solve them, I need the x and y, the coordinates where the arm has to reach to grasp the object. My question is how can I find the x and y of say the midpoint of the object from the image. Thanks </p>

答:
What you need is to know the position in (x,y) of the object with respect to your robot's arm. That is, you want to measure distance. You have several options:

Use a fiducial marker. By placing one of these images on your object, you can use an image processing algorithm to detect the marker and use its relative size and orientation to determine where the object is relative to the camera/your robot arm.
Common ones look like this:

Try looking for implementations of algorithms for reading fiducials in either ROS (Robot Operating System) modules or as functions in OpenCV.

Use a distance sensor. Some commonly used ones for hobbyists are ultrasonic and infra-red laser range finders. Place these sensors on your robot arm and have the sensor detect the object by looking for a "bump" in the reading, then calculate the distance to the object.

Use a stereo camera. You'll need to use an image processing algorithm to parse your camera outputs to detect how far away something is. Link

Use a Lidar laser range finder. These are probably out of your budget, as most of them cost between $1000 and several thousand dollars, but they can be used to generate a 3D map of your environment.

Side note: With only a 2DOF arm, you'll be limited to grasping your object in one of two configurations. (elbow in/out) You might consider using a 3DOF robot arm with a wrist so that you can more easily adjust your grasping angle.

Title: Object Grasping Robot Arm Control


问:
PID gains for motor position and velocity control
I have a servo motor with quad optical encoder and I'm trying to control its position and velocity. By controlling both I meant that if I input that the motor should reach 90° at 200rpm then it should. How can I do that? I am using an Arduino Uno. Kindly share some code if possible.

Though I have implemented the PID, I don't think it is correct because I didn't implement the feedforward controller (because I have no idea what that is) and I have not been able to find suitable gains for PID. The gains I find for small steps (or say degree rotation) do not work out well for large steps and vice versa. I have also not used a limit for integral sum (because I don't how much it should be).

I am using a Pittman motor.

答:
There are different ways to approach this problem, but in a general sense you could try this:

You have a PID controller for velocity.  It'll look something like this (untested code):

```
// PID Controller
struct PID
{
  float kP, kI, kD;
  float error, integral, derivative, previousError;
  float dT;
};<br/>
int computePID(PID* pid, float error)
{
  pid->error = error;
  pid->integral += error*dT;
  pid->derivative = (error - pid->previousError)/dT;
  pid->previousError = error;

  return pid->kP*pid->error + pid->kI*pid->integral + pid->kD*pid->derivative;
}

//Somewhere else
setArmMotor(computePID(&pid, some_error));
```

When you tune the constants right, you should be able to run your arm at a constant speed.  However, this is dependent that you have a fairly high resolution encoder, if you don't you won't have much of a way to controlling how fast your motors are spinning.

Now to control position, this will depend on your application.  The "easy" solution is to have another PID controller that controls position, where this new controller outputs a velocity instead of a motor power.

If you want a more "controlled" method of controlling velocity, you can use an acceleration profile.  For instance:

The code for this will look something like this:

float time = 0;
float enterSpeed = 0;
float maxSpeed = 10;
float exitSpeed = 0;
float speed = 0; // This is the variable that your PID's should correct to.
float acceleration = 1.0;
float distance = 100;

// Acceleration
while (speed < maxSpeed)
{
  speed = acceleration*time + enterSpeed;
  time+=1;
  delay(1);
}

// Kinematic Equations to calculate how far we need to maintain top speed for
float timeToStop = (exitSpeed-maxSpeed) / acceleration;
float distanceToStop
 = maxSpeed * timeToStop + 0.5 * acceleration * timeToStop * timeToStop;

// Maintain top velocity
while (encodersPosition + distanceToStop > distance)
{
  speed = maxSpeed;
}

// Deceleration
time = 0;
while (speed > exitSpeed)
{
  speed = maxSpeed - acceleration * time;
  time+=1;
  delay(1);
}

I did a lot of that memory, correct me if I messed up something. There are a lot of edge cases in that profile that isn't checked for, but that's the basic idea.

Body:
There are different ways to approach this problem, but in a general sense you could try this:

You have a PID controller for velocity.  It'll look something like this (untested code):

// PID Controller
struct PID
{
  float kP, kI, kD;
  float error, integral, derivative, previousError;
  float dT;
};

int computePID(PID* pid, float error)
{
  pid->error = error;
  pid->integral += error*dT;
  pid->derivative = (error - pid->previousError)/dT;
  pid->previousError = error;

  return pid->kP*pid->error + pid->kI*pid->integral + pid->kD*pid->derivative;
}

//Somewhere else
setArmMotor(computePID(&pid, some_error));

When you tune the constants right, you should be able to run your arm at a constant speed.  However, this is dependent that you have a fairly high resolution encoder, if you don't you won't have much of a way to controlling how fast your motors are spinning.

Now to control position, this will depend on your application.  The "easy" solution is to have another PID controller that controls position, where this new controller outputs a velocity instead of a motor power.

If you want a more "controlled" method of controlling velocity, you can use an acceleration profile.  For instance:

The code for this will look something like this:

float time = 0;
float enterSpeed = 0;
float maxSpeed = 10;
float exitSpeed = 0;
float speed = 0; // This is the variable that your PID's should correct to.
float acceleration = 1.0;
float distance = 100;

// Acceleration
while (speed < maxSpeed)
{
  speed = acceleration*time + enterSpeed;
  time+=1;
  delay(1);
}

// Kinematic Equations to calculate how far we need to maintain top speed for
float timeToStop = (exitSpeed-maxSpeed) / acceleration;
float distanceToStop
 = maxSpeed * timeToStop + 0.5 * acceleration * timeToStop * timeToStop;

// Maintain top velocity
while (encodersPosition + distanceToStop > distance)
{
  speed = maxSpeed;
}

// Deceleration
time = 0;
while (speed > exitSpeed)
{
  speed = maxSpeed - acceleration * time;
  time+=1;
  delay(1);
}

I did a lot of that memory, correct me if I messed up something. There are a lot of edge cases in that profile that isn't checked for, but that's the basic idea.


答:
Not technically a quadcopter, but if you use 6 Turnigy RotoMax 100cc motors, 24 inch props and 150A ESCs you ought to be able to get something close the the specs you are looking at. I used eCalc to arrive at these numbers.

some assumptions I made in the calcs:

your vehicle has 'excellent' motor cooling

it uses a 10000mAh 65C/100C 14s LiPo battery

it uses 24"x12" props with PConst=1.3 and TConst=1.0

Notice that this vehicle:

has a drive (motors+ESCs+batteries) that weighs 18.85kg

will be able to lift about 68kg (All-up weight + Add. Payload)

will fly for about 5-6 minutes

Please feel free to tweak the parameters to find the vehicle that works best for you.

Title: How do I work out the specifications of motors and propellers for a quadcopter?

Body:
What will be the specifications of motors and propellers that can approx produce a thrust of 100kg in a quadcopter?

We are planning to lift a total weight of 50 Kg along with the 20 Kg weight of the quadcopter itself. So at 50% throttle the total thrust produced by it should be 150 Kg with a per motor total thrust of 37.5 kg.

I have looked at this answer to How to calculate quadcopter lift capabilities? but don't understand how to use this information to work out the specifications of motor and propeller required for my application.

The answer given in previous question is limited for small quad & I require the specifications of BLDC motor such as Kv,torque,Imax,V,Power,etc and of Propeller suitable for such motor.


问:
Quadcopter multiple ESC angles glitch
I'm developing my fligth controller board on Tiva Launchpad for quadcoper and while calibrating PID I discovered an unexpected behaviour: sometimes quadcopter seems to experience random angle errors. While trying to investigate it, I've figured out that my code if fairly trying to compensate tham, as soon as they appear - but do not cause them. Even more - i've discovered that such behaviour appears only when two (or more) motors are adjusted, while one motor system shows pretty good stabilisation.

Here is code for PMW output for different motors:

```<code>torque[0] = (int16_t)(+ angles_correction.pitch - angles_correction.roll) + torque_set;
torque[1] = (int16_t)(+ angles_correction.pitch + angles_correction.roll) + torque_set;
torque[2] = (int16_t)(- angles_correction.pitch + angles_correction.roll) + torque_set;
torque[3] = (int16_t)(- angles_correction.pitch - angles_correction.roll) + torque_set;
</code>```

and here is recorded angles for system with one motor and two motors:

To be sure that it's not the algorithm problem, while recording this angles only Integral part of PID was non-zero, so angles were not even stabilised.

My question is - could esc noise each other (in my quad they are quite close to each other - just few sentimeters away) to cause such behaviour?
Thanks a lot!

答:
I don't know that there's enough information here to diagnose anything.

How can you get any angle on a quadcopter with only one or two motors running?

What do you mean, "while recording [these] angles only the integral part of PID was non-zero"?? Did you manually set the proportional and derivative errors or gains to zero?

My guesses would be that:

(1) you are supplying power to the motors as though they were a quadcopter when you have the physical configuration in something other than a quadcopter - you can't tune a stabilization algorithm with half of the stabilizers (motors) offline.

(2) don't monkey with the PID controller by turning off random portions and expecting performance to be the same.

(3) in general, I would avoid using the derivative term of a PID controller if at all possible (that is, use a PI controller instead). If noise causes a spike in your sensor reading for one sample then it doesn't add a lot to the P or I terms, but it causes a huge spike in the D term. Sensor noise may also play a part in your issues, but you can filter the sensor to check.

Title: Quadcopter multiple ESC angles glitch


问:
KUKA Robotics API IDE
I've got Robotics API library, a demo program and a robot. I want to develop an app for it. The best solution is offline development on some kind of simulator. I'm completely new in such tasks - is there any IDE for this? Or a way do deliver byte-code to machine? Thanks in advance!</p>

答:
If it's your first time, better off try with a simulator to check that your program doesn't break the robot's constraints or security configurations.
The most powerful simulator I came across is "V-REP", which is free for educational purposes.

V-REP is the Swiss army knife among robot simulators: you won't find a
  simulator with more functions, features, or more elaborate APIs.

The robot simulator V-REP, with integrated development environment, is
  based on a distributed control architecture: each object/model can be
  individually controlled via an embedded script, a plugin, a ROS node,
  a remote API client, or a custom solution. This makes V-REP very
  versatile and ideal for multi-robot applications. Controllers can be
  written in C/C++, Python, Java, Lua, Matlab, Octave or Urbi.

V-REP is used for fast algorithm development, factory automation
  simulations, fast prototyping and verification, robotics related
  education, remote monitoring, safety double-checking, etc.
  http://www.coppeliarobotics.com/index.html

and answering @ben:

I don't think there is any sort of IDE, the way VisualStudio or
  Arduino have IDEs. However, I do know that Kuka does have some fancy
  work-cell simulation and analysis software. This kind of thing is for
  laying out large industrial floor plans and optimizing efficiency.

In fact, KUKA's latest robots "LBR iiwa" come with a sophisticated Eclipse-based IDE called "KUKA Sunrise.Workbench.", you program your 7 DoF robot's arm directly with Java and Kuka's complete API.
And you still can program the robot with the control pendant (They call them SmartPAD) or C++ by communicating via a UDP interface called FRI (Fast Research Interface Library).

ContentLicense: CC BY-SA 4.0

Title: KUKA Robotics API IDE


问:
How to balance a flying quadcopter?
I'm using my own code to create a quadcopter robot. The hardware part is done but I need to balance the copter.

The original video demonstrating the problem was shared via dropbox and is no longer available.

I have tried to play with the speed of each motor to get it balanced. It didn't go.
I actually have a gyro and accelerometer onboard. But how shall I adjust the motor speed based on these values? What are the rules that I should beware of?

Is there any better solution other that try and error? Where shall I begin? Any tips?

答:
I believe a little Googling and you will find several of the existing controller boards have open source. For example I made a small change to hobby kings KK board last week, compiled it and it was fine (look for firmware 1.5 in the files tab). I think openAero is also readily available.

I sure would not try and start from scratch, but if you do, it is multiple PID loops on each axis, mixed with control signals from the receiver. Roll and pitch vary by changing motor speed as you guessed. Yaw is changed by changing opposite rotating pairs of motors. altitude is controlled by changing all motors at once. What code I have looked at leads me to believe you probably should be comfortable with euler angles in order to fuse sensor data from gyros and acceleration (which may or may not be I2C so learn that to if you are not familiar with it).

Title: How to balance a flying quadcopter?


问:
What is required to build a simple XY-stage?
In the scope of my PhD, I would like to build an automated microscopy set-up that should take images of a sample of 2cm by 2cm. This should be done by taking pictures of 500 micrometers by 500 micrometers.

Therefore I need to design an XY-stage moving my sample over the optical setup. I would use a Raspberry Pi to steer all the hardware.

Could you direct me to material about how to best make an XY-stage ? My questions are about what types of motors to use (stepper?), how many, how to create a good sliding mechanism to avoid jerky steps, etc.

Simple links to basic engineering of such set-ups would be more than enough for me to start, as I am a complete layman in this field.

EDIT: I have found this blogpost. It does what I require, if I get small enough angle step stepper motors.

EDIT2: I need a maximal range of motion of 10 cm in both directions. The overall size should not exceed 30x30 cm^2. Step sizes should not exceed 10 microns. I do not care about moving speed. Based upon the design in the link, buying a stepper motor with a 100:1 gear box could allow my very small radial steps (<0.05 deg) which would result in about 5 micron steps, assuming a rotor radius of about 1cm.
As far as price goes, it should not exceed commercially available options which start at about 5k USD

答:
Simple X-Y stages are well understood and form the basis for the many open source hardware projects for 3D printers.

Each axis of an XY stage can be made from a pair of 6mm stainless steel rods, three LM6UU 6mm Linear Ball Bearings, a stepper motor (typically a NEMA14/17/23 motor) and stepper driver electronics. These axes can then be connected to the Digital IO on your Raspberry Pi.

If you have access to a 3D printer, then many of the components needed to link these elements together can be downloaded and printed out. If you don't, and don't want the expense of getting a bureau to print these parts for you, then they could be fabricated in a workshop by drilling and cutting plastic, metal or even wooden blocks. If you can find appropriate the 3D (as used by 3D printers), you should be able to extract all of the information you need to fabricate them manually.

In terms of driver electronics, I would suggest that you have a look at the Open Source dual stepper motor driver by folknology, as this is a simple double sided PCB design which uses entirely through-hole components (great if you aren't too handy with the surface mount soldering required by many designs).

The XY Table blog post you posted by Geir Andersen provides a pretty good example of how to do this. The only thing I would question would be the use of two bearings on the upper stage (one per rod) and what appears to be 4 bearings on the lower stage (two per rod). I would suggest using three on each instead.

You might assume that you would want each rod to have two bearings each (the symmetry appeals aesthetically), but you get better performance, stability and accuracy by putting two bearings on one rod (usually the one closest to the drive belt) and only one bearing on the other rod, so you effectively have a leader and a follower. This prevents over-constraint, where movement is not smooth because one end is fighting the other (both trying to be 'leaders' keeping the beam perpendicular to the rod).

Similarly, only two bearings is under constrained. This is fine when your load and/or speed is low, but doesn't do as well with keeping your beam perpendicular to the rod as a three bearing system would.


问:
Is anybody using robot simulators?
Do you use simulators for developing your robot algorithms or do you test directly in your robot?
I would like to get introduced into the simulators world, but don't know from where to start... can you recommend me one?

Regards

答:
I test everything in simulation I possibly can before I run on a real robot. I use V-REP extensively and have been extremely happy with it. The developers are extremely responsive and there is a free to use version for non-commercial purposes. They also have a great demo video outlining the features in V-REP.

I've also spent a couple of months using gazebo, which is completely open source and did work for many of the basics. I moved away from it at the time because they tend to like to take their own path with fun features like new communication protocols and from scratch API implementations that aren't necessarily critical to actually simulating robots, these libraries unnecessarily re-implement existing libraries that are well written and widely used like eigen. This is based on my interactions on the mailing list and bitbucket, in addition to the experiences of others I know.

Title: Is anybody using robot simulators?


问:
Degree of Freedom
A robotic arm should pick a cuboid up of a table, rotate it around its vertical axis and put it down on all possible positions. How many degrees of freedom are at least necessary?
(All coordinates, that should be reached by the robotic arm, are in its workspace. It is not allowed to put the cuboid down and pick it up, once the robot has it )

The answer is  4 (3 translatory and 1 rotatory).

But I don’t understand why. I thouhgt that it should be 3.
2 prismatic joints:  1 to pick the cuboid up,  and another one to move it anywhere on the table.
1 revolute joint to rotate the cuboid around its vertical axis. => 2 translatory and 1 rotatory.

答: The answer is four. The arm needs to be able to move up and down, left and right, forward and backward, and rotate. The robot will need 3 translatory degrees of freedom and 1 rotatory. </p>

Title: Degree of Freedom


答: You specified that you need to be able to pick a cuboid up [off] a table(1 dof), rotate it around its vertical axis (1 dof), and put it down on all possible positions - assuming this means, "put it down at any (x,y) coordinate", then you need two more degrees of freedom - one for $x$, one for $y$. Note the implementation may vary - you could use Cartesian (x,y) actuators or you could use Polar (r,$\theta$), but whatever the combination you still wind up with two degrees of freedom.

Title: Degree of Freedom

Body:
A robotic arm should pick a cuboid up of a table, rotate it around its vertical axis and put it down on all possible positions. How many degrees of freedom are at least necessary?
(All coordinates, that should be reached by the robotic arm, are in its workspace. It is not allowed to put the cuboid down and pick it up, once the robot has it )

The answer is  4 (3 translatory and 1 rotatory).

But I don’t understand why. I thouhgt that it should be 3.
2 prismatic joints:  1 to pick the cuboid up,  and another one to move it anywhere on the table.
1 revolute joint to rotate the cuboid around its vertical axis. => 2 translatory and 1 rotatory.


问:
Voltage rpm relation
I measure the voltage ESC drawing while increasing the dc motor speed. Multimeter shows that as long as the speed increases the voltage value decreases. Can anybody explain why this is happening? </p>

答:
I think the answer here should be insightful. But basically when the motor is running, you're working under the equation

P=V*I

This equation has to stay balanced, so assuming your (P)ower remains a fixed value, then if (V) changes, current (I) has to make and opposite change in order to keep the equation balanced. In this instance, current (I) increases as speed increases, thus you get a related decrease in (V)oltage in order to maintain the balance.

EDIT: My answer is flawed because as pointed out in the comments, the assumption of power being fixed is wrong and doesn't make any sense.

Title: Voltage rpm relation


问:
How can I best protect sensitive components against damage through vibration?
It's common for components on some types of robots to experience large environmental stresses, one key one being vibration. Is this something I need to worry about with typical electronics and other sensitive components, or not really? If it is, then how do I secure such components?

I've heard of two main philosophies behind this, the first being that you should use a damping system such as with springs to absorb the shock. The second is that you should keep everything rigidly in place so it can't move, and therefore can't hit against anything else and break.

Which one should I follow, or if the answer is "it depends" what should I use as a guide as to best protect sensitive components?

答:
Components should have vibration ratings somewhere.  Pretty much anything without moving parts will be fine.  Some sensors such as accelerometers and gyroscopes are affected.

As an example, quadrotors are an application that is dramatically affected by vibration.  The four props produce an absolutely ridiculous amount of vibration and a quadrotor requires accurate sensor data from the accelerometers/gyros.  If you look at the accelerometer plots you will see an unbelievable amount of noise.

Despite this, very few quads have any form of vibration damping, a kalman filter is enough to get good data.

There is a lot of literature of vibration damping and several possible approaches (both active and passive).

I have found that memory foam is ideal for damping vibrations to electronics and small sensors such as accel/gyro.  Memory foam is very soft but more importantly is designed to dampen extremely well.  I have cut down accelerometer noise on UAVs by ~80% by using memory foam in the past.


问:
Protecting electronics against voltage/current extremes and bad polarity
I have built a robot from a wheelchair that has worked very well thus far. It is now time for me to take the next step. I need to implement a permanent power circuit with proper protection.

The lowest level of protection I can think of is a fuse, but I would like to take a step further (current/voltage/direction/switches/High/Low voltages). If some one could give some insight on this project of mine any info will be greatly appreciated.

Moderator comment:  Please see How do we address questions about related subject areas? before answering.  This question is close to the boundary, but is on-topic here.

答:
Keeping with the idea of robotics-relevant answers, another thing to take into consideration for mobile/wheeled robotics (albeit not so much with a wheelchair unless you plan to take it off-roading) is vibration and shock. In reviewing your design, ask yourself: is there anything that's going to come loose? Think connectors that aren't a very snug fit or jumper wires connected to a header pin.

There's been some questions with great answers on Electronics.SE that cover this area at the PCB level:

SMD vs. Through-hole components in high vibration environments

Board Design for High Impact Environments

While this is a pushing outside the scope of the question, be sure to account for disconnect/power loss conditions in software when possible as well. There's not a whole lot you can do on the power side if it's a single-supply system, but if you have multiple subsystems powered off of different supplies, you can monitor supply voltages so that one component can be aware of a failure elsewhere and act appropriately.

If your robot is controlled over a serial interface and the onboard controller can't get some kind of "heartbeat" signal from the host system, it needs to fail gracefully and not go careening down a hallway uncontrolled because the last command it received was "go forward".


答:
Good answers already, so I just thought I'd address this bit:

But I don’t understand why. I thought that it should be 3. 2 prismatic joints: 1 to pick the cuboid up, and another one to move it anywhere on the table. 1 revolute joint to rotate the cuboid around its vertical axis. => 2 translatory and 1 rotatory.

Not quite correct: though it seems from your question that only three would be required, in reality you need a fourth to rotate the "gripper" to pick up the item.  UNLESS you have some sort of magnetic pickup, or a specially shaped item like a cylinder - then three might work as a special case, but that would no longer be a general purpose manipulator.

Title: Degree of Freedom


答:
You can't understand this because you don't know what you observe. The electromotive force (EMF) of your motor is proportional to its speed (the ratio is called Kv). So, when the speed of your motor rises, the EMF rises too.

What does an ESC ? Basically, it hashes the input voltage to generate the expected output voltage.

So, what is this decreasing voltage value you observe ? It won't be the output voltage of the ESC, because it's rising, not falling, and, as it is hashed, you probably can't measure it with your multimeter (basic multimeters only measure continuous or sinusoidal signals).

I expect the decreasing voltage to be the input of your ESC. Why would it drop ? Because your driving a motor with a load that rises with speed (typically a propeller), and this requires current. The wires between your battery and your ESC are resistors. Let say you have 50mOhms of resistivity. If you uses 10A, the input voltage of your ESC is 0.5V less than your battery output. Moreover, your battery also have internal resistivity. If you drive more current, the output voltage of your battery drops too.

Title: Voltage rpm relation

Body: I measure the voltage ESC drawing while increasing the dc motor speed. Multimeter shows that as long as the speed increases the voltage value decreases. Can anybody explain why this is happening? </p>


问:
increase PID sampling rate on embedded system
my robotic project is running at every 1ms and the processes are taking about 0.9ms. I am running PID so my max clock rate is 1kHz. About half of the processing time are taken by SPI peripherals, IMU and encoders. Is there any recommendation on how I can run faster PID sampling rate?</p>

答:
Increasing the sample rate probably isn't going to buy you much if you can't do something useful. That is, if you don't update the control signal (e.g., motor current) at the same high sample rate, then I don't think you're going to gain much. Similarly, if your IMU or other sensors don't update at the higher frequency, polling them at a higher frequency isn't going to get you much either.

You need high frequency feedback, high frequency output, and the headroom to process at those high frequencies. If you could increase the PID sample rate, if you're still relying on the 1kHz process to provide the output then you haven't gained much. However, note that the input frequency doesn't matter too much; at a bounding very low frequency input the controller would interpret the reference like a step input, but you still get PID control/stability.

What I would suggest is either going with a faster processor or (preferred) splitting PID off into its own processor. Use a "master" to interface with the user, generate a reference signal, then pass that reference off to the PID controller. Doing this frees up the PID controller to handle only the relevant feedback (sensors) and outputs (motors).

For example, say you are running a quadcopter. The master controller gets the motion control input from the pilot, but also gets periphery input from the pilot, for things such as maybe camera gimbal control, camera control, lighting/display control, audio, heartbeat messages, feedback vehicle parameters to the pilot, etc.

Of all of these things, parse the motion refernce (pitch/roll/yaw/thrust etc.) and pass that off to the PID control chip.

Now the PID control chip gets the motion reference at the 1kHz input, but the reference doesn't need to update very quickly. The PID control chip can now focus only on polling the IMU/compass/other sensors, calculating reference-feedback errors, and modifying the outputs.


问:
Low variance resampling algorithm for particle filter
For my particle filter, I decided to try using the low variance resampling algorithm as suggested in Probabilistic Robotics. The algorithm implements systematic resampling while still considering relative particle weights. I implemented the algorithm in Matlab, almost word-for-word from the text:

```<code>function [state] = lowVarianceRS(prev_state, weight, state_size)
    state = zeros(1,state_size);    % Initialize empty final state
    r = rand;                       % Select random number between 0-1
    w = weight(1);                  % Initial weight
    i = 1;
    j = 1;

    for m = 1:state_size
        U = r + (m - 1)/state_size; % Index of original sample + size^-1
        while U > w                 % I'm not sure what this loop is doing
            i = i + 1;
            w = w + weight(i);
        end
        state(j) = prev_state(i);   % Add selected sample to resampled array
        j = j + 1;
    end
end
</code>```

As would be expected given the while loop structure, I am getting an error for accessing weight(i), where i exceeds the array dimensions.

To solve this, I was considering circularly shifting my weight array (putting the first index used as the first value in weight, so that I never exceed matrix dimensions). However, I wasn't sure if this would negatively impact the rest of the algorithm, seeing as I'm having trouble understanding the purpose of the U calculation and while loop.

Could anyone help clarify the purpose of U and the while loop, and whether or not a circular shift is an acceptable fix?

答:
I misread the text. r should be a random number between 0 and M^-1. Changing this should solve all your problems.

The re-sampling algorithm's purpose is (roughly) to remove particles that have a low probability of representing the system that you're tracking. This is done by stacking the all particles together. Each particle's size is equal to the probability that it represents the system. So the weight of all the particles is 1 or %100. Now M random spots on this range of particles are chosen and the particles that occupiesy those spots are kept. Particles that are not chosen are discarded.

The low variance re-sampling algorithm splits the particle range space into M sections and keeps the particle occupying the rand(0,M^-1) spot at each section. This is what U is, the random spot on the jth section of the probability space.

The advantage of the low variance re-sampling algorithm is the ease of implementation and it's robustness. If we randomly choose a spot M times, there is a non zero chance we could get the same particle each time. This could cause huge problems for the filter.

ignore:
It looks like your random weight r should have a standard deviation of M^-1.


问:
Arduino original or generic for a beginner?
I'm new to the robotics and electronics world, but I'm willing to dive into it. I'm a software developer and I want to create a project that uses GPS and Accelerometer data to show as a layer on Google Maps after transferred to PC.

My doubt is about which controller to get. In my country, there are generic controllers based on the Atmega328 that are being sold with a massive difference of price from the original Arduino (talking about the UNO model).

Should I start with an original model?

Should I expect to break the controller, fry it, or break any components by connecting them wrong?

Would the experience with a generic controller be less exciting than with the original Arduino one?

答: Many of generics works fine but there are difficulties like FTDI driver, working frequency, regulator voltage differences, etc. I'm still using imitations with many different projects. I couldn't fry any of them. But do not connect over 5 volt.</p>


问:
Prototyping with IRobot roomba
For a project I am building a Tele-Op Robot using the IRobot's Roomba as my drivetrain. In order for my robot to work, I need an extra castor. IRobot provides .stl and .stp files for me to use and I used them and printed the files. (The file I printed was from this link: Create® 2 Bin Modification.

This file is a new part to the drivetrain to allow another caster.

And I downloaded the first link called "Full bin bottom with caster mount"

The piece was great but it made the castor a different height then the wheels. I was wondering if anyone had this file but saved as something different so I can edit it in preferably Solidworks. I was on the phone with IRobot for over 2 hours today and they told me to post here. So please help!!!! :)

答: Are you having trouble importing the file? I'm not sure what the problem you're having is. You can edit the file in Solidworks; just import the STL, then edit the file.</p>

Title: Prototyping with IRobot roomba


问:
Quadcopter liPo battery weight/capacity trade off
I'm trying to find where additional battery capacity becomes worthless in relation to the added weight in terms of a quadcopter. Currently with a 5500 mAh battery, 11.1V, I can get between 12 minutes and 12:30 flight time out of it. My question, then, is this - within the quads lifting capability of course, is there any way to find out where the added weight of a larger battery (or more batteries) cancels out any flight time improvement? Obviously it's not going to be as long as two separate flights, landing and swapping batteries; I'm just trying to maximize my continuous 'in air' time. I'm trying to figure out where the line is (and if I've already crossed it) with tacking bigger batteries onto the quad and seeing diminishing returns. Thanks!

(Again, for now presume that the quad is strong enough to lift whatever you throw at it. With one 5500mAh, ~ 470 grams, my max throttle is about 70%)

答:
And how about a little experimenting?

I would take the lightest battery i can find and then try adding weights.
For each weight I would measure the flight time, make a "flight time / mAh" vs "takeoff weight" plot and fit a curve through the data points. Then I'd go to hobbyking and for every battery pack there I'd calculate flight time using my new magical graph. Find maximum and you're done :-)


问:
DC Motor PID control with unstable velocity feedback
Currently I am building a omnidirectional robot with 4 DC Motors with embedded incremental encoder.

However, with a constant pwm input, i am not able to control the motor to rotate in a "relatively stable" state, refer to the figure, it can be observed that the linear speed of the motors can varied in 10cm/s range. I believe one possible reason is the PWM signal generated from my Arduino Mega Controller is not good enough.

And my problem is how can I implement a stable PID controller in this case? As the speed of the motor varies even with the same input, I believe extra work like adding a filter is needed?

Any advice is appreciated >.< Thank you

答:
I have used Arduino and the PWM signal worked fine.

Have you tried supplying the motors from a DC power source, just to see how they react to a constant DC power signal, not a PWM?


问:
Formationing Algorithm for Multiple Robots
I'm looking for an algorithm for formationing multiple robots in 2D simulation. Can you suggest resources about this topic. Also I need suggestions and comments about these topics:

Can I recruit algorithm from optimization algorithms like particle or ant?

Is there any way except "go to goal" for each robot

Is patter formationing algorithms feasible?

Suggestions about a fast way of formationing/ aligning

Notes:

Im not using a robotics simulator or physics engine for this.

Robots are represented as dots.

multi robot system is homogeneous

every robot can sense obstacles and other robots in a sense range circle around the robot.

number of obstacles and robots can vary from 2 to 100

multi robot system is not a central

答: You could have a look at the papers of the kilobot project. They have your capabilities so it would be a good starting point. </p>


答:
The caster shaft can potentially not seat right causing canting of the robot.

Can you share pictures of your print? I have had good luck with printing the files posted on the iRobot thingiverse page.

Title: Prototyping with IRobot roomba

Body:
For a project I am building a Tele-Op Robot using the IRobot's Roomba as my drivetrain. In order for my robot to work, I need an extra castor. IRobot provides .stl and .stp files for me to use and I used them and printed the files. (The file I printed was from this link: Create® 2 Bin Modification.

This file is a new part to the drivetrain to allow another caster.

And I downloaded the first link called "Full bin bottom with caster mount"

The piece was great but it made the castor a different height then the wheels. I was wondering if anyone had this file but saved as something different so I can edit it in preferably Solidworks. I was on the phone with IRobot for over 2 hours today and they told me to post here. So please help!!!! :)


问:
Optimal hardware for linear algebra operations
I've been working lately on SLAM algorithms implementing extended kalman filtering to brush up on some localisation techniques and I have been thinking forward to the hardware side of things. Are there embedded chips such a microcontroller that are optimised for large linear algebra operations? What sort of embedded options are the best for processing these sorts of operations?</p>

答: I wouldn't call it an optimal solution but I've been working with some odroid XUs and have been very happy with their behavior. I'm using the Eigen linear algebra library along with ros and opencv.</p>


问:
Determine what the rotation axis is given a rotation matrix
How do I find out around which axis the coordinate system has to rotate, if the rotation matrix is given?

$ {^{a}R_{b} } $ = $ \left(\begin{matrix} 0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1 \\\end{matrix}\right)$

$ {^{a}R_{c} } $ = $ \left(\begin{matrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \\\end{matrix}\right)$

For $ {^{a}R_{b} } $ I thought, that it has to be a rotation around the z-axis, because
$R(z,\theta) =  \left(\begin{matrix} cos(\theta) & -sin(\theta) & 0 \\ sin(\theta) & cos(\theta) & 0 \\ 0 & 0 & 1 \\\end{matrix}\right)$

the values at the positions $a_{13}, a_{23},a_{33},a_{32},a_{31}$ of $ {^{a}R_{b} } $ and $R(z,\theta)$ are identical.

So I solved $cos(\theta) = 0$ =>$\theta = 90° $ => 90° rotation around z-axis.

But how do I solve it, if there is more than 1 rotation, like for $ {^{a}R_{c} } $?

答:
For starters, the product of rotation matrices are not unique.

Any orientation can be achieved by composing three elemental rotations.1

To recover a set of rotation angles you'll need to start with the full rotation matrix and then work backwards. Let's look at a 3-2-1 rotation.

$ {R_{321} } $ = $ \left(\begin{matrix}
cos\theta cos\phi & cos\theta sin\psi & -sin\theta \\
sin\phi sinθcosψ−cos\phi sinψ & sin\phi sinθsinψ+ cos\phi cosψ & sin\phi cosθ \\
cos\phi sinθcosψ+ sin\phi sinψ & cos\phi sinθsinψ−sin\phi cosψ & cos\phi cosθ \\
\end{matrix}\right)$

We can now solve for $\theta$. This can be used to solve for $\psi$ and $\phi$. Looking at your $^aR_c$ matrix, we can find the $\theta$ is $-\frac{\pi}{2}$, $\psi$ is $-\frac{\pi}{2}$, and $\phi$ is 0.

__

More on recovering euler rotations.


答:
From the Wikipedia article on conversion between the rotation matrix and Euler axis/angle:

Given a rotation matrix:
$$
\
R
= \begin{bmatrix}
r_{11} & r_{12} & r_{13}\\
r_{21} & r_{22} & r_{23}\\
r_{31} & r_{32} & r_{33}
\end{bmatrix}
\\
$$

You can get the rotation angle:
$$
\theta = \cos^{-1} \left[ 0.5(r_{11} +r_{22} + r_{33} - 1) \right] \\
n_x = \frac{r_{32} - r_{23}}{2 \sin(\theta)} \\
n_y = \frac{r_{13} - r_{31}}{2 \sin(\theta)} \\
n_z = \frac{r_{21} - r_{12}}{2 \sin(\theta)} \\
$$

So, given your first problem:
$$
R
= \begin{bmatrix}
0 & 1 & 0\\
-1 & 0 & 0\\
0 & 0 & 1
\end{bmatrix}
\\
$$

$$
\theta = \cos^{-1} \left[ 0.5(0 +0 +1 - 1) \right] \\
\theta = 1.57 \mbox{rad} = 90^{\circ} \\
n_x = \frac{0 - 0}{2 \sin(90^{\circ})} \\
n_y = \frac{0 - 0}{2 \sin(90^{\circ})} \\
n_z = \frac{-1 - 1}{2 \sin(90^{\circ})} \\
n_x = 0 \\
n_y = 0 \\
n_z = -1 \\
$$
So you can see here that, for your first problem, you rotate 90 degrees about the -z axis, or equivalently, you rotate -90 degrees about the +z axis.

Similarly, for your second problem:
$$
R
= \begin{bmatrix}
0 & 0 & 1\\
1 & 0 & 0\\
0 & 1 & 0
\end{bmatrix}
\\
$$

$$
\theta = \cos^{-1} \left[ 0.5(0 +0 + 0 - 1) \right] \\
\theta = 2.09\mbox{rad} = 120^{\circ} \\
n_x = \frac{1 - 0}{2 \sin(120^{\circ})} \\
n_y = \frac{1 - 0}{2 \sin(120^{\circ})} \\
n_z = \frac{1 - 0}{2 \sin(120^{\circ})} \\
n_x = 0.577 \\
n_y = 0.577 \\
n_z = 0.577 \\
$$

Here you have an axis of rotation that is x=y=z=0.577 (but could be scaled to, say, x=y=z=1, just for thinking about the nature of the rotation), and then you rotate +120 degrees about that axis.

Hope this helps; please comment if I've left something unclear.

Title: Determine what the rotation axis is given a rotation matrix

Body:
How do I find out around which axis the coordinate system has to rotate, if the rotation matrix is given?

$ {^{a}R_{b} } $ = $ \left(\begin{matrix} 0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1 \\\end{matrix}\right)$

$ {^{a}R_{c} } $ = $ \left(\begin{matrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \\\end{matrix}\right)$

For $ {^{a}R_{b} } $ I thought, that it has to be a rotation around the z-axis, because
$R(z,\theta) =  \left(\begin{matrix} cos(\theta) & -sin(\theta) & 0 \\ sin(\theta) & cos(\theta) & 0 \\ 0 & 0 & 1 \\\end{matrix}\right)$

the values at the positions $a_{13}, a_{23},a_{33},a_{32},a_{31}$ of $ {^{a}R_{b} } $ and $R(z,\theta)$ are identical.

So I solved $cos(\theta) = 0$ =>$\theta = 90° $ => 90° rotation around z-axis.

But how do I solve it, if there is more than 1 rotation, like for $ {^{a}R_{c} } $?


问:
MATLAB 3D Simulation with SOLIDWORKS model
I'm learning  to make a 3D simulation in MATLAB based on a model designed from SOLIDWORKS.
There is an example: SIMULINK+SOLIDWORKS

The way used here is:

Create a 3D model in SOLIDWORKS

Create a xml file applicable to import to MATLAB via SimMechanics Link

Import the model to MATLAB/SIMULINK. A simulink system is created.

After these steps, controlling the system will be implemented in SIMULINK.
But I feel simulink is kind of strict to control. I want to be more flexible, apply any algorithm to the model. And using matlab *.m file to control is more efficient way.

So my question is this: Is there any way to do 3D simulation (MATLAB+SOLIDWORKS) by using only *.m file to control, no SIMULINK anymore?

All model information will be contained in the *m.file. Maybe the step 1 and 2 are inherited, but step 3 is different.

答:
I use CAD software to generate 3D models, convert those 3D models to an STL format, then load those STL files to Matlab with the following script:

```<code>function [points,success] = LoadSTL(path)
% LoadSTL loads an ASCII STL file with units in [mm].
% The output is a structure array where each element in the array is
% a vertex.
%
% [points , success] = LoadSTL(path)
%
% path = String containing the path and extension of the file to be loaded.
% points = Matrix of locations where each column is a vertex, rows are x/y/z/1:
%    points(1,:) = x
%    points(2,:) = y
%    points(3,:) = z
%    points(4,:) = 1
%           NOTE - every three columns is a new face/facet.
% success = Bit indicating if the file was successfully opened or not.

success = 0;
fileID = fopen(path);
if fileID <0
    fprintf('File not found at path %s\n',path);
    return;
end
fprintf('Loading Path %s...\n',path);
fileData = fread(fileID,'*char');
eol = sprintf('\n');
stlFile = strsplit(fileData',eol);
fclose(fileID);
fprintf('Done.\n')
pause(0.25);
clc
assignin('base' , 'stlFile' , stlFile)
pointsTracker = 1;
for i=2:size(stlFile,2)
    if mod(pointsTracker,100)==0
        clc
        fprintf('Parsing file at %s...\n',path);
        fprintf('Currently logged %d points\n',pointsTracker);
    end

    testLine = stlFile{i};
    rawStrip = strsplit(testLine , ' ' , 'CollapseDelimiters' , true);
    if numel(rawStrip) == 5
        points(1,pointsTracker) = str2double(rawStrip{1,3})/1000;
        points(2,pointsTracker) = str2double(rawStrip{1,4})/1000;
        points(3,pointsTracker) = str2double(rawStrip{1,5})/1000;
        points(4,pointsTracker) = 1;
        pointsTracker = pointsTracker + 1;
    end
end
disp('Done.')
pause(0.25);
clc;

if mod(size(points,2),3) > 0
    disp('File format in an unexpected type.')
    disp('Check the file specified is an STL format file with ASCII formatting.')
    disp('(Error - number of vertices not a multiple of 3)')
    disp(numel(points.x))
    return;
end

success = 1;
return;
</code>```

Once this is done I save the resulting output (points) as a .mat file and load exclusively from that .mat instead of the STL file because the .mat file loads significantly faster than parsing the STL file every time.

Once you've loaded the file, you can quickly plot the STL file in Matlab with the following command:

```<code>myPlotColor = [0.5 0.5 0.5];
nFaces = size(points,2)/3;
patch(...
    reshape(points(1,:),3,nFaces) , ...
    reshape(points(2,:),3,nFaces) , ...
    reshape(points(3,:),3,nFaces) , ...
    myPlotColor);
</code>```

At this point, standard Matlab plot commands work; e.g., axis equal, hold on, etc.

Now, given how to load and display STL files in Matlab plots from an m-file, you can go about doing whatever form of control you want. Transform the CAD file with any 4x4 transform matrix composed of a rotation matrix $R$ and translation vector $s$:

$$
\mbox{transformedPoints} = \begin{bmatrix}
 & R& & s \\
0 &0 &0& 1 \\
\end{bmatrix}
\mbox{points}
$$

Plot the transformed points with the patch command shown above. As long as you've generated your CAD model such that the origin of your 3D model corresponds with the origin of your mathematical model then any movement/rotation of the mathematical model about its origin can be correctly applied to the CAD model, which can then be displayed.

I'd just like to reiterate that this file loads STL files that are in ASCII format with units in millimeters, and the resulting plot is with units in meters, but of course you can change that with the /1000 scaling during the loading of the file.

Body:
I use CAD software to generate 3D models, convert those 3D models to an STL format, then load those STL files to Matlab with the following script:

function [points,success] = LoadSTL(path)
% LoadSTL loads an ASCII STL file with units in [mm].
% The output is a structure array where each element in the array is
% a vertex.
%
% [points , success] = LoadSTL(path)
%
% path = String containing the path and extension of the file to be loaded.
% points = Matrix of locations where each column is a vertex, rows are x/y/z/1:
%    points(1,:) = x
%    points(2,:) = y
%    points(3,:) = z
%    points(4,:) = 1
%           NOTE - every three columns is a new face/facet.
% success = Bit indicating if the file was successfully opened or not.

success = 0;
fileID = fopen(path);
if fileID <0
    fprintf('File not found at path %s\n',path);
    return;
end
fprintf('Loading Path %s...\n',path);
fileData = fread(fileID,'*char');
eol = sprintf('\n');
stlFile = strsplit(fileData',eol);
fclose(fileID);
fprintf('Done.\n')
pause(0.25);
clc
assignin('base' , 'stlFile' , stlFile)
pointsTracker = 1;
for i=2:size(stlFile,2)
    if mod(pointsTracker,100)==0
        clc
        fprintf('Parsing file at %s...\n',path);
        fprintf('Currently logged %d points\n',pointsTracker);
    end

    testLine = stlFile{i};
    rawStrip = strsplit(testLine , ' ' , 'CollapseDelimiters' , true);
    if numel(rawStrip) == 5
        points(1,pointsTracker) = str2double(rawStrip{1,3})/1000;
        points(2,pointsTracker) = str2double(rawStrip{1,4})/1000;
        points(3,pointsTracker) = str2double(rawStrip{1,5})/1000;
        points(4,pointsTracker) = 1;
        pointsTracker = pointsTracker + 1;
    end
end
disp('Done.')
pause(0.25);
clc;

if mod(size(points,2),3) > 0
    disp('File format in an unexpected type.')
    disp('Check the file specified is an STL format file with ASCII formatting.')
    disp('(Error - number of vertices not a multiple of 3)')
    disp(numel(points.x))
    return;
end

success = 1;
return;

Once this is done I save the resulting output (points) as a .mat file and load exclusively from that .mat instead of the STL file because the .mat file loads significantly faster than parsing the STL file every time.

Once you've loaded the file, you can quickly plot the STL file in Matlab with the following command:

myPlotColor = [0.5 0.5 0.5];
nFaces = size(points,2)/3;
patch(...
    reshape(points(1,:),3,nFaces) , ...
    reshape(points(2,:),3,nFaces) , ...
    reshape(points(3,:),3,nFaces) , ...
    myPlotColor);

At this point, standard Matlab plot commands work; e.g., axis equal, hold on, etc.

Now, given how to load and display STL files in Matlab plots from an m-file, you can go about doing whatever form of control you want. Transform the CAD file with any 4x4 transform matrix composed of a rotation matrix $R$ and translation vector $s$:

$$
\mbox{transformedPoints} = \begin{bmatrix}
 & R& & s \\
0 &0 &0& 1 \\
\end{bmatrix}
\mbox{points}
$$

Plot the transformed points with the patch command shown above. As long as you've generated your CAD model such that the origin of your 3D model corresponds with the origin of your mathematical model then any movement/rotation of the mathematical model about its origin can be correctly applied to the CAD model, which can then be displayed.

I'd just like to reiterate that this file loads STL files that are in ASCII format with units in millimeters, and the resulting plot is with units in meters, but of course you can change that with the /1000 scaling during the loading of the file.