Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Задани на лабораторные работы. ПРК / Professional Microsoft Robotics Developer Studio

.pdf
Скачиваний:
126
Добавлен:
20.04.2015
Размер:
16.82 Mб
Скачать

www.it-ebooks.info

Chapter 14: Remotely Controlling a Mobile Robot

Summary

Setting up and programming a LEGO NXT Tribot and a Parallax Boe-Bot are covered in detail in this chapter. It should be apparent that a lot of real-world challenges affect the operation of a robot, and even seemingly simple tasks might not be easy.

You now know how to create manifests to orchestrate services, and you should understand how to use config files. The last part of the chapter explained how to subscribe to sensors and use the information to make simple steering decisions. Along the way, you played with the Dashboard and created a shortcut so that you can easily run your robot.

This chapter has used the services that come with MRDS. The next couple of chapters explain how to write your own services and develop more complex applications.

653

www.it-ebooks.info

www.it-ebooks.info

Using a Robotic Arm

The previous chapter discussed remotely controlling a wheeled robot. This chapter covers using a robotic arm, which is substantially different. Although robotic arms can be attached to a mobile robot, they are usually fixed to the floor or a table, and can therefore be directly connected to the PC that controls them with no need for wireless communication or an onboard PC.

There are many different types of articulated, robots, and arms are only a small subset. For example, bipedal humanoid robots are articulated, and so are robots that emulate snakes. However, the robot arms that build cars are probably one of the first and most successful applications of robotics in industry.

Relatively cheap hobby arms are available from several sources, such as Lynxmotion. This chapter shows you how to use a Lynx 6 robotic arm to do some simple operations. The L6 is a small, lightweight arm that is intended for hobbyists and education. The software on the book’s website (www.proMRDS.com or www.wrox.com) includes a Lynx6Arm service for controlling the arm, as well as some examples demonstrating how to use it. The original service software and several of the photos in this chapter are courtesy of Lynxmotion.

A Lynx arm is not suitable for industrial use. For that you need something like a heavy-duty arm from KUKA. You might be interested in trying out the KUKA Educational Framework for MRDS, available for download from www.kuka.com.

The KUKA framework contains several tutorials using a simulation of a KUKA LBR3 arm. However, the tutorials rapidly get into complex mathematics. The objective in this chapter is to provide an overview without going into the great depth of the KUKA tutorials.

If you have not read Chapter 8, it would be a good idea to go back and do so now. It introduces a lot of key concepts for articulated arms and does so using a simulation so that you don’t have to worry about breaking anything if you make a mistake! This chapter assumes that you are familiar with the material in Chapter 8.

www.it-ebooks.info

Part IV: Robotics Hardware

Introduction to Articulated Arms

The common factor for all articulated robots is joints. Joints can take a variety of forms, with the most common type based on a servo that can rotate around a single axis. In this case, the position of the servo is referred to as the axis angle or twist around the main axis (also called the local axis).

The Joint class in MRDS describes the type of joint, how it is connected, and several other properties. Each joint has one or more values associated with it that describe the current pose of the joint. Usually, the application maintains these values itself so that it always knows the configuration of the arm. Some arms enable you to query their current position or they provide continuous feedback. This is important for ensuring that the state information in your service actually matches the real state of the arm.

There are two primary types of joints in MRDS: angular and linear. This chapter deals exclusively with angular joints because that is what the L6 arm uses.

Rotation of a servo can be changed into a linear motion using appropriate gears. For example, a gripper can be built using a servo to spread the fingers apart or squeeze them together. Figure 15-1 shows a close-up of a L6 arm gripper in which the gears and linkages are clearly visible. The gripper servo is underneath the hand and is not visible. The servo in the middle of the wrist is for rotating the wrist, whereas the one at the end of the arm (on the right-hand side of the photo) is for tilting the wrist up and down.

Figure 15-1

Pictures of the L6 arm are courtesy of Lynxmotion and are available from

its web site (www.lynxmotion.com).

In Chapter 8, the simulation uses two linear joints to make the gripper. This complexity is hidden from you if you connect to the simulated L6 arm using the generic contract for articulated arms.

The state of an articulated arm consists of, at a minimum, a list of joints and an end effector pose. The purpose of the joint list is obvious, but if you have never used an arm before, the term end effector might be new to you.

Most robotic arms have a gripper or some other device at the end of the arm to do useful work. This is called an end effector or sometimes a tool. The location and orientation of the end effector is the most valuable piece of information that you can have. Unfortunately, as explained in a moment, determining the position of the end effector is a complicated process.

