用MATLAB控制一个真实的机械臂

所需积分/C币:27 2018-08-05 15:14:46 857KB PDF

本文档描述了如何将一个真实的、相对便宜的hobclass机器人连接到机器人工具箱的MATLAB程序。
3 DRIVING THE ROBOT 2 Getting started The first step is to connect the robot to a usb port on your computer and power it up. An LED will light on the ArbotiX board underneath the robot but apart from that nothing else will happen, the robot will not move. It's useful at this point to note which serial port device your operating system has created to communicate with the ArbotiX. On a linux r Macos system s ls /dev/tty* and for my computer I scc a devicc that I haven't sccn bcforc callcd /dev/tty. usbserial-A8OOJDPN 2.1 Flashing the Arbotix Next you need to ensure that the correct software is installed on the arbotix. You need to have the arduino ide installed on your computer and this can be downloaded from free from arduino. cc. This web site has a great deal of information to help somebody starting out with arduino. To run Arduino you will also need to have Java installed. Run arduino and cxit in ordcr to crcatc the default filos Arduino keeps extensions in a part of the filesystem that varies according to operating system. Under Macos it is in"/Documents/Arduino. Download the arbotix-XXXX zip file from Trossen Robotics and copy its arbotix folder on top of the folder Arduino. The other top level folder, pypose, contains a Python script Lo cOmmunicate with the pypose application loaded into thc ArbotiX Howevcr we will usc a matlab program to pcrform this role instead Now run arduino again, and use the Tools menu options to set the serial port and the type of board, select Arbotix. Select File/Sketchbook/pypose to open the pypose application source code and then verify it and upload it. In Arduino all programs are referred to as sketches. The program will be loaded into flash program memory so this step need only be done once 3 Driving the robot 3.1 Make MaTlAB talk to your robot Connect the robot to your computer as above and start MATLaB > arb= Arbotix('port',//dev/tty. usbserial-A8OOJDPV',servos, 5) arb= Arbotix chain on serport /dev/tty usbserial A800JDPN (open) 5 servos in chain If the class Arbot ix cannot be found then add robot/interfaces to your path. The following command will do the trick Copyright(C Peter Corke 2013 3.2 Exercising the robot 3 DRIVING THE ROBOT addpath(fu11fiie( fileparts( which( startup_xvc′)),′ robot′,′ interfaces′)) If you already have a connection to the Arbotix open you will see a warning message and the class will destroy the old connection before creating a new one Now you have a connection to the robot through the workspace class variable arb > about arb b [Arbolix 1x1(112 byLe 3.2 Exercising the robot Lel's start with something innocuous, laking the temperature of the servo notors > arb. gettemp 彐ns 41 40 which is the temperature of each servo motor in degrees Celsius. They are a bit warmer than ambient Now let's get the actual angle of joint l, the waist joint > arb getpos (1) ans 0.0869 which is the angle in radians. Of coursc, for your robot you will most likely gct a diffcrcnt answer. You can get the joint angle for the other joints in a similar way. We can get all the joint angles simultaneously >g- ark ([]) -0.0818 0.4500 3.7159 0.1125 where we consider the empty vector [ lo be the wildcard ineaning all joints Now lct's try a cautious motion, wo'll movc the gripper to its current position b setpos(5, 9(5)) and nothing happens. Lot's change the gripper anglo arb. setpos(5, 9(5)+0.5) and we hcar a noisc and scc the gripper fingers move slightly Now let's move the whole robot to its current location rb. setpos(q) d actually the method has to ask each servo in turn for its joint angle, but at the MATLaB level we can consider it instantaneous Copyright(C Peter Corke 2013 4 ROBOT KINEMATICS and the gripper moves back to its original location Enough with caution, lets move all joints by a small amount arb, setpos(q+0,1*[11110]) a II joints moved. Make sure that you have the robot, sitting squarely on the desk, perhaps with a heavy book across the back feet so that it doesn't topple over. This simple move command simply tells the servos to move a new position, and they go as fast as they can We can set the speed Lo swelling lore sedale b. setpos(q,3*[11111]) which moves back to the original pose but with all joints set to a velocity of 3 encoder units per second. The setpos ()and getpos () methods make the conversion from encoder counts to angles The robot is quite rigid since the Dynamixel servos are doing their job very well. We can relax the robot b > arb relax() which puts all the servos into a zero torque mode and we move the joints by hand. The only force we feel is due to the friction in the Dynamixel gearbox. Change the configuration of the robot and then check the new joint angles g=arb. getpos( 0.0102 0.5573 1.1505 0.5829 0,0051 We can disable the relaxed mode b > arb relax([, false) which causes the dynamixels to start servoing to whatever joint angle they currently have 4 Robot kinematics Wc can crcatc a kinematic modcl of thc phantom robot by > mdl phantom which creates the workspace variables px (the robot) and qz which are the zero joint angles. Although the robot has five servo motors, since one is the gripper, this robot has only lour joinTs The Dynamixel servos have an encoder value that varies from 0 to 1023 corresponding to -150 to 150 deg of rotation Copyright(C Peter Corke 2013 4.1 Forward kinematics 4 ROBOT KINEMATICS >>px pX Phantom (4 axis, RRRR, stdDH) theta a⊥pna 40 0) 1.571 3 qqqq 0 105 3.142 0 105 0 0 105 0 c base=1000Lcc1=00-10 0100 -1000 0010 001 001 The physical robot has it's base coordinate frame as shown in Figure 1. Something about Lool transforon Lct's plot the robot in its zoro angle posc > px plot(gz) and we see it is standing straight up. We can drive the graphical robot around using the irtual teach pendant px. teach() and manipulating the sliders causes the graphical robot to move. Note the coordinate frames of the world and of the tool We can also plot the pose of the actual robot, earlier we read the joint angles, so > px plot(q) should reflect the pose of your physical robot 4.1 Forward kinematics The pose of the end-effector can be determined using forward kinematics, so for the actual pose of the physical robot that is > px. fkine(q(1: 4)) ans 0.9999 0.0102-0.0102 4.2268 0.0102-0.9999-0.0001-0.C432 0.0102 0.00003.9999321.1689 0 0 1.C000 Copyright(C Peter Corke 2013 4.2 Inverse kinematics 4 ROBOT KINEMATICS Note that the translational component has units of millimetres, and that we had to explic- itly specify q(1: 4) since the robot has four joints but q has five servo motor positions The cnd-cffector posc can bc cxprcsscd morc concisely as > trprint(ans t=(4.22678,0.0432253,321.169),RFY=(0.00599222,0.585907,179.414)deg 4.2 Inverse kinematics When the robot is reaching down to lift an object the z-axis of its end-effector is pointing downward, that is, in the negative world z-direction. It's x-axis will be pointing in the same direction as the world x-axis. We can create a pose by T=transl(150,80,0)*trotx(pi ⊥.0000 0150.C000 1.0000-0.000080.C000 0.0000 1.0000 0 0 1.C000 which has its orientation consistent with that of the end-effector trying to reach an object Now we will compute the joint angles required to achieve this end-effector configuration The robot is underactuated so we need to specify a mask matrix to indicate the dof that we care about. We will choose: x. y z and the orientation of z. > qpx. ikine(T, zr [11 100 1 Warning: Initial joint angles results in near-singular configuration, this may slow convergence In Seriallink. ikine at 140 Warning: solution diverging, try reducing alpha In Seriallink, kine aL 234 Warning: solution diverging, try reducing alpha In seriallink, ikine at 234 Warning: ikine: iteration limit 1000 exceeded (row 1), final err 2.389275 Tn seriallink.kine at 161 8.9349-8.7578-8.5723-10.5647 As a quick sanity check we will perform the forward kinematics for these joint angles > px fkine() ans -0.5101 0.4705 0.7200150.C066 0.2720 0.8824 0.383979.9876 -0.81600.0000-0.5781-0.C000 0 0 1.C000 Copyright(C Peter Corke 2013 5 A ROBOTARM OBJECT and we see that the translational components are very close, accurate to three significant figures. The orientation is clearly quite different but as already discussed a robot with only four joints cannot achieve an arbitrary oricntation at cvcry point in its workspace We receive quite a few warning messages and the joint angles are well outside the range t to T. However we did start with a very naive estimate of the joint angles to achieve this end-effector pose. A more sensible initial pose might be >>qn=[00.6 1.2] which can be found by using the graphical teach pendant to position the robot into the approximate pose. Now the inverse kinematics has fewer warnings > =px. ikine(T, gn, [111 0 11) Warning: Initial joint angles results in near-singular configuration, this may slow convergence In seriallink. ikine at 140 Warning: ikine: iteration limit 1000 exceeded (row 1), final err.489862 In seriallink. ikine at 161 49000.6236-1.1427-1.3211 and gives a result with the joint angles within the range -t to T 5 A RobotArm object So far weve been using two objects to represent our robot: px is the standard Toolbox kinematic model that performs kinematics, plotting, teaching and so on, and arb is an interface to the real robot. We can combine them into a single more useful object > arm= RobotArm(px, arb) The ncw object > about arm arm [RobotArm] 1x1(112 bytes is a subclass of the seriallink class so it inherits all its methods. however it now has a link to the real robot and some additional methods Iet’ s start with > armmirror( which puts the arm into the relaxed mode mentioned earlier, but continually reads the joint angles and reflects them to a graphical version of the robot. As you move the physical robot rou can see it moving on the screen. The joint angles can be obtained with gI= arm. geta( Copyright(c Peter Corke 2013 REFERENCES REFERENCES The gripper servo is treated separately from motor servos. We can close the gripper gripper(0) illy open it > arm gripper(1) The argument is a floating point number between 0(fully closed )and 1(fully open) We can move smoothly to a pose by > arm jave(qz, 5) which will move the robot to the desired joint configuration in 5 seconds. The actually trajectory used is computed using the Toolbox function traj( ALSO CMOVE References 1]P. I. Corke, Robolics, Vision B CoTlrol: Furcdamnenlal Algorilhunus in MATLAB pringer,2011.ISBN978-3-612-20143-1 Copyright(C Peter Corke 2013

...展开详情

评论 下载该资源后可以进行评论 2

qq_44855357 可以参考学习
2019-04-13
回复
常微分方成 学习学习下
2019-04-01
回复
img
Elen005
  • 分享宗师

    成功上传21个资源即可获取

关注 私信 TA的资源

上传资源赚积分,得勋章
    最新推荐