IO

HDF5

HDF5 operations

farms_core.io.hdf5.dict_to_hdf5(filename, data, mode='w', **kwargs)

Dictionary to HDF5

farms_core.io.hdf5.hdf5_get(filename, key, **kwargs)

HDF5 to dictionary

farms_core.io.hdf5.hdf5_keys(filename, **kwargs)

HDF5 to dictionary

farms_core.io.hdf5.hdf5_open(filename, mode='w', max_attempts=10, attempt_delay=0.1)

Open HDF5 file with delayed attempts

farms_core.io.hdf5.hdf5_to_dict(filename, **kwargs)

HDF5 to dictionary

YAML

Input output operations for YAML files

farms_core.io.yaml.pyobject2yaml(filename, pyobject, mode='w+')

Pyobject to yaml

Parameters
  • filename (str) –

  • pyobject (Any) –

farms_core.io.yaml.read_yaml(file_path)

Read the yaml data from file.

Parameters
file_path

Location of the .yaml/yml containing the bone table.

:param file_path:
:type file_path:py:class:str
:rtype:py:data:~typing.Any
farms_core.io.yaml.write_yaml(data, file_path)

Method that dumps the data to yaml file.

Parameters
data

Dictionary containing the data to dump

file_path

File path to dump the data

:param data:
:type data:py:class:~typing.Dict
:param file_path:
:type file_path:py:class:str
farms_core.io.yaml.yaml2pyobject(filename)

Pyobject to yaml

Parameters

filename (str) –

Return type

Any

SDF

Farms SDF

class farms_core.io.sdf.Axis(**kwargs)

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate axis object from xml data

Parameters
cls<cls>

Class

data<ET.ElemenTree>

Axis data from the sdf

Returns
out<Axis>

Axis object from xml