656

www.it-ebooks.info

Chapter 15: Using a Robotic Arm

The KUKA documentation uses two terms related to the end effector:

End of Arm (EOA): The EOA is the very extremity of the arm. In the case of the L6 arm it is the tip of the gripper fingers. As the gripper opens and closes, the linkages cause the tips of the fingers to move slightly closer or farther away from the wrist (as well as side to side). This small variation is not worth worrying about.

Tool Center Point (TCP): The TCP is the location inside the tool that is important for operating the tool. For a gripper, this is midway along the fingers, where the gripper makes contact with an object that it is supposed to pick up. If you refer to Figure 15-1 and imagine an object in the center of the gripper, you will understand the difference between EOA and TCP.

Servo Basics

Servo motors are used in remote-controlled (R/C) toys such as cars and airplanes. Due to the large number of motors produced each year, they have become commodity items that are readily available in a range of sizes and types. There are both digital and analog servos, but the difference is not important here.

To move a servo, you send it a series of pulses 50 times per second (20 milliseconds apart), with the width of the pulses controlling the rotation angle of the servo horn. Figure 15-2 shows a servo with the corresponding pulses and rotation angles. The white disc on the servo is the horn, although servos often come with a horn shaped like a cross. Notice its orientation.

0.50mS

Servo

hitec 90

HS-422

1.5mS

Servo

hitec Centered

HS-422

2.50mS

Servo

hitec 90

HS-422

Figure 15-2

Reproduced from the SSC-32 Users Manual version 2.0 with permission from Lynxmotion.

657

www.it-ebooks.info

Part IV: Robotics Hardware

The L6 arm has a Lynxmotion SSC-32 controller that is used to send the appropriate pulses to the servos, which means that the MRDS service does not have do to this every 20ms. The SSC-32 can handle up to 32 servos, but the arm only has 6. It interfaces to a PC using a serial port.

A servo motor continues to drive the servo horn until the correct angle is obtained. (Servos have an internal sensor, usually a potentiometer, to measure the angle.) If the servo is prevented from reaching the desired angle, it will keep pushing in the appropriate direction, effectively applying pressure, but this causes high current drain on the power supply, and there is a limited amount of torque that the servo can apply. Once the servo reaches the correct orientation, it resists external attempts to move it and effectively “locks” itself in place. However, as soon as the power is turned off, the servo will “slump” down depending on the weight of the linkages that it is holding.

Most servo motors only need to operate over a range of 45 to 45 degrees, e.g., for the control surfaces for flying a plane. However, it is quite common for servos to have a range of 90 to 90 degrees, and some might operate over 180 to 180 degrees.

Some inexpensive robots, including the Boe-Bot, use modified servo motors in which the potentiometer has been removed or disabled. Because the servo can never find its target location, it keeps driving in the same direction and, in effect, becomes a conventional electric motor.

The last point to note about servos is that when you power them up, the servo controller usually has no idea where the servos are positioned. The interface to a servo consists of only three wires: power, ground, and pulse. There is no way for them to provide feedback. As a result, as soon as you start sending pulses to the servo, it jumps from its initial position to the specified position. For an arm, this can be quite surprising and even dangerous.

Controlling Joints: Speed and Travel Constraints

Driving an arm to reach a particular position involves sending commands to the various joints. Because the joints cannot instantaneously reach their destinations, you need to employ some strategy to ensure that the servo motors are not overloaded. There are physical limits to how fast a servo can move based on the maximum torque that the motor can apply.

Speed

In general, the speed of a joint should be kept well below its physical maximum to avoid burning it out. Another speed consideration is that the arm has inertia, and if it moves too fast it will overshoot, causing it to oscillate backwards and forwards as it settles down to the final destination.

The Lynx6Arm service provided with this chapter limits the speed that joints are allowed to move because the L6 arm is a little fragile. The service does this by calculating the difference between the current joint angle and the desired joint angle, calculating the time required based on a maximum angular speed, and then instructing the SSC-32 controller to make a timed move. If a time parameter is not supplied in a command to the SSC-32, the joint jumps to its destination as fast as possible.

The following code in the Lynx6Arm service handles the SetJointTargetPose request that sets the value for a single joint. You don’t need to know how it works in order to use the request, but it is interesting to understand how the service works under the hood.

658

www.it-ebooks.info

Chapter 15: Using a Robotic Arm

The function starts by looking up the joint details and converting the joint orientation to an angle in degrees. As with many MRDS operations, there is a lot of converting to and from quaternions and axis angles when you are working with joints. You need to become familiar with these — for example, to make a SetJointTargetPose request!

