irsl_choreonoid モジュール
https://github.com/IRSL-tut/irsl_choreonoid
irsl_choreonoid.cnoid_util
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/cnoid_util.py
- irsl_choreonoid.cnoid_util.load_script(filename)
Loading a script file
- パラメータ:
filename (str) -- URL [ URL is like 'scheme://netloc/xxx/yyy/zzz' ]
- irsl_choreonoid.cnoid_util.parseURL(url)
Parsing URL with IRSL original scheme
- パラメータ:
url (str) -- URL
- 戻り値:
Absolute path
- 戻り値の型:
str
- 例外:
SyntaxError -- Unknown scheme or netloc is passed
サンプル
>>> parseURL('choreonoid://share/dir/file') /choreonoid/share/choreonoid-2.0/dir/file
>>> parseURL('env://HOME/dir/file') /home/user/dir/file
>>> parseURL('file:///dir/file') /dir/file
>>> parseURL('file://./dir/file') /current_dir/dir/file
>>> parseURL('file://~/dir/file') /home/user/dir/file
Note: URL is like 'scheme://netloc/xxx/yyy/zzz'
Implemented scheme is 'choreonoid', 'env', 'file'
- irsl_choreonoid.cnoid_util.loadRobot(fname)
Loading robot model (.body, .vrml, .urdf??)
- パラメータ:
fname (str) -- filename of robot-model
- 戻り値:
instance of cnoid.Body.Body
- 戻り値の型:
cnoid.Body
- irsl_choreonoid.cnoid_util.exportBody(fname, body, extModelFileMode=None, filePrefix='', allInOne=True, fixMassParam=True)
Exporting .body file from an instance of cnoid.Body.Body
- パラメータ:
fname (str) --
body (cnoid.Body.Body) --
extModelFileMode (int, optional) -- 0; EmbedModels, 1; LinkToOriginalModelFiles, 2; ReplaceWithStdSceneFiles, 3; ReplaceWithObjModelFiles
filePrefix (str, optional) -- Add URI for exporting mesh files
allInOne (boolean, default=True) -- Using with filePrefix, if True, all shapes will be exported as a file.
fixMassParam (boolean, default=False) -- If True, links with mass==1.0 and inertia is identity is set small mass-parameter (they may loaded without mass parameter)
- irsl_choreonoid.cnoid_util.exportURDF(fname, body, **kwargs)
Exporting .urdf file from an instance of cnoid.Body.Body
- パラメータ:
fname (str) --
body (cnoid.Body.Body) --
kwargs (dict[str, param]) --
AddGeometry (boolean, default=True) -- Add geometries
AddOffset (boolean, default=True) -- Add offset of links
ExportDevices (boolean) --
MeshFilePrefix (str) -- Prefix of files exporting as mesh-files(.dae, .stl)
MeshURLPrefix (str) -- Prefix of file-name written in URDF
RobotName (str) -- Name of exporting robot
UseURDFPrimitiveGeometry (boolean, default=True) -- Use primitive defined at URDF
UseXacro (boolean) --
Verbose (boolean) --
- irsl_choreonoid.cnoid_util.exportBodyAsMesh(fname, input_body, meshScale=None, offset=None, useCollision=False, **kwargs)
Exporting a mesh file converted from an instance of cnoid.Body.Body
- パラメータ:
fname (str) -- Name of output file
input_body (cnoid.Body.Body) -- Robot model to be exported
meshScale (float, optional) --
offset (cnoid.IRSLCoords.coordinates, optional) --
useCollision (boolean, defalt=False) --
kwargs (dict) -- Passing to irsl_choreonoid.make_shapes.exportMesh
- irsl_choreonoid.cnoid_util.convertBodyFileToMeshFile(mesh_file_name, body_file_name, **kwargs)
Converting a mesh file to a body file
- パラメータ:
mesh_file_name (str) -- Name of output file
body_file_name (str) -- Name of input file
kwargs (dict) -- Passing to irsl_choreonoid.cnoid_util.exportBodyAsMesh
- irsl_choreonoid.cnoid_util.castValueNode(_valuenode)
Casting cnoid.Util.ValueNode type to python primitive type
- パラメータ:
_valuenode (cnoid.Util.ValueNode) -- ValueNode
- 戻り値:
Instance of python primitive type
- 戻り値の型:
dict, list, int, float, bool, str
- irsl_choreonoid.cnoid_util.mappingToDict(mapping)
Converting cnoid.Util.Mapping to dict
- パラメータ:
mapping (cnoid.Util.Mapping) -- Instance of mapping to be converted
- 戻り値:
Converted dictionary
- 戻り値の型:
dict
- irsl_choreonoid.cnoid_util.listingToList(listing)
Converting cnoid.Util.Listing to list
- パラメータ:
listing (cnoid.Util.Listing) -- Instance of listing to be converted
- 戻り値:
Converted list
- 戻り値の型:
list
- irsl_choreonoid.cnoid_util.dictToMapping(indict)
Converting dict to cnoid.Util.Mapping
- パラメータ:
indict (dict) -- Dict to be converted
- 戻り値:
Converted mapping
- 戻り値の型:
cnoid.Util.Mapping
- irsl_choreonoid.cnoid_util.listToListing(inlist)
Converting list to cnoid.Util.Mapping
- パラメータ:
inlist (list) -- List to be converted
- 戻り値:
Converted mapping
- 戻り値の型:
cnoid.Util.Mapping
- irsl_choreonoid.cnoid_util.cnoidPosition(rotation=None, translation=None)
Concatnating translation part and rotation part
- パラメータ:
translation (numpy.array, optional) -- 1x3 vector
rotation (numpy.array, optional) -- 3x3 matrix
- 戻り値:
4x4 homogeneous transformation matrix
- 戻り値の型:
numpy.array
- irsl_choreonoid.cnoid_util.cnoidRotation(cPosition)
Extracting rotation part of 4x4 matrix
- パラメータ:
cPosition (numpy.array) -- 4x4 homogeneous transformation matrix
- 戻り値:
3x3 matrix ( rotation part of cPosition )
- 戻り値の型:
numpy.array
- irsl_choreonoid.cnoid_util.cnoidTranslation(cPosition)
Extracting translation part of 4x4 matrix
- パラメータ:
cPosition (numpy.array) -- 4x4 homogeneous transformation matrix
- 戻り値:
1x3 vector ( translation part of cPosition )
- 戻り値の型:
numpy.array
- irsl_choreonoid.cnoid_util.fv(*args, **kwargs)
Simple function for making numpy.array
- パラメータ:
args (list[float]) -- List will be passed to numpy.array
kwargs (dict) -- Keyword arguments will be passed to numpy.array
- 戻り値:
vector or matrix
- 戻り値の型:
numpy.array
注釈
This function just return numpy.array(args, **kwargs)
サンプル
fv(0.1, 0.2, 0.3) => array([0, 1, 2])
Just reducing the number of typing numpy.array([0.1, 0.2, 0.3]) => fv(0.1, 0.2, 0.3)
- irsl_choreonoid.cnoid_util.isInChoreonoid()
- パラメータ:
None --
- 戻り値:
True if this script running on python-console of Choreonoid
- 戻り値の型:
boolean
irsl_choreonoid.cnoid_base
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/cnoid_base.py
- irsl_choreonoid.cnoid_base.loadProject(project_file)
Loading project file (currend project may be changed)
- パラメータ:
project_file (str) -- filename of project file (.cnoid)
- irsl_choreonoid.cnoid_base.getItemTreeView()
DEPRECATED: use cnoid.Base.ItemTreeView.instance
- irsl_choreonoid.cnoid_base.getRootItem()
DEPRECATED: use cnoid.Base.RootItem.instance
- irsl_choreonoid.cnoid_base.getOrAddWorld(name='World')
Getting or creating WorldItem
- パラメータ:
name (str, default = 'World') -- name of WorldItem
- 戻り値:
added or found WorldItem
- 戻り値の型:
cnoid.Base.WorldItem
- irsl_choreonoid.cnoid_base.addSimulator(world=None, simulator_name='AISTSimulator')
Adding SimulatorItem
- パラメータ:
world (optional) -- world item, simulator should be created under this world
simulator_name (str, default = 'AISTSimulator') -- name of SimulatorItem to be added
- 戻り値:
Added SimulatorItem
- 戻り値の型:
cnoid.BodyPlugin.AISTSimulatorItem
- irsl_choreonoid.cnoid_base.loadRobotItem(fname, name=None, world=True, addItem=True)
Load robot model and add it as a BodyItem
- パラメータ:
fname (str) -- filename (or path)
name (str, optional) -- name of loaded robot-model
world (boolean or WorldItem, default = True) -- if True, WorldItem is added
addItem (boolean) -- if True and world if False, loaded item is added to RootItem
- 戻り値:
Loaded robot-model
- 戻り値の型:
cnoid.BodyPlugin.BodyItem
- irsl_choreonoid.cnoid_base.findItem(name, root=None)
Finding item in ItemTreeView
- パラメータ:
name (str) -- name of item to be searched
- 戻り値:
found item (first one)
- 戻り値の型:
cnoid.Base.Item
- irsl_choreonoid.cnoid_base.findItems(name, root=None)
Finding item in ItemTreeView
- パラメータ:
name (str) -- name of item to be searched
- 戻り値:
all found items which has the name
- 戻り値の型:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByQuery(query, root=None)
Finding item which is query returning True in ItemTreeView
- パラメータ:
query (callable, taking 1 argument, argtype cnoid.Base.Item) -- Query function which rturns true if the item should be extracted
- 戻り値:
all found items that query returns True
- 戻り値の型:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByName(name, root=None)
Finding item with the same name in ItemTreeView
- パラメータ:
name (str) -- name of item to be searched
- 戻り値:
all found items which has the name
- 戻り値の型:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByClassExact(cls, root=None)
Finding item with class given as the argument in ItemTreeView
- パラメータ:
cls (class) -- class of item to be searched
- 戻り値:
all found items which has the name
- 戻り値の型:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByClass(cls, root=None)
Finding item with class given as the argument in ItemTreeView
- パラメータ:
cls (class) -- class of item to be searched
- 戻り値:
all found items which has the name
- 戻り値の型:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.removeItem(item_)
Removing item
- パラメータ:
item (cnoid.Base.Item) -- item to be removed
- irsl_choreonoid.cnoid_base.findBodyItem(name_or_body, root=None)
Seaching BodyItem
- パラメータ:
name_or_body (str or cnoid.Body.Body) -- If type is str, searching BodyItem with the same name. If type is body, searching BodyItem which has identical body
- 戻り値:
found BodyItem
- 戻り値の型:
cnoid.Base.Item
- irsl_choreonoid.cnoid_base.findRobot(name)
DEPRECATED: use findBodyItem
- irsl_choreonoid.cnoid_base.cameraPositionLookingFor(eye, direction, up, opencv=True)
Generating camera coordinates where designated direction is the camera's optical axis
- パラメータ:
eye (numpy.array or list[float]) -- 3D position of the camera
direction (numpy.array or list[float]) -- Direction of the camera's optical axis
up (numpy.array or list[float]) -- Up direction
opencv (boolean, default = True) -- OpenCV stype coordinates will be returned
- 戻り値:
Camera coordinates
- 戻り値の型:
注釈
Refer cnoid.Util.SgCamera.positionLookingFor
- irsl_choreonoid.cnoid_base.cameraPositionLookingAt(eye, center, up, opencv=True)
Generating camera coordinates looking at the point
- パラメータ:
eye (numpy.array or list[float]) -- 3D position of the camera
center (numpy.array or list[float]) -- 3D position wherer the camera's optical axis passes through
up (numpy.array or list[float]) -- Up direction
opencv (boolean, default = True) -- OpenCV stype coordinates will be returned
- 戻り値:
Camera coordinates
- 戻り値の型:
注釈
Refer cnoid.Util.SgCamera.positionLookingAt
- irsl_choreonoid.cnoid_base.saveImageOfScene(filename)
Saving scene as image file
- パラメータ:
filename (str) -- Name of the file to be saved
注釈
Refer cnoid.Base.SceneWidget.saveImage
- irsl_choreonoid.cnoid_base.currentSceneView()
Returning the instance of SceneView
- パラメータ:
None --
- 戻り値:
Current Instance of SceneView ( return cnoid.Base.SceneView.instance )
- 戻り値の型:
cnoid.Base.SceneView
- irsl_choreonoid.cnoid_base.currentSceneWidget()
Returning the instance of SceneWidget
- パラメータ:
None --
- 戻り値:
Current Instance of SceneWidget ( return cnoid.Base.SceneView.instance.sceneWidget )
- 戻り値の型:
cnoid.Base.SceneWidget
- irsl_choreonoid.cnoid_base.getCameraCoords(withFOV=True, opencv=True)
Returning camera position of current scene
- パラメータ:
withFOV (boolean, default = True) -- If true, getting camera's field of view
opencv (boolean, default = True) -- OpenCV stype coordinates will be returned
- 戻り値:
Tuple with camera coordinates and camera's filed of view
- 戻り値の型:
(cnoid.IRSLCoords.coordinates, float)
- irsl_choreonoid.cnoid_base.setCameraCoords(cds, fov=None, update=True, opencv=True)
Setting camera coordinates of current scene
- パラメータ:
cds (cnoid.IRSLCoords.coordinates) -- Camera's coordinates to be set
fov (float, default = None) -- Camera's filed of view to be set
update (boolean, default=True) -- If True, rendering scene with updated camera position
opencv (boolean, default=True) -- cds is OpenCV stype coordinates
- irsl_choreonoid.cnoid_base.getCameraCoordsParam(withFOV=True, opencv=True)
Returning camera position of current scene (returning dictionary type)
- パラメータ:
withFOV (boolean, default = True) -- If true, getting camera's field of view
- 戻り値:
Dictionary can be read with irsl_choreonoid.robot_util.make_coordinates, and added the keyword 'fov'
- 戻り値の型:
dict[str, param]
- irsl_choreonoid.cnoid_base.setCameraCoordsParam(param_dict, opencv=True)
Setting camera coordinates of current scene (receiving dictionary type)
- パラメータ:
param_dict (dict[str, param]) -- Dictionary can be read with irsl_choreonoid.robot_util.make_coordinates, and added the keyword 'fov'
- irsl_choreonoid.cnoid_base.getCameraMatrix()
Getting camera matrix of this scene
- Retuns:
numpy.array (3x3 matrix) : Camera Matrix
- irsl_choreonoid.cnoid_base.setCameraMatrix(camera_matrix, width=None, height=None)
Setting camera matrix of this scene
- パラメータ:
camera_matrix (numpy.array[3x3]) -- Camera matrix to be set
width (int, optional) -- Set width of this scene
height (int, optional) -- Set height of this scene
- irsl_choreonoid.cnoid_base.projectPoints(point_list, world=True)
Projecting 3D points to 2D points on image plane
- パラメータ:
point_list (list [ numpy.array[3x3] ]) -- List 3D points on world coordinates
- 戻り値:
List of projected points
- 戻り値の型:
list [ numpy.array ]
- irsl_choreonoid.cnoid_base.unprojectPoints(uv_list, depth=1.0, depth_list=None, centerRelative=False, world=True)
Projecting 3D points to 2D points on image plane
- パラメータ:
point_list (list [ numpy.array[3x3] ]) -- List 3D points on world coordinates
- 戻り値:
List of projected points
- 戻り値の型:
list [ numpy.array ]
- irsl_choreonoid.cnoid_base.setBackgroundColor(backgound_color)
Setting color of background
- パラメータ:
background_color (numpy.array or list[float]) -- Vector with 3 elements. Eech element represents 'Red', 'Green', 'Blue'.
- irsl_choreonoid.cnoid_base.disableGrid(plane=None)
Disabling to show grids
- パラメータ:
plane (int, optional) -- ID of plane to be disabled. 0: XY, 1: XZ, 2: YZ
- irsl_choreonoid.cnoid_base.enableGrid(plane=0)
Showing grids
- パラメータ:
plane (int, default = 0) -- ID of plane to show. 0: XY, 1: XZ, 2: YZ
- irsl_choreonoid.cnoid_base.setCoordinateAxes(on=True)
On/Off of the coordinate axes on the screen
- パラメータ:
on (boolean, default=True) -- On/Off of the coordinate axes
- irsl_choreonoid.cnoid_base.setViewSize(width, height)
Setting size of view(widget)
- パラメータ:
width (int) -- Width of the widget to be set
height (int) -- Height of the widget to be set
- irsl_choreonoid.cnoid_base.viewAll()
Setting camera position as viewing all objects
- irsl_choreonoid.cnoid_base.getAllBoundingBox()
Getting a boundingBox of all objects on the scene
- 戻り値:
BoundingBox of all objects on the scene
- 戻り値の型:
BoundingBox
irsl_choreonoid.make_shapes
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/make_shapes.py
- irsl_choreonoid.make_shapes.extractShapes(sg_node, currentCoords=None)
Extracting SgShape from SceneGraph
- パラメータ:
sg_node (cnoid.Util.SgNode) -- Root node to start searching
currentCoords (cnoid.IRSLCoords.coordinates, optional) -- Offset coordinates to extracted object
- 戻り値:
List of extracted objects which is tuple of object-instance and coordinates of this object
- 戻り値の型:
list [ tuple [ cnoid.Util.SgShape, cnoid.IRSLCoords.coordinates ] ]
- irsl_choreonoid.make_shapes.extractPlots(sg_node, currentCoords=None)
Extracting SgPlot from SceneGraph
- パラメータ:
sg_node (cnoid.Util.SgNode) -- Root node to start searching
currentCoords (cnoid.IRSLCoords.coordinates, optional) -- Offset coordinates to extracted object
- 戻り値:
List of extracted objects which is tuple of object-instance and coordinates of this object
- 戻り値の型:
list [ tuple [ cnoid.Util.SgPlot, cnoid.IRSLCoords.coordinates ] ]
- irsl_choreonoid.make_shapes.extractDrawables(sg_node, currentCoords=None)
Extracting drawables (SgShape, SgPlot, SgText) from SceneGraph
- パラメータ:
sg_node (cnoid.Util.SgNode) -- Root node to start searching
currentCoords (cnoid.IRSLCoords.coordinates, optional) -- Offset coordinates to extracted object
- 戻り値:
List of extracted objects which is tuple of object-instance and coordinates of this object
- 戻り値の型:
list [ tuple [ instance of drawables, cnoid.IRSLCoords.coordinates ] ]
- irsl_choreonoid.make_shapes.loadScene(fname, meshScale=None, fileUri=None, wrapped=True, rawShape=False, coords=None, **kwargs)
Loading scene(wrl, scene, ...) file using cnoid.Util.SceneLoader
- パラメータ:
fname (str) -- File name to be loaded
fileUri (str, optional) -- If fileUri is set, shapes will be set Uri for exporting files
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Loaded scene as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.loadMesh(fname, meshScale=None, fileUri=None, wrapped=True, rawShape=False, coords=None, forceGenerateNormals=True, creaseAngle=0.5235987755982988, **kwargs)
Loading mesh file using cnoid.AssimpPlugin module
- パラメータ:
fname (str) -- File name to be loaded
fileUri (str, optional) -- If fileUri is set, shapes will be set Uri for exporting files
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Loaded scene as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeBox(x, y=None, z=None, wrapped=True, rawShape=False, coords=None, texture=None, **kwargs)
Making 'Box' shape using cnoid.Util.MeshGenerator
- パラメータ:
x (float) -- Length of x-axis, if y and z is None, making 'cube'
y (float, optional) -- Length of y-direction edge
z (float, optional) -- Length of z-direction edge
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
texture (str, optional) -- Image file-name of texture
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
注釈
Origin of generated shape is the center of it
- irsl_choreonoid.make_shapes.makeCylinder(radius, height, wrapped=True, rawShape=False, coords=None, texture=None, **kwargs)
Making 'Cylinder' shape using cnoid.Util.MeshGenerator
- パラメータ:
radius (float) -- Radius of the cylinder
height (float) -- Height of the cylinder
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
texture (str, optional) -- Image file-name of texture
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
注釈
Center circle with indicated radius on XZ-plane and sweep to both side with half of height, along y-direction
- irsl_choreonoid.make_shapes.makeSphere(radius, wrapped=True, rawShape=False, coords=None, texture=None, **kwargs)
Make 'Sphere' shape using cnoid.Util.MeshGenerator
- パラメータ:
radius (float) -- Radius of the sphere
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
texture (str, optional) -- Image file-name of texture
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
注釈
Origin of generated shape is the center of it
- irsl_choreonoid.make_shapes.makeCone(radius, height, wrapped=True, rawShape=False, coords=None, texture=None, **kwargs)
Making 'Cone' shape using cnoid.Util.MeshGenerator
- パラメータ:
radius (float) -- Radius of the cone
height (float) -- Height of the cone
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
texture (str, optional) -- Image file-name of texture
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeCapsule(radius, height, wrapped=True, rawShape=False, coords=None, **kwargs)
Makeing 'Capsule' shape using cnoid.Util.MeshGenerator
- パラメータ:
radius (float) -- Radius of the cupsule
height (float, optional) -- Height of the capsule
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
注釈
Similar dimensions to 'makeCylinder' (bottom cricle is at minus y, cone's tip is at plus y)
- irsl_choreonoid.make_shapes.makeTorus(radius, corssSectionRadius, beginAngle=None, endAngle=None, wrapped=True, rawShape=False, coords=None, **kwargs)
Makeing 'Torus' shape using cnoid.Util.MeshGenerator
- パラメータ:
radius (float) -- Outer radius of the torus
crossSectionRadius (float) -- Radius of cross section
beginAngle (float, optional) -- If beginAngle and endAngle is passed, part of whole torus is created
endAngle (float, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeExtrusion(crossSection, spine, wrapped=True, rawShape=False, coords=None, texture=None, **kwargs)
Makeing 'Extrusion' shape using cnoid.Util.MeshGenerator
- パラメータ:
crossSection (list[list[float]], N x 2 matrix) -- / arg for cnoid.Util.MeshGenerator.Extrusion
spine (list[list[float]], M x 3 matrix) -- / arg for cnoid.Util.MeshGenerator.Extrusion
orientation (list[AngleAxis], optional) -- / arg for cnoid.Util.MeshGenerator.Extrusion
scale (list[list[float]], N x 2 matrix, optional) -- / arg for cnoid.Util.MeshGenerator.Extrusion
creaseAngle (float, optional) -- / arg for cnoid.Util.MeshGenerator.Extrusion
beginCap (boolean, optional) -- / arg for cnoid.Util.MeshGenerator.Extrusion
endCap (boolean, optional) -- / arg for cnoid.Util.MeshGenerator.Extrusion
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
texture (str, optional) -- Image file-name of texture
kwargs (dict[str, param]) -- Keywords for generating material, mesh, and makeExtrusionParam
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeElevationGrid(xDimension, zDimension, xSpacing, zSpacing, height, wrapped=True, rawShape=False, coords=None, texture=None, **kwargs)
Makeing 'Extrusion' shape using cnoid.Util.MeshGenerator
- パラメータ:
xDimension (int) -- Dimension of x-direction / arg for cnoid.Util.MeshGenerator.ElevationGrid
zDimension (int) -- Dimension of z-direction / arg for cnoid.Util.MeshGenerator.ElevationGrid
xSpacing (float) -- X length is (xDimension - 1) x xSpacing / arg for cnoid.Util.MeshGenerator.ElevationGrid
zSpacing (float) -- Z length is (zDimension - 1) x zSpacing / arg for cnoid.Util.MeshGenerator.ElevationGrid
height (list[float]) -- Size is ( xDimension x zDimension ) / arg for cnoid.Util.MeshGenerator.ElevationGrid
ccw (boolean, optional) -- / arg for cnoid.Util.MeshGenerator.ElevationGrid
creaseAngl (float, optional) -- / arg for cnoid.Util.MeshGenerator.ElevationGrid
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
texture (str, optional) -- Image file-name of texture
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material, mesh, and makeElevationParam
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makePoints(points, pointSize=10.0, colors=None, colorIndices=None, wrapped=True, rawShape=False, coords=None, **kwargs)
Makeing '3D point cloud' shape
- パラメータ:
points (numpy.array) -- N x 3 matrix (N is number of points)
pointSize (float, default=1.0) --
colors (list[list[float]], optional) --
colorIndices (list[int], optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgPointSet will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeText(text, textHeight=1.0, color=None, wrapped=True, rawShape=False, coords=None, **kwargs)
Makeing 'Text' shape
- パラメータ:
text (str) -- String to be displayed
textHeight (float, default=1.0) --
color (list[float], optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgText will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeLines(line_points, line_indices=None, lineWidth=5.0, colors=None, colorIndices=None, coords=None, wrapped=True, rawShape=False, **kwargs)
Makeing Lines
- パラメータ:
line_points (numpy.array) -- N x 3 matrix (N is number of points)
line_indices (list [ tuple [int] ]) -- example, [ (0, 1), (2, 3) ] represents two lines, line0 is from point0 to point1, line1 is from point2 to point3
lineWidth (float, default=5.0) --
colors (list[list[float]], optional) --
colorIndices (list[int], optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgText will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeTetrahedron(base_width, base_height, height, base_center=None, center_x=None, center_y=None, wrapped=True, rawShape=False, coords=None, **kwargs)
Making 'Tetrahedron' shape
- パラメータ:
base_width (float) --
base_height (float) --
height (float) --
base_center (float, optional) --
center_x (float, optional) --
center_y (float, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
rawShape (boolean, default = False) -- If True, instance of cnoid.Util.SgShape will be returned (ignore wrapped)
coords (cnoid.IRSLCoords.coordinates, optional) --
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeAxis(radius=0.075, length=1.0, axisLength=0.35, axisRadius=0.125, axisRatio=None, color=None, scale=None, coords=None, wrapped=True, **kwargs)
Makeing single axis shape using cylinder and cone
- パラメータ:
radius (float, default=0.15) --
length (float, default=0.8) --
axisLength (float, default=0.3) --
axisRadius (float, default=0.25) --
axisRatio (float, optional) --
color (list[float], optional) --
scale (float, optional) --
coords (cnoid.IRSLCoords.coordinates, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.make3DAxis(radius=0.15, length=0.8, axisLength=0.3, axisRadius=0.25, axisRatio=None, color=None, scale=None, x_color=[1, 0, 0], y_color=[0, 1, 0], z_color=[0, 0, 1], coords=None, wrapped=True, **kwargs)
Makeing '3D-axis' shape using cylinder and cone
- パラメータ:
radius (float, default=0.15) --
length (float, default=0.8) --
axisLength (float, default=0.3) --
axisRadius (float, default=0.25) --
axisRatio (float, optional) --
color (list[float], optional) --
scale (float, optional) --
x_color (list[float], default=[1,0,0]) --
y_color (list[float], default=[0,1,0]) --
z_color (list[float], default=[0,0,1]) --
coords (cnoid.IRSLCoords.coordinates, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.make3DAxisBox(width=0.2, length=0.8, color=None, scale=None, x_color=[1, 0, 0], y_color=[0, 1, 0], z_color=[0, 0, 1], coords=None, wrapped=True, **kwargs)
Makeing '3D-axis' shape using box
- パラメータ:
width (float, default=0.2) --
length (float, default=0.8) --
color (list[float], optional) --
scale (float, optional) --
x_color (list[float], default=[1,0,0]) --
y_color (list[float], default=[0,1,0]) --
z_color (list[float], default=[0,0,1]) --
coords (cnoid.IRSLCoords.coordinates, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeCoords(length=1.0, lineWidth=2.0, color=None, x_color=[1, 0, 0], y_color=[0, 1, 0], z_color=[0, 0, 1], coords=None, wrapped=True, **kwargs)
Makeing '3D-axis' shape using line
- パラメータ:
length (float, default=0.8) --
lineWidth (float, default=2.0) --
color (list[float], optional) --
x_color (list[float], default=[1,0,0]) --
y_color (list[float], default=[0,1,0]) --
z_color (list[float], default=[0,0,1]) --
coords (cnoid.IRSLCoords.coordinates, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeCross(length=1.0, lineWidth=2.0, color=None, x_color=[1, 0, 0], y_color=[0, 1, 0], z_color=[0, 0, 1], coords=None, wrapped=True, **kwargs)
Makeing '3D-axis' shape using crossing line
- パラメータ:
length (float, default=0.8) --
lineWidth (float, default=2.0) --
color (list[float], optional) --
x_color (list[float], default=[1,0,0]) --
y_color (list[float], default=[0,1,0]) --
z_color (list[float], default=[0,0,1]) --
coords (cnoid.IRSLCoords.coordinates, optional) --
wrapped (boolean, default = True) -- If True, the loaded scene is wrapped by irsl_choreonoid.irsl_draw_object.coordsWrapper
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeLineAlignedShape(start, end, size=0.001, shape='box', verbose=False, **kwargs)
Makeing object which is aligned with a desginated line
- パラメータ:
start (numpy.ndarray) -- 3D vector representing start-point of a line
end (numpy.ndarray) -- 3D vector representing end-point of a line
size (float) -- Size of generated object (radius or edge length)
shape (str) -- Type of Shape, 'box', 'cylinder', 'capsule', 'cone'
verbose (bool, default=False) -- If True, printing debug message
kwargs (dict[str, param]) -- Keywords for generating material and mesh
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeParallelogram(height, length, width, offset=None, angle=None, front_cut=None, back_cut=None, **kwargs)
Making a geometry, 'Parallelogram'
- パラメータ:
height (float) -- Height of the geometry
length (float) -- Length of bottom edge
width (float) -- Width of the geometry
offset (float, optional) -- Offset of a top edge and a bottom edge
angle (float, optional) -- range is [0, PI]
front_cut (float, optional) -- Cut from front-side if angle > 0
back_cut (float, optional) -- Cut from back-side if angle > 0
**kwargs -- Passing to irsl_choreonoid.make_shapes.makeExtrusion
- Retuns:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper : Created object as a node of SceneGraph or wrapped class for interactive programming
- irsl_choreonoid.make_shapes.makeBasket(width, height, tall, thickness=0.1, bottom_thickness=0.1, wrapped=True, rawShape=False, **kwargs)
Making basket shape
- パラメータ:
width (float) -- width of bottom plate (x-axis)
height (float) -- height of bottom plate (y-axis)
tall (float) -- tall of basket
thickness (float, default = 0.1) -- thickness of walls
bottom_thickness (float, default = 0.1) -- thickness of bottom plate
wrapped (boolean, default=True) -- Just passing to makeBox
rawShape (boolean, default=False) -- Just passing to makeBox
kwargs (dict[str, param]) -- Extra keyword arguments passing to makeBox
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeTableSingleLeg(width, height, tall, thickness=0.05, bottom_thickness=0.04, bottom_width=0.4, bottom_height=0.4, leg_size=0.1, wrapped=True, rawShape=False, **kwargs)
Making table with single leg
- パラメータ:
width (float) -- width of top plate (x-axis)
height (float) -- height of top plate (y-axis)
tall (float) -- tall of table
thickness (float, default = 0.05) -- thickness of top plate
bottom_thickness (float, default = 0.04) -- thickness of bottom plate
bottom_width (float, default = 0.4) -- width of bottom plate
bottom_height (float, default = 0.4) -- height of bottom plate
leg_size (float, default = 0.1) -- leg size
wrapped (boolean, default=True) -- Just passing to makeBox
rawShape (boolean, default=False) -- Just passing to makeBox
kwargs (dict[str, param]) -- Extra keyword arguments passing to makeBox
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeTable4Legs(width, height, tall, thickness=0.05, leg_size=0.1, wrapped=True, rawShape=False, **kwargs)
Making table with 4 legs
- パラメータ:
width (float) -- width of top plate (x-axis)
height (float) -- height of top plate (y-axis)
tall (float) -- tall of table
thickness (float, default = 0.05) -- thickness of top plate
leg_size (float, default = 0.1) -- leg size
wrapped (boolean, default=True) -- Just passing to makeBox
rawShape (boolean, default=False) -- Just passing to makeBox
kwargs (dict[str, param]) -- Extra keyword arguments passing to makeBox
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeRoundTable(radius, tall, thickness=0.05, bottom_thickness=0.04, bottom_width=0.4, bottom_height=0.4, leg_size=0.1, wrapped=True, rawShape=False, **kwargs)
Making round table with single leg
- パラメータ:
radius (float) -- width of top plate (x-axis)
tall (float) -- tall of table
thickness (float, default = 0.05) -- thickness of top plate
bottom_thickness (float, default = 0.04) -- thickness of bottom plate
bottom_width (float, default = 0.4) -- width of bottom plate
bottom_height (float, default = 0.4) -- height of bottom plate
leg_size (float, default = 0.1) -- leg size
wrapped (boolean, default=True) -- Just passing to makeBox
rawShape (boolean, default=False) -- Just passing to makeBox
kwargs (dict[str, param]) -- Extra keyword arguments passing to makeBox
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeWireframeCone(wrapped=True, rawShape=False, scale=[1, 1, 1], **kwargs)
Making cone with lines
- パラメータ:
wrapped (boolean, default=True) -- Just passing to makeBox
rawShape (boolean, default=False) -- Just passing to makeBox
kwargs (dict[str, param]) -- Extra keyword arguments passing to makeBox
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeBoxFromBoundingBox(bbox, line=False, wrapped=True, rawShape=False, **kwargs)
Making box with the same size and position passed bounding-box
- パラメータ:
bbox (cnoid.Util.BoundingBox or object has 'boundingBox' method) --
line (boolean, default=False) -- If True, BoundingBox is shown with line
wrapped (boolean, default=True) -- Just passing to makeBox
rawShape (boolean, default=False) -- Just passing to makeBox
kwargs (dict[str, param]) -- Extra keyword arguments passing to makeBox
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
- irsl_choreonoid.make_shapes.makeLineAlignedWall(points, height=1.0, thickness=0.1, **kwargs)
Making a wall which is aligned with a multi-segment line points on XY plane, extrude them by Z-axis(height)
- パラメータ:
points (list[numpy.array]) -- List of 2D point, representing a line on XY-plane
height (float, default=1.0) -- Height of the wall
thickness (float, default=0.1) -- Thickness of the wall
- 戻り値:
Created object as a node of SceneGraph or wrapped class for interactive programming
- 戻り値の型:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
サンプル
>>> points=[] >>> NN = 36 >>> for idx in range(NN+1): >>> xx = 2*PI/NN*idx >>> ss = math.sin(xx) >>> points.append(fv(xx, ss)) >>> sp = mkshapes.makeLineAlignedWall(points)
- irsl_choreonoid.make_shapes.exportMesh(fname, sg_node, meshScale=None, verbose=False, generatePrimitiveMesh=True, ignoreURDFPrimitive=False, outputType=None, expandVertices=False)
Exporting SgNode as a mesh file (using Assimp)
- パラメータ:
fname (str) -- File name to be saved
sg_node (cnoid.Util.SgNode) -- Root node of scene to be saved
meshScale (float, optional) --
verbose (boolean, default=False) --
generatePrimitiveMesh (boolean, default=True) --
ignoreURDFPrimitive (boolean, default=False) --
outputType (str, optional) --
- irsl_choreonoid.make_shapes.exportScene(fname, sg_node, meshScale=None, exportMesh=False, **kwargs)
Exporting SgNode as .scen file
- パラメータ:
fname (str) -- File name to be saved
sg_node (cnoid.Util.SgNode) -- Root node of scene to be saved
meshScale (float, optional) --
exportMesh (boolean, default=False) -- Exporting mesh instead of primitive type
kwargs (dict[str, param]) -- Extra keyword arguments for using to execute ''StdSceneWriter.<keyword> = <value>''
- irsl_choreonoid.make_shapes.addUriToShape(sg_node, base_name='mesh', base_uri='file:///tmp', allInOne=False)
Exporting SgNode as .scen file
- パラメータ:
sg_node (cnoid.Util.SgNode) -- Root node of scene to be add uri
base_name (str) -- Base name of uri
base_uri (str) -- Base uri to be add
注釈
uri : {base_uri}/{base_name}_{counter}
irsl_choreonoid.robot_util
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/robot_util.py
- irsl_choreonoid.robot_util.make_coordinates(coords_map, scale=1.0)
Generating coordinates(cnoid.IRSLCoords.coordinates) from dictionary
- パラメータ:
coords_map (dict[str, list[float]]) -- dictionary of describing transformation
scale (float, default = 1.0) -- Scaling for making coordinates
- 戻り値:
generated coordinates
- 戻り値の型:
- 例外:
Exception -- If there is not valid keyword
サンプル
>>> make_coordinates( {'position' : [1, 2, 3]} ) <coordinates[address] 1 2 3 / 0 0 0 1 >
>>> make_coordinates( {'pos' : [1, 2, 3], 'rpy' : [math.pi/3, 0, 0]} ) <coordinates[address] 1 2 3 / 0.5 0 0 0.866025 >
>>> make_coordinates({'rot' : [[0, -1, 0],[1, 0, 0], [0, 0, 1]]}) <coordinates[address] 0 0 0 / 0 0 0.707107 0.707107 >
>>> make_coordinates( {'angle-axis' : [0, 1, 0, math.pi/4] }) <coordinates[address] 0 0 0 / 0 0.382683 0 0.92388 >
>>> make_coordinates( {'quaternion' : [0, 0, 0, 1] }) <coordinates[address] 0 0 0 / 0 0 0 1 >
- irsl_choreonoid.robot_util.make_coords_map(coords, method=None, scale=1.0)
Generating dictonary describing transformation
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- Transformation
scale (float, default = 1.0) -- Scaling for making dictionary
- 戻り値:
Dictonary can be used by make_coordinates
- 戻り値の型:
dict[str, list[float]]
サンプル
>>> make_coords_map( make_coordinates( {'position' : [1, 2, 3]} ) ) {'pos': [1.0, 2.0, 3.0], 'aa': [1.0, 0.0, 0.0, 0.0]} >>> make_coords_map(make_coordinates( {'pos' : [0.01, 0.02, 0.03]} ), method = 'translation', scale=1000.0) {'translation': [10.0, 20.0, 30.0], 'rotation': [1.0, 0.0, 0.0, 0.0]}
- irsl_choreonoid.robot_util.make_translation_rotation(coords, unit='mm', degree=True)
Generating dictonary describing transformation (using translation, rotation)
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- Transformation
unit (str, default='mm') -- Unit of length. 'm', 'mm', 'cm', or 'inch'
degree (boolean, default=True) -- Unit of angle. If True, use degree, otherwise use radian
- 戻り値:
Dictonary can be used in .body
- 戻り値の型:
dict[str, list[float]]
- irsl_choreonoid.robot_util.axisAlignedCoords(axis, target_axis=array([0., 1., 0.]), rotate=None, up_axis=None)
Generating axis aligned coordinates.
target_axis on the generated coordinates will be axis on the world-coordinates
- パラメータ:
axis (list[float]) -- Target direction(axis)
target_axis (list[float]) -- Target axis to be alined
- 戻り値:
generated coordinates
- 戻り値の型:
サンプル
>>> ay = axisAlignedCoords([1., 1., 1.,], coordinates.Y) >>> ay.y_axis array([0.57735027, 0.57735027, 0.57735027])
>>> az = axisAlignedCoords([1., 1., 1.,], coordinates.Z) >>> az.z_axis array([0.57735027, 0.57735027, 0.57735027])
>>> target = fv(1., 1., 1.) >>> aa = axisAlignedCoords([1., 0., 1.,], target) >>> aa.transform_vector(target) array([1.22474487, 0. , 1.22474487])
- class irsl_choreonoid.robot_util.IKWrapper(robot, tip_link, tip_to_eef=None, use_joints=None, solver='QP')
ベースクラス:
object
Utility class for solving inverse-kinematics
- __init__(robot, tip_link, tip_to_eef=None, use_joints=None, solver='QP')
- パラメータ:
robot (cnoid.Body.Body) -- robot model using this instance
tip_link (str, cnoid.Body.Link) -- name or instance of tip_link
tip_to_eef (cnoid.IRSLCoords.coordinates, optional) -- coordinates of end-effector relative to tip_link
use_joints (list[str, int, cnoid.Body.Link] , optional) -- list of joint name, index or instance
solver (str, default = 'QP') -- type of solver
注釈
Coordinates system
world -> robot(root_link) -> (using joints) -> tip_link -> tip_to_eef -> end-effector < -- > target-coords(world)
Inverse-kinematics would be solved to make target-coords and end-effector at the same position.
- flush()
Updating the robot in scene
- パラメータ:
None --
- updateDefault()
Updating default values (using joints, default_pose, default_coords)
- パラメータ:
None --
- property endEffector
Current 6DOF coordinates of end-effector
- 戻り値:
coordinates of current end-effector
- 戻り値の型:
- getEndEffector(**kwargs)
Getting end-effector (function version of self.endEffector)
- パラメータ:
kwargs (dict[str, param]) -- ignored
- 戻り値:
end-effector
- 戻り値の型:
- resetJointWeights()
Reset current joint-list to default joint-list (reverting effects of using setJoints)
- パラメータ:
None --
- setJoints(jlist, enable=True)
Adding or removing joints to/from using joint-list
- パラメータ:
jlist (list[str, int, cnoid.Body.Link]) -- list of joint name, index or instance
enable (boolean, default = True) -- if True, joints are added, else joint are removed from using joint-list
- 例外:
Exception -- If wrong joint is passed
- inverseKinematics(target, revert_if_failed=True, retry=100, **kwargs)
Top method to solve inverse-kinematics
- パラメータ:
target (cnoid.IRSLCoords.coordinates) -- target coordinates of inverse-kinematics
revert_if_failed (boolean, default = True) -- if True, no modification (moving joint and root-link) to robot-model when calculation of IK is failed
retry (int, defualt = 100) -- number of retrying solving IK
constraint (str or list[float], optional) -- '6D', 'position', 'rotation', 'xyzRPY'
weight (float, default = 1.0) -- weight of constraint
base_type (str or list[float], optional) -- '2D', 'planer', 'position', 'rotation'
base_weight (float, default = 1.0) -- weight of base movement
max_iteration (int, defulat = 32) -- number of iteration
threshold (float, default = 5e-5) -- threshold for checking convergence
add_noise (float or boolean, optional) -- if True or number, adding noise to angle of joint before solving IK
debug (boolean, default = False) -- if True, printing debug message
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
注釈
constraint : [1,1,1, 1,1,1] base_type : [1,1,1, 1,1,1]
- angleVector(_angle_vector=None)
Returning current joint angle of self.robot ロボット(self.robot)への関節角度の指定して現状の値を返す。
- パラメータ:
_angle_vector (numpy.array, optional) -- 1 x len(self.default_joints) vector
各エレメントが関節角度になっているvector (numpy.array) --
- 戻り値:
1 x len(self.default_joints) vector 現在のロボットの状態で、各エレメントが関節角度になっているvector(numpy.array)。要素数はself.default_jointと同じ。
- 戻り値の型:
numpy.array
- currentAngleVector(_angle_vector=None)
Returning current joint angle of self.robot
- パラメータ:
_angle_vector (numpy.array, optional) -- 1 x len(self.current_joints) vector
- 戻り値:
1 x len(self.current_joints) vector
- 戻り値の型:
numpy.array
注釈
self.current_joints would be changed by setJoints method
- rootCoords(cds=None)
Setting and getting coordinates of rootLink
- パラメータ:
cds (cnoid.IRSLCoords.coordinates, optional) -- If argument is set, coordinates of rootLink is updated by it
- 戻り値:
coordinates of rootLink
- 戻り値の型:
- resetPose()
Resetting pose (angleVector and rootCoords)
- パラメータ:
None --
- 戻り値:
current angleVector
- 戻り値の型:
numpy.array
- addNoise(max_range=0.1, joint_list=None)
addNoise(self, max_range = 0.1, joint_list = None):
- パラメータ:
max_range (float, default = 0.1) -- range of adding noise
joint_list (list[str, int, cnoid.Body.Link], optional) -- If argument is not set, self.default_joints would be used
- property robot
Robot model using this instance
- 戻り値:
robot model
- 戻り値の型:
- property tip_link
Tip link (direct parent of end-effector)
- 戻り値:
tip link
- 戻り値の型:
- property tip_to_eef
Transformation between origin of tip_link and end-effector
- 戻り値:
Transformation to end-effector at tip_link coordinates
- 戻り値の型:
- property joint_weights
Weight of joints
- 戻り値:
weight of joints
- 戻り値の型:
list[float]
- property current_joints
Current joint-list
- 戻り値:
current_joints using IK, currentAngleVector
- 戻り値の型:
list[cnoid.Body.Link]
- property default_joints
Default joint-list (stored while initialization)
- 戻り値:
default_joints
- 戻り値の型:
list[cnoid.Body.Link]
- property default_pose
AngleVector stored while initialization
- 戻り値:
1 x len(self.default_joints) vector
- 戻り値の型:
numpy.array
- property default_coords
RootCoords stored while initialization
- 戻り値:
Transformation to end-effector at tip_link coordinates
- 戻り値の型:
- irsl_choreonoid.robot_util.linkDirectChildren(lk)
- irsl_choreonoid.robot_util.linkDescendants(lk)
- irsl_choreonoid.robot_util.mergedMassPropertyOfAllDescendants(plink)
- irsl_choreonoid.robot_util.mergeMassProperty(plink_coords, plink_mass, plink_c, plink_I, clink)
- class irsl_choreonoid.robot_util.RobotModelWrapped(robot, **kwargs)
ベースクラス:
coordsWrapper
RobotModel for programming Interactively
RobotModel is displayed as cnoid.Base.RobotItem
- __init__(robot, **kwargs)
- パラメータ:
robot (cnoid.Body.Body or cnoid.BodyPlugin.BodyItem) -- robot model using this class
- registerNamedPose(name, angles=None, root_coords=None)
Registering named pose for using with irsl_choreonoid.robot_util.RobotModelWrapped.setNamedPose
- パラメータ:
name (str) -- Name of registered pose
angles (numpy.array or list[float]) -- Angle-vector to be able to pass irsl_choreonoid.robot_util.RobotModelWrapped.angleVector
root_coords (cnoid.IRSLCoords.coordinates) -- Coordinates of Root
- registerEndEffector(name, tip_link, tip_link_to_eef=None, joint_list=None, joint_tuples=None)
Registering named pose for using with irsl_choreonoid.robot_util.RobotModelWrapped.getLimb, etc.
- パラメータ:
name (str) -- Name of limb as registered end-effector
tip_link (str or cnoid.Body.Link) -- Link which is direct parent of coordinates of end-effector
tip_link_to_eef (cnoid.IRSLCoords.coordinates) -- Coordinates tip_link to end_effector represented on link's coordinate
joint_list (list[str] or list[cnoid.Body.Link]) --
tuple((actual_name (joint_tuples () -- str, nickname:str)) ) : Tuple of actual_name and nick_name
- class EndEffector(robot, name, tip_link, tip_link_to_eef=None, joint_list=None, joint_tuples=None, hook=None)
ベースクラス:
object
EndEffector class for manipulating end-effector, limb, joint-group
- __init__(robot, name, tip_link, tip_link_to_eef=None, joint_list=None, joint_tuples=None, hook=None)
Use RobotModelWrapped.registerEndEffector
- nicknameOf(joint_name)
- rename(nick_name)
Renaming using registered nick-name
- パラメータ:
nick_name (str) -- nick-name
- 戻り値:
actual name
- 戻り値の型:
str
- joint(jname)
Getting joint in this limb by name
- パラメータ:
jname (str) -- name or nick-name of a joint
- 戻り値:
Instance of the joint
- 戻り値の型:
- property endEffector
Getting coordinate of the end-effector (return value is generated on demand)
- 戻り値:
Coordinate of the end-effector
- 戻り値の型:
- property IK
Getting IKWrapper instance using this EndEffector
- 戻り値:
IKWrapper instance using this EndEffector
- 戻り値の型:
- property angleMap
Getting dictionary [ key='jointName', value=jointAngle ]
- 戻り値:
Dictionary of key='jointName', value=jointAngle for joints in this Limb
- 戻り値の型:
dict [str, float ]
- inverseKinematics(coords, **kwargs)
Solving inverse kinematic on this limb
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- Coordinate of the target
**kwargs (dict) -- Just passing to IKWrapper
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
- move(vec, wrt=<wrt.local: 1>, **kwargs)
Relative moving end-effector linearly by translation vector
- パラメータ:
vec (numpy.array) -- Translation vector
wrt (default = cnoid.IRSLCoords.coordinates.wrt.local) -- Just passing to cnoid.IRSLCoords.coordinates.translate
kwargs (dict) -- Just passing to IKWrapper
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
- rotate(angle, axis, wrt=<wrt.local: 1>, **kwargs)
Relative moving end-effector angularly by angle-axis
- パラメータ:
angle (float) -- Rotation angle
axis (numpy.array) -- Rotation axis
wrt (default = cnoid.IRSLCoords.coordinates.wrt.local) -- Just passing to cnoid.IRSLCoords.coordinates.rotate
kwargs (dict) -- Just passing to IKWrapper
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
- moveCoords(coords, wrt=<wrt.local: 1>, **kwargs)
Relative moving end-effector by transformation of coordinates
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- Relative coordinates
wrt (default = cnoid.IRSLCoords.coordinates.wrt.local) -- Just passing to cnoid.IRSLCoords.coordinates.transform
kwargs (dict) -- Just passing to IKWrapper
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
- jointAngle(name, angle=None)
Setting or getting angle of the joint (limb version)
- パラメータ:
name (str) -- Name of a joint, 'nickname' is acceptable.
angle (float, optional) -- Angle [radian] to be set
- 戻り値:
Angle of the joint, if do not find the name, None would be returned
- 戻り値の型:
float
- setAngleMap(angle_map)
Setting angles of the joint (limb version)
- パラメータ:
angle_map (dict[str, float]) -- Keyword is a joint name and value is a joint angle. 'nickname' is acceptable.
- 戻り値:
If angles is set, returns True
- 戻り値の型:
boolean
- getAngleMap(*args)
Getting angles of the joint (limb version)
- パラメータ:
name_list (list[str]) -- List of joint names. 'nickname' is acceptable.
- 戻り値:
Keyword is a joint name and value is a joint angle.
- 戻り値の型:
dict[str, float]
- angleVector(angle_vector=None)
Setting or getting angle-vector (limb version)
- パラメータ:
angle_vector (numpy.array) -- Vector of angle[radian] to be set
- 戻り値:
Vector of angle[radian]
- 戻り値の型:
numpy.array
- property robot
Robot-model using wrapped by this instance
- 戻り値:
Instance of robot model currently using
- 戻り値の型:
- property item
Robot-model using wrapped by this instance
- 戻り値:
Instance of robot-item currently using
- 戻り値の型:
cnoid.BodyPlugin.BodyItem
- setMode(mode=None)
Set updating mode
- パラメータ:
mode (int, optional) -- Mode to be set (0: kinematics mode, 1: rendering mode, 2: rendering immediately mode)
- 戻り値:
Current mode (0: kinematics mode, 1: rendering mode, 2: rendering immediately mode, -1: do nothing while hook)
- 戻り値の型:
int
- property linkList
List of links
- 戻り値:
List of links
- 戻り値の型:
list [cnoid.Body.Link]
- property linkNames
List of link names
- 戻り値:
List of link names
- 戻り値の型:
list [str]
- property jointList
List of joints
- 戻り値:
List of joints
- 戻り値の型:
list [cnoid.Body.Link]
- property jointNames
List of joint names
- 戻り値:
List of joint names
- 戻り値の型:
list [cnoid.Body.Link]
- property deviceList
List of devices
- 戻り値:
List of devices
- 戻り値の型:
list [cnoid.Body.Device]
- property deviceNames
List of device names
- 戻り値:
List of device names
- 戻り値の型:
list [cnoid.Body.Device]
- device(arg)
Instance of the device
- パラメータ:
arg (str, int, object) -- name or index of the device
- 戻り値:
instance of the device
- 戻り値の型:
- linkCoords(str_idx_instance)
Coordinates of the link
- パラメータ:
str_index_instance (str, int, object) -- name or index of the link
- 戻り値:
coordinate of the link
- 戻り値の型:
- jointCoords(str_idx_instance)
Coordinates of the joint
- パラメータ:
str_index_instance (str, int, object) -- name or index of the joint
- 戻り値:
coordinate of the joint
- 戻り値の型:
- deviceCoords(str_idx_instance)
Coordinates of the device
- パラメータ:
str_index_instance (str, int, object) -- name or index of the device
- 戻り値:
coordinate of the device
- 戻り値の型:
- angleVector(angles=None)
Setting or getting angle-vector
- パラメータ:
angle_vector (numpy.array) -- Vector of angle[radian] to be set
- 戻り値:
Vector of angle[radian]
- 戻り値の型:
numpy.array
- jointAngle(name, angle=None)
Setting or getting angle of the joint
- パラメータ:
name (str) -- Name of a joint
angle (float, optional) -- Angle [radian] to be set
- 戻り値:
Angle of the joint, if do not find the name, None would be returned
- 戻り値の型:
float
- setAngleMap(angle_map)
Setting angles of the joint
- パラメータ:
angle_map (dict[str, float]) -- Keyword is a joint name and value is a joint angle. 'nickname' is acceptable.
- 戻り値:
If angles is set, returns True
- 戻り値の型:
boolean
- getAngleMap(*args)
Getting angles of the joint
- パラメータ:
name_list (list[str]) -- List of joint names. 'nickname' is acceptable.
- 戻り値:
Keyword is a joint name and value is a joint angle.
- 戻り値の型:
dict[str, float]
- rootCoords(coords=None)
Getting or setting coordinates of root link of robot
- パラメータ:
coords (cnoid.IRSLCoords.coordinates, optional) -- Coordinate to be set
- 戻り値:
Current coordinates of root link of robot
- 戻り値の型:
- setDefaultPose()
Setting default pose if registered
- setInitialPose()
Setting initial pose if registered
- setZeroPose()
Setting all joint angles to zero
- setNamedPose(name)
Setting named pose, name should be registered by irsl_choreonoid.robot_util.RobotModelWrapped.registerNamedPose
- パラメータ:
name (str) -- Name of registered pose
- getLimb(limb_name)
Getting limb as end-effector, name should be registered by irsl_choreonoid.robot_util.RobotModelWrapped.registerEndEffector
- パラメータ:
limb_name (str) -- Name of registered limb as end-effector
- 戻り値:
Instance of EndEffector
- 戻り値の型:
- 例外:
Exception -- If wrong limb name is passed
- getEndEffector(limb_name)
Getting coordinates of end-effector of limb (return value is generated on demand)
- パラメータ:
limb_name (str) -- Name of registered limb as end-effector
- 戻り値:
Current coordinates of end-effector of limb
- 戻り値の型:
- property rleg
Pre defined accessor of limb, same as self.getLimb('rleg')
- 戻り値:
Instance of EndEffector (rleg)
- 戻り値の型:
- property lleg
Pre defined accessor of limb, same as self.getLimb('lleg')
- 戻り値:
Instance of EndEffector (lleg)
- 戻り値の型:
- property rarm
Pre defined accessor of limb, same as self.getLimb('rarm')
- 戻り値:
Instance of EndEffector (rarm)
- 戻り値の型:
- property larm
Pre defined accessor of limb, same as self.getLimb('larm')
- 戻り値:
Instance of EndEffector (larm)
- 戻り値の型:
- property arm
Pre defined accessor of limb, same as self.getLimb('arm')
- 戻り値:
Instance of EndEffector (arm)
- 戻り値の型:
- property head
Pre defined accessor of limb, same as self.getLimb('head')
- 戻り値:
Instance of EndEffector (head)
- 戻り値の型:
- property torso
Pre defined accessor of limb, same as self.getLimb('torso')
- 戻り値:
Instance of EndEffector (torso)
- 戻り値の型:
- property rlegEndEffector
Pre defined accessor to end-effector, same as self.getLimb('rleg').endEffector
- 戻り値:
Current coordinates of end-effector of limb(rleg)
- 戻り値の型:
- property llegEndEffector
Pre defined accessor to end-effector, same as self.getLimb('lleg').endEffector
- 戻り値:
Current coordinates of end-effector of limb(lleg)
- 戻り値の型:
- property rarmEndEffector
Pre defined accessor to end-effector, same as self.getLimb('rarm').endEffector
- 戻り値:
Current coordinates of end-effector of limb(rarm)
- 戻り値の型:
- property larmEndEffector
Pre defined accessor to end-effector, same as self.getLimb('larm').endEffector
- 戻り値:
Current coordinates of end-effector of limb(larm)
- 戻り値の型:
- property armEndEffector
Pre defined accessor to end-effector, same as self.getLimb('arm').endEffector
- 戻り値:
Current coordinates of end-effector of limb(arm)
- 戻り値の型:
- property headEndEffector
Pre defined accessor to end-effector, same as self.getLimb('head').endEffector
- 戻り値:
Current coordinates of end-effector of limb(head)
- 戻り値の型:
- property torsoEndEffector
Pre defined accessor to end-effector, same as self.getLimb('torso').endEffector
- 戻り値:
Current coordinates of end-effector of limb(torso)
- 戻り値の型:
- inverseKinematics(coords, limb_name='default', **kwargs)
Solving inverse kinematic of the limb
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- Coordinate of the target
limb_name (str, default='default') -- Name of the limb
**kwargs (dict) -- Just passing to IKWrapper
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
- footMidCoords(p=0.5)
Getting coordinates representing mid-point of leg's end-effector
- パラメータ:
p (float, default=0.5) -- Parameter of mid-point. (0.5, 0.0, 1.0 represents the center, rleg, lleg, respectively)
- 戻り値:
Coordinates indicating the mid-point of legs
- 戻り値の型:
注釈
This method requires settings of limbs( 'rleg' and 'lleg' )
- fixLegToCoords(coords, p=0.5)
Locating the robot by fixing the legs to designated coordinates
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- Target coordinates ( footMidCoords of this robot will be the same as this coordinates )
p (float, default=0.5) -- Parameter of mid-point. (0.5, 0.0, 1.0 represents the center, rleg, lleg, respectively)
注釈
This method requires settings of limbs( 'rleg' and 'lleg' )
- fixSelfCoordsToTarget(selfcoords, target_coords)
- keepJointLimit(on_=True)
Setting mode to keep joint limits
- パラメータ:
on (boolean, default=True) --
- 戻り値:
Returns current settings
- 戻り値の型:
(boolean)
- trimJointAngles()
Force setting joint angles inside the range of limits
- calcMinimumDuration(target_angle_vector, original_angle_vector=None, ratio=1.0)
Calculating duration for the fastest movement depend on a joint limit
- パラメータ:
target_angle_vector (numpy.array) -- AngleVector to be moved to
original_angle_vector (numpy.array, optional) -- AngleVector to be moved from. If this argument is not given, current angles will be used.
ratio (float) -- Result will be multipled by this value
- 戻り値:
Duration [ second ]
- 戻り値の型:
float
- fullBodyIK(targets, limbs, com_target=None, base_target=None, revert_if_failed=True, retry=10, **kwargs)
Top method to solve fullbody inverse-kinematics
- パラメータ:
targets (cnoid.IRSLCoords.coordinates) -- List of coordinates as target for inverse-kinematics
limbs (irsl_choreonoid.robot_util.RobotModelWrapped.EndEffector) -- List of limb(EndEffector), size of limbs should be equal to size of targets
com_target (numpy.array) -- Target of COM ( Center of Mass )
base_target (cnoid.IRSLCoords.coordinates) -- Target of base (root_link)
revert_if_failed (boolean, default = True) -- if True, no modification (moving joint and root-link) to robot-model when calculation of IK is failed
retry (int, defualt = 100) -- number of retrying solving IK
**kwargs (dict) -- Other keywords just passing to fullBodyIKRaw (See irsl_choreonoid.robot_util.RobotModelWrapped.fullBodyIKRaw)
- 戻り値:
IK was success or not, and total count of calculation
- 戻り値の型:
(boolean, int)
注釈
constraint : [1,1,1, 1,1,1] base_type : [1,1,1, 1,1,1]
- fullBodyIKRaw(targets, limbs, com_target=None, base_target=None, constraint='6D', base_type='xy', com_constraint=[1, 1, 0], weight=1.0, base_weight=1.0, debug=False, max_iteration=32, threshold=5e-05, use_joint_limit=True, joint_limit_max_error=0.01, position_precision=None, com_precision=None, joint_limit_precision=0.1, **kwargs)
- legsCOM_IK(r_target, l_target, com_target=None, **kwargs)
- armsCOM_IK(r_target, l_target, com_target=None, **kwargs)
- moveCentroidOnFoot(p=0.5, **kwargs)
- addLink(name, parentLink, offset, jointType=<JointType.FixedJoint: 3>, visualShape=None, collisionShape=None, **kwargs)
Adding new link
- パラメータ:
name (str) --
parentLink (cnoid.Body.Link) --
offset (cnoid.IRSLCoords.coordinates) --
() (kwargs) --
() --
() --
() --
注釈
keywords for kwargs are listed below. JointName, Mass, CenterOfMass, Inertia, EquivalentRotorInertia, JointId, JointAxis, JointVelocityRange, JointRange, JointEffortRange, InitialJointDisplacement, ActuationMode
- setFrame(name, parentLink, offset)
Setting temporary frame (link), which is connected by fixed-joint
- パラメータ:
name (str) -- Name of the adding link
parentLink (str or cnoid.Body.Link) -- Link name or instance of link which the adding link is connected to
offset (cnoid.IRSLCoords.coordinates) -- Offset from parentLink to the adding link ( on parentLink coordinates )
- generateCurrentVisual(scalable=False, init_coords=None)
Generate visual (scene graph) of robot with current state
- パラメータ:
scalable (boolean, default=False) -- Enable methods, scale and switch
init_coords (cnoid.IRSLCoords.coordinates, optional) -- Coordinates of root-coords of generated visual
- 戻り値:
Wrapped SceneGrap (can visualize with DrawInterface)
- 戻り値の型:
- class irsl_choreonoid.robot_util.ImportedRobotModel(robot=None, item=True, world=False, **kwargs)
ベースクラス:
RobotModelWrapped
Class for making specific robot model
Set model_cls.model_file in the module
model_module.robot_class should be set
サンプル
>>> ### SpecificRobotClass.py >>> class SpecificRobotClass(ImportedRobotModel): >>> def __init__(self, robot=None, item=True, world=False, **kwargs): >>> super().__init__(robot=robot, item=item, world=world, **kwargs) >>> >>> def _setting_before_init(self, robot, **kwargs): ## override >>> pass >>> >>> def _init_ending(self, **kwargs): ## override >>> pass >>> SpecificRobotClass.model_file = 'path_to_model_file' ## 1. ## >>> robot_class = SpecificRobotClass ## 2. ##
- __init__(robot=None, item=True, world=False, **kwargs)
- パラメータ:
robot (cnoid.Body.Body or cnoid.BodyPlugin.BodyItem) --
item (boolean, default=True) -- If true, loading as BodyItem
world (boolean, default=True) -- If true, BodyItem will be loaded under WorldItem
irsl_choreonoid.draw_coords
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/draw_coords.py
- class irsl_choreonoid.draw_coords.DrawCoordsList(x_color=array([1, 0, 0]), y_color=array([0, 1, 0]), z_color=array([0, 0, 1]), length=0.1, width=None)
ベースクラス:
object
Drawing list of coordinates
- __init__(x_color=array([1, 0, 0]), y_color=array([0, 1, 0]), z_color=array([0, 0, 1]), length=0.1, width=None)
DrawCoordsList(initializer)
- パラメータ:
x_color (numpy.array, default = [1, 0, 0]) -- color of x-axis
y_color (numpy.array, default = [0, 1, 0]) -- color of y-axis
z_color (numpy.array, default = [0, 0, 1]) -- color of z-axis
length (float, default = 0.1) -- length of axis
width (float, optional) -- width of axis
- property count
Number of coords stored in this instance
- 戻り値:
current number of coords stored in this instance
- 戻り値の型:
int
- property T
Transformation matrix
- 戻り値:
4x4 matrix, homogeneous transformation matrix (cnoidPosition)
- 戻り値の型:
numpy.array
- property interface
Actual interface instance
- 戻り値:
actual instance to draw lines
- 戻り値の型:
cnoid.DrawInterface.DrawInterface
- setOrigin(coords)
Setting new origin
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- new origin to be set
- getOrigin()
Getting current origin
- パラメータ:
None --
- 戻り値:
current origin
- 戻り値の型:
- setLineWidth(_width)
Set line width
- パラメータ:
_width (float) -- line width to be set
- flush()
Force rendering coords
- パラメータ:
None --
- clear()
Clear all drawn coords
- パラメータ:
None --
- addCoords(coords, flush=True)
Draw coordinates (3-axis, position and rotation)
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- coordinates to be drawn
flush (boolean, default = True) -- if True, rendering scene immediately
- 戻り値:
number of drawn coords
- 戻り値の型:
int
- addCross(coords, flush=True)
Draw cross (3-axis, line is crossing at center)
- パラメータ:
coords (cnoid.IRSLCoords.coordinates) -- coordinates to be drawn
flush (boolean, default = True) -- if True, rendering scene immediately
- 戻り値:
number of drawn coords
- 戻り値の型:
int
- addPoint(point, flush=True)
Draw point (cross with no rotation)
- パラメータ:
point (numpy.array) -- 1x3 vector, point to be drawn
flush (boolean, default = True) -- if True, rendering scene immediately
- 戻り値:
number of drawn coords
- 戻り値の型:
int
- class irsl_choreonoid.draw_coords.DrawCoordsListWrapped(**kwargs)
ベースクラス:
DrawCoordsList
,coordsWrapper
Wrapped version of irsl_choreonoid.DrawCoordsList
Using for drawing coordinates interactively
- __init__(**kwargs)
- パラメータ:
kwargs (dict[str, param]) -- this is passing to irsl_choreonoid.robot_util.make_coordinates for making initial_coords of coordsWrapper
- class irsl_choreonoid.draw_coords.GeneralDrawInterfaceWrapped(**kwargs)
ベースクラス:
GeneralDrawInterface
,coordsWrapper
Wrapped version of cnoid.DrawInterface.GeneralDrawInterface
Using for drawing SceneGraph objects interactively
- property SgPosTransform
Generating instance of cnoid.Util.SgPosTransform, which represents the root position of this instance
- Returns:
Root of drawn objects in this instance at SceneGraph
- Return Type:
cnoid.Util.SgPosTransform
- __init__(**kwargs)
- パラメータ:
kwargs (dict[str, param]) -- this is passing to irsl_choreonoid.robot_util.make_coordinates for making initial_coords of coordsWrapper
- flush(doImmediately=False)
Force rendering scene
- パラメータ:
None --
- clear(flush=True)
Clear all added objects
- パラメータ:
flush (boolean, default = True) -- If it is False, the scene is not rendered
- addObject(obj, update=True, hook=True)
This method is overrided, just passing arguments to addPyObject
- addObjects(objlst, update=True, hook=True)
Adding objects to be drawn
- パラメータ:
objlst (list[cnoid.Util.SgNode]) -- list of objects to be drawn
update (boolean, default = False) -- if True, rendering scene immediately
- removeObject(obj, update=True)
This method is overrided, just passing arguments to removePyObject
- removeObjects(objlst, update=True)
Removing objects to be drawn
- パラメータ:
objlst (list[cnoid.Util.SgNode]) -- list of objects to be removed
update (boolean, default = False) -- if True, rendering scene immediately
- addPyObject(obj, update=True, hook=True)
Adding object to be drawn
- パラメータ:
obj (cnoid.Util.SgNode) -- object to be drawn
update (boolean, default = False) -- if True, rendering scene immediately
- removePyObject(obj, update=True)
Removing drawn object
- パラメータ:
obj (cnoid.Util.SgNode) -- object to be removed
update (boolean, default = False) -- if True, rendering scene immediately
class coordsWrapper
Base class for using coordinates interactively.
Inherited by class DrawCoordsListWrapped and class GeneralDrawInterfaceWrapped.
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/irsl_draw_object.py
- class irsl_choreonoid.irsl_draw_object.coordsWrapper(target, init_coords=None, update_callback=None, kinematics_callback=None, original_object=None, scalable=False)
ベースクラス:
coordinates
class coordsWrapper(cnoid.IRSLCoords.coordinates)
This class aims to wrap a cnoid Object which have position (SgPosTransform, Link, etc.)
You can access to this object with methods in cnoid.IRSLCoords.coordinates,
Some mthods (newcoords, translate, rotate, transform) to update itself are overrided to add calling callback_function.
Then, you can run some process when the position of the target is updated.
- __init__(target, init_coords=None, update_callback=None, kinematics_callback=None, original_object=None, scalable=False)
- パラメータ:
target (object) -- wrapped target which have property 'T' for setting cnoidPosition
init_coords (cnoid.IRSLCoords.coordinates, optional) -- coordinates of this instance
update_callback (function(), optional) -- callback function which is called when target is updated (including drawing)
kinematics_callback (function(), optional) -- callback function which is called when target is updated (only updating kinematics)
scalable (boolean, default=False) -- call setScalable() within constructor
- assoc(child, coords=None)
Associate coordinates as a child
- パラメータ:
child (irsl_choreonoid.irsl_draw_object.coordsWrapper) -- child coordinates
coords (cnoid.Body.Link or cnoid.Util.SgPosTransform) -- Coordinates on parent
- dissoc(child)
Finish association with child coordinates
- パラメータ:
- dissocFromParent()
Finish association with parent coordinates
- clearChildren()
Clear all children
- property descendants
Getting all children
- isChild(coords)
Query: Is it a child ?
- isParent(coords)
Query: Is it a parent ?
- hasChild()
Query: Does it have child ?
- setScalable()
Enabling to use methods, setScale and setTurnedOn
- setColorChangeable()
Enabling to use methods, changeColor
- changeColor(color=None, ambient=None, emissive=None, specular=None, specularExponent=None, transparent=None, update=False)
Changing color ( use setColorChangeable method before using this method )
- updateTarget(update=True)
Updating self.target and call callback_function
- パラメータ:
None --
- setUpdateCallback(func)
Setting callback function for updating drawings
- パラメータ:
func (function()) -- callback function which is called when target is updated
- setKinematicsCallback(func)
Setting callback function for updating kinematics
- パラメータ:
func (function()) -- callback function which is called when target is updated
- newcoords(cds)
Wrapped method of newcoords in cnoid.IRSLCoords.coordinates
- パラメータ:
cds (cnoid.IRSLCoords.coordinates) -- replace pos and rot in self with cds
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- translate(pos, wrt=None)
Wrapped method of translate in cnoid.IRSLCoords.coordinates
- パラメータ:
pos (numpy.array) -- 1x3 vector, translation vector
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- locate(pos, wrt=None)
Wrapped method of locate in cnoid.IRSLCoords.coordinates
- パラメータ:
pos (numpy.array) -- 1x3 vector, translation vector
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- rotate(ang, axis, wrt=None)
Wrapped method of rotate in cnoid.IRSLCoords.coordinates
- パラメータ:
ang (float) -- angle to rotate [radian]
aixs (numpy.array) -- 1x3 vector, axis to rotate around
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- orient(ang, axis, wrt=None)
Wrapped method of orient in cnoid.IRSLCoords.coordinates
- パラメータ:
ang (float) -- angle to rotate [radian]
aixs (numpy.array) -- 1x3 vector, axis to rotate around
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- rotate_with_matrix(rot, wrt=None)
Wrapped method of rotate_with_matrix in cnoid.IRSLCoords.coordinates
- パラメータ:
rot (numpy.array) -- 3x3 matrix, matrix applied to rotate
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- orient_with_matrix(rot, wrt=None)
Wrapped method of orient_with_matrix in cnoid.IRSLCoords.coordinates
- パラメータ:
rot (numpy.array) -- 3x3 matrix, matrix applied to rotate
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- transform(trs, wrt=None)
Wrapped method of transform in cnoid.IRSLCoords.coordinates
- パラメータ:
trs (cnoid.IRSLCoords.coordinates) -- Transformation to be applied
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- move_to(trs, wrt=None)
Wrapped method of move_to in cnoid.IRSLCoords.coordinates
- パラメータ:
trs (cnoid.IRSLCoords.coordinates) -- Transformation to be applied
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) -- Reference coordinates applying this method
- 戻り値:
identical instance which was called with this method
- 戻り値の型:
- property target
Wrapped target of this instance, which was manipulated by methods of this class
- 戻り値:
instance which have method 'T' to set cnoidPosition (4x4 matrix)
- 戻り値の型:
object
- property object
Wrapped object of this instance, which was manipulated by methods of this class
- 戻り値:
Utility slot set while initializing
- 戻り値の型:
object
注釈
target is a transformed target such as cnoid.Util.SgPosTransform object is a utility slot for handling a child of the target (Shape, etc...)
- setScale(float_or_vec, update=False)
Setting scale of drawn objects
- パラメータ:
float_or_vec (float or [float]) -- Parameter of scale
update (boolean, default=False) -- Update drawn object in screen
- setTurnedOn(on=True, update=False)
Switching On/Off of drawn objects
- パラメータ:
on (boolean, default=False) -- Switch to draw this object
update (boolean, default=False) -- Update drawn object in screen
irsl_choreonoid.RobotBuilder
https://github.com/IRSL-tut/irsl_choreonoid/blob/main/irsl_choreonoid/RobotBuilder.py
- class irsl_choreonoid.RobotBuilder.RobotBuilder(robot=None, gui=True, name=None)
ベースクラス:
object
Building robot interactively
- class JointType(value)
ベースクラス:
IntEnum
An enumeration.
- __init__(robot=None, gui=True, name=None)
- パラメータ:
robot (,optional) --
gui (boolean, default=True) --
name (str, optional) --
- property body
Currently builded robot model
- 戻り値:
Currently builded robot model
- 戻り値の型:
- property bodyItem
Currently displayed BodyItem
- 戻り値:
Currently displayed BodyItem
- 戻り値の型:
cnoid.BodyPlugin.BodyItem
- property draw
DrawInterface for accessing raw-level display methods
- 戻り値:
DrawInterface
- 戻り値の型:
irsl_choreonoid.draw_coords.DrawInterfaceWrapped
- hideRobot()
Hiding robot model (uncheck RobotItem)
- showRobot()
Showing robot model (check RobotItem)
- resetRobot()
Resetting joint-angles of the robot
- newRobot(robot=None, name=None)
Restarting with new robot(item)
- パラメータ:
robot (str, optional) --
name (str, optional) -- name of RobotItem
- clear()
Clearing showing geometries
- objects()
Getting list of shown objects
- addShape(shape)
Adding a shape
- パラメータ:
shape (cnoid.Util.SgNode) -- Shape to be added
- addShapes(shapes)
Adding a shapes
- パラメータ:
shapes (list[cnoid.Util.SgNode]) -- Shapes to be added
- removeShape(shape)
Removing a shape
- パラメータ:
shape (cnoid.Util.SgNode) -- Shape to be removed
- removeShapes(shapes)
Removing a shapes
- パラメータ:
shapes (list[cnoid.Util.SgNode]) -- Shapes to be removed
- createLinkFromShape(name=None, mass=None, density=1000.0, parentLink=None, root=False, clear=True, collision=None, useCollisionForMassparam=False, overwriteMassparam=None, **kwargs)
Creating link from drawn shapes and appending to the other link
- パラメータ:
name (str, optional) --
mass (float, optional) --
density (float, default=1000.0) --
parentLink (cnoid.Body.Link, optional) --
root (boolean, default=False) --
clear (boolean, default=True) --
collision (cnoid.Util.SgNode, optional) --
useCollisionForMassparam (boolean, default=False) --
overwriteMassparam (dict, optional) -- 'mass', 'COM', 'inertia'
**kwargs --
- 戻り値:
Created link
- 戻り値の型:
- viewInfo(autoScale=False, **kwargs)
Showing information of links. (joint-type, joint-axis, mass, center-of-mass, inertia) :param autoScale: :type autoScale: boolean, default=False :param **kwargs:
- 戻り値:
Created shapes
- 戻り値の型:
[]
- notifyUpdate()
Notifying update for redrawing robot-model and shapes
- createJointShape(jointType=<JointType.FreeJoint: 2>, wrapped=True, coords=None, add=True, scale=0.3, **kwargs)
Creating and showing jointShape
- パラメータ:
jointType (cnoid.Body.Link.JointType, default=FixedJoint) --
wrapped (boolean, default=True) --
coords (cnoid.IRSLCoords.coordinates, optional) --
add (boolean, default=True) --
scale (float, default=0.3) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- createLink(name='', mass=0.1, COM=None, density=None, inertia=None, shape=None, visual=None, collision=None, **kwargs)
Creating a link
- パラメータ:
name (str, default='') --
mass (float, default=0.1) --
COM (numpy.array, optional) --
density (float, optional) --
inertia (numpy.array, optional) --
shape (cnoid.Util.SgNode, optional) --
visual (cnoid.Util.SgNode, optional) --
collision (cnoid.Util.SgNode, optional) --
**kwargs --
- 戻り値:
Created Link
- 戻り値の型:
- createRootLink(**kwargs)
Creating a link and adding it as root-link
- パラメータ:
**kwargs --
- 戻り値:
Created Link
- 戻り値の型:
- createVisualizedLinkShape(alink, scale=0.1, wrapped=True, addCOM=True, addInertia=True, addJoint=True, addDevice=True, addToLink=False, useCollision=False, useInertiaBox=False)
- パラメータ:
alink (cnoid.Body.Link) --
scale (float, default=0.1) --
wrapped (boolean, default=True) --
addCOM (boolean, default=True) --
addInertia (boolean, default=True) --
addJoint (boolean, default=True) --
addDevice (boolean, default=True) --
addToLink (boolean, default=False) --
useCollision (boolean, default=False) --
useInertiaBox (boolean, default=False) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- exportBody(fname, modelName=None, mode=0, **kwargs)
Exporting created robot-model to file as .body file
- パラメータ:
fname (str) -- Name of file
modelName (str, optional) --
mode (int, default=0) -- 0:EmbedModels, 1:LinkToOriginalModelFiles, 2:ReplaceWithStdSceneFiles, 3:ReplaceWithObjModelFiles
kwargs (dict) --
- exportURDF(fname, **kwargs)
Exporting created robot-model to file as .urdf file
- パラメータ:
fname (str) -- Name of file
kwargs (dict) --
- loadScene(fname, wrapped=True, add=True, **kwargs)
Loading scene as a shape, see irsl_choreonoid.make_shapes.loadScene
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- loadMesh(fname, wrapped=True, add=True, **kwargs)
Loading mesh as a shape, see irsl_choreonoid.make_shapes.loadMesh
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeBox(x, y=None, z=None, wrapped=True, add=True, **kwargs)
Making box shape, see irsl_choreonoid.make_shapes.makeBox
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeCylinder(radius, height, wrapped=True, add=True, **kwargs)
Making cylinder shape, see irsl_choreonoid.make_shapes.makeCylinder
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeSphere(radius, wrapped=True, add=True, **kwargs)
Making sphere shape, see irsl_choreonoid.make_shapes.makeSphere
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeCone(radius, height, wrapped=True, add=True, **kwargs)
Making cone shape, see irsl_choreonoid.make_shapes.makeCone
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeCapsule(radius, height, wrapped=True, add=True, **kwargs)
Making capsule shape, see irsl_choreonoid.make_shapes.makeCapsule
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeTorus(radius, corssSectionRadius, beginAngle=None, endAngle=None, wrapped=True, add=True, **kwargs)
Making torus shape, see irsl_choreonoid.make_shapes.makeTorus
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeExtrusion(crossSection, spine, wrapped=True, add=True, **kwargs)
Making extrusion shape, see irsl_choreonoid.make_shapes.makeExtrusion
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeElevationGrid(xDimension, zDimension, xSpacing, zSpacing, height, wrapped=True, add=True, **kwargs)
Making elevation-grid shape, see irsl_choreonoid.make_shapes.makeElevationGrid
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- make3DAxis(coords=None, add=True, **kwargs)
Making 3D-axis shape, see irsl_choreonoid.make_shapes.make3DAxis
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- make3DAxisBox(coords=None, add=True, **kwargs)
Making 3D-axis shape (type: box), see irsl_choreonoid.make_shapes.make3DAxisBox
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeCoords(coords=None, add=True, **kwargs)
Making 3D-axis shape (type: line), see irsl_choreonoid.make_shapes.makeCoords
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeCross(coords=None, add=True, **kwargs)
Making 3D-axis shape (type: crossing-line), see irsl_choreonoid.make_shapes.makeCross
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape
- makeLineAlignedShape(start, end, add=True, **kwargs)
Making shape which is aligned to designated line, see irsl_choreonoid.make_shapes.makeLineAlignedShape
- パラメータ:
add (boolean, default=True) --
- 戻り値:
Created shape
- 戻り値の型:
Shape