xml(joint)
class farms_core.io.sdf.Box(size, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Box shape from xml data.

Parameters
cls<Box>

Box class data

data<ET.ElementTree>

Box object data

Returns
out<Box>

Box model

xml(parent)
class farms_core.io.sdf.Capsule(radius, length, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Capsule shape from xml data.

Parameters
cls<Capsule>

Capsule class data

data<ET.ElementTree>

Capsule object data

Returns
out<Capsule>

Capsule model

xml(parent)
class farms_core.io.sdf.Collision(name, **kwargs)

Bases: farms_core.io.sdf.Shape

classmethod from_xml(data)

Generate collision shape model from xml.

Parameters
cls<Shape>

Shape class data

data<ET.ElementTree>

Visual/Collision object data

Returns
out<Shape>

Shape model

class farms_core.io.sdf.Cylinder(radius, length, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Cylinder shape from xml data.

Parameters
cls<Cylinder>

Cylinder class data

data<ET.ElementTree>

Cylinder object data

Returns
out<Cylinder>

Cylinder model

xml(parent)
class farms_core.io.sdf.Heightmap(uri, size, pos, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Heightmap shape from xml data.

Parameters
cls<Heightmap>

Heightmap class data

data<ET.ElementTree>

Heightmap object data

Returns
out<Heightmap>

Heightmap model

xml(parent)
class farms_core.io.sdf.Inertial(pose, mass, inertias, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod box(size, pose, **kwargs)

Box

classmethod capsule(length, radius, pose, **kwargs)

Capsule

classmethod cylinder(length, radius, pose, **kwargs)

Cylinder

classmethod empty(units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Empty

classmethod from_mesh(path, pose, scale=1, **kwargs)

From mesh

classmethod from_xml(data)

Create Inertial object from xml data.

Parameters
cls<cls>

Class

data<ET.ElemenTree>

Inertial data from the sdf

Returns
out<Inertial>

Inertial object from xml

classmethod sphere(radius, pose, **kwargs)

Sphere

static valid_inertia(inertia)

Check if inertia matrix is positive, bounded and non zero.

static valid_mass(mass)

Check if mass is positive, bounded and non zero.

xml(link)
class farms_core.io.sdf.Joint(name, joint_type, parent, child, **kwargs)

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate joint object from xml data

Parameters
cls<cls>

Class

data<ET.ElemenTree>

Joint data from the sdf

Returns
out<Joint>

Joint object from xml

xml(model)
class farms_core.io.sdf.Link(name, pose, **kwargs)

Bases: farms_core.options.Options

classmethod box(name, pose, **kwargs)

Box

classmethod capsule(name, pose, **kwargs)

Capsule

classmethod cylinder(name, pose, **kwargs)

Cylinder

classmethod empty(name, pose, **kwargs)

Empty

classmethod from_mesh(name, mesh, pose, **kwargs)

From mesh

classmethod from_xml(data)

Create link object from parsed xml data.

classmethod heightmap(name, uri, pose, **kwargs)

Heightmap

classmethod plane(name, pose, **kwargs)

Plane

classmethod sphere(name, pose, **kwargs)

Sphere

xml(model)
class farms_core.io.sdf.Mesh(uri, scale, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Mesh shape from xml data.

Parameters
cls<Mesh>

Mesh class data

data<ET.ElementTree>

Mesh object data

Returns
out<Mesh>

Mesh model

xml(parent)
class farms_core.io.sdf.ModelSDF(name, pose, **kwargs)

Bases: farms_core.options.Options

Farms SDF

change_units(units)

Change the units of all elements in the model.

classmethod create_model(data, directory='')

Create ModelSDF from parsed sdf model data.

classmethod from_urdf(filename)

Read from URDF file

get_base_link()

Find the base link in the model

Parameters
model: <ModelSDF>

SDF model object

Returns
base_link: <str>

Name of the base link in the model

get_base_links()

Find the base link in the model

Parameters
model: <ModelSDF>

SDF model object

Returns
base_links: <list>

List of names of base links in the model

get_children(link)

Get children

get_joint(joint_name)

Get joint object in the model

Parameters
joint_name: <str>

Name of the joint to find in the model.

Returns
joint: <Link>

Link object with name = joint_name None if no object with joint_name found

get_joint_index(joint_name)

Get joint index in the model

Parameters
joint_name: <str>

Name of the joint to find in the model.

Returns
index: <int>

Joint index with name = joint_name None if no object with joint_name found

param joint_name
:type joint_name:py:class:str
get_link(link_name)

Get link object in the model

Parameters
link_name: <str>

Name of the link to find in the model.

Returns
link: <Link>

Link object with name = link_name None if no object with link_name found

param link_name
:type link_name:py:class:str
get_link_index(link_name)

Get link index in the model

Parameters
link_name: <str>

Name of the link to find in the model.

Returns
index: <int>

Link index with name = link_name None if no object with link_name found

param link_name
:type link_name:py:class:str
get_parent(link)

Get parent

get_parent_joint(link)

Get parent

classmethod read(filename)

Read from an SDF FILE.

validate()

Validate model

write(filename='animat.sdf')

Write SDF to file

xml(use_world=True)
xml_str()

xml string

class farms_core.io.sdf.Plane(normal, size, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Plane shape from xml data.

Parameters
cls<Plane>

Plane class data

data<ET.ElementTree>

Plane object data

Returns
out<Plane>

Plane model

xml(parent)
class farms_core.io.sdf.Shape(name, geometry, suffix, **kwargs)

Bases: farms_core.options.Options

classmethod bounding_from_mesh(name, mesh, scale, **kwargs)

Create bounding shape from mesh.

classmethod box(name, size, **kwargs)

Box

classmethod capsule(name, radius, length, **kwargs)

Box

classmethod cylinder(name, radius, length, **kwargs)

Cylinder

classmethod from_mesh(name, mesh, scale, **kwargs)

From mesh

classmethod heightmap(name, uri, size, pos, **kwargs)

Heightmap

classmethod plane(name, normal, size, **kwargs)

Plane

classmethod sphere(name, radius, **kwargs)

Box

xml(link)
class farms_core.io.sdf.Sphere(radius, units={'kilograms': 1, 'meters': 1, 'seconds': 1})

Bases: farms_core.options.Options

classmethod from_xml(data)

Generate Sphere shape from xml data.

Parameters
cls<Sphere>

Sphere class data

data<ET.ElementTree>

Sphere object data

Returns
out<Sphere>

Sphere model

xml(parent)
class farms_core.io.sdf.Visual(name, **kwargs)

Bases: farms_core.io.sdf.Shape

classmethod from_xml(data)

Generate visual shape model from xml.

Parameters
cls<Shape>

Shape class data

data<ET.ElementTree>

Visual/Collision object data

Returns
out<Shape>

Shape model

xml(link)
farms_core.io.sdf.compute_child_inertial_in_parent(parent_link, child_link)

Compute the combined inertial representation of links in parent frame using Steiner’s formula

farms_core.io.sdf.convert_poses_urdf2sdf_recursive(tree, pose, links, joint_parenting)

Convert poses urdf2sdf recursive

farms_core.io.sdf.convert_urdf2sdf(robot)

Convert URDF2SDF

farms_core.io.sdf.create_parent_tree(model)

Parenting tree

farms_core.io.sdf.create_tree(robot)

Create tree

farms_core.io.sdf.create_tree_recursive(tree, parenting)

Tree recursive

farms_core.io.sdf.get_floats_from_text(text, split=' ')

Get floats from text

farms_core.io.sdf.get_inertia_tensor_from_vector(inertia_vector)

Get the inertia tensor from the inertia vector of six elements

Parameters

inertia_vector (list) –

Return type

ndarray

farms_core.io.sdf.get_inertia_vector_from_tensor(inertia_tensor)

Get the inertia vector of six elements from the inertia tensor

Parameters

inertia_tensor (ndarray) –

Return type

list

farms_core.io.sdf.get_parenting(links, joints)

Get parenting

farms_core.io.sdf.get_pose_from_xml(data)

Get pose

farms_core.io.sdf.merge_fixed_joints(model)

Method to merge fixed links in the model.

Parameters
model: <ModelSDF>

SDF model

Returns
return: <None>

The method operates directly on the given model

farms_core.io.sdf.merge_fixed_joints_recursive(model, link_child_links, link_child_joints, link)

Merge fixed joints in the model

Parameters
model: <ModelSDF>

SDF model

link_child_links: <dict>

Link and associated child links

link_child_joints: <dict>

Link and associated child joints

link: <Link>

Link to start the recursion from

farms_core.io.sdf.remove_joint(model, joint_name)

Remove joint in the model

Parameters
model: <ModelSDF>

Model SDF

joint_name: <str>

Name of the joint to remove from the model.

farms_core.io.sdf.remove_link(model, link_name)

Remove link in the model

Parameters
model: <ModelSDF>

Model SDF

link_name: <str>

Name of the link to remove from the model.

farms_core.io.sdf.replace_file_name_in_path(file_path, new_name)

Replace a file name in a given path. File extension is retained

Parameters
file_path<str>

Path to the file object

new_name<str>

Name to replace the original file name

Returns
out<str>

New path with the replaced file name