private IEnumerator<ITask> SetJointPoseHandler(armproxy.SetJointTargetPose update)

{

//Find out which joint it is from the name string name = update.Body.JointName;

int index = _channelLookup[name];

//Get the joint

Joint j = _jointLookup[name];

// Figure out the desired angle in degrees

AxisAngle orientation = update.Body.TargetOrientation;

float orientationAngle = orientation.Angle * Math.Sign(orientation.Axis.X); float jointAngle = Conversions.RadiansToDegrees(orientationAngle);

The time parameter is calculated based on the change in the joint angle and the MaxAngularSpeed, which is a value set in the service state. If you want to make the arm move faster, you can change the value of MaxAngularSpeed and recompile the service. (It is not exposed through a configuration file.) However, be aware that making the arm move too fast can make it wobble!

float angleDiff; int moveTime;

//Calculate the difference between the current angle and the

//requested angle and then figure out the time to take angleDiff = Math.Abs(jointAngle - _state.Angles[index]);

//Calculate the elapsed time for the move

moveTime = (int)((angleDiff / _state.MaxAngularSpeed) * 1000.0f); // If the time is very small, ignore it

if (moveTime < 20) moveTime = -1;

The jointAngle is saved in a cache in the state for use the next time. It must be converted to a servo angle and then to a pulse width to send to the SSC-32. The conversion function called JointAngleToServoAngle allows remapping of the joint angles and is used to make the real arm match the conventions used in the simulated arm. Following the conversion, the information is put into a SSC32ServoMove request and sent to the SSC-32 controller. Note that the joint properties also contain a speed parameter that can act to limit the speed of movement.

//Update the joint angle in the state now

//NOTE: This will also be updated during a Get request

//with info from the arm itself

_state.Angles[index] = jointAngle;

int servoAngle = JointAngleToServoAngle(index, (int)(orientationAngle * 180 / Math.PI));

(continued)

659

www.it-ebooks.info

Part IV: Robotics Hardware

(continued)

int pulseWidth = AngleToPulseWidth(servoAngle);

ssc32.SSC32ServoMove moveCommand = new ssc32.SSC32ServoMove(); moveCommand.Channels = new int[1] { index }; moveCommand.PulseWidths = new int[1] { pulseWidth }; moveCommand.Speeds = new int[1] {(int) physicalmodel.Vector3.Length(

ProxyConversion.FromProxy(j.State.Angular.DriveTargetVelocity))};

//Always apply some sort of reasonable time so that the arm does

//not move suddenly

moveCommand.Time = moveTime;

ssc32.SendSSC32Command command = new ssc32.SendSSC32Command(moveCommand); _ssc32Port.Post(command);

yield return Arbiter.Choice(command.ResponsePort, delegate(ssc32.SSC32ResponseType response)

{

update.ResponsePort.Post(DefaultUpdateResponseType.Instance);

},

delegate(Fault fault)

{

update.ResponsePort.Post(fault);

}

);

}

Notice that the code posts a response back to the caller as soon as the command is sent to the SSC-32. At this stage, the motion will not have completed. There are various options here. In the case of the sample applications in this chapter, the code simply waits for a period of time before issuing a new motion request. Alternatively, the arm service could interrogate the SSC-32 to determine when the motion has completed and only send the response after the command has finished executing. The simulation takes this approach.

Travel Constraints

There is another architectural issue here. The Lynx6Arm service implements a hard constraint on the speed of arm movements. In the case of the simulation, the limit is applied by the caller specifying the amount of time allowed for the motion to complete. It is up to you whether you want to impose an internal limit and treat the arm as a “black box” or take complete control and suffer the consequences of getting it wrong. However, the Lynx6Arm service tries to protect novice users from themselves.

Ideally, to minimize the stress on the motors and the jerkiness of the motion, each joint should gradually accelerate to some maximum speed, travel at this speed for a while, and then decelerate so that it arrives at its destination. The KUKA documentation defines three different approaches for point-to-point (PTP) motion:

Asynchronous PTP: All joints get to their target destinations in the shortest possible time.

Synchronous PTP: Joints travel at different speeds so that they all arrive at the same time.

Fully Synchronous PTP: The acceleration and deceleration phases are also synchronized to minimize wear and tear on the joints.

660

www.it-ebooks.info

Chapter 15: Using a Robotic Arm

As shown in the preceding code, the Lynx6Arm service does not do any accelerating or decelerating. It does apply a maximum speed, however, and most of the time this works fine. The extra sophistication and overhead of a motion planner are not essential.

