Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/robot/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ namespace jiminy
}

void Model::removeFrames(const std::vector<std::string> & frameNames,
const std::vector<pinocchio::FrameType> & filter)
const std::vector<pinocchio::FrameType> & allowed)
{
// Make sure that no simulation is already running
if (getIsLocked())
Expand All @@ -491,14 +491,14 @@ namespace jiminy

/* Check that the frame can be safely removed from the theoretical model.
If so, then it holds true for the extended model. */
if (!filter.empty())
if (!allowed.empty())
{
for (const std::string & frameName : frameNames)
{
const pinocchio::FrameIndex frameIndex =
getFrameIndex(pinocchioModelTh_, frameName);
const pinocchio::FrameType frameType = pinocchioModelTh_.frames[frameIndex].type;
if (std::find(filter.begin(), filter.end(), frameType) != filter.end())
if (std::find(allowed.begin(), allowed.end(), frameType) == allowed.end())
{
JIMINY_THROW(std::logic_error,
"Not allowed to remove frame '",
Expand Down
2 changes: 1 addition & 1 deletion python/jiminy_py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def finalize_options(self) -> None:
# Python linter
"pylint>=3.1",
# Python static type checker
"mypy>=1.5.0",
"mypy>=1.5.0,<1.18",
# Dependency for documentation generation
"pygments",
# Dependency for documentation generation
Expand Down
26 changes: 14 additions & 12 deletions python/jiminy_py/src/jiminy_py/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def generate_default_hardware_description_file(
for joint_descr in root.findall('./joint'):
child_obj = joint_descr.find('./child')
assert child_obj is not None
links.remove(child_obj.get('link'))
link = child_obj.get('link')
if link is not None:
links.remove(link)
link_root = next(iter(links))

# Extract the list of parent and child links, excluding the one related
Expand Down Expand Up @@ -250,7 +252,7 @@ def generate_default_hardware_description_file(

# Extract sensors
for gazebo_sensor_descr in gazebo_plugin_descr.iterfind('sensor'):
sensor_info = OrderedDict(body_name=body_name)
sensor_info: Dict[str, Any] = OrderedDict(body_name=body_name)

# Extract the sensor name
sensor_name = gazebo_sensor_descr.attrib['name']
Expand Down Expand Up @@ -331,10 +333,10 @@ def generate_default_hardware_description_file(
if plugin == "libgazebo_ros_force.so":
body_name_obj = gazebo_plugin_descr.find('bodyName')
assert body_name_obj is not None
body_name = body_name_obj.text
body_name_text = body_name_obj.text
force_sensor_info = sensors_info[ForceSensor.type]
force_sensor_info[f"{body_name}Wrench"] = OrderedDict(
frame_name=body_name)
force_sensor_info[f"{body_name_text}Wrench"] = OrderedDict(
frame_name=body_name_text)
else:
LOGGER.warning("Unsupported Gazebo plugin '%s'", plugin)

Expand Down Expand Up @@ -422,9 +424,9 @@ def generate_default_hardware_description_file(
sensor_info['motor_name'] = motor_name

# Extract the associated joint name
joint_descr = transmission_descr.find('./joint')
assert isinstance(joint_descr, ET.Element)
joint_name = joint_descr.attrib['name']
transmission_joint_descr = transmission_descr.find('./joint')
assert isinstance(transmission_joint_descr, ET.Element)
joint_name = transmission_joint_descr.attrib['name']
motor_info['joint_name'] = joint_name
joint_transmissions.add(joint_name)

Expand Down Expand Up @@ -466,16 +468,16 @@ def generate_default_hardware_description_file(

# Define default encoder sensors, and default effort sensors if no
# transmission available.
for joint_descr in root.iterfind('joint'):
for root_joint_descr in root.iterfind('joint'):
encoder_info = OrderedDict()

# Skip fixed joints
joint_type = joint_descr.attrib['type'].casefold()
joint_type = root_joint_descr.attrib['type'].casefold()
if joint_type == 'fixed':
continue

# Extract the joint name
joint_name = joint_descr.attrib['name']
joint_name = root_joint_descr.attrib['name']
encoder_info['joint_name'] = joint_name

# Add the sensor to the robot's hardware
Expand All @@ -484,7 +486,7 @@ def generate_default_hardware_description_file(

# Add motors to robot hardware by default if no transmission found
if not joint_transmissions:
joint_limit_descr = joint_descr.find('./limit')
joint_limit_descr = root_joint_descr.find('./limit')
assert joint_limit_descr is not None
if float(joint_limit_descr.attrib['effort']) == 0.0:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@
from pathlib import PureWindowsPath
from contextlib import AbstractContextManager
from typing import (
Dict, Any, List, Callable, Optional, Tuple, Union, Sequence, Literal, Type)
Dict,
Any,
List,
Callable,
Optional,
Tuple,
Union,
Sequence,
Literal,
Type,
Iterable,
)

import numpy as np

Expand Down Expand Up @@ -1357,8 +1368,11 @@ def append_mesh(self,
# Parse the mesh file toe extract axis up if provided
def parse_xml(xml_path: str) -> Tuple[ET.Element, Dict[str, str]]:
xml_iter = ET.iterparse(xml_path, events=["start-ns"])
xml_namespaces = dict(prefix_namespace_pair
for _, prefix_namespace_pair in xml_iter)
prefix_namespace_pairs: Iterable[tuple[str, str]] = (
prefix_namespace_pair
for _, prefix_namespace_pair in xml_iter
)
xml_namespaces = dict(prefix_namespace_pairs)
return (xml_iter.root, # type: ignore[attr-defined]
xml_namespaces)

Expand Down
1 change: 1 addition & 0 deletions python/jiminy_py/src/jiminy_py/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,7 @@ def add_marker(
# Add new marker
create_shape = getattr(self._gui, f"append_{shape}")
create_shape(self._markers_group, name, **shape_kwargs)
assert isinstance(pose, np.ndarray) or callable(pose)
marker_data: MarkerDataType = {
"pose": pose, "scale": scale, "color": color}
self.markers[name] = marker_data
Expand Down
Loading