Robotics Toolbox - SerialLink.plot使用說明(en)

以下內容來源:rvctools\robot@SerialLink\plot.m、rvctools\robot\Octave@SerialLink\plot.m
工具箱版本:v9.10

每次都找文件,費勁,放在這兒當筆記查詢使用。結合本文,可以設置Robotics Toolbox中機器人的顯示問題,如設置工作區大小,設置視角,設置是否顯示基座,是否顯示手腕、是否顯示手腕標籤,是否顯示末端軌跡點,地板顏色等等等等~

Ctrl+F調出查找框,輸入關鍵詞搜索。

使用案例

  • puma560.plot(q,'movie','M'):%保存過程爲png圖片,存儲在當前工作目錄下的/M目錄下
  • puma560.plot(q,'tile1color',[0 255 255],'tile2color',[255 251 0]):設置地板顏色爲青色、金色相間

在這裏插入圖片描述

  • puma560.plot(q,'trail','.r','notiles'):設置顯示末端軌跡點,無地板

在這裏插入圖片描述

RGB顏色查詢:www.sioe.cn/yingyong/yanse-rgb-16/

SerialLink.plot Graphical display and animation

R.plot(Q, options) displays a graphical animation of a robot based on the kinematic model. A stick figure polyline joins the origins of the link coordinate frames. The robot is displayed at the joint angle Q (1xN), or if a matrix (MxN) it is animated as the robot moves along the M-point trajectory.

Options:

  • ‘workspace’, W Size of robot 3D workspace, W = [xmn, xmx ymn ymx zmn zmx]

  • ‘floorlevel’,L Z-coordinate of floor (default -1)

  • ‘delay’,D Delay betwen frames for animation (s)

  • ‘fps’,fps Number of frames per second for display, inverse of ‘delay’ option

  • ‘[no]loop’ Loop over the trajectory forever

  • ‘[no]raise’ Autoraise the figure

  • ‘movie’,M Save frames as files in the folder M

  • ‘trail’,L Draw a line recording the tip path, with line style L

  • ‘scale’,S Annotation scale factor

  • ‘zoom’,Z Reduce size of auto-computed workspace by Z, makes robot look bigger

  • ‘ortho’ Orthographic view

  • ‘perspective’ Perspective view (default)

  • ‘view’,V Specify view V=‘x’, ‘y’, ‘top’ or [az el] for side elevations, plan view, or general view by azimuth and elevation angle.

  • ‘top’ View from the top.

  • ‘[no]shading’ Enable Gouraud shading (default true)

  • ‘lightpos’,L Position of the light source (default [0 0 20])

  • ‘[no]name’ Display the robot’s name

  • ‘[no]wrist’ Enable display of wrist coordinate frame

  • ‘xyz’ Wrist axis label is XYZ

  • ‘noa’ Wrist axis label is NOA

  • ‘[no]arrow’ Display wrist frame with 3D arrows

  • ‘[no]tiles’ Enable tiled floor (default true)

  • ‘tilesize’,S Side length of square tiles on the floor (default 0.2)

  • ‘tile1color’,C Color of even tiles [r g b] (default [0.5 1 0.5] light green)

  • ‘tile2color’,C Color of odd tiles [r g b] (default [1 1 1] white)

  • ‘[no]shadow’ Enable display of shadow (default true)

  • ‘shadowcolor’,C Colorspec of shadow, [r g b]

  • ‘shadowwidth’,W Width of shadow line (default 6)

  • ‘[no]jaxes’ Enable display of joint axes (default false)

  • ‘[no]jvec’ Enable display of joint axis vectors (default false)

  • ‘[no]joints’ Enable display of joints

  • ‘jointcolor’,C Colorspec for joint cylinders (default [0.7 0 0])

  • ‘jointdiam’,D Diameter of joint cylinder in scale units (default 5)

  • ‘linkcolor’,C Colorspec of links (default ‘b’)

  • ‘[no]base’ Enable display of base ‘pedestal’

  • ‘basecolor’,C Color of base (default ‘k’)

  • ‘basewidth’,W Width of base (default 3)

The options come from 3 sources and are processed in order:

  • Cell array of options returned by the function PLOTBOTOPT (if it exists)
  • Cell array of options given by the ‘plotopt’ option when creating the
    SerialLink object.
  • List of arguments in the command line.

Many boolean options can be enabled or disabled with the ‘no’ prefix. The various option sources can toggle an option, the last value is taken.

Graphical annotations and options::

The robot is displayed as a basic stick figure robot with annotations
such as:

  • shadow on the floor
  • XYZ wrist axes and labels
  • joint cylinders and axes
    which are controlled by options.

The size of the annotations is determined using a simple heuristic from the workspace dimensions. This dimension can be changed by setting the multiplicative scale factor using the ‘mag’ option.

Figure behaviour:

  • If no figure exists one will be created and the robot drawn in it.
  • If no robot of this name is currently displayed then a robot will
    be drawn in the current figure. If hold is enabled (hold on) then the
    robot will be added to the current figure.
  • If the robot already exists then that graphical model will be found
    and moved.

