问:
How to perform this reference system transformation?
I have two quaternions that indicate the initial orientation of a four wheel robot, each one in relative to one reference systems.

The robot's orientation given by a quaternion q is not the same in the two reference systems: For one reference system the quaternion q1 might refer to the robot looking at positive x while the same quaternion components q1 in the second reference system might refer to the robot looking at the negative x.

I have two matrices which indicate the position of the robot in time in its correspondent reference system.

I want to find the correspondent points of the first matrix in to the second reference system. Each matrix is built with a different sensor, so the results will be similar but not exactly the same.

I think I should find the transformation from the first reference system to the second and then apply it for each point of the first matrix. How can I find this transformation? The translation part I think is clear, but the rotation not at all.

Edit:

@WildCrustacean

The solution proposed does not solve the problem, I think that the reason is because each system represents the robot in a different way.

In the initial one (A) the robot moving forward with no rotation would increase in the X axis. In the goal referential system (B) the robot moving forward with no rotation would increase in the Z axis. (See figure for more details)

```<code>First system (A)
 ______
|\  T  \
| \_____\     z
|B |    | : y ^
 \ | R  |    \|
  \|____|     +--> x

Second system (B)
 ______
|\  T  \
| \_____\     x
|B |    | :   ^
 \ | R  |     |
  \|____|     +--> z
               \
                y

R: Right side
B: Back side
T: Top
</code>```

I think I have to apply an extra rotation to change the initial quaternion that belongs to the first system to be in accordance with the second system before applying the transformation of your post.

One rotation of 180 degrees around x followed by one of 90 around y. Would rotate from A to B

This is how I tried to solve it:

```<code># Quaternion to adjust reference system
first_quat = make_quaternion(unitary_x, pi) # Generates the quaternion that rotates pi around X
second_quat = make_quaternion(unitary_y, pi/2.0) # Generates the quaternion that rotates pi/2 around Y
composed_fs_q = first_quat*second_quat

# Quaternion to rotate from one reference system to the other
quaternion_ini_A = quaternion_ini_A*composed_fs_q
A2B_quaternion = quaternion_ini_B*(quaternion_ini_A.inverse())
</code>```

A2B_quaternion is the quaternion that I use for the rotation but still doesn't perform the right rotation. Any idea?

答:
So you need to find the rotation that gets you from the first coordinate system to the second, and then combine that with the translation to get the final transformation matrix.

Since you have quaternions q1 and q2, you can write this rotation as:

$q = q_2 * q_1^{-1}$

You can then convert from the quaternion form to a rotation matrix to make the final transformation matrix, there are equations for this.

The final transformation would be of the form:

$\begin{bmatrix}\boldsymbol{R} & \boldsymbol{t}\\\boldsymbol{0} & 1\end{bmatrix}$

Where $\boldsymbol{R}$ is the 3x3 rotation matrix and $\boldsymbol{t}$ is the 3x1 translation vector.


问:
What relay or other gizmo do I need to switch between two circuits?
I have built a fighting bot but improvements could be made. I currently use 1 channel to switch spinners on and off and another for self righting.  The spinners cannot turn during self righting as they are against the floor so I have to switch them off with one switch and activate self righting with another to avoid the spinner motors burning out and then once self righted reverse both switch positions again.  Currently each circuit has a normally off relay (5v from the receiver controlling 24V to load), in an ideal world I would have got a relay that allows one circuit 'on' and the other 'off' and then the opposite when given the signal by the receiver e.g. when a single switch on the remote control is 'off' then circuit A is 'off' and circuit B is 'on', when the remote switch is 'on' circuit A in 'on' and circuit B is 'off' - this would free up a remote channel and also ensure the two circuits can never be closed at the same time - with me so far? anyway turns out that this type of relay does not exist for control by a remote receiver so what I am trying to achieve is the following:

So it's not actually a relay as that suggests one voltage controlling another so what is this illusive gizmo I seek actually called?  Can I buy one on Amazon?

I'm trying to avoid going down the route of IF / THEN gates on a separate PCB, the daft thing is that all I want is an electrical version of exactly what the pneumatic actuator does - when powered air goes down one hose and when off goes down another.

Thanks in advance.

After looking at some of the answers - (thanks everyone) it allowed me to find this:

 from http://www.superdroidrobots.com/shop/item.aspx/dpdt-8a-relay-rc-switch/766/

答:
You have the circuit for energizing relay 1. In this circuit you put in series one of the output contacts of relay 2 which are not the "main" output contacts, just a low voltage "additional" contact. If relay 2 is energized the circuit to energize relay 1 will be also closed.

The circuit energising relay 1 will consist of +5V in series with the additional contact of relay 2 the coil of relay 1 in series and ground.

ContentLicense: CC BY-SA 3.0


答:
I know that you do not want any complicated logic gates so I present you some MOSFET instead. With a N-Channel and a P-channel MOSFET a simple
mutual exclusion logic can be realized.

N channel – For an N channel MOSFET, the source is connected to ground. If we want to let current flow, we can easily raise the voltage on the gate allowing current to flow. If no current is to flow, the gate pin should be grounded

P channel – Looking at the P channel MOSFET, the source is connected to the power rail. In order to allow current to flow the Gate needs to be pulled to ground. To stop the current flow, the gate needs to be pulled to supply voltage. More about FETs here.

So basically one will conduct while the other won't if you tie the gates together and drive it from a common signal source. So one channel of the remote receiver drives the gates of the FETs. The schematic will be the following:

There are additional Zener diodes in series with relay coils' flyback diodes. The reason is that a single flyback diode will delay the release of the relay contact, so there can be a short period when both of the relays are ON. To reduce this delay a zener diode or a resistor can be added in series with the flyback diode. Select the value of the zener or resistor to be compatible with whatever the driver can withstand.

If a resistor is used:

$$ R = \frac{V_{peak}}{I_{coil}}$$
$$ Power = I_{coil}^2 \times R \times dutycycle$$

If a zener diode is used:

$$ V_Z = V_{peak} $$
$$ Power = V_Z \times I_{coil} \times dutycycle$$

The fastest release time can be achieved using a zener diode. Here is a simulation of the circuit. You can check the release times if you remove the zeners.

Title: What relay or other gizmo do I need to switch between two circuits?

Body:
I have built a fighting bot but improvements could be made. I currently use 1 channel to switch spinners on and off and another for self righting.  The spinners cannot turn during self righting as they are against the floor so I have to switch them off with one switch and activate self righting with another to avoid the spinner motors burning out and then once self righted reverse both switch positions again.  Currently each circuit has a normally off relay (5v from the receiver controlling 24V to load), in an ideal world I would have got a relay that allows one circuit 'on' and the other 'off' and then the opposite when given the signal by the receiver e.g. when a single switch on the remote control is 'off' then circuit A is 'off' and circuit B is 'on', when the remote switch is 'on' circuit A in 'on' and circuit B is 'off' - this would free up a remote channel and also ensure the two circuits can never be closed at the same time - with me so far? anyway turns out that this type of relay does not exist for control by a remote receiver so what I am trying to achieve is the following:

So it's not actually a relay as that suggests one voltage controlling another so what is this illusive gizmo I seek actually called?  Can I buy one on Amazon?

I'm trying to avoid going down the route of IF / THEN gates on a separate PCB, the daft thing is that all I want is an electrical version of exactly what the pneumatic actuator does - when powered air goes down one hose and when off goes down another.

Thanks in advance.

After looking at some of the answers - (thanks everyone) it allowed me to find this:

 from http://www.superdroidrobots.com/shop/item.aspx/dpdt-8a-relay-rc-switch/766/

Body:
I know that you do not want any complicated logic gates so I present you some MOSFET instead. With a N-Channel and a P-channel MOSFET a simple
mutual exclusion logic can be realized.

N channel – For an N channel MOSFET, the source is connected to ground. If we want to let current flow, we can easily raise the voltage on the gate allowing current to flow. If no current is to flow, the gate pin should be grounded

P channel – Looking at the P channel MOSFET, the source is connected to the power rail. In order to allow current to flow the Gate needs to be pulled to ground. To stop the current flow, the gate needs to be pulled to supply voltage. More about FETs here.

So basically one will conduct while the other won't if you tie the gates together and drive it from a common signal source. So one channel of the remote receiver drives the gates of the FETs. The schematic will be the following:

There are additional Zener diodes in series with relay coils' flyback diodes. The reason is that a single flyback diode will delay the release of the relay contact, so there can be a short period when both of the relays are ON. To reduce this delay a zener diode or a resistor can be added in series with the flyback diode. Select the value of the zener or resistor to be compatible with whatever the driver can withstand.

If a resistor is used:

$$ R = \frac{V_{peak}}{I_{coil}}$$
$$ Power = I_{coil}^2 \times R \times dutycycle$$

If a zener diode is used:

$$ V_Z = V_{peak} $$
$$ Power = V_Z \times I_{coil} \times dutycycle$$

The fastest release time can be achieved using a zener diode. Here is a <a href="http://www.falstad.com/circuit/circuitjs.html?cct=$%201%200.000005%206.450009306485578%2043%205%2050%0A172%20912%2048%20912%2016%200%206%205%205%200%200%200.5%20Relay%20Supply%20Voltage%0Af%20752%20352%20816%20352%200%201.5%200.02%0Aw%20656%20112%20656%2064%200%0Aw%20576%20112%20656%20112%200%0Aw%20752%20112%20656%20112%200%0Ar%20512%20352%20512%20432%200%2010000%0Ar%20752%20352%20752%20432%200%2010000%0Aw%20912%20288%20912%20176%200%0Aw%20912%20176%20912%2048%200%0AL%20656%2064%20656%2032%200%200%20false%205%200%0A172%20944%2048%20944%2016%200%206%2024%2024%200%200%200.5%20Load%20Supply%20Voltage%0A178%20944%20320%20944%20416%200%201%200.2%204.999998999170298e-8%200.05%201000000%200.02%2020%0Aw%20944%20272%20944%2048%200%0A178%20704%20320%20704%20416%200%201%200.2%200.0563283975725781%200.05%201000000%200.02%2020%0Aw%20704%20272%20704%20320%200%0Aw%20704%20272%20944%20272%200%0Aw%20944%20272%20944%20320%200%0Aw%20576%20320%20608%20320%200%0Ad%20816%20288%20864%20288%201%200.805904783%0Aw%20576%20288%20576%20320%200%0Aw%20608%20320%20656%20320%200%0Aw%20896%20320%20816%20320%200%0Ad%20576%20288%20624%20288%201%200.805904783%0Aw%20816%20320%20816%20336%200%0Aw%20752%20352%20752%20112%200%0Ar%20688%20480%20688%20592%200%20100%0Ar%20928%20480%20928%20592%200%20100%0Ag%20688%20592%20688%20624%200%0A207%20688%20480%20608%20512%200%20Pneumatic%20actuator%0Aw%20688%20416%20688%20480%200%0A207%20928%20480%20992%20512%200%20Motor%0Aw%20928%20416%20928%20480%200%0Aw%20816%20368%20816%20432%200%0Aw%20816%20288%20816%20320%200%0Aw%20912%20288%20912%20320%200%0Af%20512%20352%20576%20352%201%201.5%200.02%0Az%20672%20288%20624%20288%201%200.805904783%206.7%0Az%20912%20288%20864%20288%201%200.805904783%205.6%0Aw%20816%20432%20752%20432%200%0Aw%20752%20432%20752%20592%200%0Aw%20752%20592%20688%20592%200%0Aw%20752%20592%20928%20592%200%0Aw%20672%20320%20672%20288%200%0Aw%20672%20288%20672%20176%200%0Aw%20672%20176%20912%20176%200%0Aw%20576%20368%20576%20432%200%0Aw%20576%20432%20512%20432%200%0Aw%20512%20432%20512%20592%200%0Aw%20512%20592%20688%20592%200%0Aw%20576%20336%20576%20320%200%0Aw%20512%20352%20512%20112%200%0Aw%20512%20112%20576%20112%200%0Ao%2029%2064%200%20291%2040%200.4%200%20-1%0Ao%2031%2064%200%20291%2040%200.4%201%20-1%0A" rel="nofollow noreferrer">simulation of the circuit. You can check the release times if you remove the zeners.


