Modules in irsl_choreonoid
https://github.com/IRSL-tut/irsl_choreonoid
module 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
- Parameters:
filename (str) – URL [ URL is like ‘scheme://netloc/xxx/yyy/zzz’ ]
- irsl_choreonoid.cnoid_util.parseURL(url)
Parsing URL with IRSL original scheme
- Parameters:
url (str) – URL
- Returns:
Absolute path
- Return type:
str
- Raises:
SyntaxError – Unknown scheme or netloc is passed
Examples
>>> 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??)
- Parameters:
fname (str) – filename of robot-model
- Returns:
instance of cnoid.Body.Body
- Return type:
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
- Parameters:
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
- Parameters:
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
- Parameters:
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
- Parameters:
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
- Parameters:
_valuenode (cnoid.Util.ValueNode) – ValueNode
- Returns:
Instance of python primitive type
- Return type:
dict, list, int, float, bool, str
- irsl_choreonoid.cnoid_util.mappingToDict(mapping)
Converting cnoid.Util.Mapping to dict
- Parameters:
mapping (cnoid.Util.Mapping) – Instance of mapping to be converted
- Returns:
Converted dictionary
- Return type:
dict
- irsl_choreonoid.cnoid_util.listingToList(listing)
Converting cnoid.Util.Listing to list
- Parameters:
listing (cnoid.Util.Listing) – Instance of listing to be converted
- Returns:
Converted list
- Return type:
list
- irsl_choreonoid.cnoid_util.dictToMapping(indict)
Converting dict to cnoid.Util.Mapping
- Parameters:
indict (dict) – Dict to be converted
- Returns:
Converted mapping
- Return type:
cnoid.Util.Mapping
- irsl_choreonoid.cnoid_util.listToListing(inlist)
Converting list to cnoid.Util.Mapping
- Parameters:
inlist (list) – List to be converted
- Returns:
Converted mapping
- Return type:
cnoid.Util.Mapping
- irsl_choreonoid.cnoid_util.cnoidPosition(rotation=None, translation=None)
Concatnating translation part and rotation part
- Parameters:
translation (numpy.array, optional) – 1x3 vector
rotation (numpy.array, optional) – 3x3 matrix
- Returns:
4x4 homogeneous transformation matrix
- Return type:
numpy.array
- irsl_choreonoid.cnoid_util.cnoidRotation(cPosition)
Extracting rotation part of 4x4 matrix
- Parameters:
cPosition (numpy.array) – 4x4 homogeneous transformation matrix
- Returns:
3x3 matrix ( rotation part of cPosition )
- Return type:
numpy.array
- irsl_choreonoid.cnoid_util.cnoidTranslation(cPosition)
Extracting translation part of 4x4 matrix
- Parameters:
cPosition (numpy.array) – 4x4 homogeneous transformation matrix
- Returns:
1x3 vector ( translation part of cPosition )
- Return type:
numpy.array
- irsl_choreonoid.cnoid_util.fv(*args, **kwargs)
Simple function for making numpy.array
- Parameters:
args (list[float]) – List will be passed to numpy.array
kwargs (dict) – Keyword arguments will be passed to numpy.array
- Returns:
vector or matrix
- Return type:
numpy.array
Note
This function just return numpy.array(args, **kwargs)
Examples
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()
- Parameters:
None –
- Returns:
True if this script running on python-console of Choreonoid
- Return type:
boolean
module 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)
- Parameters:
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
- Parameters:
name (str, default = 'World') – name of WorldItem
- Returns:
added or found WorldItem
- Return type:
cnoid.Base.WorldItem
- irsl_choreonoid.cnoid_base.addSimulator(world=None, simulator_name='AISTSimulator')
Adding SimulatorItem
- Parameters:
world (optional) – world item, simulator should be created under this world
simulator_name (str, default = 'AISTSimulator') – name of SimulatorItem to be added
- Returns:
Added SimulatorItem
- Return type:
cnoid.BodyPlugin.AISTSimulatorItem
- irsl_choreonoid.cnoid_base.loadRobotItem(fname, name=None, world=True, addItem=True)
Load robot model and add it as a BodyItem
- Parameters:
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
- Returns:
Loaded robot-model
- Return type:
cnoid.BodyPlugin.BodyItem
- irsl_choreonoid.cnoid_base.findItem(name, root=None)
Finding item in ItemTreeView
- Parameters:
name (str) – name of item to be searched
- Returns:
found item (first one)
- Return type:
cnoid.Base.Item
- irsl_choreonoid.cnoid_base.findItems(name, root=None)
Finding item in ItemTreeView
- Parameters:
name (str) – name of item to be searched
- Returns:
all found items which has the name
- Return type:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByQuery(query, root=None)
Finding item which is query returning True in ItemTreeView
- Parameters:
query (callable, taking 1 argument, argtype cnoid.Base.Item) – Query function which rturns true if the item should be extracted
- Returns:
all found items that query returns True
- Return type:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByName(name, root=None)
Finding item with the same name in ItemTreeView
- Parameters:
name (str) – name of item to be searched
- Returns:
all found items which has the name
- Return type:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByClassExact(cls, root=None)
Finding item with class given as the argument in ItemTreeView
- Parameters:
cls (class) – class of item to be searched
- Returns:
all found items which has the name
- Return type:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.findItemsByClass(cls, root=None)
Finding item with class given as the argument in ItemTreeView
- Parameters:
cls (class) – class of item to be searched
- Returns:
all found items which has the name
- Return type:
list [ cnoid.Base.Item ]
- irsl_choreonoid.cnoid_base.removeItem(item_)
Removing item
- Parameters:
item (cnoid.Base.Item) – item to be removed
- irsl_choreonoid.cnoid_base.findBodyItem(name_or_body, root=None)
Seaching BodyItem
- Parameters:
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
- Returns:
found BodyItem
- Return type:
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
- Parameters:
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
- Returns:
Camera coordinates
- Return type:
Note
Refer cnoid.Util.SgCamera.positionLookingFor
- irsl_choreonoid.cnoid_base.cameraPositionLookingAt(eye, center, up, opencv=True)
Generating camera coordinates looking at the point
- Parameters:
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
- Returns:
Camera coordinates
- Return type:
Note
Refer cnoid.Util.SgCamera.positionLookingAt
- irsl_choreonoid.cnoid_base.saveImageOfScene(filename)
Saving scene as image file
- Parameters:
filename (str) – Name of the file to be saved
Note
Refer cnoid.Base.SceneWidget.saveImage
- irsl_choreonoid.cnoid_base.currentSceneView()
Returning the instance of SceneView
- Parameters:
None –
- Returns:
Current Instance of SceneView ( return cnoid.Base.SceneView.instance )
- Return type:
cnoid.Base.SceneView
- irsl_choreonoid.cnoid_base.currentSceneWidget()
Returning the instance of SceneWidget
- Parameters:
None –
- Returns:
Current Instance of SceneWidget ( return cnoid.Base.SceneView.instance.sceneWidget )
- Return type:
cnoid.Base.SceneWidget
- irsl_choreonoid.cnoid_base.getCameraCoords(withFOV=True, opencv=True)
Returning camera position of current scene
- Parameters:
withFOV (boolean, default = True) – If true, getting camera’s field of view
opencv (boolean, default = True) – OpenCV stype coordinates will be returned
- Returns:
Tuple with camera coordinates and camera’s filed of view
- Return type:
(cnoid.IRSLCoords.coordinates, float)
- irsl_choreonoid.cnoid_base.setCameraCoords(cds, fov=None, update=True, opencv=True)
Setting camera coordinates of current scene
- Parameters:
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)
- Parameters:
withFOV (boolean, default = True) – If true, getting camera’s field of view
- Returns:
Dictionary can be read with irsl_choreonoid.robot_util.make_coordinates, and added the keyword ‘fov’
- Return type:
dict[str, param]
- irsl_choreonoid.cnoid_base.setCameraCoordsParam(param_dict, opencv=True)
Setting camera coordinates of current scene (receiving dictionary type)
- Parameters:
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
- Parameters:
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
- Parameters:
point_list (list [ numpy.array[3x3] ]) – List 3D points on world coordinates
- Returns:
List of projected points
- Return type:
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
- Parameters:
point_list (list [ numpy.array[3x3] ]) – List 3D points on world coordinates
- Returns:
List of projected points
- Return type:
list [ numpy.array ]
- irsl_choreonoid.cnoid_base.setBackgroundColor(backgound_color)
Setting color of background
- Parameters:
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
- Parameters:
plane (int, optional) – ID of plane to be disabled. 0: XY, 1: XZ, 2: YZ
- irsl_choreonoid.cnoid_base.enableGrid(plane=0)
Showing grids
- Parameters:
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
- Parameters:
on (boolean, default=True) – On/Off of the coordinate axes
- irsl_choreonoid.cnoid_base.setViewSize(width, height)
Setting size of view(widget)
- Parameters:
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
- Returns:
BoundingBox of all objects on the scene
- Return type:
BoundingBox
module 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
- Parameters:
sg_node (cnoid.Util.SgNode) – Root node to start searching
currentCoords (cnoid.IRSLCoords.coordinates, optional) – Offset coordinates to extracted object
- Returns:
List of extracted objects which is tuple of object-instance and coordinates of this object
- Return type:
list [ tuple [ cnoid.Util.SgShape, cnoid.IRSLCoords.coordinates ] ]
- irsl_choreonoid.make_shapes.extractPlots(sg_node, currentCoords=None)
Extracting SgPlot from SceneGraph
- Parameters:
sg_node (cnoid.Util.SgNode) – Root node to start searching
currentCoords (cnoid.IRSLCoords.coordinates, optional) – Offset coordinates to extracted object
- Returns:
List of extracted objects which is tuple of object-instance and coordinates of this object
- Return type:
list [ tuple [ cnoid.Util.SgPlot, cnoid.IRSLCoords.coordinates ] ]
- irsl_choreonoid.make_shapes.extractDrawables(sg_node, currentCoords=None)
Extracting drawables (SgShape, SgPlot, SgText) from SceneGraph
- Parameters:
sg_node (cnoid.Util.SgNode) – Root node to start searching
currentCoords (cnoid.IRSLCoords.coordinates, optional) – Offset coordinates to extracted object
- Returns:
List of extracted objects which is tuple of object-instance and coordinates of this object
- Return type:
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
- Parameters:
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
- Returns:
Loaded scene as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Loaded scene as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
Note
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
Note
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
Note
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
Note
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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’
- Parameters:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
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)
- Parameters:
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
- Returns:
Created object as a node of SceneGraph or wrapped class for interactive programming
- Return type:
cnoid.Util.SgPosTransform or irsl_choreonoid.irsl_draw_object.coordsWrapper
Examples
>>> 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)
- Parameters:
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
- Parameters:
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
- Parameters:
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
Note
uri : {base_uri}/{base_name}_{counter}
module 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
- Parameters:
coords_map (dict[str, list[float]]) – dictionary of describing transformation
scale (float, default = 1.0) – Scaling for making coordinates
- Returns:
generated coordinates
- Return type:
- Raises:
Exception – If there is not valid keyword
Examples
>>> 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
- Parameters:
coords (cnoid.IRSLCoords.coordinates) – Transformation
scale (float, default = 1.0) – Scaling for making dictionary
- Returns:
Dictonary can be used by make_coordinates
- Return type:
dict[str, list[float]]
Examples
>>> 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)
- Parameters:
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
- Returns:
Dictonary can be used in .body
- Return type:
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
- Parameters:
axis (list[float]) – Target direction(axis)
target_axis (list[float]) – Target axis to be alined
- Returns:
generated coordinates
- Return type:
Examples
>>> 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')
Bases:
object
Utility class for solving inverse-kinematics
- __init__(robot, tip_link, tip_to_eef=None, use_joints=None, solver='QP')
- Parameters:
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
Note
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
- Parameters:
None –
- updateDefault()
Updating default values (using joints, default_pose, default_coords)
- Parameters:
None –
- property endEffector
Current 6DOF coordinates of end-effector
- Returns:
coordinates of current end-effector
- Return type:
- getEndEffector(**kwargs)
Getting end-effector (function version of self.endEffector)
- Parameters:
kwargs (dict[str, param]) – ignored
- Returns:
end-effector
- Return type:
- resetJointWeights()
Reset current joint-list to default joint-list (reverting effects of using setJoints)
- Parameters:
None –
- setJoints(jlist, enable=True)
Adding or removing joints to/from using joint-list
- Parameters:
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
- Raises:
Exception – If wrong joint is passed
- inverseKinematics(target, revert_if_failed=True, retry=100, **kwargs)
Top method to solve inverse-kinematics
- Parameters:
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
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
Note
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)への関節角度の指定して現状の値を返す。
- Parameters:
_angle_vector (numpy.array, optional) – 1 x len(self.default_joints) vector
各エレメントが関節角度になっているvector (numpy.array) –
- Returns:
1 x len(self.default_joints) vector 現在のロボットの状態で、各エレメントが関節角度になっているvector(numpy.array)。要素数はself.default_jointと同じ。
- Return type:
numpy.array
- currentAngleVector(_angle_vector=None)
Returning current joint angle of self.robot
- Parameters:
_angle_vector (numpy.array, optional) – 1 x len(self.current_joints) vector
- Returns:
1 x len(self.current_joints) vector
- Return type:
numpy.array
Note
self.current_joints would be changed by setJoints method
- rootCoords(cds=None)
Setting and getting coordinates of rootLink
- Parameters:
cds (cnoid.IRSLCoords.coordinates, optional) – If argument is set, coordinates of rootLink is updated by it
- Returns:
coordinates of rootLink
- Return type:
- resetPose()
Resetting pose (angleVector and rootCoords)
- Parameters:
None –
- Returns:
current angleVector
- Return type:
numpy.array
- addNoise(max_range=0.1, joint_list=None)
addNoise(self, max_range = 0.1, joint_list = None):
- Parameters:
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
- Returns:
robot model
- Return type:
- property tip_link
Tip link (direct parent of end-effector)
- Returns:
tip link
- Return type:
- property tip_to_eef
Transformation between origin of tip_link and end-effector
- Returns:
Transformation to end-effector at tip_link coordinates
- Return type:
- property joint_weights
Weight of joints
- Returns:
weight of joints
- Return type:
list[float]
- property current_joints
Current joint-list
- Returns:
current_joints using IK, currentAngleVector
- Return type:
list[cnoid.Body.Link]
- property default_joints
Default joint-list (stored while initialization)
- Returns:
default_joints
- Return type:
list[cnoid.Body.Link]
- property default_pose
AngleVector stored while initialization
- Returns:
1 x len(self.default_joints) vector
- Return type:
numpy.array
- property default_coords
RootCoords stored while initialization
- Returns:
Transformation to end-effector at tip_link coordinates
- Return type:
- 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)
Bases:
coordsWrapper
RobotModel for programming Interactively
RobotModel is displayed as cnoid.Base.RobotItem
- __init__(robot, **kwargs)
- Parameters:
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
- Parameters:
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.
- Parameters:
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)
Bases:
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
- Parameters:
nick_name (str) – nick-name
- Returns:
actual name
- Return type:
str
- joint(jname)
Getting joint in this limb by name
- Parameters:
jname (str) – name or nick-name of a joint
- Returns:
Instance of the joint
- Return type:
- property endEffector
Getting coordinate of the end-effector (return value is generated on demand)
- Returns:
Coordinate of the end-effector
- Return type:
- property IK
Getting IKWrapper instance using this EndEffector
- Returns:
IKWrapper instance using this EndEffector
- Return type:
- property angleMap
Getting dictionary [ key=’jointName’, value=jointAngle ]
- Returns:
Dictionary of key=’jointName’, value=jointAngle for joints in this Limb
- Return type:
dict [str, float ]
- inverseKinematics(coords, **kwargs)
Solving inverse kinematic on this limb
- Parameters:
coords (cnoid.IRSLCoords.coordinates) – Coordinate of the target
**kwargs (dict) – Just passing to IKWrapper
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
- move(vec, wrt=<wrt.local: 1>, **kwargs)
Relative moving end-effector linearly by translation vector
- Parameters:
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
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
- rotate(angle, axis, wrt=<wrt.local: 1>, **kwargs)
Relative moving end-effector angularly by angle-axis
- Parameters:
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
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
- moveCoords(coords, wrt=<wrt.local: 1>, **kwargs)
Relative moving end-effector by transformation of coordinates
- Parameters:
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
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
- jointAngle(name, angle=None)
Setting or getting angle of the joint (limb version)
- Parameters:
name (str) – Name of a joint, ‘nickname’ is acceptable.
angle (float, optional) – Angle [radian] to be set
- Returns:
Angle of the joint, if do not find the name, None would be returned
- Return type:
float
- setAngleMap(angle_map)
Setting angles of the joint (limb version)
- Parameters:
angle_map (dict[str, float]) – Keyword is a joint name and value is a joint angle. ‘nickname’ is acceptable.
- Returns:
If angles is set, returns True
- Return type:
boolean
- getAngleMap(*args)
Getting angles of the joint (limb version)
- Parameters:
name_list (list[str]) – List of joint names. ‘nickname’ is acceptable.
- Returns:
Keyword is a joint name and value is a joint angle.
- Return type:
dict[str, float]
- angleVector(angle_vector=None)
Setting or getting angle-vector (limb version)
- Parameters:
angle_vector (numpy.array) – Vector of angle[radian] to be set
- Returns:
Vector of angle[radian]
- Return type:
numpy.array
- property robot
Robot-model using wrapped by this instance
- Returns:
Instance of robot model currently using
- Return type:
- property item
Robot-model using wrapped by this instance
- Returns:
Instance of robot-item currently using
- Return type:
cnoid.BodyPlugin.BodyItem
- setMode(mode=None)
Set updating mode
- Parameters:
mode (int, optional) – Mode to be set (0: kinematics mode, 1: rendering mode, 2: rendering immediately mode)
- Returns:
Current mode (0: kinematics mode, 1: rendering mode, 2: rendering immediately mode, -1: do nothing while hook)
- Return type:
int
- property linkList
List of links
- Returns:
List of links
- Return type:
list [cnoid.Body.Link]
- property linkNames
List of link names
- Returns:
List of link names
- Return type:
list [str]
- property jointList
List of joints
- Returns:
List of joints
- Return type:
list [cnoid.Body.Link]
- property jointNames
List of joint names
- Returns:
List of joint names
- Return type:
list [cnoid.Body.Link]
- property deviceList
List of devices
- Returns:
List of devices
- Return type:
list [cnoid.Body.Device]
- property deviceNames
List of device names
- Returns:
List of device names
- Return type:
list [cnoid.Body.Device]
- device(arg)
Instance of the device
- Parameters:
arg (str, int, object) – name or index of the device
- Returns:
instance of the device
- Return type:
- linkCoords(str_idx_instance)
Coordinates of the link
- Parameters:
str_index_instance (str, int, object) – name or index of the link
- Returns:
coordinate of the link
- Return type:
- jointCoords(str_idx_instance)
Coordinates of the joint
- Parameters:
str_index_instance (str, int, object) – name or index of the joint
- Returns:
coordinate of the joint
- Return type:
- deviceCoords(str_idx_instance)
Coordinates of the device
- Parameters:
str_index_instance (str, int, object) – name or index of the device
- Returns:
coordinate of the device
- Return type:
- angleVector(angles=None)
Setting or getting angle-vector
- Parameters:
angle_vector (numpy.array) – Vector of angle[radian] to be set
- Returns:
Vector of angle[radian]
- Return type:
numpy.array
- jointAngle(name, angle=None)
Setting or getting angle of the joint
- Parameters:
name (str) – Name of a joint
angle (float, optional) – Angle [radian] to be set
- Returns:
Angle of the joint, if do not find the name, None would be returned
- Return type:
float
- setAngleMap(angle_map)
Setting angles of the joint
- Parameters:
angle_map (dict[str, float]) – Keyword is a joint name and value is a joint angle. ‘nickname’ is acceptable.
- Returns:
If angles is set, returns True
- Return type:
boolean
- getAngleMap(*args)
Getting angles of the joint
- Parameters:
name_list (list[str]) – List of joint names. ‘nickname’ is acceptable.
- Returns:
Keyword is a joint name and value is a joint angle.
- Return type:
dict[str, float]
- rootCoords(coords=None)
Getting or setting coordinates of root link of robot
- Parameters:
coords (cnoid.IRSLCoords.coordinates, optional) – Coordinate to be set
- Returns:
Current coordinates of root link of robot
- Return type:
- 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
- Parameters:
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
- Parameters:
limb_name (str) – Name of registered limb as end-effector
- Returns:
Instance of EndEffector
- Return type:
- Raises:
Exception – If wrong limb name is passed
- getEndEffector(limb_name)
Getting coordinates of end-effector of limb (return value is generated on demand)
- Parameters:
limb_name (str) – Name of registered limb as end-effector
- Returns:
Current coordinates of end-effector of limb
- Return type:
- property rleg
Pre defined accessor of limb, same as self.getLimb(‘rleg’)
- Returns:
Instance of EndEffector (rleg)
- Return type:
- property lleg
Pre defined accessor of limb, same as self.getLimb(‘lleg’)
- Returns:
Instance of EndEffector (lleg)
- Return type:
- property rarm
Pre defined accessor of limb, same as self.getLimb(‘rarm’)
- Returns:
Instance of EndEffector (rarm)
- Return type:
- property larm
Pre defined accessor of limb, same as self.getLimb(‘larm’)
- Returns:
Instance of EndEffector (larm)
- Return type:
- property arm
Pre defined accessor of limb, same as self.getLimb(‘arm’)
- Returns:
Instance of EndEffector (arm)
- Return type:
- property head
Pre defined accessor of limb, same as self.getLimb(‘head’)
- Returns:
Instance of EndEffector (head)
- Return type:
- property torso
Pre defined accessor of limb, same as self.getLimb(‘torso’)
- Returns:
Instance of EndEffector (torso)
- Return type:
- property rlegEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘rleg’).endEffector
- Returns:
Current coordinates of end-effector of limb(rleg)
- Return type:
- property llegEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘lleg’).endEffector
- Returns:
Current coordinates of end-effector of limb(lleg)
- Return type:
- property rarmEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘rarm’).endEffector
- Returns:
Current coordinates of end-effector of limb(rarm)
- Return type:
- property larmEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘larm’).endEffector
- Returns:
Current coordinates of end-effector of limb(larm)
- Return type:
- property armEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘arm’).endEffector
- Returns:
Current coordinates of end-effector of limb(arm)
- Return type:
- property headEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘head’).endEffector
- Returns:
Current coordinates of end-effector of limb(head)
- Return type:
- property torsoEndEffector
Pre defined accessor to end-effector, same as self.getLimb(‘torso’).endEffector
- Returns:
Current coordinates of end-effector of limb(torso)
- Return type:
- inverseKinematics(coords, limb_name='default', **kwargs)
Solving inverse kinematic of the limb
- Parameters:
coords (cnoid.IRSLCoords.coordinates) – Coordinate of the target
limb_name (str, default='default') – Name of the limb
**kwargs (dict) – Just passing to IKWrapper
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
- footMidCoords(p=0.5)
Getting coordinates representing mid-point of leg’s end-effector
- Parameters:
p (float, default=0.5) – Parameter of mid-point. (0.5, 0.0, 1.0 represents the center, rleg, lleg, respectively)
- Returns:
Coordinates indicating the mid-point of legs
- Return type:
Note
This method requires settings of limbs( ‘rleg’ and ‘lleg’ )
- fixLegToCoords(coords, p=0.5)
Locating the robot by fixing the legs to designated coordinates
- Parameters:
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)
Note
This method requires settings of limbs( ‘rleg’ and ‘lleg’ )
- fixSelfCoordsToTarget(selfcoords, target_coords)
- keepJointLimit(on_=True)
Setting mode to keep joint limits
- Parameters:
on (boolean, default=True) –
- Returns:
Returns current settings
- Return type:
(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
- Parameters:
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
- Returns:
Duration [ second ]
- Return type:
float
- fullBodyIK(targets, limbs, com_target=None, base_target=None, revert_if_failed=True, retry=10, **kwargs)
Top method to solve fullbody inverse-kinematics
- Parameters:
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)
- Returns:
IK was success or not, and total count of calculation
- Return type:
(boolean, int)
Note
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
- Parameters:
name (str) –
parentLink (cnoid.Body.Link) –
offset (cnoid.IRSLCoords.coordinates) –
() (kwargs) –
() –
() –
() –
Note
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
- Parameters:
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
- Parameters:
scalable (boolean, default=False) – Enable methods, scale and switch
init_coords (cnoid.IRSLCoords.coordinates, optional) – Coordinates of root-coords of generated visual
- Returns:
Wrapped SceneGrap (can visualize with DrawInterface)
- Return type:
- class irsl_choreonoid.robot_util.ImportedRobotModel(robot=None, item=True, world=False, **kwargs)
Bases:
RobotModelWrapped
Class for making specific robot model
Set model_cls.model_file in the module
model_module.robot_class should be set
Examples
>>> ### 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)
- Parameters:
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
module 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)
Bases:
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)
- Parameters:
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
- Returns:
current number of coords stored in this instance
- Return type:
int
- property T
Transformation matrix
- Returns:
4x4 matrix, homogeneous transformation matrix (cnoidPosition)
- Return type:
numpy.array
- property interface
Actual interface instance
- Returns:
actual instance to draw lines
- Return type:
cnoid.DrawInterface.DrawInterface
- setOrigin(coords)
Setting new origin
- Parameters:
coords (cnoid.IRSLCoords.coordinates) – new origin to be set
- getOrigin()
Getting current origin
- Parameters:
None –
- Returns:
current origin
- Return type:
- setLineWidth(_width)
Set line width
- Parameters:
_width (float) – line width to be set
- flush()
Force rendering coords
- Parameters:
None –
- clear()
Clear all drawn coords
- Parameters:
None –
- addCoords(coords, flush=True)
Draw coordinates (3-axis, position and rotation)
- Parameters:
coords (cnoid.IRSLCoords.coordinates) – coordinates to be drawn
flush (boolean, default = True) – if True, rendering scene immediately
- Returns:
number of drawn coords
- Return type:
int
- addCross(coords, flush=True)
Draw cross (3-axis, line is crossing at center)
- Parameters:
coords (cnoid.IRSLCoords.coordinates) – coordinates to be drawn
flush (boolean, default = True) – if True, rendering scene immediately
- Returns:
number of drawn coords
- Return type:
int
- addPoint(point, flush=True)
Draw point (cross with no rotation)
- Parameters:
point (numpy.array) – 1x3 vector, point to be drawn
flush (boolean, default = True) – if True, rendering scene immediately
- Returns:
number of drawn coords
- Return type:
int
- class irsl_choreonoid.draw_coords.DrawCoordsListWrapped(**kwargs)
Bases:
DrawCoordsList
,coordsWrapper
Wrapped version of irsl_choreonoid.DrawCoordsList
Using for drawing coordinates interactively
- __init__(**kwargs)
- Parameters:
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)
Bases:
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)
- Parameters:
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
- Parameters:
None –
- clear(flush=True)
Clear all added objects
- Parameters:
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
- Parameters:
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
- Parameters:
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
- Parameters:
obj (cnoid.Util.SgNode) – object to be drawn
update (boolean, default = False) – if True, rendering scene immediately
- removePyObject(obj, update=True)
Removing drawn object
- Parameters:
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)
Bases:
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)
- Parameters:
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
- Parameters:
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
- Parameters:
- 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
- Parameters:
None –
- setUpdateCallback(func)
Setting callback function for updating drawings
- Parameters:
func (function()) – callback function which is called when target is updated
- setKinematicsCallback(func)
Setting callback function for updating kinematics
- Parameters:
func (function()) – callback function which is called when target is updated
- newcoords(cds)
Wrapped method of newcoords in cnoid.IRSLCoords.coordinates
- Parameters:
cds (cnoid.IRSLCoords.coordinates) – replace pos and rot in self with cds
- Returns:
identical instance which was called with this method
- Return type:
- translate(pos, wrt=None)
Wrapped method of translate in cnoid.IRSLCoords.coordinates
- Parameters:
pos (numpy.array) – 1x3 vector, translation vector
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) – Reference coordinates applying this method
- Returns:
identical instance which was called with this method
- Return type:
- locate(pos, wrt=None)
Wrapped method of locate in cnoid.IRSLCoords.coordinates
- Parameters:
pos (numpy.array) – 1x3 vector, translation vector
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) – Reference coordinates applying this method
- Returns:
identical instance which was called with this method
- Return type:
- rotate(ang, axis, wrt=None)
Wrapped method of rotate in cnoid.IRSLCoords.coordinates
- Parameters:
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
- Returns:
identical instance which was called with this method
- Return type:
- orient(ang, axis, wrt=None)
Wrapped method of orient in cnoid.IRSLCoords.coordinates
- Parameters:
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
- Returns:
identical instance which was called with this method
- Return type:
- rotate_with_matrix(rot, wrt=None)
Wrapped method of rotate_with_matrix in cnoid.IRSLCoords.coordinates
- Parameters:
rot (numpy.array) – 3x3 matrix, matrix applied to rotate
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) – Reference coordinates applying this method
- Returns:
identical instance which was called with this method
- Return type:
- orient_with_matrix(rot, wrt=None)
Wrapped method of orient_with_matrix in cnoid.IRSLCoords.coordinates
- Parameters:
rot (numpy.array) – 3x3 matrix, matrix applied to rotate
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) – Reference coordinates applying this method
- Returns:
identical instance which was called with this method
- Return type:
- transform(trs, wrt=None)
Wrapped method of transform in cnoid.IRSLCoords.coordinates
- Parameters:
trs (cnoid.IRSLCoords.coordinates) – Transformation to be applied
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) – Reference coordinates applying this method
- Returns:
identical instance which was called with this method
- Return type:
- move_to(trs, wrt=None)
Wrapped method of move_to in cnoid.IRSLCoords.coordinates
- Parameters:
trs (cnoid.IRSLCoords.coordinates) – Transformation to be applied
wrt (cnoid.IRSLCoords.coordinates.wrt or cnoid.IRSLCoords.coordinates, optional) – Reference coordinates applying this method
- Returns:
identical instance which was called with this method
- Return type:
- property target
Wrapped target of this instance, which was manipulated by methods of this class
- Returns:
instance which have method ‘T’ to set cnoidPosition (4x4 matrix)
- Return type:
object
- property object
Wrapped object of this instance, which was manipulated by methods of this class
- Returns:
Utility slot set while initializing
- Return type:
object
Note
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
- Parameters:
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
- Parameters:
on (boolean, default=False) – Switch to draw this object
update (boolean, default=False) – Update drawn object in screen
module 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)
Bases:
object
Building robot interactively
- class JointType(value)
Bases:
IntEnum
An enumeration.
- __init__(robot=None, gui=True, name=None)
- Parameters:
robot (,optional) –
gui (boolean, default=True) –
name (str, optional) –
- property body
Currently builded robot model
- Returns:
Currently builded robot model
- Return type:
- property bodyItem
Currently displayed BodyItem
- Returns:
Currently displayed BodyItem
- Return type:
cnoid.BodyPlugin.BodyItem
- property draw
DrawInterface for accessing raw-level display methods
- Returns:
DrawInterface
- Return type:
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)
- Parameters:
robot (str, optional) –
name (str, optional) – name of RobotItem
- clear()
Clearing showing geometries
- objects()
Getting list of shown objects
- addShape(shape)
Adding a shape
- Parameters:
shape (cnoid.Util.SgNode) – Shape to be added
- addShapes(shapes)
Adding a shapes
- Parameters:
shapes (list[cnoid.Util.SgNode]) – Shapes to be added
- removeShape(shape)
Removing a shape
- Parameters:
shape (cnoid.Util.SgNode) – Shape to be removed
- removeShapes(shapes)
Removing a shapes
- Parameters:
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
- Parameters:
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 –
- Returns:
Created link
- Return type:
- 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:
- Returns:
Created shapes
- Return type:
[]
- 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
- Parameters:
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) –
- Returns:
Created shape
- Return type:
Shape
- createLink(name='', mass=0.1, COM=None, density=None, inertia=None, shape=None, visual=None, collision=None, **kwargs)
Creating a link
- Parameters:
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 –
- Returns:
Created Link
- Return type:
- createRootLink(**kwargs)
Creating a link and adding it as root-link
- Parameters:
**kwargs –
- Returns:
Created Link
- Return type:
- createVisualizedLinkShape(alink, scale=0.1, wrapped=True, addCOM=True, addInertia=True, addJoint=True, addDevice=True, addToLink=False, useCollision=False, useInertiaBox=False)
- Parameters:
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) –
- Returns:
Created shape
- Return type:
Shape
- exportBody(fname, modelName=None, mode=0, **kwargs)
Exporting created robot-model to file as .body file
- Parameters:
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
- Parameters:
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
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- loadMesh(fname, wrapped=True, add=True, **kwargs)
Loading mesh as a shape, see irsl_choreonoid.make_shapes.loadMesh
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeBox(x, y=None, z=None, wrapped=True, add=True, **kwargs)
Making box shape, see irsl_choreonoid.make_shapes.makeBox
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeCylinder(radius, height, wrapped=True, add=True, **kwargs)
Making cylinder shape, see irsl_choreonoid.make_shapes.makeCylinder
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeSphere(radius, wrapped=True, add=True, **kwargs)
Making sphere shape, see irsl_choreonoid.make_shapes.makeSphere
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeCone(radius, height, wrapped=True, add=True, **kwargs)
Making cone shape, see irsl_choreonoid.make_shapes.makeCone
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeCapsule(radius, height, wrapped=True, add=True, **kwargs)
Making capsule shape, see irsl_choreonoid.make_shapes.makeCapsule
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeTorus(radius, corssSectionRadius, beginAngle=None, endAngle=None, wrapped=True, add=True, **kwargs)
Making torus shape, see irsl_choreonoid.make_shapes.makeTorus
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeExtrusion(crossSection, spine, wrapped=True, add=True, **kwargs)
Making extrusion shape, see irsl_choreonoid.make_shapes.makeExtrusion
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeElevationGrid(xDimension, zDimension, xSpacing, zSpacing, height, wrapped=True, add=True, **kwargs)
Making elevation-grid shape, see irsl_choreonoid.make_shapes.makeElevationGrid
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- make3DAxis(coords=None, add=True, **kwargs)
Making 3D-axis shape, see irsl_choreonoid.make_shapes.make3DAxis
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- make3DAxisBox(coords=None, add=True, **kwargs)
Making 3D-axis shape (type: box), see irsl_choreonoid.make_shapes.make3DAxisBox
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeCoords(coords=None, add=True, **kwargs)
Making 3D-axis shape (type: line), see irsl_choreonoid.make_shapes.makeCoords
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeCross(coords=None, add=True, **kwargs)
Making 3D-axis shape (type: crossing-line), see irsl_choreonoid.make_shapes.makeCross
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape
- makeLineAlignedShape(start, end, add=True, **kwargs)
Making shape which is aligned to designated line, see irsl_choreonoid.make_shapes.makeLineAlignedShape
- Parameters:
add (boolean, default=True) –
- Returns:
Created shape
- Return type:
Shape