Multiple views of the same robot:

If one or more plots of this robot already exist then these will all be moved according to the argument Q. All robots in all windows with the same name will be moved.

Create a robot in figure 1

      figure(1)
      p560.plot(qz);

Create a robot in figure 2

      figure(2)
      p560.plot(qz);

Now move both robots

      p560.plot(qn)

Multiple robots in the same figure::

Multiple robots can be displayed in the same plot, by using “hold on” before calls to robot.plot().

Create a robot in figure 1

       figure(1)
       p560.plot(qz);

Make a clone of the robot named bob

       bob = SerialLink(p560, 'name', 'bob');

Draw bob in this figure

       hold on
       bob.plot(qn)

To animate both robots so they move together:

       qtg = jtraj(qr, qz, 100);
       for q=qtg'
         p560.plot(q');
         bob.plot(q');
       end

Making an animation movie::

  • The ‘movie’ options saves frames as files NNNN.png into the specified folder
  • The specified folder will be created
  • To convert frames to a movie use a command like:
       ffmpeg -r 10 -i %04d.png out.avi

Notes:

  • The options are processed when the figure is first drawn, to make different options come into effect it is neccessary to clear the figure.
  • The link segments do not neccessarily represent the links of the robot, they are a pipe network that joins the origins of successive link coordinate frames.
  • Delay betwen frames can be eliminated by setting option ‘delay’, 0 or ‘fps’, Inf.
  • By default a quite detailed plot is generated, but turning off labels, axes, shadows etc. will speed things up.
  • Each graphical robot object is tagged by the robot’s name and has UserData that holds graphical handles and the handle of the robot object.
  • The graphical state holds the last joint configuration
  • The size of the plot volume is determined by a heuristic for an all-revolute robot. If a prismatic joint is present the ‘workspace’ option is required. The ‘zoom’ option can reduce the size of this workspace.

See also SerialLink.plot3d, plotbotopt, SerialLink.animate, SerialLink.teach, SerialLink.fkine.

HANDLES:

A robot comprises a bunch of individual graphical elements and these are
kept in a structure:

  h.link     the graphical elements that comprise each joint/link
  h.wrist     the coordinate frame marking the wrist frame
  h.shadow    the robot's shadow
  h.floorlevel the z-coordinate of the tiled floor
  h.robot pointer to the robot object
  h.opt   the final options structure

The h.link graphical element is tagged with the robot’s name and has this
struct as its UserData.

 h.links -> h -> robot

This enables us to find all robots with a given name, in all figures,
and update them.

PLOT Graphical robot animation

PLOT(ROBOT, Q)
PLOT(ROBOT, Q, options)

Displays a graphical animation of a robot based on the
kinematic model.  A stick figure polyline joins the origins of
the link coordinate frames.
The robot is displayed at the joint angle Q, or if a matrix it is
animated as the robot moves along the trajectory.

The graphical robot object holds a copy of the robot object and
the graphical element is tagged with the robot's name (.name method).
This state also holds the last joint configuration 
drawn (.q method).

If no robot of this name is currently displayed then a robot will
be drawn in the current figure.  If the robot already exists then
that graphical model will be found and moved.

MULTIPLE VIEWS OF THE SAME ROBOT
If one or more plots of this robot already exist then these will all
be moved according to the argument Q.

MULTIPLE ROBOTS
Multiple robots can be displayed in the same plot, by using "hold on"
before calls to plot(robot).

options is a list of any of the following:
'workspace' [xmin, xmax ymin ymax zmin zmax]
'perspective' 'ortho'	controls camera view mode
'erase' 'noerase'	controls erasure of arm during animation
'base' 'nobase'		controls display of base 'pedestal'
'loop' 'noloop'		controls display of base 'pedestal'
'wrist' 'nowrist'	controls display of wrist
'name', 'noname'	display the robot's name near the first joint
'shadow' 'noshadow'	controls display of shadow
'xyz' 'noa'		wrist axis label
'joints' 'nojoints'	controls display of joints
'mag' scale		annotation scale factor

The options come from 3 sources and are processed in the order:
1. Cell array of options returned by the function PLOTBOTOPT
2. Cell array of options returned by the .plotopt method of the
   robot object.  These are set by the .plotopt method.
3. List of arguments in the command line.

GRAPHICAL ANNOTATIONS:

The basic stick figure robot can be annotated with
	shadow on the floor
	XYZ wrist axes and labels
	joint cylinders and axes

All of these require some kind of dimension and this is determined
using a simple heuristic from the workspace dimensions.  This dimension
can be changed by setting the multiplicative scale factor using the
'mag' option above.

GETTING GRAPHICAL ROBOT STATE:
q = PLOT(ROBOT)
Returns the joint configuration from the state of an existing
graphical representation of the specified robot. If multiple
instances exist, that of the first one returned by findobj() is
given.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章