问:
Compatibilty of my setup?
I'm building my first quadcopter, and these are the components I intend to buy:

Motor: EMAX BL2212 1400 KV Brushless Outrunner Motor around 0.9 kg thrust:

Flight Controller: Multiwii V2.5 Flight Controller

Propellers: I don't know which one to get: fut-electronics propellers collection

GPS: Skylab UART GPS Module SKM58   (Small Form Factor)

Radio Communication: Radio Telemetry 915 Mhz (3DR), is there an affordable alternative to buying a radio telemetry maybe using Wi-Fi?

ESCs: 4x1 ESC (4x25A) - Speed Controller for Quadcopter

Battery: I don't know which one to choose

My questions are:

Are the components compatible?

What battery to choose?

If I'm not planning to do GPS planned missions, would the GPS be important for anything else?

By the way I intend to attach a camera or a smart-phone to it for video capturing I think it is about an extra 200 grams.

答:
The website that you have used seems to be down, however looking at the specs announced on banggood, it looks compatible.
You would need some 8*4 props and a 3S battery, I'd advise getting a 3000mAh one that can handle full power (200W per motor so 800W total for a 12V*3Ah battery=>36Wh so that's 800/36=22C) so a 3S 3000mAh 25C constant LiPo would be perfect to achieve the performance needed
Also for the transmitter and the receiver what are you going to use, because telemetry won't pilot the quadcopter
Btw, telemetry won't be of any use for your first quadcopter, same goes for the GPS, you'll first pilot in stabilized and then accro and if you are willing to do some stabilized photography and video, you can add a GPS for the quad to fly by GPS (that means that it will move geographically according to your commands and it's GPS position)
Also if you are kinda new on quadcopters I'd advise you to get a KK2.1.5 as a flight controller to begin with, the good thing about it is that you can change your PID, channel settings on the go, though it doesn't support GPS and a lot of other features that multiwii's have</p>

Title: Compatibilty of my setup?


问:
How to update an EKF when no inputs are available?
I'm using an  Extended Kalman filter where the motion model is a function of the states and the inputs, with additive white noise, i.e.
$$ x_k = f(x_{k-1},u_{k-1}) +\delta_{k-1} \quad , \quad \delta_{k-1} \sim N(0,\Delta_{k-1})$$

If $x_{k-1}$ and $u_{k-1}$ are know, then the prediction step is done as
$$\hat{x}_{k|k-1} = f(\hat{x}_{k-1|k-1},u_{k-1}) $$
$$ f' = \frac{\partial F}{\partial x_{k-1}}\Big|_{x_{k-1}=\hat{x}_{k-1|k-1}~,~u=u_{k-1}} $$
$$ P_{k|k-1} = f'P_{k-1|k-1}f $$

However, at some time steps I won't know the value of $u$, the input. What is the optimal way to perform the prediction step in this scenario?

My thoughts so far are to set
$$\hat{x}_{k|k-1} = \hat{x}_{k-1|k-1} ~,$$
since I have no new information to update it... but no idea how to estimate the covariance matrix $P_{k|k-1}$.

答:
You can use the last value $u_{t-1}$ if the time step is not too big ($\delta t$ is small).

Or, you can keep track of $u$ some time steps in the past, e.g. ten of them and extrapolate $u_t$ when you lose it. You can use a line equation for that:

$$
y = mx + b
$$

You can use a simple linear regression to find the values of $m$ and $b$.


问:
Cleanflight : 4 first channels not working and "Failed to open serial port"
I just finished assembling my new 250 quad which is equipped with an SP F3 Flight controller.
I think that I kinda bricked my FC in the first 10 minutes of configuring it:

I first plugged it in, installed a few drivers and opened cleanflight
Cleanflight recognized it, no problem for now.
I then tried to test the RX channels and discovered that apart from the 4 AUX channels, none of them worked, I swapped the plugs on the transmitter and saw that the RX was OK, it's the FC that didn't show anything on the first 4 channels
After reading some stuff about upgrading the firmware I did something completely wrong, I followed the first 10 seconds of this guide, using baseflight... though my board isn't baseflight it's cleanflight, and I did the mistake of clicking the "Flash firmware" button which then made it impossible to use it and flash it.

After some trial and error I finally had a problem where cleanflight tells me that it cannot flash the firmware on it because "Failed to open serial port"
I used Process Explorer to check if any program was using and holding the COM3 port but no
No Program was using it.
Thank you for reading this very long and probably stupid question, do you have anything that I can try?

答:
The com issue has been fixed by uninstalling all serial->COM drivers and programs that could've been interfering?? Dunno, some more Windows 10 magic I guess, but now remains he issue of the 4 first channels not working

I then installed the latest cleanflight firmware by following this guide, flashed without any problem.

It indeed fixed the channel issue and all I had to do next was to change the PID settings and reversed the yaw (I installed CCW motors where there should be CW) using "set yaw_direction = -1" on the CLI

It's now fully functional


问:
Using the Create2 Tethered Driving program- inputting a string of keyboard presses
I'm attempting to do a quick and dirty autonomous path with the create2. I'm using the tethered driving program seen here.

I set my own buttons just to make it rotate 90° and go forward one "pulse". I'd like to know, does anyone have any ideas on how to trick the attached Create2_TetheredDrive.py into thinking it's seeing a series of keyboard entries?

答:
You can try putting your series of commands (or keyboard entries) as an array. After which, you can assign a for loop for this button, which will then run through the array of instructions.

The array might look something like this:

```<code>cmds = ['self.callbackKeyRight', 'self.callbackKeyDown',  'self.callbackKeyDown']
</code>```

and the for loop code to run the array might look something like this:

```<code> if event.type == '2': # KeyPress; need to figure out how to get constant
        if k == 'Z':   # Set some key here
            for i in range(len(cmds)):
                cmds[i] = True
                motionChange = True
                print 'Cmd number: ' + i
</code>```

Body:
You can try putting your series of commands (or keyboard entries) as an array. After which, you can assign a for loop for this button, which will then run through the array of instructions.

The array might look something like this:

cmds = ['self.callbackKeyRight', 'self.callbackKeyDown',  'self.callbackKeyDown']

and the for loop code to run the array might look something like this:

 if event.type == '2': # KeyPress; need to figure out how to get constant
        if k == 'Z':   # Set some key here
            for i in range(len(cmds)):
                cmds[i] = True
                motionChange = True
                print 'Cmd number: ' + i


问:
Should I use an arduino to control my balancing robot's motors?
I'm building a 2-wheel balancing robot from old parts. DC motors from an old printer, wheels from a BBQ, bodywork from an old optical drive etc.

The brain of the robot is a Raspberry Pi 3. I'm using an L298N motor driver to control 2x 12-35v DC motors. Balance and movement will be 'sensed' using a 10DOF L3GD20 LSM303D Gyro, Accelerometer & Compass board. I'm currently using an Arduino with PWM for multi speed and direction of each motor. A PID loop will keep the robot balanced.

It looks like this:
Raspberry Pi > Arduino > L298N > Motors

So far everything is good (don't worry I'm not going to ask "Where do I start??" :D)

My question is this: should I continue to control the sensors and motors' driver using the Arduino, having the Pi issue higher level commands to the Arduino, OR should I just let the Pi do all the leg work?

I'm trying to keep power consumption to a minimum but I want to keep the processing overhead of the balancing and movement away from the Pi. Additionally, I've read that an Arduino is better at this sort of work due to the fact that it has a built in clock, where a Pi doesn't. I assume the PID loop will be slowed if the device (the Pi) is working on other processing tasks like navigation and face recognition etc.

Are my assumptions correct and which direction would guys steer towards?

Your knowledge and wise words would be very much appreciated!!

答:
If you want to have a good balancing, PID loop timing is very important. Standard Raspberry OS, like Raspbian can't guarantee you any precise timing, so once your loop period may be 10ms, once it can be 1s, resulting in a robot to fall. You can try to run some real time operating system on RPi, like FreeRTOS, that would have preemptive capabilities (so a process with high priority, like PID, would interrupt other, lower priority processes).

That being said, I think that using an Arduino is a very good choice, as it nicely separates high level processing, from low level control tasks.


答:
Very simply, you can use a single pole, double throw relay.  This has two outputs:  one is normally open and the other is normally closed.  Both will not be energized concurrently.

EDIT (based on Chuck's comment):
In some applications, in which turn-on and turn-off timing is critical, you need to decide between a "make before break" and a "break before make" type of SPDT relay.   With your 'bot application this timing difference shouldn't be critical, but if you want to be sure that one action occurs before the other, you can enforce that with proper selection of the relay.


问:
Suggestion for relevant non-complex simulator
I've recently started working on some localization algorithms like probabilistic road map and SLAM algorithms. What I'm looking for is a software that would help me in simulation for such algorithms. I started with pythons graphics.py and have now started working with Gazebo and ROS, but I've found it complex to use.

Is there any similar freeware simulation software that is easy to setup and work with, thus allowing me to reduce my time stressing over the simulation part and working more on the algorithms?

答:
just use matlab or and python with a set of fixed features in space represented as points. Don't do any vision processing. At this point any vision processing would be overkill.

you are making this way too complex.

the measurements for your slam can be angles to features. create a set of 30 features randomly populating a 20m by 20m square. make your view point move in a circle around the square.

this is enough to get started with slam.

if you only rely on other people's packages and modules without going through the trouble of building your own you will never really get a sense of how these things work and break.


问:
Software simulation vs. real world scale model simulation
There are high quality software robotics simulators like Gazebo available today. What is the difference between a pure software simulation and a real world (say RC) scale model simulation? Is it possible to skip the scale model simulation and only do SW simulation and then build a full scale final product right away? Does scale model simulation have any advantages over say Gazebo?

I don't have any direct experience with developing a product in robotics but if I try to think then I guess the SW simulation may primarily be used to develop the very basics of a product and then scale model simulation may take over or complement SW simulation. My personal view is that any (even small scale) real world simulation/testing is beneficial because the features of real world (noise, dust etc.) can hardly be simulated in SW. Is this true? Also small scale model will be many times cheaper than full scale one.

I am considering an autonomous car (self-driving) as one of the possible products resulting from such simulation. I read that vision is one of the weak parts of SW simulators. I can think that sensing in general may be a weak part of SW simulators since any real sensor is imperfect and noisy which Gazebo may not take into account...

答:
First Simulators available like Gazebo, Yes there are many simulators, You can check v-rep (free) or whebots or matlab (non-free) for example.

What is the difference between a pure software simulation and a real world (say RC) scale model simulation? The pure simulation don't count noise and non-accurate parameters you use

For example when you specify weight, torque or any other specs in the simulation you can't be sure all those specs are exactly true in real world.

Is it possible to skip the scale model simulation and only do SW simulation and then build a full scale final product right away? If you don't need to simulate electronic circuits, sensors and control system, In other words you want to simulate the mechanism only, Yes, Else no.


问:
Why can't you buy continuous servos with absolute positioning?
I've been looking at parts for a beginners robotics kit (I teach at a museum) and have been wondering about servos.

You can buy continuous servos with relative position encoders. But I can't find continuous rotation servos with absolute position encoders. Do these exist? If not, why not?

I understand that some forums don't like shopping questions, but I suspect that this part doesn't exist and I'd like to understand why.

Also, I understand that most servos use a potentiometer as a position encoder and that these don't turn more than 1 rotation, but there are other types of encoders that seem like they would do the job.

Thanks for the help!

答:
I am looking into this type of absolute position encoder.
They were used in the NAO robot.
They are small, accurate and typically under $10 USD.</p>


问:
Calculating screw breakaway torque
I'm trying to use motor-sizing tool developed by oriental motor to choose good servo motor for my cnc

The tool requires breakaway torque of my screw as input, I searched online but I got people measuring it using wrench.

I'm working on simulating the machine before I buy anything so I don't have the screw to test anything on i.

This is the screw I want to use and all the specs are available in the link, I need to calculate the breakaway torque mathematically so is there any way?

答:
You can approximate the breakaway torque by considering static friction only. From the static friction coefficient of the lead screw (by knowing the maximum load on the spindle, coming from the application) you can calculate the static friction torque of the nut on the lead screw.

You should do the same with all linear guides and/or bearings that you have and sum them up. That will be your breakaway torque.

For the lead screw: F = c*N where F is the static friction force, c is the static friction constant and N is the normal force. In this case you have to convert the Force to Torque Torque = Force x Lead /2pi. Or the lead screw manufacturer might give directly the constant which links static friction constant to torque.

Title: Calculating screw breakaway torque

ContentLicense: CC BY-SA 4.0


问:
Error while running rosserial node in ROS
I have an Arduino connected to ROS through serial port. I wrote an ardiuno code to drive motors. below is my code.

```<code>//Library to communicate with I2C devices
    #include "Wire.h"
    #include <Messenger.h>
    //Contain definition of maximum limits of various data type
    #include <limits.h>
     //Messenger object
    Messenger Messenger_Handler = Messenger();

    //////////////////////////////////////////////////////////////////////////////////////
    //Motor Pin definition
    //Left Motor
    #define USE_USBCOM
    #define INA_1 7
    #define INB_1 12
      //PWM 1 pin
    #define PWM_1 5

    //Right Motor
    #define INA_2 11
    #define INB_2 10

    //PWM 2 pin
    #define PWM_2 6
    #define RESET_PIN 4

    ///////////////////////////////////////////////////////////////////////////////////////
    //Motor speed from PC
    //Motor left and right speed
    float motor_left_speed = 0;
    float motor_right_speed = 0;
    /////////////////////////////////////////////////////////////////

    //Setup serial, motors and Reset functions
    void setup()
    {

      //Init Serial port with 115200 baud rate
      Serial.begin(57600);

      //Setup Motors
      SetupMotors();
       SetupReset();
      //Set up Messenger
      Messenger_Handler.attach(OnMssageCompleted);
       }
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Setup Motors() function

    void SetupMotors()
    {

     //Left motor
     pinMode(INA_1,OUTPUT);
     pinMode(INB_1,OUTPUT);

     //Right Motor
     pinMode(INA_2,OUTPUT);
     pinMode(INB_2,OUTPUT);

    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Setup Reset() function

    void SetupReset()

    {

      pinMode(RESET_PIN,OUTPUT);

      ///Conenect RESET Pins to the RESET pin of launchpad,its the 16th PIN
      digitalWrite(RESET_PIN,HIGH);

    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //MAIN LOOP

    void loop()
    {

        //Read from Serial port
        Read_From_Serial();

        //Update motor values with corresponding speed and send speed values through serial port
        Update_Motors();

    delay(1000);
      }
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Read from Serial Function

    void Read_From_Serial()

    {
       while(Serial.available() > 0)
        {

           int data = Serial.read();
           Messenger_Handler.process(data);

        }

    }
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //OnMssg Complete function definition

    void OnMssageCompleted()
    {

      char reset[] = "r";
      char set_speed[] = "s";

      if(Messenger_Handler.checkString(reset))
      {

         Reset();

      }
      if(Messenger_Handler.checkString(set_speed))
      {

         //This will set the speed
         Set_Speed();
         return;

      }
    }
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Set speed
    void Set_Speed()
    {

      motor_left_speed = Messenger_Handler.readLong();
      motor_right_speed = Messenger_Handler.readLong();

    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Reset function
    void Reset()
    {

      delay(1000);
      digitalWrite(RESET_PIN,LOW);

    }
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Will update both motors
    void Update_Motors()
    {

      moveRightMotor(motor_right_speed);
      moveLeftMotor(motor_left_speed);

     }

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //Motor running function

    void moveRightMotor(float rightServoValue)
    {
      if (rightServoValue>0)
      {

     digitalWrite(INA_1,HIGH);
     digitalWrite(INB_1,LOW);
     analogWrite(PWM_1,rightServoValue);

      }
      else if(rightServoValue<0)
      {
     digitalWrite(INA_1,LOW);
     digitalWrite(INB_1,HIGH);
     analogWrite(PWM_1,abs(rightServoValue));

      }

      else if(rightServoValue == 0)
      {
     digitalWrite(INA_1,HIGH);
     digitalWrite(INB_1,HIGH);

      }
    }
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void moveLeftMotor(float leftServoValue)
    {
     if (leftServoValue > 0)
      {
    digitalWrite(INA_2,LOW);
    digitalWrite(INB_2,HIGH);
    analogWrite(PWM_2,leftServoValue);
      }
      else if(leftServoValue < 0)
      {
     digitalWrite(INA_2,HIGH);
     digitalWrite(INB_2,LOW);
     analogWrite(PWM_2,abs(leftServoValue));

      }
      else if(leftServoValue == 0)
      {

       digitalWrite(INA_2,HIGH);
       digitalWrite(INB_2,HIGH);

       }

    }
</code>```

when i load the code to arduino and start rosserial node using command

rosrun rosserial_python serial_node.py /dev/ttyACM0

ROS throws below error

[ERROR] [WallTime: 1475949610.718804] Unable to sync with device;
  possible link problem or link software version mismatch such as hydro
  rosserial_python with groovy Arduino

I have tried changing the baud rate and fixing it similar in ROS and arduino but nothing helped

答:
i suggest you take a look at Tones' answer : http://answers.ros.org/question/210875/arduino-rosserial-unable-to-sync-with-device/?answer=237868#post-id-237868

i'm using the second workaround :

Start the serial_node with baud rate 0, exit and restart the serial node with the correct baud rate. You have to repeat this every time the error occurs.


问:
What is the difference between Kinect for Windows and Kinect for XBox?
As I see there is a huge price gap between the two \$223 vs \$99 (at amazon).

My intention is to use one of those from Ubuntu linux to perform depth sensing, navigation etc. and naturally I prefer the cheaper.
However I am not sure if I miss some important point while betting on the Kinect for Xbox version.

As it seems the Windows version is overpriced because it has the license for development. Here it is stated that there are internal differences but without exact details (The minimum sensing distance seems to be better for Windows version.).

Could anyone give a comparison chart?
It would be good to know about

Connectivity: USB, special connector, ... .

Hardware differences: are they the same or do they really differ in weight, energy consumption, speed, sensing range, ...?

Driver: could I use Xbox version under Ubuntu?

API usage: could I develop on Xbox version, could I use the same/similar API on both, is the API for Xbox mature enough?

License: is it against the license of Xbox version to develop for home/hobby/educational use?

Thanks.

答:
From Microsoft site:
What's the difference between the Kinect for Windows sensor and the Kinect for Xbox 360 sensor?

The Kinect for Windows sensor is a fully-tested and supported Kinect experience on Windows with features such as “near mode,” skeletal tracking control, API improvements, and improved USB support across a range of Windows computers and Windows-specific 10’ acoustic models.

The sensor was specifically designed to be used with computers, and includes a shortened USB cable to ensure reliability across a broad range of computers. Kinect for Xbox 360 was built for and tested with the Xbox 360 only, not with any other platform, which is why it is not licensed for general commercial use, supported, or under warranty when used on any other platform.

Microsoft has a large team of engineers that is dedicated to continual improvements of the hardware and software associated with Kinect for Windows, and is committed to providing ongoing access to Microsoft's deep investment in human tracking and speech recognition.


问:
Kalman filter: 3D measurement error to individiual components
I'm working on a Kalman filter for estimating the position of a point in 3D space. I know that I can measure its 3D position directly with a variance of about 2 mm (in other words: the variance of the norm of the measured x, y, z vector is about 2 mm).

I'd like to fill my measurement noise covariance matrix based on this, so my question is:

How does this relate to the variance of the individual x, y, z measurements? I'm looking for three equal variances, assuming independency.

答: Take a bunch of measurements of your system while states are static and compute the noise matrix yourself. As long as recording measurements is relatively straightforward this should be a painless process. It will also verify that your measurements are as accurate as you believe. </p>


问:
Platooning leader follower code
I'm trying to develop a platoon leader follower formation for two robots in Matlab. The paper I'm trying to follow is this.

I've got next code, where I want follower robot to follow the leader robot's path, just in a very simple way, no kinematics. But I cannot get it. Does anybody know which is my error?

```<code>x1=linspace(0,10,100); //x1 and y1 represent the leader's path
y1=sin(x1);
plot(x1(1:100),y1(1:100));
hold on;

x2=zeros(1,100);
y2=zeros(1,100);

x2(1)=-5; //x2, y2 represent the follower's position
x2(2)=-4;
landa=0.1; //represents the euclidean distance between robots

theta_leader(2)=atan((y1(2)-y1(1))/(x1(2)-x1(1)));
theta_follower(2)=atan((y2(2)-y2(1))/(x2(2)-x2(1)));
alfa(2)=atan((y1(2)-y2(2))/(x1(2)-x2(2)))-theta_follower(2);
phi(2)=pi-(theta_leader(2) - alfa(2) - theta_follower(2));

for i=3:100
     landa(i)=0.1;
      x2(i)=x1(i)*cos(theta_leader(i-1))-landa(i)*cos(alfa(i-1)+theta_follower(i-1));
      y2(i)=y1(i)*sin(theta_leader(i-1))-landa(i)*sin(alfa(i-1)+theta_follower(i-1));

      theta_leader(i)=atan((y1(i)-y1(i-1))/(x1(i)-x1(i-1)));

      alfa(i)=atan((y1(i)-y2(i))/(x1(i)-x2(i)))-theta_follower(i-1);
      phi(i)=pi-(theta_leader(i) - alfa(i) - theta_follower(i-1));
      theta_follower(i)=phi(i)-alfa(i)+theta_leader(i)-3.1415;
  end

  plot(x2,y2,'or');
</code>```

答:
I don't have access to the article, so I have to guess about the expected behavior.

Looking at your code, the first thing I did was to change all of your atan functions to atan2 because atan doesn't work correctly in all quadrants. Never use atan.

That didn't fix it. So the second thing I did was to change how you calculate the follower heading (theta_follower) from the way it was calculated in the loop (which seems to be based on the leader's heading) to the way it was calculated the first time, which is based on the difference in the current position and previous position. Still no dice.

So, then I was trying to figure out how else the follower's position is determined and I noticed it's not based on the leader's position. It's based on the leader's position times the sine/cosine of the leader's heading. I don't know why the sine/cosine of the leader's heading was included in the calculation, but I removed it. And then it worked.

Now, the only thing I'm not sure about is whether the follower's heading is supposed to be the way you have it in the loop or the way you have it the first time. That is, I can't tell if you want the follower's heading to be what it actually is or if you want it to be based on the leader's heading. The first time you calculate the heading, you calculated it to be the actual heading.

If you leave the theta_follower code in the loop the way you have it, then the follower's heading is set to be whatever the leader's heading is and the follower can never catch the leader. The follower's path is offset from the leader.

If you set the theta_follower code to be the actual heading, then the follower's path looks "messier", but it is actually tracking the path of the leader. It overshoots one side, overshoots the other, then back-and-forth oscillating about the leader's path. I think this is the behavior you want, because behavior like this would have the follower on the same road as the leader. The way it was written, the leader would be on the road and the follower would (smoothly) drive on the sidewalk because it can't course-correct to the same path.

Here's the code:

```<code>x1=linspace(0,10,100); %x1 and y1 represent the leader's path
y1=sin(x1);
plot(x1(1:100),y1(1:100));
hold on;

x2=zeros(1,100);
y2=zeros(1,100);

x2(1)=-5; %x2, y2 represent the follower's position
x2(2)=-4;
landa=0.1; %represents the euclidean distance between robots

%-------
% Moved from atan to atan2
%-------
%theta_leader(2)=atan((y1(2)-y1(1))/(x1(2)-x1(1)));
%theta_follower(2)=atan((y2(2)-y2(1))/(x2(2)-x2(1)));
%alfa(2)=atan((y1(2)-y2(2))/(x1(2)-x2(2)))-theta_follower(2);
theta_leader(2)=atan2((y1(2)-y1(1)),(x1(2)-x1(1)));
theta_follower(2)=atan2((y2(2)-y2(1)),(x2(2)-x2(1)));
alfa(2)=atan2((y1(2)-y2(2)),(x1(2)-x2(2)))-theta_follower(2);

phi(2)=pi-(theta_leader(2) - alfa(2) - theta_follower(2));

for i=3:100
    landa(i)=0.1;

    %-------
    % THIS APPEARS TO HAVE BEEN THE PROBLEM
    %-------
    %x2(i)=x1(i)*cos(theta_leader(i-1))-landa(i)*cos(alfa(i-1)+theta_follower(i-1));
    %y2(i)=y1(i)*sin(theta_leader(i-1))-landa(i)*sin(alfa(i-1)+theta_follower(i-1));
    x2(i)=x1(i)-landa(i)*cos(alfa(i-1)+theta_follower(i-1));
    y2(i)=y1(i)-landa(i)*sin(alfa(i-1)+theta_follower(i-1));

    %-------
    % Moved from atan to atan2
    %-------
    %theta_leader(i)=atan((y1(i)-y1(i-1))/(x1(i)-x1(i-1)));
    theta_leader(i)=atan2((y1(i)-y1(i-1)),(x1(i)-x1(i-1)));
    %alfa(i)=atan((y1(i)-y2(i))/(x1(i)-x2(i)))-theta_follower(i-1);
    alfa(i)=atan2((y1(i)-y2(i)),(x1(i)-x2(i)))-theta_follower(i-1);

    phi(i)=pi-(theta_leader(i) - alfa(i) - theta_follower(i-1));

    %--------
    % Questionable code here
    %--------
    theta_follower(i)=phi(i)-alfa(i)+theta_leader(i)-3.1415;  % Side comment - you add pi and then subtract it for some reason.
    %theta_follower(i)=atan2((y2(i)-y2(i-1)),(x2(i)-x2(i-1)));

    %--------
    % Moved plot inside the loop to watch it for more intuition regarding
    % what's happening.
    %--------
    plot(x2(i),y2(i),'or');
    pause(0.1)
end
</code>```

:EDIT:

The authors of the paper don't include the code they used to generate any of the plots. Further, it looks like implementing the block diagram they provided doesn't work either. They do state that Equation 8 is used by referencing figure 5, which means that they have, in fact, incorrectly included the sine/cosine terms. The heading of the leader does not at all affect the position of the follower.

That said, I tried implementing their block diagram after making that change and I believe it works. You skipped quite a bit in your implementation, including finding the derivative of position and heading and then performing the numeric integration. See the revised code below (the earlier code above should not be used, but I'll leave it for posterity).

Note the value k is used, as described in the paper, as a control gain to decide how well the follower tracks the leader. Play around with it to see how well the follower does or does not track the leader. Also, the initial path is odd because the follower starts so far from the leader.

```<code>x1=linspace(0,10,100); %x1 and y1 represent the leader's path
y1=sin(x1);
figure(1)
clf;
plot(x1(1:100),y1(1:100));
hold on;

x2=zeros(1,100);
y2=zeros(1,100);

x2(1)=-5; %x2, y2 represent the follower's position

%------- END ORIGINAL CODE ---------%
y2(1)=-4; % <---- NOTE: Originally this was x2(2) = -4. I'm assuming it should have been y2(1) = -4.
alpha_d = 0;
rho_d = 0.1;
rho = sqrt((x1(1)-x2(1))^2 + (y1(1)-y2(1))^2);
alpha = 0;
phi = 0;
prevLeaderAngle = 0;
followerAngle = 0;

dT = x1(2) - x1(1); % I don't have any reference for time scales or speed so I have to fake it.
k = 1;
fullIntegral = [rho; alpha; phi];

for i = 2:numel(x1)
    leaderLinearVelocity = sqrt((x1(i)-x1(i-1))^2 + (y1(i)-y1(i-1))^2)/dT;
    % Linear velocity is change in position divided by change in time.
    leaderAngle = atan2((y1(i)-y1(i-1)),(x1(i)-x1(i-1)));
    leaderAngularVelocity = (leaderAngle-prevLeaderAngle)/dT;
    prevLeaderAngle = leaderAngle;

    leaderSpeed = [leaderLinearVelocity; leaderAngularVelocity];

    formationDerivative = (k*eye(2))*[(rho_d-rho);(alpha_d-alpha)];
    followerSpeed = [-(1/cos(alpha)) , 0; -(tan(alpha)/rho) , -1] * ...
        (formationDerivative - [-(cos(phi)) , 0; (sin(phi)/rho) , 0] * leaderSpeed);

    fullDerivative = [-cos(alpha) , 0; sin(alpha)/rho , -1; sin(alpha)/rho , 0]*...
        followerSpeed + [-cos(phi) , 0; sin(phi)/rho , 0; sin(phi)/rho , -1]*...
        leaderSpeed;
    fullIntegral = fullIntegral + fullDerivative*dT;
    rho = fullIntegral(1);
    alpha = fullIntegral(2);
    phi = fullIntegral(3);

    x2(i) = x1(i) - rho*cos(alpha + followerAngle);
    y2(i) = y1(i) - rho*sin(alpha + followerAngle);
    followerAngle = phi - alpha + leaderAngle - pi;

    newHeading = followerAngle + followerSpeed(2)*dT;
    dS = followerSpeed(1)*dT;
    plot(x2(i),y2(i),'o','Color',[1 0 0]);
    plot(x1(i),y1(i),'x','Color',[0 0 1]);
    drawnow;
    pause(0.1)
end
</code>```

Title: Platooning leader follower code

Body:
I don't have access to the article, so I have to guess about the expected behavior.

Looking at your code, the first thing I did was to change all of your atan functions to atan2 because atan doesn't work correctly in all quadrants. Never use atan.

That didn't fix it. So the second thing I did was to change how you calculate the follower heading (theta_follower) from the way it was calculated in the loop (which seems to be based on the leader's heading) to the way it was calculated the first time, which is based on the difference in the current position and previous position. Still no dice.

So, then I was trying to figure out how else the follower's position is determined and I noticed it's not based on the leader's position. It's based on the leader's position times the sine/cosine of the leader's heading. I don't know why the sine/cosine of the leader's heading was included in the calculation, but I removed it. And then it worked.

Now, the only thing I'm not sure about is whether the follower's heading is supposed to be the way you have it in the loop or the way you have it the first time. That is, I can't tell if you want the follower's heading to be what it actually is or if you want it to be based on the leader's heading. The first time you calculate the heading, you calculated it to be the actual heading.

If you leave the theta_follower code in the loop the way you have it, then the follower's heading is set to be whatever the leader's heading is and the follower can never catch the leader. The follower's path is offset from the leader.

If you set the theta_follower code to be the actual heading, then the follower's path looks "messier", but it is actually tracking the path of the leader. It overshoots one side, overshoots the other, then back-and-forth oscillating about the leader's path. I think this is the behavior you want, because behavior like this would have the follower on the same road as the leader. The way it was written, the leader would be on the road and the follower would (smoothly) drive on the sidewalk because it can't course-correct to the same path.

Here's the code:

x1=linspace(0,10,100); %x1 and y1 represent the leader's path
y1=sin(x1);
plot(x1(1:100),y1(1:100));
hold on;

x2=zeros(1,100);
y2=zeros(1,100);

x2(1)=-5; %x2, y2 represent the follower's position
x2(2)=-4;
landa=0.1; %represents the euclidean distance between robots

%-------
% Moved from atan to atan2
%-------
%theta_leader(2)=atan((y1(2)-y1(1))/(x1(2)-x1(1)));
%theta_follower(2)=atan((y2(2)-y2(1))/(x2(2)-x2(1)));
%alfa(2)=atan((y1(2)-y2(2))/(x1(2)-x2(2)))-theta_follower(2);
theta_leader(2)=atan2((y1(2)-y1(1)),(x1(2)-x1(1)));
theta_follower(2)=atan2((y2(2)-y2(1)),(x2(2)-x2(1)));
alfa(2)=atan2((y1(2)-y2(2)),(x1(2)-x2(2)))-theta_follower(2);

phi(2)=pi-(theta_leader(2) - alfa(2) - theta_follower(2));

for i=3:100
    landa(i)=0.1;

    %-------
    % THIS APPEARS TO HAVE BEEN THE PROBLEM
    %-------
    %x2(i)=x1(i)*cos(theta_leader(i-1))-landa(i)*cos(alfa(i-1)+theta_follower(i-1));
    %y2(i)=y1(i)*sin(theta_leader(i-1))-landa(i)*sin(alfa(i-1)+theta_follower(i-1));
    x2(i)=x1(i)-landa(i)*cos(alfa(i-1)+theta_follower(i-1));
    y2(i)=y1(i)-landa(i)*sin(alfa(i-1)+theta_follower(i-1));

    %-------
    % Moved from atan to atan2
    %-------
    %theta_leader(i)=atan((y1(i)-y1(i-1))/(x1(i)-x1(i-1)));
    theta_leader(i)=atan2((y1(i)-y1(i-1)),(x1(i)-x1(i-1)));
    %alfa(i)=atan((y1(i)-y2(i))/(x1(i)-x2(i)))-theta_follower(i-1);
    alfa(i)=atan2((y1(i)-y2(i)),(x1(i)-x2(i)))-theta_follower(i-1);

    phi(i)=pi-(theta_leader(i) - alfa(i) - theta_follower(i-1));

    %--------
    % Questionable code here
    %--------
    theta_follower(i)=phi(i)-alfa(i)+theta_leader(i)-3.1415;  % Side comment - you add pi and then subtract it for some reason.
    %theta_follower(i)=atan2((y2(i)-y2(i-1)),(x2(i)-x2(i-1)));

    %--------
    % Moved plot inside the loop to watch it for more intuition regarding
    % what's happening.
    %--------
    plot(x2(i),y2(i),'or');
    pause(0.1)
end

:EDIT:

The authors of the paper don't include the code they used to generate any of the plots. Further, it looks like implementing the block diagram they provided doesn't work either. They do state that Equation 8 is used by referencing figure 5, which means that they have, in fact, incorrectly included the sine/cosine terms. The heading of the leader does not at all affect the position of the follower.

That said, I tried implementing their block diagram after making that change and I believe it works. You skipped quite a bit in your implementation, including finding the derivative of position and heading and then performing the numeric integration. See the revised code below (the earlier code above should not be used, but I'll leave it for posterity).

Note the value k is used, as described in the paper, as a control gain to decide how well the follower tracks the leader. Play around with it to see how well the follower does or does not track the leader. Also, the initial path is odd because the follower starts so far from the leader.

x1=linspace(0,10,100); %x1 and y1 represent the leader's path
y1=sin(x1);
figure(1)
clf;
plot(x1(1:100),y1(1:100));
hold on;

x2=zeros(1,100);
y2=zeros(1,100);

x2(1)=-5; %x2, y2 represent the follower's position

%------- END ORIGINAL CODE ---------%
y2(1)=-4; % <---- NOTE: Originally this was x2(2) = -4. I'm assuming it should have been y2(1) = -4.
alpha_d = 0;
rho_d = 0.1;
rho = sqrt((x1(1)-x2(1))^2 + (y1(1)-y2(1))^2);
alpha = 0;
phi = 0;
prevLeaderAngle = 0;
followerAngle = 0;

dT = x1(2) - x1(1); % I don't have any reference for time scales or speed so I have to fake it.
k = 1;
fullIntegral = [rho; alpha; phi];

for i = 2:numel(x1)
    leaderLinearVelocity = sqrt((x1(i)-x1(i-1))^2 + (y1(i)-y1(i-1))^2)/dT;
    % Linear velocity is change in position divided by change in time.
    leaderAngle = atan2((y1(i)-y1(i-1)),(x1(i)-x1(i-1)));
    leaderAngularVelocity = (leaderAngle-prevLeaderAngle)/dT;
    prevLeaderAngle = leaderAngle;

    leaderSpeed = [leaderLinearVelocity; leaderAngularVelocity];

    formationDerivative = (k*eye(2))*[(rho_d-rho);(alpha_d-alpha)];
    followerSpeed = [-(1/cos(alpha)) , 0; -(tan(alpha)/rho) , -1] * ...
        (formationDerivative - [-(cos(phi)) , 0; (sin(phi)/rho) , 0] * leaderSpeed);

    fullDerivative = [-cos(alpha) , 0; sin(alpha)/rho , -1; sin(alpha)/rho , 0]*...
        followerSpeed + [-cos(phi) , 0; sin(phi)/rho , 0; sin(phi)/rho , -1]*...
        leaderSpeed;
    fullIntegral = fullIntegral + fullDerivative*dT;
    rho = fullIntegral(1);
    alpha = fullIntegral(2);
    phi = fullIntegral(3);

    x2(i) = x1(i) - rho*cos(alpha + followerAngle);
    y2(i) = y1(i) - rho*sin(alpha + followerAngle);
    followerAngle = phi - alpha + leaderAngle - pi;

    newHeading = followerAngle + followerSpeed(2)*dT;
    dS = followerSpeed(1)*dT;
    plot(x2(i),y2(i),'o','Color',[1 0 0]);
    plot(x1(i),y1(i),'x','Color',[0 0 1]);
    drawnow;
    pause(0.1)
end


问:
Self Driving Robotics Project : ROS or Python
So, I am working on building a simple self driving tank (small) that needs to navigate a large hall.  I plan to use ultrasonics, LIDAR and a Kinect.  I am pretty happy with how I will build all of this.  My main question is would this be easier to do in ROS or write it in Python.  I have very basic knowledge of ROS but have been programming for many years (Java, Objective C etc).

I assume I will need to load in a basic map of static objects / floor plan.  Use SLAM etc (which I see is possible in Python).

Sorry if this is a vague question. My hoping is someone on here who has used ROS a lot will turn round and say its the way to go

答:
You can use both! ROS nodes can be written in python.

I'm doing a similar project and the reusability of ros code is a nice thing to have in mind. ROS also have many things already implemented (even that you want to build everything from scratch).

The message types of ROS will also provide an easier to integrate application, for future projects and expansions.

my advice is to use ROS AND Python


问:
Numpy alternatives for linear algebra and kinematics in python?
Are there any decent python numerical package libraries besides numpy for python? Numpy relies on gfortan which itself must be compiled correctly for your platform to avoid hidden/insidious numerical errors in numpy.

I need a matrix algebra package to do kinematics, path planning, and machine learning in python that isn't sensitive to  gfortran version and compiler options.

答:
OpenCV is available with python bindings. It's not geared at strictly numerical applications, but it might be sufficient.

It includes some matrix math and machine learning algorithms.

I can't say you won't ever experience numerical problems, but it's not based on gfortran.


问:
How to connect ethernet based Hokuyo scanner?
This is a very basic beginner question, I know, but I am having trouble connecting to the Hokuyo UST-10LX sensor and haven't really found much in terms of helpful documentation online.

I tried connecting the Hokuyo UST-10LX directly to the ethernet port of a Lubuntu 15.04 machine. The default settings of the Hokuyo UST-10LX are apparently:
ip addr: 192.168.0.10
netmask: 255.255.255.0
gateway: 192.168.0.1

So, I tried going to the network manager and setting IPv4 settings manually, to have the ip addr be 192.168.0.9, netmask of 255.255.255.0, and gateway to 192.168.0.1. I also have a route set up to the settings of the scanner.

I then go into the terminal and run:

```<code>rosrun urg_node urg_node _ip_address:=192.168.0.10
</code>```

and get this output:

```<code>[ERROR] [1444754011.353035050]: [setParam] Failed to contact master at [localhost:11311].  Retrying...
</code>```

How might I fix this? I figure it's just a simple misunderstanding on my end, but through all my searching I couldn't find anything to get me up and running :(

Thank you for the help! :)

EDIT:

HighVoltage pointed out to me that I wasn't running roscore which was indeed the case. I was actually running into problems before that when I still had roscore up, and when I tried it again, this was the output of the rosrun command:

```<code>[ERROR] [1444828808.364581810]: Error connecting to Hokuyo: Could not open network Hokuyo:
192.168.0.10:10940
could not open ethernet port.
</code>```

Thanks again!

答:
Please see here:

How to interface with the UST series Hokuyo Laser Scanners


问:
Help finding robot tracks
I have a Robot with tracks. One of the tracks broke and I need to find a replacement, the tracks use the same plastic interconnects/pieces as this:

They were very popular years back. Does anyone know the brand/name?

答:
Found them on Pololu. Still don't know the exact manufacturer but I digress...

https://www.pololu.com/product/2074

Title: Help finding robot tracks


问:
Motor-controller with path output
I'm entirely new to robotics and have the following design requirement for a project I'm working on:

Given a robot capable of positioning an object in three dimensional space ( vis. a plastic extruder or syringe, etc ), allow the robot's end user to manually move that object through a path so that the robot's motor/controller will output the path taken.

I'm sure there must be motor-controller packages with such a feature, but I have no idea what keywords to search for so as to learn more about this type of hardware.

The basic idea is to allow the end user to give the robot instructions by manually moving the object through a procedure, then recording that procedure, manipulating it and playing it back.

Can anyone give me some keywords to get me started in my research?

答:
Some keywords you can use are teach and repeat robot programming, and programming by demonstration.  You can also study how teach pendants work.

EDIT (expanded to include motor controller behaviors):

For some robots, particularly hobby and educational robots, the system can just disable the brakes and/or servos (or remove the motor's bus voltage), and let the operator move the end effector by hand.  The controller, in this teach mode, records the sequence of encoder values for each joint for the entire time the robot is in teach mode, and allows subsequent playback.   For larger robots, with large link inertias, this can be challenging for the operator to do.   I have worked on systems that energize the motors and compensate for gravity so that the operator can move the end effector with ease even though the links were heavy.  This is tricky from a safety perspective, and usually require a "live man" switch to be continually engaged because the operator is in the robot's workspace with the system powered on.   Most teach and repeat processes that I've seen use a teach pendant, in which the operator uses a joystick, switches, or programming commands to guide the robot to a series of discrete "taught points," rather than recording the actual sequence of encoder values throughout the entire path.  These taught points can then be programmed into a robot's move commands, with additional options of setting motion parameters such as speeds, accelerations, and settling windows for each motion segment.

Title: Motor-controller with path output


问:
What exactly is $\omega_k$ in the stage cost of moving horizon estimation?
In (nonlinear) moving horizon estimation the aim is to estimate an unknown state sequence $\{x_k\}_{k=0}^T$ over a moving horizon N using measurements $y_k$ up to time $T$ and a system model as constraint. All the papers I've seen so far 1,2,3 the following cost function is used:

$$
\phi = \min_{z,\{\omega_k\}_{k = T-N}^{T-1}} \sum_{k = T-N}^{T-1} \underbrace{\omega_k^TQ^{-1}\omega_k + \nu_k^TR^{-1}\nu_k}_{\text{stage cost } L_k(\omega,\nu)} + \underbrace{\mathcal{\hat{Z}}_{T-N}(z)}_{\text{approximated arrival cost}}
$$

The noise sequence $\{\omega_k\}_{k = T-N}^{T-1}$ should be optimized/minimized in order to solve for the unknown state sequence using the prediction model:

$$
x_{k+1} = f(x_k,\omega_k)
$$

whereas the measurement model is defined as

$$
y_k = h(x_k) + \nu_k
$$

with additive noise $\nu$.

The question is what exactly is $\omega_k$ in the stage cost?

In the papers $\nu$ is defined to be

$$
\nu_k = y_k - h(x_k)
$$

However, $\omega_k$ remains undefined.
If I can assume additive noise $\omega$ in the prediction model, I think $\omega_k$ is something like the follwoing:

$$
\omega_k = x_{k+1} - f(x_k)
$$

If this should be correct, then my next Problem is that I don't know the states $x_k$, $x_{k+1}$ (they should be estimated).

EDIT

Is it possible that my guess for $\omega_k = x_{k+1} - f(x_k)$ is "wrong" and it is enough to just consider:

the measurement $\nu_k = y_k - h(x_k)$ in the cost function $\phi$

the prediction model as constraint?

And let the optimization do the "rest" in finding a possible solution of a noise sequence $\{\omega_k\}_{k = T-N}^{T-1}$? In this case which Matlab solver would you suggest? I thought of using lsqnonlin since my problem is a sum of squares. Is it possible to use lsqnonlin with the prediction model as constraint?

1 Fast Moving Horizon Estimation of nonlinear processes via Carleman linearization

2 Constrained state estimation for nonlinear discrete-time systems: stability and moving horizon approximations

3 Introduction to Nonlinear Model Predictive Control and Moving Horizon
Estimation

答: What helped to solve my question was to use fmincon with the process noise $\omega_k$ as decision variable and to use the measurement noise which includes the state in the equation $\nu_k = y_k - h(x_k)$. To come up with a solution for the state $x_k$ I just solve the prediction model using an initial state at the beginning of the moving window $x_{k-N}$ and also the noise sequence. Where the noise sequence is the decision variable. Using this method, the prediction model constraint is "included" in the cost function. Of course at the very first start of the optimizaiton, a random noise sequence is chosen (with magnitude according to the state variables). After each run of the optimization the shifted noise sequence from the previous run can be taken as initial guess.</p>


问:
State estimation of mobile robot
For a mobile robot - four wheels, front wheel steering - I use the following (bicycle) prediction model to estimate its state based on accurate radar measurements only. No odometry or any other input information $u_k$ is available from the mobile robot itself.

$$
\begin{bmatrix}
      x_{k+1} \\
      y_{k+1} \\
      \theta_{k+1} \\
      v_{k+1} \\
      a_{k+1} \\
      \kappa_{k+1} \\
    \end{bmatrix} =
    f_k(\vec{x}_k,u_k,\vec{\omega}_k,\Delta t) =
    \begin{bmatrix}
      x_k + v_k \Delta t \cos \theta_k \\
      y_k + v_k \Delta t \sin \theta_k \\
      \theta_k + v_k \kappa_k \Delta t \\
      v_k + a_k \Delta t \\
      a_k \\
      \kappa_k + \frac{a_{y,k}}{v_{x,k}^2}
    \end{bmatrix}
    +
    \begin{bmatrix}
      \omega_x \\
      \omega_y \\
      \omega_{\theta} \\
      \omega_v \\
      \omega_a \\
      \omega_{\kappa}
 \end{bmatrix}
$$

where $x$ and $y$ are the position, $\theta$ is the heading and $v$, $a$ are the velocity and acceleration respectively. Vector $\vec{\omega}$ is zero mean white gaussian noise and $\Delta t$ is sampling time. These mentioned state variables $\begin{bmatrix} x & y & \theta & v & a \end{bmatrix}$ are all measured although $\begin{bmatrix} \theta & v & a \end{bmatrix}$ have high variance. The only state that is not measured is curvature $\kappa$. Therfore it is computed using the measured states $\begin{bmatrix} a_{y,k} & v_{x,k}^2\end{bmatrix}$ which are the lateral acceleration and the longitudinal velocity.

My Question:

Is there a better way on predicting heading $\theta$, velocity $v$, acceleration $a$, and curvature $\kappa$?

Is it enough for $a_{k+1}$ to just assume gaussian noise $\omega_a$ and use the previous best estimate $a_k$ or is there an alternative?

For curvature $\kappa$ I also thought of using yaw rate $\dot{\theta}$ as $\kappa = \frac{\dot{\theta}}{v_x}$ but then I would have to estimate the yaw rate too.

To make my nonlinear filter model complete here is the measurement model:

$$
\begin{equation}
   \label{eq:bicycle-model-leader-vehicle-h}
   y_k = h_k(x_k,k) + v_k =
   \begin{bmatrix}
     1 & 0 & 0 & 0 & 0 & 0 \\
     0 & 1 & 0 & 0 & 0 & 0 \\
     0 & 0 & 1 & 0 & 0 & 0 \\
     0 & 0 & 0 & 1 & 0 & 0 \\
     0 & 0 & 0 & 0 & 1 & 0 \\
   \end{bmatrix}
   \begin{bmatrix}
     x_k \\
     y_k \\
     \theta_k \\
     v_k \\
     a_k \\
     \kappa_k \\
   \end{bmatrix}
   +
   \begin{bmatrix}
     v_x \\
     v_y \\
     v_{\theta} \\
     v_v \\
     v_a \\
   \end{bmatrix}
 \end{equation}
$$

More Info on the available data:

The measured state vector is already obtained/estimated using a kalman filter. What I want to achive is a smooth trajectory with the estimate $\kappa$. For this it is a requirement to use another Kalman filter or a moving horizon estimation approach.

答:
My solution is to use the following model with disturbance only at acceleration and curvature.

$$
\begin{bmatrix}
      x_{k+1} \\
      y_{k+1} \\
      \theta_{k+1} \\
      v_{k+1} \\
      a_{k+1} \\
      \kappa_{k+1} \\
    \end{bmatrix} =
    f_k(\vec{x}_k,u_k,\vec{\omega}_k,\Delta t) =
    \begin{bmatrix}
      x_k + v_k \Delta t \cos \theta_k \\
      y_k + v_k \Delta t \sin \theta_k \\
      \theta_k + v_k \kappa_k \Delta t \\
      v_k + a_k \Delta t \\
      a_k + \omega_a \\
      \kappa_k + \omega_{\kappa}
    \end{bmatrix}
$$

Title: State estimation of mobile robot


问:
Appropriate control scheme for gripper end-effector
I want to use a gripper end-effector (3 fingers, single actuator tendon-driven with force sensors in fingers) to grip and hold fragile objects such as an egg. I can not seem to figure out which control scheme would be most appropriate for the situation. Would using an impedance control with negligible dynamic interaction be effective or a hybrid control with force/position control?

My idea was to simply tense the tendon (slowly) encompassing the object until the force sensor gives a feedback that contact has been made (+ a little grip force), what category of control scheme would that fall into?

答:
If you have a simple controller (e.g. force control or position control) the factor which decides what kind of controller is it is the reference signal which has to correspond to the feedback signal.

My idea was to simply tense the tendon (slowly) encompassing the object until the force sensor gives a feedback that contact has been made (+ a little grip force), what category of control scheme would that fall into ?

If tensing the tendon is through a force signal then this is force control. If you do it by position or velocity (since you mentioned slowly) then it is position control. This idea will most probably be simple to implement and will work (but this is an opinion based remark). You will find many examples for using impedance control for gripping in the scientific literature. It is generally a good idea to start with something simple (incrementing tension until a threshold) and develop that further to impedance control if ti doesn't perform good enough.

Hybrid control has probably many different definitions, the one if which is commonly used in robotics, which is position control in on dimension, force control in a different dimension. (i.e. writing on a white board with the robot controlling the marker, keep force contact perpendicular to the position controlled heading direction).


问:
Python libraries for image processing and feedback control on raspberry pi
I'm building a motion detection and object recognition camera with feedback control for a hexy robot. Fortunately most of the servo control is handled by the analog servo controls and the high-level logic can be implemented in python on a raspberry pi. What's the right combination of python modules to implement:

a daemon/service to trigger and execute image capture and processing

a daemon/service to regularly update the hexy with the latest motion plan and servo setpoints

the image processing for recognition and tracking of objects from the webcam

I'm currently using python-daemon for the services and comparing the various pypi opencv libraries to see if any of them look promising. Anyone have experience with these on a raspberry pi or ARM processor in a robotics application?

remotecv                  - remotecv is an OpenCV server for face recognition

ctypes-opencv             - ctypes-opencv - A Python wrapper for OpenCV using ctypes

pyopencv                  - PyOpenCV - Boost.Python and NumPy

opencv-cython             - An alternative OpenCV wrapper

CVtypes                   - Python OpenCV wrapper using ctypes

Tippy                     - another Toolbox for Image Processing, based on OpenCV

These each depend on a deep list of low-level libraries and/or compilers like Boost->numpy->gfortran or cython->gcc or ctypes. I'm concerned about compatibility and performance of these lowlevel libraries on Raspbian and an ARM processor.

Anyone with a known working architecture for image processing and real-time control in python on an ARM processor will get their answer upvoted and/or accepted.

答:
You could just install OpenCV on a Raspberry Pi board and run your own performance tests.  What counts as "real-time control" and image processing will depend on your specific application, so if OpenCV can't handle it then you should post another question with more concrete performance requirements.

A colleague of mine says that:

OpenCV runs fine [on a Raspberry Pi], and is easy to install (sudo apt-get install libopencv-dev). I found the board quite capable and not far behind performance of the Beagle Board. As an example, Apriltags (http://people.csail.mit.edu/kaess/apriltags/) runs at 3.5fps at 320x240 from a USB camera


问:
Question about ROS, how to explain to someone what ROS is?
Over the summer, I have configured ROS navigation stack on a mobile robot (with radar and Kinect) so that it can autonomously navigate in the unknown environment. I also wrote a python program that allow the robot to track human motion, also using the open source library.

Currently, I am applying to software job. I thought this experience is very relevant to software programming. But, I am actually stuck on how to explain what ROS is. And when I use the packages (eg, navigation stack) on a robot, am I actually doing coding? Can I say ROS is just an API?

答:
Compare it to a message bus connecting different services through publish/subscribe mechanism. All enterprise software engineers should be able to understand this comparison.

If you write source code you are coding. If you do not write source code you are not coding. Please note that coding can also cover graphical languages like Function blocks or  similar. Coding is not necessarily only the implementation of complex algorithms, writing source code that glues together different libraries or just calling them is also coding.

ROS is not just an API.


问:
Bullet vs ODE to simulate robotic arm
For a research project at university I have been tasked with simulating a "robot arm". The simulation is to be compared with the real life version for accuracy. The arm will be lifting other objects and building simple structures in the demonstration.

My supervisor has asked that we build this simulator from scratch so I am currently selecting a physics engine.

In this link, it seems bullet is not accurate enough, albeit this was in 2010, for the original poster's needs in robotic simulation.

This comparison believes bullet is better in general but says that documentation is lacking, which is important to me as this is my first time using a physics engine such as this.

so thoughts on these or any other physics engine that may be more suitable?

答:
The accuracy of the physics engine will most likely not be a problem. Differences between real world systems and their models are a much larger factor of errors then the slight differences between physics engines so you can use any physics engine you like.

You will not be able to have accurate models (geometry imprecisions, mass characteristic imprecisions, imprecisions in friction constants, etc.)

To my knowledge OpenRAVE can do dynamics and it is meant for robotics, so you will find lots of examples on modelling robots. If you have to start from scratch you can use its API.

Title: Bullet vs ODE to simulate robotic arm


答:
Isn't using a physics engine cheating if your advisor wants you to start from scratch?

I would choose simbody over those two. It has great documentation and was designed for simulation instead of video games.

What exactly are you trying learn (or predict, or compare) from the simulator? If you want a useful simulation it matters a lot.

The history of robotics is full of simulation projects that died useless because the researcher was not really sure what they were simulating or why.

Title: Bullet vs ODE to simulate robotic arm

Body:
For a research project at university I have been tasked with simulating a "robot arm". The simulation is to be compared with the real life version for accuracy. The arm will be lifting other objects and building simple structures in the demonstration.

My supervisor has asked that we build this simulator from scratch so I am currently selecting a physics engine.

In this link, it seems bullet is not accurate enough, albeit this was in 2010, for the original poster's needs in robotic simulation.

This comparison believes bullet is better in general but says that documentation is lacking, which is important to me as this is my first time using a physics engine such as this.

so thoughts on these or any other physics engine that may be more suitable?


答:
ROS is a framework to do component based development of software for robotics.

Component based development has been around for a while in software engineering. One advantage is that you can split the process of developing components - self sustained modules that perform a specific task - and how a bunch of them are applied together in a system quite well. It creates different roles in the development process.

In your case you have used the components to get a running system. The skills you acquired seem to be in the area of python programming (I would consider this a form of coding), robotics and of course ROS.

Title: Question about ROS, how to explain to someone what ROS is?

Body:
Over the summer, I have configured ROS navigation stack on a mobile robot (with radar and Kinect) so that it can autonomously navigate in the unknown environment. I also wrote a python program that allow the robot to track human motion, also using the open source library.

Currently, I am applying to software job. I thought this experience is very relevant to software programming. But, I am actually stuck on how to explain what ROS is. And when I use the packages (eg, navigation stack) on a robot, am I actually doing coding? Can I say ROS is just an API?


问:
In vision based localization, is it possible to make multiple vehicles cooperate to improve the estimation of each other?
I am currently working on a project that involves structure from motion using multiple cameras on multiple aerial vehicles (each vehicle has a monocular camera: think of it as a distributed stereo), and I am trying to extend this to include localization as well. My pipeline currently goes: robots at known locations -> take pictures -> reconstruct.

When it comes to localizing the vehicles as well using this incrementally built map, the standard approach that comes to mind is to apply the PNP algorithm on each camera (assuming the reconstructed scene is visible to all cameras) which results in the 3D pose: but this doesn't necessarily take advantage of the fact that multiple cameras exist, apart from the fact that they are used in reconstructing the environment. Is there anything I can exploit using multiple cameras/vehicles that would result in enhanced localization accuracy of all of the vehicles as compared to a "single vehicle performing PNP on a known map" scenario?

答:
You can do it by fusion using a Kalman filter:

You have a process model model:

$$
x_t = g(x_{t-1},u_t)
$$

Now, you have multiple measurements of the same process model from different perspectives:

$$
z1_t = h_1(x_{t}) \leftarrow \text{camera 1} \\
z2_t = h_2(x_{t}) \leftarrow \text{camera 2} \\
\cdots \\
zn_t = h_n(x_{t}) \leftarrow \text{camera n} \\
$$

In the prediction step of the Kalman filter, nothing changes you have only one process:

$$
\bar{x}_t = g(x_{t-1},u_t) \\
\bar{\Sigma}_t = G_t \Sigma_{t-1} G_t^\intercal + R_t
$$

And for the update step, you have to include all the measurements:

$$
K_t = \bar{\Sigma}_t H_t^\intercal ( H_t \bar{\Sigma}_t H_t^\intercal + Q_t )^{-1} \\
x_t = \bar{x}_t + K_t ( z_t - h( \bar{x}_t ) ) \\
\Sigma_t = ( I - K_t H_t ) \bar{\Sigma}_t
$$

The trick is defining how you are building the matrices in the update step:

$$
z_t = \left[ \begin{array}{c} z1_t \\ z2_t \\ \cdots \\ zn_t \end{array} \right]
$$

$$
h(\bar{x}_t) = \left[ \begin{array}{c} h_1(\bar{x}_t) \\ h_2(\bar{x}_t) \\ \cdots \\ h_n(\bar{x}_t) \end{array} \right]
$$

$$
H_t = \left[ \begin{array}{c} H1_t \\ H2_t \\ \cdots \\ Hn_t \end{array} \right]
$$

$$
Q_t = \left[ \begin{array}{cccc} Q1_t & 0 & 0 & 0 \\ 0 & Q2_t & 0 & 0 \\ \cdots \\ 0 & 0 & 0 & Qn_t \end{array} \right]
$$


问:
Is there a way to use a single dc motor output for two different loads?
Is there a way to use a single dc motor output for two different loads (by using gears, relays etc) ? Please see the illustration below:

To clarify the illustration, I get the dc motor power at "output 1" gear which is extended over an idler gear to output 2 gear. All three are in contact (though the picture doesn't quite show it). Load 1 and Load 2 are two separate gears connected to different loads (wheels etc) and initially not in contact with the bottom gears. On switching on the relays 1, 2 - the load bearing gears, move towards the output1 and output2 and mesh with them to drive Load 1, 2.

答:
The gear trains in many printers and multifunction devices, and in some scanners, have a transfer gear that drives two different gears, depending on which way the drive motor is running.  The pictures below show several such transfer gears in the left-side gear train of a Brother MFC-1970MC (1, 2), a 1998-vintage fax/copier/printer/scanner/answering machine multifunction device.  The right-side gear train only has half-a-dozen gears in it and isn't shown.

The 1970MC has one drive motor to power four different operations: printer paper pickup, printer paper drive, scan sheet pickup, and scan sheet drive.  I suspect that the solenoid (shown in first and last pictures) selects between printer and scanner operation, and that the swinging transfer gears (some of which appear in all pictures) select between paper pickup and paper drive.

Above: When A turns CW (clockwise), D is driven by the transfer gear C.  Gears A and C go CW while B and D go CCW.  The turning resistance of C causes the arm to swing to the left.  When C encounters D, B continues forcing C to the left so that C and D mesh strongly.

Below: When A turns CCW, E is driven by the transfer gear C.  Gears A and C go CCW while B and E turn CW.

(Note, there is a one-way clutch or ratchet beneath the black gear E; when E is driven, the white gear beneath E does not turn.  When D is driven, it drives the two gears at very top center in picture, so driving the white gear beneath E.  Thus E rotates CW whenever A rotates.  D rotates CCW when A goes CW.  D does not rotate when A goes CCW.)

At the center of the picture above are two swing transfer gears, labeled P and Q.  When the solenoid is out (not energized) the hook at the end of arm R prevents Q from swinging.  Also, a hook on P (more visible in first photo) slides over end of R so if P is operating Q cannot.  When the solenoid is in, Q can swing, and the hook on P hits the end of R, so if Q is operating P cannot engage the gear to its right.


问:
What are these mechanical parts attached to robot arm structures, seen on larger robots?
Between the shoulder and elbow pitch joints, I see two types of connecting structures on larger robots. I've attached a picture.

My questions:

1) What are each of the respective mechanical parts called?

2) What is their purpose for the robot arm?

Thanks!

答:
What you marked as "pump looking things" are hydraulic springs. Their purpose is to reduce the load on the motors.

What you marked as "What is going on here" has 2 component.

A mass used as a counterbalance, also to ease the load on the motors and possibly to reduce the radial torque load on the bearing.

The four bar linkage mt allows the move the motor and gearbox of axis 3 alongside axis two, which brings the overall center of gravity to a favourable position (closer to the base).


答:
The "pump-looking" things are either hydraulic cylinders, or mechanical dampers if the robot is electrically driven.  EDIT:  I'll accept @50k4's identification as hydraulic springs.

In the "what's going on back here" department, the long thin member is a linkage.  It is part of a 4-bar parallelogram linkage which allows the forearm to be driven using a motor which is located far below the elbow (the lowest red piece in your picture).  The benefit of this arrangement is that the upper arm link does not have to carry the weight of that motor.  Please note that I am using "upper arm" in the anthropomorphic sense.  It is the link closest to the shoulder.

The other part of "what's going on back here" is the large blob of metal.  Notice that this blob has its top center carved out so that the linkage can nest in there, thus increasing the forearm's range of motion.  The blob itself is a counterweight.  By adding counterweights, the load on the motors due to gravity is reduced, even though the total inertia that the motor must move is larger.

Title: What are these mechanical parts attached to robot arm structures, seen on larger robots?

Body:
Between the shoulder and elbow pitch joints, I see two types of connecting structures on larger robots. I've attached a picture.

My questions:

1) What are each of the respective mechanical parts called?

2) What is their purpose for the robot arm?

Thanks!


问:
How to convert this arduino code snippet to AVR GCC?
I recently engaged with a university robotics project (based on ROS) and my main processing controller is Raspberry Pi and the system stability controller is Atmega 32 microcontroller (It is responsible for driving motors and check the communication protocols ex:-i2c,rs232 are working in good manner). So the motor controller of this robot is a i2c type one and and it drives the motors according to the i2c signals that coming from the i2c port of the Atmega 32 microcontroller. The main controller communicate with the Atmega 32 using rs232 protocol. So I found an arduino code as below,

```<code>// This function is called once when the program starts.
void setup() {
     // Choose a baud rate and configuration. 115200
     // Default is 8-bit with No parity and 1 stop bit
     Serial.begin(115200, SERIAL_8N1);
}

// This function will loop as quickly as possible, forever.
void loop() {
    byte charIn;
    if(Serial.available()){ // A byte has been received
        charIn = Serial.read(); // Read the character in from the master microcontroller
        Serial.write(charIn); // Send the character back to the master microcontroller
    }
}
</code>```

The communication between processing board and microcontroller as below diagram

There is an already available arduino library called rosserial for ROS. But I want this in AVR GCC.What I want is convert this code to traditional avr gcc code that work on atmel studio 6

答:
I never worked with Arduino, but there is a lot going on behind the scenes in the Arduino Serial class. The examples below should get you started, its not supposed to be compilable or functional as a whole. The example is for UART0.

Serial.begin() performs the low level initialization. If you do this manually it will look something like this:

```<code>void UART0_Init(uint32_t baud) {
    uint16_t value = (((uint32_t)F_CPU / (baud * 16UL)) - 1);

    /* Set baud rate */
    UBRR0H = (uint8_t)(value >> 8);
    UBRR0L = (uint8_t)value;

    /* Enable USART receiver and transmitter */
    UCSR0B = (1 << RXEN0) | (1 << TXEN0);

    /* Set frame format: asynchronous, 8data, no parity, 1stop bit */
    UCSR0C = (1 << UCSZ00) | (1 << UCSZ01);

    // enable UART-Receive-Interrupt
    UCSR0B |= (1 << RXCIE0);
}
</code>```

Then there is the interrupt service routine for the receiver and you would need some state variables to communicate new data to the "main process".

```<code>volatile uint8_t lastByteReceived;
volatile bool newDataAvailable;

ISR (USART0_RX_vect) {
    lastByteReceived = UDR0;
    newDataAvailable = true;
}
</code>```

The Arduino loop() represents more or less the classic while(true){} function in main().

```<code>int main(void) {
    while (1) {
        if (newDataAvailable) {
            newDataAvailable = false;
            // ...write lastByteReceived to a buffer or process it otherwise
        }
    }
}
</code>```

PS: Isn't there support for syntax highlighting on SE robotics?

Body:
I never worked with Arduino, but there is a lot going on behind the scenes in the Arduino Serial class. The examples below should get you started, its not supposed to be compilable or functional as a whole. The example is for UART0.

Serial.begin() performs the low level initialization. If you do this manually it will look something like this:

void UART0_Init(uint32_t baud) {
    uint16_t value = (((uint32_t)F_CPU / (baud * 16UL)) - 1);

    /* Set baud rate */
    UBRR0H = (uint8_t)(value >> 8);
    UBRR0L = (uint8_t)value;

    /* Enable USART receiver and transmitter */
    UCSR0B = (1 << RXEN0) | (1 << TXEN0);

    /* Set frame format: asynchronous, 8data, no parity, 1stop bit */
    UCSR0C = (1 << UCSZ00) | (1 << UCSZ01);

    // enable UART-Receive-Interrupt
    UCSR0B |= (1 << RXCIE0);
}

Then there is the interrupt service routine for the receiver and you would need some state variables to communicate new data to the "main process".

volatile uint8_t lastByteReceived;
volatile bool newDataAvailable;

ISR (USART0_RX_vect) {
    lastByteReceived = UDR0;
    newDataAvailable = true;
}

The Arduino loop() represents more or less the classic while(true){} function in main().

int main(void) {
    while (1) {
        if (newDataAvailable) {
            newDataAvailable = false;
            // ...write lastByteReceived to a buffer or process it otherwise
        }
    }
}

PS: Isn't there support for syntax highlighting on SE robotics?


答:
Firstly, the Arduino IDE already uses the AVR GCC compiler. Put another way, all of your Arduino (.ino) code gets transformed into a C++ (ie .cpp) file and then gets compiled with AVR GCC.

The easiest way to move to Atmel/Visual Studio is to use Visual Micro. It is a great product, the documentation is good and the transition is almost seamless.

To migrate your code manually you will have to first convert your .ino file into a .cpp file (see). All of the raw libraries can be found in the Arduino instalation folder. My files were located at C:\Program Files (x86)\arduino-x.x.x\hardware\arduino\cores\arduino\. Any other external libraries will also need to be moved into your new project folder from C:\Program Files (x86)\arduino-x.x.x\libraries\.

Title: How to convert this arduino code snippet to AVR GCC?

Body:
I recently engaged with a university robotics project (based on ROS) and my main processing controller is Raspberry Pi and the system stability controller is Atmega 32 microcontroller (It is responsible for driving motors and check the communication protocols ex:-i2c,rs232 are working in good manner). So the motor controller of this robot is a i2c type one and and it drives the motors according to the i2c signals that coming from the i2c port of the Atmega 32 microcontroller. The main controller communicate with the Atmega 32 using rs232 protocol. So I found an arduino code as below,

```<code>// This function is called once when the program starts.
void setup() {
     // Choose a baud rate and configuration. 115200
     // Default is 8-bit with No parity and 1 stop bit
     Serial.begin(115200, SERIAL_8N1);
}

// This function will loop as quickly as possible, forever.
void loop() {
    byte charIn;
    if(Serial.available()){ // A byte has been received
        charIn = Serial.read(); // Read the character in from the master microcontroller
        Serial.write(charIn); // Send the character back to the master microcontroller
    }
}
</code>```

The communication between processing board and microcontroller as below diagram

There is an already available arduino library called rosserial for ROS. But I want this in AVR GCC.What I want is convert this code to traditional avr gcc code that work on atmel studio 6


答: Impedance control is some kind of analog control. It can be implemented on memory based circuits from the 1950s. That was state-of-the-art before the NASA was on the moon. Some authors has extended this control schema with reinforcement learning. A better possibility for controlling a robohand is to use digitalcomputer only. That means, no mathematical formulas or analog circuits are the way to go, but algorithms, software-engineering and programmable computers. A good starting point is to implement a randomized algorithm (perhaps in matlab) which uses a behavior tree to "reach", "pregrasp" and "grasp" an object. The parameters which are difficult to calculate like the grasppoint or the direction of the gripper can be leave out as random. The algorithm works because after 10 or more repetitions the gripper uses the right parameters via luck.</p>

Title: Appropriate control scheme for gripper end-effector

Body:
I want to use a gripper end-effector (3 fingers, single actuator tendon-driven with force sensors in fingers) to grip and hold fragile objects such as an egg. I can not seem to figure out which control scheme would be most appropriate for the situation. Would using an impedance control with negligible dynamic interaction be effective or a hybrid control with force/position control?

My idea was to simply tense the tendon (slowly) encompassing the object until the force sensor gives a feedback that contact has been made (+ a little grip force), what category of control scheme would that fall into?


答:
I believe the term you're looking for is compliant control. In a compliant control system, there is a position reference and a force reference, and essentially each is allowed to actuate the joint until either achieves the reference.

So, if you had a position reference of 10 and a force reference of 1, then both the force and position controllers would want to move in the "+" direction. If an obstacle is encountered in the environment, then the position controller is essentially "paused" because the force output of the actuator achieved its goal of 1. As soon as the obstacle clears, the force output drops (because nothing is resisting any more) and the motion resumes until either force or position goals are achieved.

There are a variety of ways compliance is achieved - series elastic actuators, torque/force limits (clamping), parallel control loops, etc., but everything that utilizes the concept of a force-limited position control system is called "compliant".


问:
Connected battery, esc and motor does not power up the arduino
I am currently doing my first arduino project and i am having trouble finishing it.

I have a 3s lipo battery connected with an esc (120A) that is connected to a motor (270KV). From the esc i am connecting two jumper cables that goes to GND and pin 9.
I do not have a jumper cable on the red wire from the ESC.

This is how it looks:

Below you can see a link to a sketch that I found online. The only difference compared to my schematic is that I have an Arduino Uno.

When I insert the battery and switch the ESC to "on" the ESC starts up correctly and the fan starts to go. But the arduino does not get any power. It is still "OFF".

I also noticed that my motor has 4 cables. 3 "bigger" cables that goes to the ESC's 3 big cables. And then a 4th one hanging loose right now because i do not quite know what to do with it. I also noticed there is a hole in the ESC where I can insert this. The hole has 6 "inputs" however where as the loose wire from the motor has 5. Therefor I am a bit concerned if that should be connected there or not.

So to summarize, the problem is that the Arduino does not turn "ON" with my current schematic.
Any help, tips is very appreciated!!

答:
your arduino is off because you are not powering it. you need to power the arduino.

The battery in the drawing is used exclusively to power the motor. The arduino needs its own separate power supply.

To power the arduino off of a battery you will need something like this.

you can set the output voltage via a usb connection.

If you have additional questions please start a new thread.