Although it might be obvious, it is important to realize that an arm cannot move to every possible position within a hemisphere around its base. There are combinations of joint angles that will violate constraints either on the way that the joints and linkages are interconnected or on the servo motors themselves. In addition, of course, there are combinations of angles that will result in the arm crashing into the ground. In fact, an arm has a fairly limited range over which is it safe to operate.

Another problem is that an arm is a cantilever and there can be large stresses on the joints when the arm picks up a heavy object. The L6 arm has a load limit of only about 85g. It can successfully pick up an AA battery, but it is not a good idea to have it pick up anything much heavier than this.

Lastly, if you have never used an arm before, it might not be apparent to you that moving the EOA in a straight line is a nontrivial task. Joints rotate, so changing the angle of a joint invariably means that you have to change the angle of another joint to compensate and keep the EOA moving in a straight line.

This is referred to as linear motion, and most industrial applications require linear movements. If you have an industrial robotic arm, the controller itself might be able to do the necessary calculations on-the- fly. In that case, you are off the hook, but if you have a hobby robot arm like the L6, then you need to interpolate a series of points along the motion path and execute them in sequence.

Luckily, if you are only moving a small distance, such as approaching an object to pick it up, the motion of the arm is approximately linear provided that all of the joints move simultaneously in a synchronous PTP fashion. The Lynx6Arm service does not implement linear motions, but as you will see from the sample applications this is not a significant problem.

The KUKA tutorials discuss at length the various approaches to motion planning and control for moving robotic arms. The calculations are quite complex, and are not implemented in the Lynx6Arm service.

Forward Kinematics

An articulated arm consists of a set of linkages with servos at the joints. The more joints there are, the more complex the calculations are to determine the location of the end effector. Given the values of all of the joint angles, the process of calculating the end effector pose is called a forward, or direct, kinematic transformation.

Arm Linkage Configuration

Forward kinematics can be done using simple geometry if you know the configuration and measurements of the arm linkages. Using the L6 arm as an example, the forward kinematics calculations can be done as explained here.

This chapter does not cover the general case of kinematics for all robotic arms, but concentrates on the specific case of the Lynx 6 arm. Unless you are building your own robotic arm, you shouldn’t need to write your own code to perform these calculations; the manufacturer should provide you with the necessary software. In the case of the Lynx 6, the RIOS (Robotic arm Interactive Operating System) software that comes with the arm does the necessary calculations and can be used to control the arm. However, this book is about MRDS, so the calculations are embedded in the Lynx6Arm service.

661

www.it-ebooks.info

Part IV: Robotics Hardware

The physical dimensions of the arm are provided in the following table. All measurements are between joints’ centers, except for the last one, which is measured to the tip of the gripper. The values in the table are in inches because these are the units that the manufacturer uses. However, MRDS works in meters so the values need to be converted. (The conversion factor of 1 inch equals 2.54cm is exact because the two systems were aligned a long time ago to allow precise conversions.)

Link

Length

 

 

Base to Shoulder (H also called L0)

2.5"

Upper Arm (L1)

4.75"

Lower Arm (L2)

4.75"

Hand (L3)

5.75" (L3 L4 L5)

Wrist to Wrist Rotator (L4)

2.25"

Gripper (L5)

3.5"

 

 

Forget about the wrist rotation (which happens between L4 and L5). It is not really relevant, as most of the time the wrist will be horizontal. The “tip” of the gripper is always taken to be the point midway between the tips of the two fingers, regardless of how far open the gripper is.

Finally, a Use for Grade-School Geometry

First, note that the shoulder, elbow, and wrist joints all rotate in the same plane. This is an important point because it allows simple geometry to be used, rather than 3D matrix algebra.

If you look at the arm side-on, the linkages for a typical pose of the robot might look like the simplified diagram in Figure 15-3. The wrist is rotated in the diagram so you can see the two fingers. The hand consists of the wrist rotation mechanism and the gripper, but for the purposes of the example it is only necessary to know the total length of the hand (L3).

 

 

Wrist

 

 

 

Joint

y

Elbow

 

 

 

 

 

Joint

Lower Arm

Hand

x

 

 

 

 

 

 

z

 

Upper Arm

 

 

Shoulder

 

Height

Joint

 

 

 

 

 

Base

Depth

Figure 15-3

The height and depth specify the location of the tip of the gripper relative to the center of the base, which is the origin. A right-hand coordinate system is shown in Figure 15-3. It is intended to show the

662