file_path
stringlengths 20
202
| content
stringlengths 9
3.85M
| size
int64 9
3.85M
| lang
stringclasses 9
values | avg_line_length
float64 3.33
100
| max_line_length
int64 8
993
| alphanum_fraction
float64 0.26
0.93
|
---|---|---|---|---|---|---|
shikimori/shikimori/config/locales/frontend/achievements.ru.yml
|
ru:
frontend:
achievements:
title:
gained: Открыто достижение
lost: Потеряно достижение
| 116 |
YAML
| 15.714283 | 34 | 0.62069 |
shikimori/shikimori/config/locales/frontend/application.ru.yml
|
ru:
frontend:
application:
sure_to_leave_page: |-
Здесь написан и не сохранён какой-то комментарий!
Точно покинуть страницу?
| 153 |
YAML
| 20.999997 | 57 | 0.640523 |
shikimori/shikimori/config/locales/frontend/statistics.en.yml
|
en:
frontend:
statistics:
number: Number
anime_with_score: <b>%{count}</b> anime scored <b>%{score}</b>
anime_of_type: <b>%{count}</b> anime of type <b>%{type}</b>
anime_in_year: '%{count} %{type} in %{year}'
anime_with_rating_in_year: '%{count} %{rating} anime in %{year}'
share: Share
ratings_share: '%{percent}% share of %{rating} in %{year}'
genres_share: '%{percent}% share of %{genre} in %{year}'
| 457 |
YAML
| 37.166664 | 70 | 0.56674 |
shikimori/shikimori/config/locales/frontend/user_rates.ru.yml
|
ru:
frontend:
user_rates:
button:
add_to_list: Добавить в список
remove_from_my_list: Удалить из списка
| 132 |
YAML
| 17.999997 | 46 | 0.606061 |
shikimori/shikimori/config/locales/frontend/application.en.yml
|
en:
frontend:
application:
sure_to_leave_page: |-
You have not saved your comment!
Are you sure you want to leave this page?
| 153 |
YAML
| 20.999997 | 49 | 0.614379 |
shikimori/shikimori/config/locales/frontend/dynamic_elements.en.yml
|
en:
frontend:
dynamic_elements:
check_height:
expand: expand
shiki_editable:
your_request_will_be_considered: >-
Your request will be considered. Domo arigato.
topic:
load_comments: Load next %{comment_count} %{of_total_comments} %{comment_word}
type_label: Topic
of: of
comment:
one: comment
few: comments
many: comments
new_message_added:
one: '%{count} new message added'
few: '%{count} new messages added'
many: '%{count} new messages added'
new_comment_added:
one: '%{count} new comment added'
few: '%{count} new comments added'
many: '%{count} new comments added'
comment:
type_label: Comment
marked_as_offtopic: Comment has been marked as offtopic
multiple_marked_as_offtopic: Comments have been marked as offtopic
marked_as_summary: Comment has been marked as summary
not_marked_as_offtopic: Removed offtopic marking
not_marked_as_summary: Removed summary marking
dialog:
type_label: Dialog
message:
type_label: Message
review:
type_label: Review
authorized_action:
register_to_complete_action: >-
Please <a href="/users/sign_up">register</a>
to complete this action.
day_registered_action:
action_will_be_available: >-
Action will be available one day after
<a href="/users/sign_up">registration</a>.
week_registered_action:
action_will_be_available: >-
Action will be available one day after
<a href="/users/sign_up">registration</a>.
not_implemented_yet_action: This action is temporarily not available
| 1,816 |
YAML
| 28.786885 | 86 | 0.598568 |
shikimori/shikimori/config/locales/frontend/dynamic_elements.ru.yml
|
ru:
frontend:
dynamic_elements:
check_height:
expand: развернуть
shiki_editable:
your_request_will_be_considered: >-
Твой запрос будет рассмотрен. Домо аригато.
topic:
load_comments: Загрузить ещё %{comment_count} %{of_total_comments} %{comment_word}
type_label: Топик
of: из
comment:
one: комментарий
few: комментария
many: комментариев
new_message_added:
one: Добавлено %{count} новое сообщение
few: Добавлено %{count} новых сообщения
many: Добавлено %{count} новых сообщений
new_comment_added:
one: Добавлен %{count} новый комментарий
few: Добавлено %{count} новых комментария
many: Добавлено %{count} новых комментариев
comment:
type_label: Комментарий
marked_as_offtopic: Комментарий помечен оффтопиком
multiple_marked_as_offtopic: Комментарии помечены оффтопиком
marked_as_summary: Комментарий помечен отзывом
not_marked_as_offtopic: Метка оффтопика снята
not_marked_as_summary: Метка отзыва снята
dialog:
type_label: Диалог
message:
type_label: Сообщение
review:
type_label: Отзыв
authorized_action:
register_to_complete_action: >-
Для этого действия тебе необходима
<a href="/users/sign_up">регистрация</a> на сайте.
day_registered_action:
action_will_be_available: >-
Действие станет доступно через сутки после
<a href="/users/sign_up">регистрации</a>.
week_registered_action:
action_will_be_available: >-
Действие станет доступно через неделю после
<a href="/users/sign_up">регистрации</a>.
not_implemented_yet_action: Это действие временно недоступно
| 1,864 |
YAML
| 29.57377 | 90 | 0.621781 |
cKohl10/TactileSim/exts/README.md
|
To add the contact extension to Isaac Sim:
1: Open the extensions window, *Window* > *Extensions*
2: Add the path to extenstions in the *Extension Search Paths* window in the form `/TactileSim/exts`
3: Open the extension from the toolbar at the top of the screen.
To use the extension:
1: After creating a CSV list of sensor positions, radius, and paths as described in `/TactileSim/blender_scripts/sensor_bay_addon/README.md`
2: IMPORTANT: For a new robot, a contact sensor has to first be manually added to each link that will be covered.
This allows the link to become the parent of a contact sensor. After manually adding the sensor once, it can be deleted and the robot can be saved.
| 714 |
Markdown
| 43.687497 | 150 | 0.7507 |
cKohl10/TactileSim/exts/contact_ext_test/Contact_Extension_Test_python/ContactSensorClass.py
|
# Tactile Contact Sensor Functions
# Author: Carson Kohlbrenner
# Date: 6/3/2024
from .AbstracSensorClass import AbstractSensorOperator
import numpy as np
import omni.kit.commands
import omni.ui as ui
from omni.isaac.sensor import _sensor
from omni.isaac.core.utils.stage import get_current_stage
from omni.isaac.core.utils.prims import is_prim_path_valid, get_prim_children
from omni.isaac.ui.element_wrappers import CollapsableFrame
from omni.isaac.ui.ui_utils import get_style, LABEL_WIDTH
from pxr import Gf
class ContactSensorOperator(AbstractSensorOperator):
def __init__(self):
super().__init__()
self.parent_paths = [] # List of parent paths for each sensor
self.sliders = [] # List of sliders for each sensor on the UI
self.meters_per_unit = 1.00 # Unit conversion factor
self.activated = False # Flag to determine if the sensors are active
self.sensor_description = "Contact Sensors" # Description of the sensor type
# Data structure to store sensor information
class Sensor:
def __init__(self, name, position, radius, parent_path):
self.name = name
self.position = position
self.radius = radius
self.parent_path = parent_path
self.path = parent_path + "/tact_sensor_" + name
def import_sensors_fn(self):
"""
Function that executes when the user clicks the 'Update' button
Imports the sensor data from the CSV file and creates the sensors
Expects the CSV file to have the following format:
Sensor Name, X Offset, Y Offset, Z Offset, Radius, Parent Path
"""
self.activated = True
self._cs = _sensor.acquire_contact_sensor_interface()
# Remove all sensors already on the robot
message = "Removing existing sensors...\n"
self._status_report_field.set_text(message)
self.remove_sensors()
message += "Sensors successfully removed\n\n"
self._status_report_field.set_text(message)
#Change the text of the status report field to show the import status
path = self.config_path
message += "Importing sensor data from '" + path + "'...\n"
self._status_report_field.set_text(message)
#Import the sensor data from the CSV file
try:
names, positions, radii, parent_paths, data = self.import_csv(path)
self.parent_paths = parent_paths
self.remove_sensors() # Second call to ensure all sensors are removed after parent paths are updated
message += "File opened successfully\n"
# Output the data to the status report field
# message += "\n\nSensor Data:\n"
# for i in range(len(names)):
# message += str(data[i]) + "\n"
except:
message += "Invalid file path or file format!"
message += "\nPlease make sure the file has at least 2 sensors and is formatted correctly.\n"
self._status_report_field.set_text(message)
return
self._status_report_field.set_text(message)
# Determine the number of sensors and their positions
num_sensors = len(data)
self.sensors = {}
sensor_count = 0 # Keep track of the number of sensors created successfully
for i in range(num_sensors):
# Create a contact sensor at the specified position
# message += "\nCreating sensor " + str(i) + " at position " + str(positions[i]) + "...\n"
# self._status_report_field.set_text(message)
# Check if the parent path is valid
if not is_prim_path_valid(parent_paths[i]):
message += "Could not find parent path: " + parent_paths[i] + "\n"
self._status_report_field.set_text(message)
continue
# Get the parent prim
parent_prim = get_current_stage().GetPrimAtPath(parent_paths[i])
# Check if the appled link has a rigidbody component (Unknown if this is necessary)
# if not parent_prim.HasAPI(UsdPhysics.RigidBodyAPI):
# message += "Parent path does not have a rigidbody component: " + parent_paths[i] + "\n"
# self._status_report_field.set_text(message)
# continue
# Create the sensor
self.create_contact_sensor(parent_paths[i], positions[i], radii[i], names[i])
sensor_count = sensor_count + 1
message += "\nSuccessfully created " + str(sensor_count) + " sensors\n"
self._status_report_field.set_text(message)
# Populate the sensor readings frame with the new sensors
self.update_sensor_readings_frame()
def import_csv(self, path):
"""
Function that imports the sensor data from a CSV file
CSV file should have the following format:
Sensor Name, X Offset, Y Offset, Z Offset, Radius, Parent Path
"""
try:
data = np.genfromtxt(path, delimiter=',', skip_header=1, dtype=str)
# Save the first column as a list of names, the 2-4th columns as a list of positions, and the 5th column as a list of parent paths
names = data[:, 0]
# Convert the positions to a list of Gf.Vec3d objects
positions = []
for i in range(len(data)):
positions.append(Gf.Vec3d(float(data[i, 1]), float(data[i, 2]), float(data[i, 3])))
radii = []
for i in range(len(data)):
radii.append(float(data[i, 4]))
# Save the parent paths as a list of strings
parent_paths = []
for i in range(len(data)):
parent_paths.append(data[i, 5])
return names, positions, radii, parent_paths, data
except:
return None
def create_contact_sensor(self, parent_path, position, radius, name):
# Create the sensor at the specified position
result, sensor = omni.kit.commands.execute(
"IsaacSensorCreateContactSensor",
path="/tact_sensor_" + name,
parent=parent_path,
min_threshold=0,
max_threshold=1000000,
color=(1, 0, 0, 1),
radius=radius,
sensor_period=1,
translation=position,
visualize=True,
)
# Add the sensor to the list of sensors
self.sensors[name] = self.Sensor(name, position, radius, parent_path)
def remove_sensors(self):
"""
Function that removes all sensors from the robot
"""
if len(self.parent_paths) == 0:
return
for parent_path in self.parent_paths:
# Find all prims under the parent path that contain "tact_sensor" in their name
try:
parent_prim = get_current_stage().GetPrimAtPath(parent_path)
prims = get_prim_children(parent_prim)
except:
self._status_report_field.set_text("Unexpected path!\n")
return
#self._status_report_field.set_text("Found " + str(len(prims)) + " sensors to remove\n")
# Remove all prims found
for prim in prims:
if "tact_sensor" in prim.GetName():
omni.kit.commands.execute('DeletePrims', paths=[parent_path + "/" + prim.GetName()])
def remove_sensors_fn(self):
"""
Function that executes when the user clicks the 'Remove Sensors' button
Removes all sensors from the robot
"""
self.activated = False
self.remove_sensors()
self._status_report_field.set_text("All sensors removed\n\n\n If sensors remain, choose the correct configuration file and click 'Update'\n")
# This function updates the sensor readings in the UI at every physics step
def sensor_update(self, dt):
#self._status_report_field.set_text("Updating sensor readings...\n")
if len(self.sliders) > 0:
slider_num = 0
for s in self.sensors.values():
#self._status_report_field.set_text("Updating sensor " + s.name + " at path " + s.path + "...\n")
reading = self._cs.get_sensor_reading(s.path)
if reading.is_valid:
self.sliders[slider_num].model.set_value(
float(reading.value) * self.meters_per_unit
) # readings are in kg⋅m⋅s−2, converting to Newtons
else:
self.sliders[slider_num].model.set_value(0)
slider_num += 1
# contacts_raw = self._cs.get_body_contact_raw_data(self.leg_paths[0])
# if len(contacts_raw):
# c = contacts_raw[0]
# # print(c)
def create_sensor_readings_frame(self):
self.sensor_readings_frame = CollapsableFrame("Sensor Readings", collapsed=False)
def update_sensor_readings_frame(self):
# Color and style for the UI elements
self.sliders = []
self.colors = [0xFFBBBBFF, 0xFFBBFFBB, 0xBBFFBBBB, 0xBBBBFFFF]
style = {"background_color": 0xFF888888, "color": 0xFF333333, "secondary_color": self.colors[0]}
#message = "There are " + str(len(self.sensors)) + " sensors\n"
with self.sensor_readings_frame:
# Vertical stack to hold the sensor readings in the frame
with ui.VStack(style=get_style(), spacing=5, height=0):
for s in self.sensors.values():
#message += "Creating reading bar for sensor " + s.name + "...\n"
with ui.HStack():
ui.Label(s.name, width=LABEL_WIDTH, tooltip="Force in Newtons")
# ui.Spacer(height=0, width=10)
style["secondary_color"] = self.colors[0]
self.sliders.append(ui.FloatDrag(min=0.0, max=15.0, step=0.001, style=style))
self.sliders[-1].enabled = False
ui.Spacer(width=20)
| 10,168 |
Python
| 41.195021 | 149 | 0.586644 |
cKohl10/TactileSim/exts/contact_ext_test/Contact_Extension_Test_python/AbstracSensorClass.py
|
# Abstract Sensor Class
# Author: Carson Kohlbrenner
# Date: 6/3/2024
"""
This class is an abstract class that defines the basic structure of a sensor.
"""
class AbstractSensorOperator:
def __init__(self):
self.sensors = {}
self.config_path = ""
self._status_report_field = None
def import_sensors_fn(self):
"""
Function that executes when the user clicks the 'Update' button
Imports the sensor data from the CSV file and creates the sensors
"""
pass
def remove_sensors_fn(self):
"""
Function that removes all sensors from the robot
"""
pass
def sensor_update(self, dt):
"""
Function that updates the sensor data
"""
pass
def create_sensor_readings_frame(self):
"""
Function that creates the sensor readings frame
"""
pass
def update_sensor_readings_frame(self):
"""
Function that updates the sensor readings
"""
pass
| 1,040 |
Python
| 22.65909 | 77 | 0.584615 |
cKohl10/TactileSim/exts/contact_ext_test/Contact_Extension_Test_python/extension.py
|
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import asyncio
import gc
import omni
import omni.kit.commands
import omni.physx as _physx
import omni.timeline
import omni.ui as ui
import omni.usd
from omni.isaac.ui.element_wrappers import ScrollingWindow
from omni.isaac.ui.menu import MenuItemDescription
from omni.kit.menu.utils import add_menu_items, remove_menu_items
from omni.usd import StageEventType
from .global_variables import EXTENSION_DESCRIPTION, EXTENSION_TITLE
from .ui_builder import UIBuilder
"""
This file serves as a basic template for the standard boilerplate operations
that make a UI-based extension appear on the toolbar.
This implementation is meant to cover most use-cases without modification.
Various callbacks are hooked up to a seperate class UIBuilder in .ui_builder.py
Most users will be able to make their desired UI extension by interacting solely with
UIBuilder.
This class sets up standard useful callback functions in UIBuilder:
on_menu_callback: Called when extension is opened
on_timeline_event: Called when timeline is stopped, paused, or played
on_physics_step: Called on every physics step
on_stage_event: Called when stage is opened or closed
cleanup: Called when resources such as physics subscriptions should be cleaned up
build_ui: User function that creates the UI they want.
"""
class ContactExtension(omni.ext.IExt):
def on_startup(self, ext_id: str):
"""Initialize extension and UI elements"""
self.ext_id = ext_id
self._usd_context = omni.usd.get_context()
# Build Window
self._window = ScrollingWindow(
title=EXTENSION_TITLE, width=800, height=500, visible=False, dockPreference=ui.DockPreference.LEFT_BOTTOM
)
self._window.set_visibility_changed_fn(self._on_window)
action_registry = omni.kit.actions.core.get_action_registry()
action_registry.register_action(
ext_id,
f"CreateUIExtension:{EXTENSION_TITLE}",
self._menu_callback,
description=f"Add {EXTENSION_TITLE} Extension to UI toolbar",
)
self._menu_items = [
MenuItemDescription(name="Demo Test", onclick_action=(ext_id, f"CreateUIExtension:{EXTENSION_TITLE}")),
]
add_menu_items(self._menu_items, EXTENSION_TITLE)
# Filled in with User Functions
self.ui_builder = UIBuilder(self._window)
# Events
self._usd_context = omni.usd.get_context()
self._physxIFace = _physx.acquire_physx_interface()
self._physx_subscription = None
self._stage_event_sub = None
self._timeline = omni.timeline.get_timeline_interface()
def on_shutdown(self):
self._models = {}
remove_menu_items(self._menu_items, EXTENSION_TITLE)
action_registry = omni.kit.actions.core.get_action_registry()
action_registry.deregister_action(self.ext_id, f"CreateUIExtension:{EXTENSION_TITLE}")
if self._window:
self._window = None
self.ui_builder.cleanup()
gc.collect()
def _on_window(self, visible):
if self._window.visible:
# Subscribe to Stage and Timeline Events
self._usd_context = omni.usd.get_context()
events = self._usd_context.get_stage_event_stream()
self._stage_event_sub = events.create_subscription_to_pop(self._on_stage_event)
stream = self._timeline.get_timeline_event_stream()
self._timeline_event_sub = stream.create_subscription_to_pop(self._on_timeline_event)
self._build_ui()
else:
self._usd_context = None
self._stage_event_sub = None
self._timeline_event_sub = None
self.ui_builder.cleanup()
def _build_ui(self):
with self._window.frame:
with ui.VStack(spacing=5, height=0):
self._build_extension_ui()
async def dock_window():
await omni.kit.app.get_app().next_update_async()
def dock(space, name, location, pos=0.5):
window = omni.ui.Workspace.get_window(name)
if window and space:
window.dock_in(space, location, pos)
return window
tgt = ui.Workspace.get_window("Viewport")
dock(tgt, EXTENSION_TITLE, omni.ui.DockPosition.LEFT, 0.33)
await omni.kit.app.get_app().next_update_async()
self._task = asyncio.ensure_future(dock_window())
#################################################################
# Functions below this point call user functions
#################################################################
def _menu_callback(self):
self._window.visible = not self._window.visible
self.ui_builder.on_menu_callback()
def _on_timeline_event(self, event):
if event.type == int(omni.timeline.TimelineEventType.PLAY):
if not self._physx_subscription:
self._physx_subscription = self._physxIFace.subscribe_physics_step_events(self._on_physics_step)
elif event.type == int(omni.timeline.TimelineEventType.STOP):
self._physx_subscription = None
self.ui_builder.on_timeline_event(event)
def _on_physics_step(self, step):
self.ui_builder.on_physics_step(step)
def _on_stage_event(self, event):
if event.type == int(StageEventType.OPENED) or event.type == int(StageEventType.CLOSED):
# stage was opened or closed, cleanup
self._physx_subscription = None
self.ui_builder.cleanup()
self.ui_builder.on_stage_event(event)
def _build_extension_ui(self):
# Call user function for building UI
self.ui_builder.build_ui()
def _on_update(self, dt):
if self._timeline.is_playing() and self.ui_builder.sliders:
slider_num = 0
for s in self.ui_builder.sensors.values():
reading = self._cs.get_sensor_reading(s.path)
if reading.is_valid:
self.sliders[slider_num].model.set_value(
float(reading.value) * self.meters_per_unit
) # readings are in kg⋅m⋅s−2, converting to Newtons
else:
self.sliders[slider_num].model.set_value(0)
slider_num += 1
# contacts_raw = self._cs.get_body_contact_raw_data(self.leg_paths[0])
# if len(contacts_raw):
# c = contacts_raw[0]
# # print(c)
| 6,988 |
Python
| 37.401099 | 117 | 0.632227 |
cKohl10/TactileSim/exts/contact_ext_test/Contact_Extension_Test_python/contact_sensor_example.py
|
# Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import asyncio
import weakref
import carb
import omni
import omni.kit.commands
import omni.physx as _physx
import omni.ui as ui
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.sensor import _sensor
from omni.isaac.ui.menu import make_menu_item_description
from omni.isaac.ui.ui_utils import LABEL_WIDTH, get_style, setup_ui_headers
from omni.kit.menu.utils import MenuItemDescription, add_menu_items, remove_menu_items
from pxr import Gf, UsdGeom
EXTENSION_NAME = "Contact Sensor Example"
class Contact_sensor_demo(omni.ext.IExt):
def on_startup(self, ext_id: str):
ext_manager = omni.kit.app.get_app().get_extension_manager()
self._ext_id = ext_id
self._extension_path = ext_manager.get_extension_path(ext_id)
self._menu_items = [
MenuItemDescription(
name="Sensors",
sub_menu=[make_menu_item_description(ext_id, "Contact", lambda a=weakref.proxy(self): a.build_ui())],
)
]
add_menu_items(self._menu_items, "Isaac Examples")
self.meters_per_unit = 1.00
self._window = None
def _on_stage_event(self, event):
if event.type == int(omni.usd.StageEventType.CLOSED):
self.on_closed()
def build_ui(self):
if self._window is None:
self._cs = _sensor.acquire_contact_sensor_interface()
self._timeline = omni.timeline.get_timeline_interface()
self.sub = _physx.get_physx_interface().subscribe_physics_step_events(self._on_update)
self.leg_paths = ["/Ant/Arm_{:02d}/Lower_Arm".format(i + 1) for i in range(4)]
self.shoulder_joints = ["/Ant/Arm_{:02d}/Upper_Arm/shoulder_joint".format(i + 1) for i in range(4)]
self.lower_joints = ["{}/lower_arm_joint".format(i) for i in self.leg_paths]
self._sensor_handles = [0 for i in range(4)]
self.sliders = None
# self._window = ui.Window(
# title="Contact Sensor Sample", width=300, height=200, dockPreference=ui.DockPreference.LEFT_BOTTOM
# )
self.sliders = []
self.colors = [0xFFBBBBFF, 0xFFBBFFBB, 0xBBFFBBBB, 0xBBBBFFFF]
style = {"background_color": 0xFF888888, "color": 0xFF333333, "secondary_color": self.colors[0]}
self.plots = []
self.plot_vals = []
self._window = ui.Window(
title=EXTENSION_NAME, width=600, height=0, visible=True, dockPreference=ui.DockPreference.LEFT_BOTTOM
)
with self._window.frame:
with ui.VStack(spacing=5, height=0):
title = "Contact Sensor Example"
doc_link = "https://docs.omniverse.nvidia.com/isaacsim/latest/features/sensors_simulation/isaac_sim_sensors_physics_based_contact.html"
overview = "This Example shows how to Surface load sensors applied to a body. "
overview += "It works by summing all forces applied on a given trigger shperical region intersected with the given body surface."
overview += (
"\nPress PLAY to start the simulation, hold 'shift' and left click the model to drag it around"
)
overview += "\n\nPress the 'Open in IDE' button to view the source code."
setup_ui_headers(self._ext_id, __file__, title, doc_link, overview)
frame = ui.CollapsableFrame(
title="Sensor Readings",
height=0,
collapsed=False,
style=get_style(),
style_type_name_override="CollapsableFrame",
horizontal_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_AS_NEEDED,
vertical_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_ALWAYS_ON,
)
with frame:
with ui.VStack(style=get_style(), spacing=5):
for i in range(4):
with ui.HStack():
ui.Label("Arm {}".format(i + 1), width=LABEL_WIDTH, tooltip="Force in Newtons")
# ui.Spacer(height=0, width=10)
style["secondary_color"] = self.colors[i]
self.sliders.append(ui.FloatDrag(min=0.0, max=15.0, step=0.001, style=style))
self.sliders[-1].enabled = False
ui.Spacer(width=20)
asyncio.ensure_future(self.create_scenario())
self._window.visible = True
def on_shutdown(self):
self.on_closed()
remove_menu_items(self._menu_items, "Isaac Examples")
def on_closed(self):
if self._window:
self.sub = None
self._timeline = None
self._stage_event_subscription = None
self._window = None
def _on_update(self, dt):
if self._timeline.is_playing() and self.sliders:
for i in range(4):
reading = self._cs.get_sensor_reading(self.leg_paths[i] + "/sensor")
if reading.is_valid:
self.sliders[i].model.set_value(
float(reading.value) * self.meters_per_unit
) # readings are in kg⋅m⋅s−2, converting to Newtons
else:
self.sliders[i].model.set_value(0)
# contacts_raw = self._cs.get_body_contact_raw_data(self.leg_paths[0])
# if len(contacts_raw):
# c = contacts_raw[0]
# # print(c)
async def create_scenario(self):
self._assets_root_path = get_assets_root_path()
if self._assets_root_path is None:
carb.log_error("Could not find Isaac Sim assets folder")
return
# Add Contact Sensor
await omni.usd.get_context().open_stage_async(self._assets_root_path + "/Isaac/Robots/Simple/ant.usd")
await omni.kit.app.get_app().next_update_async()
self.meters_per_unit = UsdGeom.GetStageMetersPerUnit(omni.usd.get_context().get_stage())
self.sensor_offsets = [Gf.Vec3d(40, 0, 0), Gf.Vec3d(40, 0, 0), Gf.Vec3d(40, 0, 0), Gf.Vec3d(40, 0, 0)]
self.color = [(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1), (1, 1, 0, 1)]
self.sensorGeoms = []
for i in range(4):
result, sensor = omni.kit.commands.execute(
"IsaacSensorCreateContactSensor",
path="/sensor",
parent=self.leg_paths[i],
min_threshold=0,
max_threshold=10000000,
color=self.color[i],
radius=0.12,
sensor_period=-1,
translation=self.sensor_offsets[i],
visualize=True,
)
self._events = omni.usd.get_context().get_stage_event_stream()
self._stage_event_subscription = self._events.create_subscription_to_pop(
self._on_stage_event, name="Contact Sensor Sample stage Watch"
)
| 7,649 |
Python
| 43.219653 | 155 | 0.569225 |
cKohl10/TactileSim/exts/contact_ext_test/Contact_Extension_Test_python/ui_builder backup.py
|
# This software contains source code provided by NVIDIA Corporation.
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import numpy as np
import omni.timeline
import omni.ui as ui
import omni.kit.commands
import time
import os
import sys
import carb
from omni.isaac.core.articulations import Articulation
from omni.isaac.core.objects.cuboid import FixedCuboid
from omni.isaac.core.prims import XFormPrim
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.prims import is_prim_path_valid, get_all_matching_child_prims, delete_prim, get_prim_children
from omni.isaac.core.utils.stage import add_reference_to_stage, create_new_stage, get_current_stage
from omni.isaac.core.world import World
from omni.isaac.ui.element_wrappers import CollapsableFrame, StateButton, Button, TextBlock, StringField, DropDown
from omni.isaac.ui.element_wrappers.core_connectors import LoadButton, ResetButton
from omni.isaac.ui.ui_utils import get_style, LABEL_WIDTH
from omni.usd import StageEventType
from pxr import Sdf, UsdLux, Gf
from omni.isaac.sensor import _sensor
from omni.isaac.proximity_sensor import Sensor, register_sensor, clear_sensors
from .scenario import ExampleScenario
from pxr import UsdPhysics
class UIBuilder:
def __init__(self, window):
# Window to hold the UI elements
self.window = window
# Frames are sub-windows that can contain multiple UI elements
self.frames = []
# UI elements created using a UIElementWrapper instance
self.wrapped_ui_elements = []
# Get access to the timeline to control stop/pause/play programmatically
self._timeline = omni.timeline.get_timeline_interface()
self.parent_paths = []
self.sensors = {}
# Contact Parameters
self.meters_per_unit = 1.00
version = sys.version
executable = sys.executable
print(f"Python version: {version}")
print(f"Python executable location: {executable}")
# Data structure to store sensor information
class Sensor:
def __init__(self, name, position, radius, parent_path):
self.name = name
self.position = position
self.radius = radius
self.parent_path = parent_path
self.path = parent_path + "/tact_sensor_" + name
###################################################################################
# The Functions Below Are Called Automatically By extension.py
###################################################################################
def on_menu_callback(self):
"""Callback for when the UI is opened from the toolbar.
This is called directly after build_ui().
"""
pass
def on_timeline_event(self, event):
"""Callback for Timeline events (Play, Pause, Stop)
Args:
event (omni.timeline.TimelineEventType): Event Type
"""
if event.type == int(omni.timeline.TimelineEventType.STOP):
# When the user hits the stop button through the UI, they will inevitably discover edge cases where things break
# For complete robustness, the user should resolve those edge cases here
# In general, for extensions based off this template, there is no value to having the user click the play/stop
# button instead of using the Load/Reset/Run buttons provided.
#self._scenario_state_btn.reset()
#self._scenario_state_btn.enabled = False
pass
def on_physics_step(self, step: float):
"""Callback for Physics Step.
Physics steps only occur when the timeline is playing
Args:
step (float): Size of physics step
"""
self.contact_sensor_update(step)
def on_stage_event(self, event):
"""Callback for Stage Events
Args:
event (omni.usd.StageEventType): Event Type
"""
if event.type == int(StageEventType.OPENED):
# If the user opens a new stage, the extension should completely reset
self._reset_extension()
def cleanup(self):
"""
Called when the stage is closed or the extension is hot reloaded.
Perform any necessary cleanup such as removing active callback functions
Buttons imported from omni.isaac.ui.element_wrappers implement a cleanup function that should be called
"""
for ui_elem in self.wrapped_ui_elements:
ui_elem.cleanup()
################################# Individual Frames ##################################################
def create_status_report_frame(self):
self._status_report_frame = CollapsableFrame("Status Report", collapsed=False)
with self._status_report_frame:
with ui.VStack(style=get_style(), spacing=5, height=0):
self._status_report_field = TextBlock(
"Last UI Event",
num_lines=3,
tooltip="Prints the latest change to this UI",
include_copy_button=True,
)
def update_sensor_readings_frame(self):
# Color and style for the UI elements
self.sliders = []
self.colors = [0xFFBBBBFF, 0xFFBBFFBB, 0xBBFFBBBB, 0xBBBBFFFF]
style = {"background_color": 0xFF888888, "color": 0xFF333333, "secondary_color": self.colors[0]}
#message = "There are " + str(len(self.sensors)) + " sensors\n"
with self.sensor_readings_frame:
# Vertical stack to hold the sensor readings in the frame
with ui.VStack(style=get_style(), spacing=5, height=0):
for s in self.sensors.values():
#message += "Creating reading bar for sensor " + s.name + "...\n"
with ui.HStack():
ui.Label(s.name, width=LABEL_WIDTH, tooltip="Force in Newtons")
# ui.Spacer(height=0, width=10)
style["secondary_color"] = self.colors[0]
self.sliders.append(ui.FloatDrag(min=0.0, max=15.0, step=0.001, style=style))
self.sliders[-1].enabled = False
ui.Spacer(width=20)
#self._status_report_field.set_text(message)
def create_sensor_readings_frame(self):
self.sensor_readings_frame = CollapsableFrame("Sensor Readings", collapsed=False)
def create_import_sensors_frame(self):
buttons_frame = CollapsableFrame("Import Sensors", collapsed=False)
with buttons_frame:
with ui.VStack(style=get_style(), spacing=5, height=0):
string_field = StringField(
"Import CSV File",
default_value="TactileSim/sensor_configs",
tooltip="Path to sensor positioning file",
read_only=False,
multiline_okay=False,
on_value_changed_fn=self._on_string_field_value_changed_fn,
use_folder_picker=True,
#item_filter_fn=is_usd_or_python_path,
)
self.wrapped_ui_elements.append(string_field)
dropdown = DropDown(
"Config Options",
tooltip=" Select an option from the DropDown",
populate_fn=self.dropdown_populate_fn,
on_selection_fn=self._on_dropdown_item_selection,
)
self.wrapped_ui_elements.append(dropdown)
dropdown.repopulate() # This does not happen automatically, and it triggers the on_selection_fn
button = Button(
"Refresh Sensor Positions",
"Update",
tooltip="Reread the data from the specified file path to update sensors",
on_click_fn=self.import_sensors_fn,
)
self.wrapped_ui_elements.append(button)
self._status_report_field = TextBlock(
"Import Status",
num_lines=10,
tooltip="Outputs the status of the import process",
include_copy_button=True,
)
def build_ui(self):
"""
Build a custom UI tool to run your extension.
This function will be called any time the UI window is closed and reopened.
"""
self._cs = _sensor.acquire_contact_sensor_interface()
self.create_import_sensors_frame()
self.create_sensor_readings_frame()
#self.create_status_report_frame()
############################## Import Frame Functions ########################################
def dropdown_populate_fn(self):
"""
Function that populates the dropdown with options
Returns all the files in the directory specified by the string field
"""
options = []
# Get the path from the string field
path = self.wrapped_ui_elements[0].get_value()
# Get all the files in the directory
try:
options = os.listdir(path)
# Add an empty string to the beginning of the list
options.insert(0, "")
# Add a 'Go Back' option at the end of the list
options.append("Go Back")
except:
options = []
return options
def import_sensors_fn(self):
"""
Function that executes when the user clicks the 'Refresh Sensors' button
"""
# Remove all sensors already on the robot
message = "Removing existing sensors...\n"
self._status_report_field.set_text(message)
#self.countdown(3, "Remove Sensors")
self.remove_sensors("tactile_sensors")
message += "Sensors successfully removed\n\n"
self._status_report_field.set_text(message)
#Change the text of the status report field to show the import status
path = self.config_path
message += "Importing sensor data from '" + path + "'...\n"
self._status_report_field.set_text(message)
#Import the sensor data from the CSV file
try:
names, positions, radii, parent_paths, data = self.import_csv(path)
self.parent_paths = parent_paths
self.remove_sensors("tactile_sensors") # Second call to ensure all sensors are removed after parent paths are updated
message += "File opened successfully\n"
# Output the data to the status report field
# message += "\n\nSensor Data:\n"
# for i in range(len(names)):
# message += str(data[i]) + "\n"
except:
message += "Invalid file path or file format!"
message += "\nPlease make sure the file has at least 2 sensors and is formatted correctly.\n"
self._status_report_field.set_text(message)
return
self._status_report_field.set_text(message)
# Determine the number of sensors and their positions
num_sensors = len(data)
self.sensors = {}
sensor_count = 0 # Keep track of the number of sensors created successfully
for i in range(num_sensors):
# Create a contact sensor at the specified position
# message += "\nCreating sensor " + str(i) + " at position " + str(positions[i]) + "...\n"
# self._status_report_field.set_text(message)
# Check if the parent path is valid
if not is_prim_path_valid(parent_paths[i]):
message += "Could not find parent path: " + parent_paths[i] + "\n"
self._status_report_field.set_text(message)
continue
# Get the parent prim
parent_prim = get_current_stage().GetPrimAtPath(parent_paths[i])
# Check if the appled link has a rigidbody component
# if not parent_prim.HasAPI(UsdPhysics.RigidBodyAPI):
# message += "Parent path does not have a rigidbody component: " + parent_paths[i] + "\n"
# self._status_report_field.set_text(message)
# continue
# Create the sensor
self.create_contact_sensor(parent_paths[i], positions[i], radii[i], names[i])
sensor_count = sensor_count + 1
message += "\nSuccessfully created " + str(sensor_count) + " sensors\n"
self._status_report_field.set_text(message)
# Populate the sensor readings frame with the new sensors
#self.update_sensor_readings_frame()
# This function breaks down the CSV file into its components. Make sure the CSV file is formatted correctly
#
# The CSV file should be formatted as follows:
# - The first row should contain the names of the sensors
# - The second row should contain the x, y, and z positions of the sensors
# - The third row should contain the radii of the sensors
# - The fourth row should contain the parent paths of the sensors
#
def import_csv(self, path):
"""
Function that imports data from a CSV file
Args:
path (str): The path to the CSV file
"""
try:
data = np.genfromtxt(path, delimiter=',', skip_header=1, dtype=str)
# Save the first column as a list of names, the 2-4th columns as a list of positions, and the 5th column as a list of parent paths
names = data[:, 0]
# Convert the positions to a list of Gf.Vec3d objects
positions = []
for i in range(len(data)):
positions.append(Gf.Vec3d(float(data[i, 1]), float(data[i, 2]), float(data[i, 3])))
radii = []
for i in range(len(data)):
radii.append(float(data[i, 4]))
# Save the parent paths as a list of strings
parent_paths = []
for i in range(len(data)):
parent_paths.append(data[i, 5])
return names, positions, radii, parent_paths, data
except:
return None
def create_contact_sensor(self, parent_path, position, radius, name):
result, sensor = omni.kit.commands.execute(
"IsaacSensorCreateContactSensor",
path="/tact_sensor_" + name,
parent=parent_path,
min_threshold=0,
max_threshold=1000000,
color=(1, 0, 0, 1),
radius=radius,
sensor_period=1,
translation=position,
visualize=True,
)
# Add the sensor to the list of sensors
self.sensors[name] = self.Sensor(name, position, radius, parent_path)
def remove_sensors(self, sensor_label):
"""
Function that removes all sensors from the robot
"""
if len(self.parent_paths) == 0:
return
for parent_path in self.parent_paths:
# Find all prims under the parent path that contain "tact_sensor" in their name
try:
parent_prim = get_current_stage().GetPrimAtPath(parent_path)
prims = get_prim_children(parent_prim)
except:
self._status_report_field.set_text("Unexpected path!\n")
return
#self._status_report_field.set_text("Found " + str(len(prims)) + " sensors to remove\n")
# Remove all prims found
for prim in prims:
if sensor_label in prim.GetName():
omni.kit.commands.execute('DeletePrims', paths=[parent_path + "/" + prim.GetName()])
def _on_string_field_value_changed_fn(self, value):
"""
Function that executes when the user changes the value of the string field
Sets the value of the string field to what the user entered
"""
self.wrapped_ui_elements[0].set_value(value)
# Update the dropdown with the new path
self.wrapped_ui_elements[1].repopulate()
def _on_dropdown_item_selection(self, item):
"""
Function that executes when the user selects an item from the dropdown
Sets the value of the dropdown to the item the user selected
"""
# Go back if the user selects the empty string
if item == "Go Back":
# Get the path from the string field minus the last folder
path = self.wrapped_ui_elements[0].get_value()
parts = path.split("/")
path = "/".join(parts[:-1])
self.wrapped_ui_elements[0].set_value(path)
self.wrapped_ui_elements[1].repopulate()
return
if item == "":
return
self.config_path = self.wrapped_ui_elements[0].get_value() + "/" + item
if self.config_path[-4:] != ".csv":
# If the user selects a file that is not a CSV file, and it is a folder, update the string field with the new path
self.wrapped_ui_elements[0].set_value(self.config_path)
self.wrapped_ui_elements[1].repopulate()
pass
######################################################################################
# Contact updates
######################################################################################
# This function updates the sensor readings in the UI at every physics step
def contact_sensor_update(self, dt):
#self._status_report_field.set_text("Updating sensor readings...\n")
if len(self.sliders) > 0:
slider_num = 0
for s in self.sensors.values():
reading = self._cs.get_sensor_reading(s.path)
if reading.is_valid:
self.sliders[slider_num].model.set_value(
float(reading.value) * self.meters_per_unit
) # readings are in kg⋅m⋅s−2, converting to Newtons
else:
self.sliders[slider_num].model.set_value(0)
slider_num += 1
# contacts_raw = self._cs.get_body_contact_raw_data(self.leg_paths[0])
# if len(contacts_raw):
# c = contacts_raw[0]
# # print(c)
######################################################################################
# Functions Below This Point Support The Provided Example And Can Be Deleted/Replaced
######################################################################################
def countdown(self, seconds, name=""):
for i in range(seconds, 0, -1):
#message += str(i) + "...\n"
# self._status_report_field.set_text(message)
print(name + " Countdown: " + str(i))
time.sleep(1)
print("\n")
return
# def _on_init(self):
# self._articulation = None
# self._cuboid = None
# self._scenario = ExampleScenario()
# def _add_light_to_stage(self):
# """
# A new stage does not have a light by default. This function creates a spherical light
# """
# sphereLight = UsdLux.SphereLight.Define(get_current_stage(), Sdf.Path("/World/SphereLight"))
# sphereLight.CreateRadiusAttr(2)
# sphereLight.CreateIntensityAttr(100000)
# XFormPrim(str(sphereLight.GetPath())).set_world_pose([6.5, 0, 12])
# def _setup_scene(self):
# """
# This function is attached to the Load Button as the setup_scene_fn callback.
# On pressing the Load Button, a new instance of World() is created and then this function is called.
# The user should now load their assets onto the stage and add them to the World Scene.
# In this example, a new stage is loaded explicitly, and all assets are reloaded.
# If the user is relying on hot-reloading and does not want to reload assets every time,
# they may perform a check here to see if their desired assets are already on the stage,
# and avoid loading anything if they are. In this case, the user would still need to add
# their assets to the World (which has low overhead). See commented code section in this function.
# """
# # Load the UR10e
# robot_prim_path = "/ur10e"
# path_to_robot_usd = get_assets_root_path() + "/Isaac/Robots/UniversalRobots/ur10e/ur10e.usd"
# # Do not reload assets when hot reloading. This should only be done while extension is under development.
# # if not is_prim_path_valid(robot_prim_path):
# # create_new_stage()
# # add_reference_to_stage(path_to_robot_usd, robot_prim_path)
# # else:
# # print("Robot already on Stage")
# create_new_stage()
# self._add_light_to_stage()
# add_reference_to_stage(path_to_robot_usd, robot_prim_path)
# # Create a cuboid
# self._cuboid = FixedCuboid(
# "/Scenario/cuboid", position=np.array([0.3, 0.3, 0.5]), size=0.05, color=np.array([255, 0, 0])
# )
# self._articulation = Articulation(robot_prim_path)
# # Add user-loaded objects to the World
# world = World.instance()
# world.scene.add(self._articulation)
# world.scene.add(self._cuboid)
# def _setup_scenario(self):
# """
# This function is attached to the Load Button as the setup_post_load_fn callback.
# The user may assume that their assets have been loaded by their setup_scene_fn callback, that
# their objects are properly initialized, and that the timeline is paused on timestep 0.
# In this example, a scenario is initialized which will move each robot joint one at a time in a loop while moving the
# provided prim in a circle around the robot.
# """
# self._reset_scenario()
# # UI management
# self._scenario_state_btn.reset()
# self._scenario_state_btn.enabled = True
# self._reset_btn.enabled = True
# def _reset_scenario(self):
# self._scenario.teardown_scenario()
# self._scenario.setup_scenario(self._articulation, self._cuboid)
# def _on_post_reset_btn(self):
# """
# This function is attached to the Reset Button as the post_reset_fn callback.
# The user may assume that their objects are properly initialized, and that the timeline is paused on timestep 0.
# They may also assume that objects that were added to the World.Scene have been moved to their default positions.
# I.e. the cube prim will move back to the position it was in when it was created in self._setup_scene().
# """
# self._reset_scenario()
# # UI management
# self._scenario_state_btn.reset()
# self._scenario_state_btn.enabled = True
# def _update_scenario(self, step: float):
# """This function is attached to the Run Scenario StateButton.
# This function was passed in as the physics_callback_fn argument.
# This means that when the a_text "RUN" is pressed, a subscription is made to call this function on every physics step.
# When the b_text "STOP" is pressed, the physics callback is removed.
# Args:
# step (float): The dt of the current physics step
# """
# self._scenario.update_scenario(step)
# def _on_run_scenario_a_text(self):
# """
# This function is attached to the Run Scenario StateButton.
# This function was passed in as the on_a_click_fn argument.
# It is called when the StateButton is clicked while saying a_text "RUN".
# This function simply plays the timeline, which means that physics steps will start happening. After the world is loaded or reset,
# the timeline is paused, which means that no physics steps will occur until the user makes it play either programmatically or
# through the left-hand UI toolbar.
# """
# self._timeline.play()
# def _on_run_scenario_b_text(self):
# """
# This function is attached to the Run Scenario StateButton.
# This function was passed in as the on_b_click_fn argument.
# It is called when the StateButton is clicked while saying a_text "STOP"
# Pausing the timeline on b_text is not strictly necessary for this example to run.
# Clicking "STOP" will cancel the physics subscription that updates the scenario, which means that
# the robot will stop getting new commands and the cube will stop updating without needing to
# pause at all. The reason that the timeline is paused here is to prevent the robot being carried
# forward by momentum for a few frames after the physics subscription is canceled. Pausing here makes
# this example prettier, but if curious, the user should observe what happens when this line is removed.
# """
# self._timeline.pause()
def _reset_extension(self):
"""This is called when the user opens a new stage from self.on_stage_event().
All state should be reset.
"""
self._on_init()
self._reset_ui()
# def _reset_ui(self):
# self._scenario_state_btn.reset()
# self._scenario_state_btn.enabled = False
# self._reset_btn.enabled = False
| 25,818 |
Python
| 41.187908 | 142 | 0.589395 |
cKohl10/TactileSim/exts/contact_ext_test/Contact_Extension_Test_python/ui_builder.py
|
# This software contains source code provided by NVIDIA Corporation.
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from .AbstracSensorClass import AbstractSensorOperator
from .ContactSensorClass import ContactSensorOperator
import numpy as np
import omni.timeline
import omni.ui as ui
import omni.kit.commands
import time
import os
import sys
import carb
from omni.isaac.core.utils.prims import is_prim_path_valid, get_all_matching_child_prims, delete_prim, get_prim_children
from omni.isaac.core.utils.stage import add_reference_to_stage, create_new_stage, get_current_stage
from omni.isaac.core.world import World
from omni.isaac.ui.element_wrappers import CollapsableFrame, StateButton, Button, TextBlock, StringField, DropDown
from omni.isaac.ui.ui_utils import get_style, LABEL_WIDTH
from omni.usd import StageEventType
from pxr import Sdf, UsdLux, Gf
from omni.isaac.sensor import _sensor
#from omni.isaac.proximity_sensor import Sensor, register_sensor, clear_sensors
from .scenario import ExampleScenario
from pxr import UsdPhysics
class UIBuilder:
def __init__(self, window):
# Window to hold the UI elements
self.window = window
# Frames are sub-windows that can contain multiple UI elements
self.frames = []
# UI elements created using a UIElementWrapper instance
self.wrapped_ui_elements = []
# Get access to the timeline to control stop/pause/play programmatically
self._timeline = omni.timeline.get_timeline_interface()
# Create a list to hold all sensor operators
self._sensor_operators = []
############### Add Sensor Operators Here ################
self._sensor_operators.append(ContactSensorOperator()) # Add a contact sensor operator
#########################################################
# Debugging
# version = sys.version
# executable = sys.executable
# print(f"Python version: {version}")
# print(f"Python executable location: {executable}")
###################################################################################
# The Functions Below Are Called Automatically By extension.py
###################################################################################
def on_menu_callback(self):
"""Callback for when the UI is opened from the toolbar.
This is called directly after build_ui().
"""
pass
def on_timeline_event(self, event):
"""Callback for Timeline events (Play, Pause, Stop)
Args:
event (omni.timeline.TimelineEventType): Event Type
"""
if event.type == int(omni.timeline.TimelineEventType.STOP):
# When the user hits the stop button through the UI, they will inevitably discover edge cases where things break
# For complete robustness, the user should resolve those edge cases here
# In general, for extensions based off this template, there is no value to having the user click the play/stop
# button instead of using the Load/Reset/Run buttons provided.
#self._scenario_state_btn.reset()
#self._scenario_state_btn.enabled = False
pass
def on_physics_step(self, step: float):
"""Callback for Physics Step.
Physics steps only occur when the timeline is playing
Args:
step (float): Size of physics step
"""
# Update the sensor readings for all added sensors
for operator in self._sensor_operators:
operator.sensor_update(step)
def on_stage_event(self, event):
"""Callback for Stage Events
Args:
event (omni.usd.StageEventType): Event Type
"""
if event.type == int(StageEventType.OPENED):
# If the user opens a new stage, the extension should completely reset
self._reset_extension()
def cleanup(self):
"""
Called when the stage is closed or the extension is hot reloaded.
Perform any necessary cleanup such as removing active callback functions
Buttons imported from omni.isaac.ui.element_wrappers implement a cleanup function that should be called
"""
for ui_elem in self.wrapped_ui_elements:
ui_elem.cleanup()
################################# Individual Frames ##################################################
def create_status_report_frame(self):
self._status_report_frame = CollapsableFrame("Status Report", collapsed=False)
with self._status_report_frame:
with ui.VStack(style=get_style(), spacing=5, height=0):
self._status_report_field = TextBlock(
"Last UI Event",
num_lines=3,
tooltip="Prints the latest change to this UI",
include_copy_button=True,
)
#link the status report frame to the sensor operators to allow them to update the status report
for operator in self._sensor_operators:
operator._status_report_field = self._status_report_field
def create_import_sensors_frame(self):
buttons_frame = CollapsableFrame("Import Sensors", collapsed=False)
with buttons_frame:
with ui.VStack(style=get_style(), spacing=5, height=0):
string_field = StringField(
"Import CSV File",
default_value="TactileSim/sensor_configs",
tooltip="Path to sensor positioning file",
read_only=False,
multiline_okay=False,
on_value_changed_fn=self._on_string_field_value_changed_fn,
use_folder_picker=True,
#item_filter_fn=is_usd_or_python_path,
)
self.wrapped_ui_elements.append(string_field)
dropdown = DropDown(
"Config Options",
tooltip=" Select an option from the DropDown",
populate_fn=self.dropdown_populate_fn,
on_selection_fn=self._on_dropdown_item_selection,
)
self.wrapped_ui_elements.append(dropdown)
dropdown.repopulate() # This does not happen automatically, and it triggers the on_selection_fn
# Add a button to all supported sensor operators
for operator in self._sensor_operators:
button = Button(
"Refresh " + operator.sensor_description,
"Update",
tooltip="Reread the data from the specified file path to update sensors",
on_click_fn=operator.import_sensors_fn,
)
self.wrapped_ui_elements.append(button)
# Add a remove sensors button to all supported sensor operators
for operator in self._sensor_operators:
button = Button(
"Remove " + operator.sensor_description,
"Remove All",
tooltip="Remove all sensors " + operator.sensor_description + " from the robot",
on_click_fn=operator.remove_sensors_fn,
)
self.wrapped_ui_elements.append(button)
self._status_report_field = TextBlock(
"Import Status",
num_lines=10,
tooltip="Outputs the status of the import process",
include_copy_button=True,
)
# Add the status report field to the sensor operators
for operator in self._sensor_operators:
operator._status_report_field = self._status_report_field
def create_all_sensor_readings_frames(self):
# Create a sensor readings frame for each sensor operator
for operator in self._sensor_operators:
operator.create_sensor_readings_frame()
def build_ui(self):
"""
Build a custom UI tool to run your extension.
This function will be called any time the UI window is closed and reopened.
"""
self.create_import_sensors_frame()
self.create_all_sensor_readings_frames()
############################## Import Frame Functions ########################################
def dropdown_populate_fn(self):
"""
Function that populates the dropdown with options
Returns all the files in the directory specified by the string field
"""
options = []
# Get the path from the string field
path = self.wrapped_ui_elements[0].get_value()
# Get all the files in the directory
try:
options = os.listdir(path)
# Add an empty string to the beginning of the list
options.insert(0, "")
# Add a 'Go Back' option at the end of the list
options.append("Go Back")
except:
options = []
return options
def _on_string_field_value_changed_fn(self, value):
"""
Function that executes when the user changes the value of the string field
Sets the value of the string field to what the user entered
"""
self.wrapped_ui_elements[0].set_value(value)
# Update the dropdown with the new path
self.wrapped_ui_elements[1].repopulate()
def _on_dropdown_item_selection(self, item):
"""
Function that executes when the user selects an item from the dropdown
Sets the value of the dropdown to the item the user selected
"""
# Go back if the user selects the empty string
if item == "Go Back":
# Get the path from the string field minus the last folder
path = self.wrapped_ui_elements[0].get_value()
parts = path.split("/")
path = "/".join(parts[:-1])
self.wrapped_ui_elements[0].set_value(path)
self.wrapped_ui_elements[1].repopulate()
return
if item == "":
return
self.config_path = self.wrapped_ui_elements[0].get_value() + "/" + item
# Update the config path in the sensor operators
for operator in self._sensor_operators:
operator.config_path = self.config_path
if self.config_path[-4:] != ".csv":
# If the user selects a file that is not a CSV file, and it is a folder, update the string field with the new path
self.wrapped_ui_elements[0].set_value(self.config_path)
self.wrapped_ui_elements[1].repopulate()
pass
######################################################################################
# Functions Below This Point Support The Provided Example And Can Be Deleted/Replaced
######################################################################################
def countdown(self, seconds, name=""):
for i in range(seconds, 0, -1):
#message += str(i) + "...\n"
# self._status_report_field.set_text(message)
print(name + " Countdown: " + str(i))
time.sleep(1)
print("\n")
return
def _on_init(self):
# Frames are sub-windows that can contain multiple UI elements
self.frames = []
# UI elements created using a UIElementWrapper instance
self.wrapped_ui_elements = []
# Get access to the timeline to control stop/pause/play programmatically
self._timeline = omni.timeline.get_timeline_interface()
# Create a list to hold all sensor operators
self._sensor_operators = []
############### Add Sensor Operators Here ################
self._sensor_operators.append(ContactSensorOperator()) # Add a contact sensor operator
#########################################################
# Debugging
# version = sys.version
# executable = sys.executable
# print(f"Python version: {version}")
# print(f"Python executable location: {executable}")
# def _add_light_to_stage(self):
# """
# A new stage does not have a light by default. This function creates a spherical light
# """
# sphereLight = UsdLux.SphereLight.Define(get_current_stage(), Sdf.Path("/World/SphereLight"))
# sphereLight.CreateRadiusAttr(2)
# sphereLight.CreateIntensityAttr(100000)
# XFormPrim(str(sphereLight.GetPath())).set_world_pose([6.5, 0, 12])
# def _setup_scene(self):
# """
# This function is attached to the Load Button as the setup_scene_fn callback.
# On pressing the Load Button, a new instance of World() is created and then this function is called.
# The user should now load their assets onto the stage and add them to the World Scene.
# In this example, a new stage is loaded explicitly, and all assets are reloaded.
# If the user is relying on hot-reloading and does not want to reload assets every time,
# they may perform a check here to see if their desired assets are already on the stage,
# and avoid loading anything if they are. In this case, the user would still need to add
# their assets to the World (which has low overhead). See commented code section in this function.
# """
# # Load the UR10e
# robot_prim_path = "/ur10e"
# path_to_robot_usd = get_assets_root_path() + "/Isaac/Robots/UniversalRobots/ur10e/ur10e.usd"
# # Do not reload assets when hot reloading. This should only be done while extension is under development.
# # if not is_prim_path_valid(robot_prim_path):
# # create_new_stage()
# # add_reference_to_stage(path_to_robot_usd, robot_prim_path)
# # else:
# # print("Robot already on Stage")
# create_new_stage()
# self._add_light_to_stage()
# add_reference_to_stage(path_to_robot_usd, robot_prim_path)
# # Create a cuboid
# self._cuboid = FixedCuboid(
# "/Scenario/cuboid", position=np.array([0.3, 0.3, 0.5]), size=0.05, color=np.array([255, 0, 0])
# )
# self._articulation = Articulation(robot_prim_path)
# # Add user-loaded objects to the World
# world = World.instance()
# world.scene.add(self._articulation)
# world.scene.add(self._cuboid)
# def _setup_scenario(self):
# """
# This function is attached to the Load Button as the setup_post_load_fn callback.
# The user may assume that their assets have been loaded by their setup_scene_fn callback, that
# their objects are properly initialized, and that the timeline is paused on timestep 0.
# In this example, a scenario is initialized which will move each robot joint one at a time in a loop while moving the
# provided prim in a circle around the robot.
# """
# self._reset_scenario()
# # UI management
# self._scenario_state_btn.reset()
# self._scenario_state_btn.enabled = True
# self._reset_btn.enabled = True
# def _reset_scenario(self):
# self._scenario.teardown_scenario()
# self._scenario.setup_scenario(self._articulation, self._cuboid)
# def _on_post_reset_btn(self):
# """
# This function is attached to the Reset Button as the post_reset_fn callback.
# The user may assume that their objects are properly initialized, and that the timeline is paused on timestep 0.
# They may also assume that objects that were added to the World.Scene have been moved to their default positions.
# I.e. the cube prim will move back to the position it was in when it was created in self._setup_scene().
# """
# self._reset_scenario()
# # UI management
# self._scenario_state_btn.reset()
# self._scenario_state_btn.enabled = True
# def _update_scenario(self, step: float):
# """This function is attached to the Run Scenario StateButton.
# This function was passed in as the physics_callback_fn argument.
# This means that when the a_text "RUN" is pressed, a subscription is made to call this function on every physics step.
# When the b_text "STOP" is pressed, the physics callback is removed.
# Args:
# step (float): The dt of the current physics step
# """
# self._scenario.update_scenario(step)
# def _on_run_scenario_a_text(self):
# """
# This function is attached to the Run Scenario StateButton.
# This function was passed in as the on_a_click_fn argument.
# It is called when the StateButton is clicked while saying a_text "RUN".
# This function simply plays the timeline, which means that physics steps will start happening. After the world is loaded or reset,
# the timeline is paused, which means that no physics steps will occur until the user makes it play either programmatically or
# through the left-hand UI toolbar.
# """
# self._timeline.play()
# def _on_run_scenario_b_text(self):
# """
# This function is attached to the Run Scenario StateButton.
# This function was passed in as the on_b_click_fn argument.
# It is called when the StateButton is clicked while saying a_text "STOP"
# Pausing the timeline on b_text is not strictly necessary for this example to run.
# Clicking "STOP" will cancel the physics subscription that updates the scenario, which means that
# the robot will stop getting new commands and the cube will stop updating without needing to
# pause at all. The reason that the timeline is paused here is to prevent the robot being carried
# forward by momentum for a few frames after the physics subscription is canceled. Pausing here makes
# this example prettier, but if curious, the user should observe what happens when this line is removed.
# """
# self._timeline.pause()
def _reset_extension(self):
"""This is called when the user opens a new stage from self.on_stage_event().
All state should be reset.
"""
self._on_init()
self._reset_ui()
def _reset_ui(self):
"""This function is called by _reset_extension() to reset the UI to its initial state.
This function should not reset the state of the extension, only the UI.
"""
for frame in self.frames:
frame.delete()
self.frames = []
self.wrapped_ui_elements = []
self.build_ui()
| 19,266 |
Python
| 41.720621 | 140 | 0.598827 |
cKohl10/TactileSim/exts/contact_ext_test/docs/CHANGELOG.md
|
# Changelog
## [0.1.0] - 2024-05-17
### Added
- Initial version of Contact Extension Test Extension
| 103 |
Markdown
| 11.999999 | 53 | 0.679612 |
cKohl10/TactileSim/exts/Util_example/docs/CHANGELOG.md
|
# Changelog
## [0.1.0] - 2024-05-17
### Added
- Initial version of Example of utilities Extension
| 101 |
Markdown
| 11.749999 | 51 | 0.673267 |
cKohl10/TactileSim/blender_scripts/save_sensor_pos.py
|
# Save Sensor Position Script
# Author: Carson Kohlbrenner
# Date Created: 5/29/2024
# Last Modified: 5/29/2024
# Description: This exports all sensor locations in Blender into a CSV file that Isaac Sim can accept.
#
# Output CSV format:
# SensorNum, X, Y, Z, radius, parent_path
import bpy
import bmesh
# Get the active object
obj = bpy.context.active_object
# Ensure we are in the correct mode
bpy.ops.object.mode_set(mode='OBJECT')
# Get the geometry data
mesh = obj.data
# Create a BMesh to access vertex data
bm = bmesh.new()
bm.from_mesh(mesh)
# Get the custom attribute (assuming it is a point cloud)
positions = [v.co for v in bm.verts]
# Write positions to a file
output_file = "C:/path_to_your_file/instance_positions.txt"
with open(output_file, 'w') as f:
for pos in positions:
f.write(f"{pos.x}, {pos.y}, {pos.z}\n")
bm.free()
print(f"Instance positions written to {output_file}")
| 915 |
Python
| 22.487179 | 102 | 0.713661 |
cKohl10/TactileSim/blender_scripts/verts2sensors.py
|
import csv
import re
from pxr import Usd, UsdGeom
########################################################
# Extract vertices from a USD file and save to a CSV file
# All sensors positions are the vertices of the geometry in the USD file
########################################################
def remove_repeated_prims(path):
parts = path.split('/')
for i in range(len(parts) - 1, 0, -1):
if parts[i] == parts[i - 1]:
del parts[i]
return '/'.join(parts)
def extract_vertices(usd_file, csv_file):
# Open the USD file
stage = Usd.Stage.Open(usd_file)
# Open the CSV file for writing
with open(csv_file, 'w', newline='') as csvfile:
csvwriter = csv.writer(csvfile)
# Write the header row
csvwriter.writerow(['SensorNum', 'X', 'Y', 'Z', 'parent_path'])
vert_count = 1
# Iterate through all the prims in the stage
for prim in stage.Traverse():
# Check if the prim is a geometry (has points)
if prim.IsA(UsdGeom.PointBased):
geom = UsdGeom.PointBased(prim)
# Get the points (vertices) of the geometry
points = geom.GetPointsAttr().Get()
parent_path = prim.GetPath().pathString
# Omit 'Root' from the parent path
parent_path = parent_path.replace('/Root', '')
# Remove any triple digit numbers from the parent path
parent_path = re.sub(r'_\d{3,}', '', parent_path)
# Blender splits the vertices into seperate objects, so we need to remove the repeated prims
parent_path = remove_repeated_prims(parent_path)
# Write each point to the CSV
for point in points:
csvwriter.writerow([vert_count, point[0], point[1], point[2], 0.1, parent_path])
vert_count += 1
print(f'Vertices extracted from {usd_file} and saved to {csv_file}')
print(f'Vertex count: {vert_count - 1}')
# Example usage
usd_file = 'scenes/Ant Scene/robots/Ant_decimated.usd'
csv_file = 'sensor_configs/ant_vertices.csv'
extract_vertices(usd_file, csv_file)
| 2,233 |
Python
| 36.864406 | 108 | 0.552172 |
cKohl10/TactileSim/blender_scripts/sensor_bay_addon/README.md
|
Blender Tactile Sensor Addon Capabilities
1) Use weight painting to apply tactile sensors with configurable density.
2) Save the output as a CSV for reading into Isaac Sim
Importing the Addon:
Applying the Skin Geometry Node:
Saving your Configurations
| 267 |
Markdown
| 19.615383 | 78 | 0.782772 |
cKohl10/TactileSim/blender_scripts/sensor_bay_addon/sensor_bay_addon.py
|
bl_info = {
"name": "Tactile Sensor Bay",
"author": "Carson Kohlbrenner",
"version": (1, 0),
"blender": (2, 80, 0),
"location": "View3D > Add > Mesh > New Object",
"description": "Paint on tactile sensors over a surface and save them for Isaac Sim",
"warning": "",
"doc_url": "https://github.com/cKohl10/TactileSim",
"category": "",
}
import bpy
import bmesh
import csv
import os
import re
from bpy.utils import resource_path
from pathlib import Path
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty
from bpy.types import Operator
class SensorData:
def __init__(self, pos, radius, parent):
self.pos = pos
self.radius = radius
self.parent = parent
def __str__(self):
return f"Pos: {self.pos}, Radius: {self.radius}, Parent: {self.parent}"
def __repr__(self):
return str(self)
def check_children_for_sensors(obj, parent_path):
sensor_data = []
# Get the parent path from the root object
parent_path = parent_path + "/" + obj.name
is_sensor_attribtue_name = "is_sensor"
pos_attribute_name = "sensor_pos"
rad_attribute_name = "radii"
default_radius = False
# Loop through all of the children objects and search for GeometryNodes modifier
for child in obj.children:
pos_attribute_data = []
# Recursively check the children for sensors
sensor_data = check_children_for_sensors(child, sensor_data, parent_path)
# Loop through all of the children objects and search for GeometryNodes modifier
#print(f"\nChecking object {child.name} under {parent_path}...")
# Ensure the object has geometry nodes modifier
if child.modifiers.get('Skin') is None:
#print(f"{child.name} does not have a Skin modifier.")
continue
# Get the evaluated geometry
depsgraph = bpy.context.evaluated_depsgraph_get()
eval_obj = child.evaluated_get(depsgraph)
mesh = eval_obj.to_mesh()
# Check if the position data exists
if pos_attribute_name not in mesh.attributes:
#print(f"Attribute {attribute_name} not found in object {child.name}.")
# for other_name in mesh.attributes:
# print(f"Found attribute: {other_name}.")
continue
if is_sensor_attribtue_name not in mesh.attributes:
#print(f"Attribute {is_sensor_attribtue_name} not found in object {child.name}.")
continue
if rad_attribute_name not in mesh.attributes:
#Set a default radius value if the radii attribute is not found
print(f"Attribute {rad_attribute_name} not found in object {child.name}. Setting default radius of 0.1.")
default_radius = True
# Get the attribute data
pos_attribute_data = mesh.attributes[pos_attribute_name].data
# Get the radii attribute data
rad_attribute_data = []
if not default_radius:
rad_attribute_data = mesh.attributes[rad_attribute_name].data
is_sensor_data = mesh.attributes[is_sensor_attribtue_name].data
# Get path to object
parent_path = parent_path + "/" + child.name
# Remove any triple digit numbers from the parent path
parent_path = re.sub(r'\.\d{3,}', '', parent_path)
# Add the attribute data to the sensor data list
for i in range(len(pos_attribute_data)):
if is_sensor_data[i].value:
if default_radius:
sensor_data.append(SensorData(pos_attribute_data[i].vector, 0.1, parent_path))
else:
sensor_data.append(SensorData(pos_attribute_data[i].vector, rad_attribute_data[i].value, parent_path))
print(f"Found {len(pos_attribute_data)} sensor positions in object {child.name}.")
# Clean up
eval_obj.to_mesh_clear()
return sensor_data
def save_attribute_to_csv(context, file_path):
# Get the object
obj = context.object
# Expand the ~ symbol into the path of the home directory
#file_path = os.path.expanduser(file_path)
# Make an array of all sensor positions,radii, and parent paths
sensor_data = []
# Check the children for sensors
sensor_data = check_children_for_sensors(obj, "")
# Check if there are any sensor positions
if len(sensor_data) == 0:
print("No sensor positions found.")
return
# Save the attribute data to CSV
with open(file_path, 'w', newline='') as csvfile:
csv_writer = csv.writer(csvfile)
csv_writer.writerow(['Index', 'X', 'Y', 'Z', 'Radius', 'Parent'])
for i, element in enumerate(sensor_data):
pos = element.pos
csv_writer.writerow([i, pos.x, pos.y, pos.z, element.radius, element.parent])
# print(f"\nAttribute {attribute_name} saved to {file_path}")
print(f"Sensor count: {len(sensor_data)}")
class SensorSaveOperator(Operator, ExportHelper):
"""Saves the sensors in the scene"""
bl_idname = "object.save_sensors_operator"
bl_label = "Save Sensor Positions"
filename_ext = ".csv"
filter_glob: StringProperty(
default="*.csv",
options={'HIDDEN'},
maxlen=255, # Max internal buffer length, longer would be clamped.
)
def execute(self, context):
print("SensorSaveOperator.execute called\n")
if self.filepath: # Check if filepath has been set
save_attribute_to_csv(context, self.filepath)
else:
self.report({'WARNING'}, "No file selected") # Report a warning if no file was selected
return {'CANCELLED'}
return {'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self) # Open file explorer
return {'RUNNING_MODAL'}
class SensorPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Sensor Bay"
bl_idname = "OBJECT_PT_SENSOR_BAY"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row()
row.label(text="Save sensors as CSV", icon='FILE_TICK')
row = layout.row()
row.label(text="Selected root prim: " + obj.name)
row = layout.row()
row.prop(obj, "name")
row = layout.row()
row.operator("object.save_sensors_operator")
def register():
bpy.utils.register_class(SensorSaveOperator)
bpy.utils.register_class(SensorPanel)
def unregister():
bpy.utils.unregister_class(SensorSaveOperator)
bpy.utils.unregister_class(SensorPanel)
if __name__ == "__main__":
register()
| 6,835 |
Python
| 31.865384 | 122 | 0.625018 |
makolon/hsr_isaac_tamp/README.md
|
# TAMP-HSR
This repository implement PDDLStream for Toyota Human Support Robot (HSR) and offer parallel reinforcement learning environment on Isaac Sim.
## Getting Started
### Prerequisited
- NVIDIA Docker
- NVIDIA RTX GPU
- NVIDIA Driver 515.xx
https://github.com/makolon/hsr_isaac_tamp/assets/39409362/e7945ca0-e040-47cc-b73f-0cf99413d30d
https://github.com/makolon/hsr_isaac_tamp/assets/39409362/0322855f-2aa6-46a2-963e-28bc1f77577c
### Installation
1. Clone the repository
```
$ git clone --recursive git@github.com/makolon/tamp-hsr.git
```
2. Build docker image
```
$ cd tamp-hsr/docker/docker_hsr/
$ ./build.sh
```
3. Run docker container
```
$ cd tamp-hsr/docker/docker_hsr/
$ ./run.sh
```
4. Compile FastDownward
```
$ cd tamp-hsr/hsr_tamp/downward/
$ git submodule update --init --recursive
$ python3 build.py
$ cd ./builds/
$ ln -s release release32
```
## Usage
### Simulation
#### PDDLStream only for 2d environment
You can test PDDLStream on 2D pygame environment.
```
$ cd tamp-hsr/hsr_tamp/experiments/env_2d/
$ python3 tamp_planner.py
```
#### PDDLStream only for 3d environment
You can test PDDLStream on 3D pybullet environment including cooking, holding block task.
```
$ cd tamp-hsr/hsr_tamp/experiments/env_3d/
$ python3 tamp_planner.py --problem <problem_name>
```
### Real
#### Execute plan on 2D environment
1. Enter to hsrb_mode
```
$ hsrb_mode
```
2. Set up ROS configurations
```
$ cd tamp-hsr/hsr_ros/hsr_ws/
$ source devel/setup.bash
```
3. Execute ROS scripts
```
$ roslaunch env_2d exec_tamp.launch --mode <feedforward/feedback>
```
#### Execute plan on 3D environment
1. Enter to hsrb_mode
```
$ hsrb_mode
```
2. Set up ROS configurations
```
$ cd tamp-hsr/hsr_ros/hsr_ws/
$ source devel/setup.bash
```
3. Launch gearbox assembling scipts
```
$ roslaunch env_3d exec_tamp.launch --mode <feedforward/feedback>
````
## Setup IKfast
### Compile IKfast
Build & run docker for openrave that contain IKfast scripts.
```
$ cd tamp-hsr/docker/docker_openrave/
$ ./build.sh
$ ./run.sh
```
Then, execute ikfast scripts that can automatically create cpp IK solver and copy and plaste the appropriate scripts to <ik_solver>.cpp.
```
$ ./exec_openrave.sh
```
After that process, you can call IK solver in python script by executing the following commands.
```
$ cd tamp-hsr/hsr_tamp/experiments/env_3d/utils/pybullet_tools/ikfast/hsrb/
$ python3 setup.py
```
### Create HSR Collada Model
If you don't have hsr collada model, you have to run the following commands in docker_openrave container. \
Terminal 1.
```
$ cd /ikfast/
$ roscore
```
Terminal 2.
```
$ cd /ikfast
$ export MYROBOT_NAME='hsrb4s'
$ rosrun collada_urdf urdf_to_collada "$MYROBOT_NAME".urdf "$MYROBOT_NAME".dae
```
Then, you can see the generated HSR collada model using following commands.
```
$ openrave-robot.py "$MYROBOT_NAME".dae --info links
$ openrave "$MYROBOT_NAME".dae
```
For more informations, please refer to the [following document](http://docs.ros.org/en/kinetic/api/moveit_tutorials/html/doc/ikfast/ikfast_tutorial.html).
## Setup Motion Capture
### Prerequisited
- Windows11 PC
- Windows11 with ROS
- OptiTrack
### Usage
Check IP address of the HSR PC and own IP address.
```
ipconfig
```
Then, execute the following commands in the ROS executable terminal.
```
set ROS_HOSTNAME=<OWN IP ADDRESS>
set ROS_IP=<OWN IP ADDRESS>
set ROS_MASTER_URI=http://<HSR PC IP ADDRESS>:11311
C:\path\to\catkin_ws\devel\setup.bat
cd C:\path\to\catkin_ws\src\mocap_msg\src && python MocapRosPublisher.py
```
| 3,514 |
Markdown
| 22.433333 | 154 | 0.72453 |
makolon/hsr_isaac_tamp/hsr_ros/README.md
|
# HSR-ROS
| 10 |
Markdown
| 4.499998 | 9 | 0.6 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/test/script/analyze_trajectory.py
|
import glob
import argparse
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial.transform import Rotation as R
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.animation import FuncAnimation
class AnalyzeTrajectory(object):
def __init__(self, idx=0, mode='both', joint_index=None):
# Load ee trajectory
self.sim_ee_traj = np.load(f"log/simulation_ee_traj.npy", allow_pickle=True)
self.measured_ee_traj = np.load(f"log/measured_ee_traj_{idx}.npy", allow_pickle=True)
# Load joint trajectory
self.sim_joint_traj = np.load(f"log/simulation_joint_traj.npy", allow_pickle=True)
self.measured_joint_traj = np.load(f"log/measured_joint_traj_{idx}.npy", allow_pickle=True)
# Length of ee/joint trajectory
self.ee_traj_len = min(len(self.sim_ee_traj), len(self.measured_ee_traj))
self.jt_traj_len = min(len(self.sim_joint_traj), len(self.measured_joint_traj))
# Visualization settings
self.fps = 8
self.num_joints = 8
self.mode = mode
self.joint_index = joint_index
self.joint_name = {'2': 'BaseRotation', '3': 'ArmLift', '4': 'ArmFlex',
'5': 'ArmRoll', '6': 'WristFlex', '7': 'WristRoll'}
if self.joint_index is None:
self.vis_all = True
else:
self.vis_all = False
def visualize_ee_3d_traj(self):
# Visualize end effector trajectory
animation_duration = self.ee_traj_len
self.time_steps_ee_3d = np.linspace(0, animation_duration, animation_duration * self.fps)
fig = plt.figure()
self.ax_ee_3d = fig.add_subplot(111, projection='3d')
self.ax_ee_3d.view_init(elev=45, azim=75)
ani = FuncAnimation(fig, self.update_ee_3d_traj_animation, frames=animation_duration, interval=1000/self.fps)
# Save fig
ani.save(f"{self.mode}_end_effector_3d_trajectory.gif", writer='imagemagick', fps=10)
ani.save(f"{self.mode}_end_effector_3d_trajectory.mp4", writer='ffmpeg', fps=10)
def visualize_ee_2d_traj(self, dir='x'):
# Visualize end effector trajectory
animation_duration = self.ee_traj_len
self.time_steps_ee_2d = np.linspace(0, animation_duration, animation_duration * self.fps)
fig = plt.figure()
self.ax_ee_2d = fig.add_subplot(1, 1, 1)
ani = FuncAnimation(fig, self.update_ee_2d_traj_animation, frames=animation_duration, interval=1000/self.fps)
# Save fig
ani.save(f"{self.mode}_end_effector_2d_trajectory.gif", writer='imagemagick', fps=10)
ani.save(f"{self.mode}_end_effector_2d_trajectory.mp4", writer='ffmpeg', fps=10)
def visualize_joint_2d_traj(self):
# Visualize each joint trajectory
animation_duration = self.jt_traj_len
self.time_steps_jt_2d = np.linspace(0, animation_duration, animation_duration * self.fps)
if self.vis_all:
fig, self.ax_jt = plt.subplots(self.num_joints, 1, sharex=True)
ani = FuncAnimation(fig, self.update_all_joint_2d_traj_animation, frames=animation_duration, interval=1000/self.fps)
else:
fig = plt.figure()
self.ax_jt = fig.add_subplot(1, 1, 1)
ani = FuncAnimation(fig, self.update_joint_2d_traj_animation, frames=animation_duration, interval=1000/self.fps)
# Save fig
if self.vis_all:
ani.save(f"{self.mode}_all_joint_2d_trajectory.gif", writer='imagemagick', fps=10)
ani.save(f"{self.mode}_all_joint_2d_trajectory.mp4", writer='ffmpeg', fps=10)
else:
ani.save(f"{self.mode}_joint_{self.joint_index}_2d_trajectory.gif", writer='imagemagick', fps=10)
ani.save(f"{self.mode}_joint_{self.joint_index}_2d_trajectory.mp4", writer='ffmpeg', fps=10)
def update_ee_3d_traj_animation(self, i):
self.ax_ee_3d.cla()
self.ax_ee_3d.set_xlim(0.5, 1.5)
self.ax_ee_3d.set_ylim(-1.0, 1.0)
self.ax_ee_3d.set_zlim(0.0, 1.0)
self.ax_ee_3d.set_xticks([0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5])
self.ax_ee_3d.set_yticks([-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0])
self.ax_ee_3d.set_xlabel("X")
self.ax_ee_3d.set_ylabel("Y")
self.ax_ee_3d.set_zlabel("Z")
self.ax_ee_3d.set_title(f"Time: {self.time_steps_ee_3d[i]:.2f}s")
if self.mode == 'simulation':
### Simulation
position = self.sim_ee_traj[i][0]
orientation = self.sim_ee_traj[i][1]
rotation_matrix = R.from_quat(orientation).as_matrix()
self.ax_ee_3d.scatter(*position, color='b', marker='*', s=3)
axis_x_length, axis_y_length, axis_z_length = 0.075, 0.1, 0.05
x_axis = position + axis_x_length * rotation_matrix[:, 0]
y_axis = position + axis_y_length * rotation_matrix[:, 1]
z_axis = position + axis_z_length * rotation_matrix[:, 2]
self.ax_ee_3d.plot([position[0], x_axis[0]], [position[1], x_axis[1]], [position[2], x_axis[2]], color='r', linewidth='3')
self.ax_ee_3d.plot([position[0], y_axis[0]], [position[1], y_axis[1]], [position[2], y_axis[2]], color='g', linewidth='3')
self.ax_ee_3d.plot([position[0], z_axis[0]], [position[1], z_axis[1]], [position[2], z_axis[2]], color='b', linewidth='3')
traj = self.sim_ee_traj[:i+1, 0]
x = [point[0] for point in traj]
y = [point[1] for point in traj]
z = [point[2] for point in traj]
self.ax_ee_3d.plot(x, y, z, color='deepskyblue', linewidth=1, marker='*', markersize=2)
elif self.mode == 'measured':
### Measured
position = self.measured_ee_traj[i][0]
orientation = self.measured_ee_traj[i][1]
rotation_matrix = R.from_quat(orientation).as_matrix()
self.ax_ee_3d.scatter(*position, color='g', marker='^', s=3)
axis_x_length, axis_y_length, axis_z_length = 0.075, 0.1, 0.05
x_axis = position + axis_x_length * rotation_matrix[:, 0]
y_axis = position + axis_y_length * rotation_matrix[:, 1]
z_axis = position + axis_z_length * rotation_matrix[:, 2]
self.ax_ee_3d.plot([position[0], x_axis[0]], [position[1], x_axis[1]], [position[2], x_axis[2]], color='r', linewidth='3')
self.ax_ee_3d.plot([position[0], y_axis[0]], [position[1], y_axis[1]], [position[2], y_axis[2]], color='g', linewidth='3')
self.ax_ee_3d.plot([position[0], z_axis[0]], [position[1], z_axis[1]], [position[2], z_axis[2]], color='b', linewidth='3')
traj = self.measured_ee_traj[:i+1, 0]
x = [point[0] for point in traj]
y = [point[1] for point in traj]
z = [point[2] for point in traj]
self.ax_ee_3d.plot(x, y, z, color='limegreen', linewidth=1, marker='^', markersize=2)
elif self.mode == 'both':
### Simulation
position = self.sim_ee_traj[i][0]
orientation = self.sim_ee_traj[i][1]
rotation_matrix = R.from_quat(orientation).as_matrix()
self.ax_ee_3d.scatter(*position, color='b', marker='*', s=3)
axis_x_length, axis_y_length, axis_z_length = 0.075, 0.1, 0.05
x_axis = position + axis_x_length * rotation_matrix[:, 0]
y_axis = position + axis_y_length * rotation_matrix[:, 1]
z_axis = position + axis_z_length * rotation_matrix[:, 2]
self.ax_ee_3d.plot([position[0], x_axis[0]], [position[1], x_axis[1]], [position[2], x_axis[2]], color='r', linewidth='3')
self.ax_ee_3d.plot([position[0], y_axis[0]], [position[1], y_axis[1]], [position[2], y_axis[2]], color='g', linewidth='3')
self.ax_ee_3d.plot([position[0], z_axis[0]], [position[1], z_axis[1]], [position[2], z_axis[2]], color='b', linewidth='3')
traj = self.sim_ee_traj[:i+1, 0]
x = [point[0] for point in traj]
y = [point[1] for point in traj]
z = [point[2] for point in traj]
self.ax_ee_3d.plot(x, y, z, color='deepskyblue', linewidth=1, marker='*', markersize=2)
### Measured
position = self.measured_ee_traj[i][0]
orientation = self.measured_ee_traj[i][1]
rotation_matrix = R.from_quat(orientation).as_matrix()
self.ax_ee_3d.scatter(*position, color='g', marker='^', s=3)
axis_x_length, axis_y_length, axis_z_length = 0.075, 0.1, 0.05
x_axis = position + axis_x_length * rotation_matrix[:, 0]
y_axis = position + axis_y_length * rotation_matrix[:, 1]
z_axis = position + axis_z_length * rotation_matrix[:, 2]
self.ax_ee_3d.plot([position[0], x_axis[0]], [position[1], x_axis[1]], [position[2], x_axis[2]], color='r', linewidth='3')
self.ax_ee_3d.plot([position[0], y_axis[0]], [position[1], y_axis[1]], [position[2], y_axis[2]], color='g', linewidth='3')
self.ax_ee_3d.plot([position[0], z_axis[0]], [position[1], z_axis[1]], [position[2], z_axis[2]], color='b', linewidth='3')
traj = self.measured_ee_traj[:i+1, 0]
x = [point[0] for point in traj]
y = [point[1] for point in traj]
z = [point[2] for point in traj]
self.ax_ee_3d.plot(x, y, z, color='limegreen', linewidth=1, marker='^', markersize=2)
def update_ee_2d_traj_animation(self, i):
self.ax_ee_2d.cla()
self.ax_ee_2d.set_xlim(0, self.ee_traj_len)
self.ax_ee_2d.set_ylim(0.0, 1.5)
self.ax_ee_2d.set_xlabel("Time (s)")
self.ax_ee_2d.set_ylabel("End Effector Value (rad)")
self.ax_ee_2d.set_title(f"Joint Values over Time")
self.sim_ee_traj.T
self.measured_ee_traj.T
### Simulation / Measured
for idx in self.joint_idxs:
for joint_values in self.sim_ee_traj[idx*len(self.joint_idxs)]:
self.ax_ee_2d.plot(self.time_steps_jt_2d[:i+1], joint_values[:i+1])
for joint_values in self.measured_joint_traj[idx*len(self.joint_idxs)]:
self.ax_ee_2d.plot(self.time_steps_jt_2d[:i+1], joint_values[:i+1])
self.ax_ee_2d.legend(loc="upper left")
def update_all_joint_2d_traj_animation(self, i):
plot_length = self.jt_traj_len / self.fps
for joint_index in range(self.num_joints):
if joint_index == 0:
min_range, max_range = 0.0, 1.5
self.ax_jt[joint_index].cla()
self.ax_jt[joint_index].grid()
self.ax_jt[joint_index].set_xlim(0, plot_length)
self.ax_jt[joint_index].set_ylim(min_range, max_range)
self.ax_jt[joint_index].set_ylabel("X Position (m)", fontsize=8)
self.ax_jt[joint_index].set_title("Joint Values over Time", fontsize=14)
elif joint_index == 1:
min_range, max_range = -1.0, 1.0
self.ax_jt[joint_index].cla()
self.ax_jt[joint_index].grid()
self.ax_jt[joint_index].set_xlim(0, plot_length)
self.ax_jt[joint_index].set_ylabel("Y Position (m)", fontsize=8)
self.ax_jt[joint_index].set_ylim(min_range, max_range)
elif joint_index == 2:
min_range, max_range = -np.pi, np.pi
y_label = f"{self.joint_name[str(joint_index)]} Value(rad)"
self.ax_jt[joint_index].cla()
self.ax_jt[joint_index].grid()
self.ax_jt[joint_index].set_xlim(0, plot_length)
self.ax_jt[joint_index].set_ylim(min_range, max_range)
self.ax_jt[joint_index].set_ylabel(y_label, fontsize=8)
elif joint_index == 3:
min_range, max_range = -0.1, 0.5
y_label = f"{self.joint_name[str(joint_index)]} Value(m)"
self.ax_jt[joint_index].cla()
self.ax_jt[joint_index].grid()
self.ax_jt[joint_index].set_xlim(0, plot_length)
self.ax_jt[joint_index].set_ylim(min_range, max_range)
self.ax_jt[joint_index].set_ylabel(y_label, fontsize=8)
elif joint_index in (4, 5, 6):
min_range, max_range = -np.pi, np.pi
y_label = f"{self.joint_name[str(joint_index)]} Value(rad)"
self.ax_jt[joint_index].cla()
self.ax_jt[joint_index].grid()
self.ax_jt[joint_index].set_xlim(0, plot_length)
self.ax_jt[joint_index].set_ylim(min_range, max_range)
self.ax_jt[joint_index].set_ylabel(y_label, fontsize=8)
elif joint_index == 7:
min_range, max_range = -np.pi, np.pi
y_label = f"{self.joint_name[str(joint_index)]} Value(rad)"
self.ax_jt[joint_index].cla()
self.ax_jt[joint_index].grid()
self.ax_jt[joint_index].set_xlim(0, plot_length)
self.ax_jt[joint_index].set_ylim(min_range, max_range)
self.ax_jt[joint_index].set_ylabel(y_label, fontsize=8)
self.ax_jt[joint_index].set_xlabel("Time (s)", fontsize=12)
### Simulation
traj = self.sim_joint_traj[:i, joint_index]
self.ax_jt[joint_index].plot(self.time_steps_jt_2d[:i], traj, linestyle='dashed', label='simulation')
### Measured
traj = self.measured_joint_traj[:i, joint_index]
self.ax_jt[joint_index].plot(self.time_steps_jt_2d[:i], traj, linestyle='dashdot', label='measured')
self.ax_jt[joint_index].legend(loc="upper right", fontsize=12)
def update_joint_2d_traj_animation(self, i):
plot_length = self.jt_traj_len / self.fps
if self.joint_index == 0:
min_range, max_range = 0.0, 1.5
self.ax_jt.cla()
self.ax_jt.grid()
self.ax_jt.set_xlim(0, plot_length)
self.ax_jt.set_ylim(min_range, max_range)
self.ax_jt.set_xlabel("Time (s)", fontsize=12)
self.ax_jt.set_ylabel("X Position (m)", fontsize=12)
self.ax_jt.set_title("Joint Values over Time", fontsize=14)
elif self.joint_index == 1:
min_range, max_range = -1.0, 1.0
self.ax_jt.cla()
self.ax_jt.grid()
self.ax_jt.set_xlim(0, plot_length)
self.ax_jt.set_ylim(min_range, max_range)
self.ax_jt.set_xlabel("Time (s)", fontsize=12)
self.ax_jt.set_ylabel("Y Position Value (m)", fontsize=12)
self.ax_jt.set_title("Joint Values over Time", fontsize=14)
elif self.joint_index == 3:
min_range, max_range = -0.1, 0.5
self.ax_jt.cla()
self.ax_jt.grid()
self.ax_jt.set_xlim(0, plot_length)
self.ax_jt.set_ylim(min_range, max_range)
self.ax_jt.set_xlabel("Time (s)", fontsize=12)
self.ax_jt.set_ylabel("ArmLift Value (m)", fontsize=12)
self.ax_jt.set_title("Joint Values over Time", fontsize=14)
else:
min_range, max_range = -np.pi, np.pi
self.ax_jt.cla()
self.ax_jt.grid()
self.ax_jt.set_xlim(0, plot_length)
self.ax_jt.set_ylim(min_range, max_range)
self.ax_jt.set_xlabel("Time (s)", fontsize=12)
self.ax_jt.set_ylabel(f"{self.joint_name[str(self.joint_index)]} Value(rad)", fontsize=12)
self.ax_jt.set_title("Joint Values over Time", fontsize=14)
### Simulation
traj = self.sim_joint_traj[:i, self.joint_index]
self.ax_jt.plot(self.time_steps_jt_2d[:i], traj, linestyle='dashed', label='simulation')
### Measured
traj = self.measured_joint_traj[:i, self.joint_index]
self.ax_jt.plot(self.time_steps_jt_2d[:i], traj, linestyle='dashdot', label='measured')
self.ax_jt.legend(loc="upper right", fontsize=12)
class AnalyzeMultipleTrajectory(object):
def __init__(self):
self.file_names = glob.glob('log/*.npy', recursive=True)
self.num_files = 1 # int(len(self.file_names) / 4)
self.sim_ee_traj = []
self.measured_ee_traj = []
self.true_ee_traj = []
self.sim_joint_traj = []
self.measured_joint_traj = []
self.ee_traj_len = []
self.jt_traj_len = []
for idx in range(self.num_files):
# Load ee trajectory
self.sim_ee_traj.append(np.load(f"log/simulation_ee_traj.npy", allow_pickle=True))
self.measured_ee_traj.append(np.load(f"log/measured_ee_traj_{idx}.npy", allow_pickle=True))
self.true_ee_traj.append(np.load(f"log/true_ee_traj_{idx}.npy", allow_pickle=True))
# Load joint trajectory
self.sim_joint_traj.append(np.load(f"log/simulation_joint_traj.npy", allow_pickle=True))
self.measured_joint_traj.append(np.load(f"log/measured_joint_traj_{idx}.npy", allow_pickle=True))
# Length of ee/joint trajectory
self.ee_traj_len.append(min(len(self.sim_ee_traj[idx]), len(self.measured_ee_traj[idx])))
self.jt_traj_len.append(min(len(self.sim_joint_traj[idx]), len(self.measured_joint_traj[idx])))
# Visualization settings
self.num_joints = 8
self.joint_name = {'2': 'BaseRotation', '3': 'ArmLift', '4': 'ArmFlex',
'5': 'ArmRoll', '6': 'WristFlex', '7': 'WristRoll'}
def plot_ee_traj(self, axis='xy'):
all_in_one = False
if all_in_one:
if axis == 'xy':
fig_xy, ax_xy = plt.subplots()
ax_xy.set_xlim(0.5, 1.5)
ax_xy.set_ylim(-1.0, 1.0)
ax_xy.set_xlabel('X-axis Position (m)')
ax_xy.set_ylabel('Y-axis Position (m)')
elif axis == 'yz':
fig_yz, ax_yz = plt.subplots()
ax_yz.set_xlim(-1.0, 1.0)
ax_yz.set_ylim(0.0, 1.0)
ax_yz.set_xlabel('Y-axis Position (m)')
ax_yz.set_ylabel('Z-axis Position (m)')
elif axis == 'zx':
fig_zx, ax_zx = plt.subplots()
ax_zx.set_xlim(0.0, 1.0)
ax_zx.set_ylim(0.5, 1.5)
ax_zx.set_xlabel('Z-axis Position (m)')
ax_zx.set_ylabel('X-axis Position (m)')
for idx in range(self.num_files):
for i in range(self.ee_traj_len[idx]):
sim_traj = self.sim_ee_traj[idx][i]
sim_x = sim_traj[0][0]
sim_y = sim_traj[0][1]
sim_z = sim_traj[0][2]
measured_traj = self.measured_ee_traj[idx][i]
measured_x = measured_traj[0][0]
measured_y = measured_traj[0][1]
measured_z = measured_traj[0][2]
true_traj = self.true_ee_traj[idx][i]
true_x = true_traj[0][0]
true_y = true_traj[0][1]
true_z = true_traj[0][2]
if axis == 'xy':
ax_xy.plot(sim_x, sim_y, marker='*', markersize=3, color='tomato', label='Simulation Trajectory')
ax_xy.plot(measured_x, measured_y, marker='^', markersize=3, color='deepskyblue', label='Measured Trajectory')
elif axis == 'yz':
ax_yz.plot(sim_y, sim_z, marker='*', markersize=3, color='coral', label='Simulation Trajectory')
ax_yz.plot(measured_y, measured_z, marker='^', markersize=3, color='goldenrod', label='Measured Trajectory')
elif axis == 'zx':
ax_zx.plot(sim_z, sim_x, marker='*', markersize=3, color='springgreen', label='Simulation Trajectory')
ax_zx.plot(measured_z, measured_x, marker='^', markersize=3, color='lightseagreen', label='Measured Trajectory')
if axis == 'xy':
ax_xy.set_title('End Effector XY-axis Trajectory')
plt.savefig('XY_traj.png')
plt.close()
elif axis == 'yz':
ax_yz.set_title('End Effector YZ-axis Trajectory')
plt.savefig('YZ_traj.png')
plt.close()
elif axis == 'zx':
ax_zx.set_title('End Effector ZX-axis Trajectory')
plt.savefig('ZX_traj.png')
plt.close()
else:
for idx in range(self.num_files):
if axis == 'xy':
fig_xy, ax_xy = plt.subplots()
ax_xy.set_xlim(0.5, 1.5)
ax_xy.set_ylim(-1.0, 1.0)
ax_xy.set_xlabel('X-axis Position (m)')
ax_xy.set_ylabel('Y-axis Position (m)')
elif axis == 'yz':
fig_yz, ax_yz = plt.subplots()
ax_yz.set_xlim(-1.0, 1.0)
ax_yz.set_ylim(0.0, 1.0)
ax_yz.set_xlabel('Y-axis Position (m)')
ax_yz.set_ylabel('Z-axis Position (m)')
elif axis == 'zx':
fig_zx, ax_zx = plt.subplots()
ax_zx.set_xlim(0.0, 1.0)
ax_zx.set_ylim(0.5, 1.5)
ax_zx.set_xlabel('Z-axis Position (m)')
ax_zx.set_ylabel('X-axis Position (m)')
for i in range(self.ee_traj_len[idx]):
sim_traj = self.sim_ee_traj[idx][i]
sim_x = sim_traj[0][0]
sim_y = sim_traj[0][1]
sim_z = sim_traj[0][2]
measured_traj = self.measured_ee_traj[idx][i]
measured_x = measured_traj[0][0]
measured_y = measured_traj[0][1]
measured_z = measured_traj[0][2]
true_traj = self.true_ee_traj[idx][i]
true_x = true_traj[0][0]
true_y = true_traj[0][1]
true_z = true_traj[0][2]
if axis == 'xy':
ax_xy.plot(sim_x, sim_y, marker='*', markersize=3, color='tomato', label='Simulation Trajectory')
ax_xy.plot(measured_x, measured_y, marker='*', markersize=3, color='deepskyblue', label='Measured Trajectory')
ax_xy.plot(true_x, true_y, marker='*', markersize=3, color='green', label='True Trajectory')
elif axis == 'yz':
ax_yz.plot(sim_y, sim_z, marker='*', markersize=3, color='coral', label='Simulation Trajectory')
ax_yz.plot(measured_y, measured_z, marker='*', markersize=3, color='deepskyblue', label='Measured Trajectory')
ax_yz.plot(true_y, true_z, marker='*', markersize=3, color='green', label='True Trajectory')
elif axis == 'zx':
ax_zx.plot(sim_z, sim_x, marker='*', markersize=3, color='springgreen', label='Simulation Trajectory')
ax_zx.plot(measured_z, measured_x, marker='*', markersize=3, color='deepskyblue', label='Measured Trajectory')
ax_zx.plot(true_z, true_x, marker='*', markersize=3, color='green', label='True Trajectory')
if axis == 'xy':
ax_xy.set_title('End Effector XY-axis Trajectory')
plt.savefig('XY_traj.png')
plt.close()
elif axis == 'yz':
ax_yz.set_title('End Effector YZ-axis Trajectory')
plt.savefig('YZ_traj.png')
plt.close()
elif axis == 'zx':
ax_zx.set_title('End Effector ZX-axis Trajectory')
plt.savefig('ZX_traj.png')
plt.close()
def evaluate_ee_error_correlation(self, axis='yz'):
all_in_one = False
if all_in_one:
if axis == 'xy':
fig_xy, ax_xy = plt.subplots()
ax_xy.set_xlim(-0.5, 0.5)
ax_xy.set_ylim(-0.5, 0.5)
ax_xy.set_xlabel('X-axis Error (m)')
ax_xy.set_ylabel('Y-axis Error (m)')
x_range = np.arange(-0.5, 0.5, 0.01)
y_range = np.arange(-0.5, 0.5, 0.01)
ax_xy.plot(x_range, y_range, color='tan', linestyle="--")
elif axis == 'yz':
fig_yz, ax_yz = plt.subplots()
ax_yz.set_xlim(-0.5, 0.5)
ax_yz.set_ylim(-0.5, 0.5)
ax_yz.set_xlabel('Y-axis Error (m)')
ax_yz.set_ylabel('Z-axis Error (m)')
x_range = np.arange(-0.5, 0.5, 0.01)
y_range = np.arange(-0.5, 0.5, 0.01)
ax_yz.plot(x_range, y_range, color='tan', linestyle="--")
elif axis == 'zx':
fig_zx, ax_zx = plt.subplots()
ax_zx.set_xlim(-0.5, 0.5)
ax_zx.set_ylim(-0.5, 0.5)
ax_zx.set_xlabel('Z-axis Error (m)')
ax_zx.set_ylabel('X-axis Error (m)')
x_range = np.arange(-0.5, 0.5, 0.01)
y_range = np.arange(-0.5, 0.5, 0.01)
ax_zx.plot(x_range, y_range, color='tan', linestyle="--")
for idx in range(self.num_files):
diff_l1_all = []
diff_l1_x = []
diff_l1_y = []
diff_l1_z = []
for i in range(self.ee_traj_len[idx]):
sim_traj = self.sim_ee_traj[idx][i]
sim_x = sim_traj[0][0]
sim_y = sim_traj[0][1]
sim_z = sim_traj[0][2]
measured_traj = self.measured_ee_traj[idx][i]
measured_x = measured_traj[0][0]
measured_y = measured_traj[0][1]
measured_z = measured_traj[0][2]
l1_x = np.array([sim_x - measured_x])
l1_y = np.array([sim_y - measured_y])
l1_z = np.array([sim_z - measured_z])
l1_norm = l1_x + l1_y + l1_z
diff_l1_x.append(l1_x)
diff_l1_y.append(l1_y)
diff_l1_z.append(l1_z)
diff_l1_all.append(l1_norm)
if axis == 'xy':
ax_xy.plot(l1_x, l1_y, marker='x', markersize=3, color='teal', label='XY Error')
elif axis == 'yz':
ax_yz.plot(l1_y, l1_z, marker='x', markersize=3, color='coral', label='YZ Error')
elif axis == 'zx':
ax_zx.plot(l1_z, l1_x, marker='x', markersize=3, color='palevioletred', label='ZX Error')
diff_l1_x = np.array(diff_l1_x)
diff_l1_y = np.array(diff_l1_y)
diff_l1_z = np.array(diff_l1_z)
corr_mat = np.concatenate((diff_l1_x, diff_l1_y, diff_l1_z), axis=1)
corr_mat = corr_mat.T
corr_coef = np.corrcoef(corr_mat)
print('corr_coef:', corr_coef)
if axis == 'xy':
coef = corr_coef[0][1]
ax_xy.set_title(f'End Effector XY-axis Error Correlation: r={coef:.3f}')
plt.savefig('XY_correlation.png')
plt.close()
elif axis == 'yz':
coef = corr_coef[1][2]
ax_yz.set_title(f'End Effector YZ-axis Error Correlation: r={coef:.3f}')
plt.savefig('YZ_correlation.png')
plt.close()
elif axis == 'zx':
coef = corr_coef[2][0]
ax_zx.set_title(f'End Effector ZX-axis Error Correlation: r={coef:.3f}')
plt.savefig('ZX_correlation.png')
plt.close()
else:
for idx in range(self.num_files):
if axis == 'xy':
fig_xy, ax_xy = plt.subplots()
ax_xy.set_xlim(-0.5, 0.5)
ax_xy.set_ylim(-0.5, 0.5)
ax_xy.set_xlabel('X-axis Error (m)')
ax_xy.set_ylabel('Y-axis Error (m)')
x_range = np.arange(-0.5, 0.5, 0.01)
y_range = np.arange(-0.5, 0.5, 0.01)
ax_xy.plot(x_range, y_range, color='tan', linestyle="--")
elif axis == 'yz':
fig_yz, ax_yz = plt.subplots()
ax_yz.set_xlim(-0.5, 0.5)
ax_yz.set_ylim(-0.5, 0.5)
ax_yz.set_xlabel('Y-axis Error (m)')
ax_yz.set_ylabel('Z-axis Error (m)')
x_range = np.arange(-0.5, 0.5, 0.01)
y_range = np.arange(-0.5, 0.5, 0.01)
ax_yz.plot(x_range, y_range, color='tan', linestyle="--")
elif axis == 'zx':
fig_zx, ax_zx = plt.subplots()
ax_zx.set_xlim(-0.5, 0.5)
ax_zx.set_ylim(-0.5, 0.5)
ax_zx.set_xlabel('Z-axis Error (m)')
ax_zx.set_ylabel('X-axis Error (m)')
x_range = np.arange(-0.5, 0.5, 0.01)
y_range = np.arange(-0.5, 0.5, 0.01)
ax_zx.plot(x_range, y_range, color='tan', linestyle="--")
diff_l1_all = []
diff_l1_x = []
diff_l1_y = []
diff_l1_z = []
for i in range(self.ee_traj_len[idx]):
sim_traj = self.sim_ee_traj[idx][i]
sim_x = sim_traj[0][0]
sim_y = sim_traj[0][1]
sim_z = sim_traj[0][2]
measured_traj = self.measured_ee_traj[idx][i]
measured_x = measured_traj[0][0]
measured_y = measured_traj[0][1]
measured_z = measured_traj[0][2]
l1_x = np.array([sim_x - measured_x])
l1_y = np.array([sim_y - measured_y])
l1_z = np.array([sim_z - measured_z])
l1_norm = l1_x + l1_y + l1_z
diff_l1_x.append(l1_x)
diff_l1_y.append(l1_y)
diff_l1_z.append(l1_z)
diff_l1_all.append(l1_norm)
if axis == 'xy':
ax_xy.plot(l1_x, l1_y, marker='x', markersize=3, color='teal', label='XY Error')
elif axis == 'yz':
ax_yz.plot(l1_y, l1_z, marker='x', markersize=3, color='coral', label='YZ Error')
elif axis == 'zx':
ax_zx.plot(l1_z, l1_x, marker='x', markersize=3, color='palevioletred', label='ZX Error')
diff_l1_x = np.array(diff_l1_x)
diff_l1_y = np.array(diff_l1_y)
diff_l1_z = np.array(diff_l1_z)
corr_mat = np.concatenate((diff_l1_x, diff_l1_y, diff_l1_z), axis=1)
corr_mat = corr_mat.T
corr_coef = np.corrcoef(corr_mat)
print('corr_coef:', corr_coef)
if axis == 'xy':
coef = corr_coef[0][1]
ax_xy.set_title(f'End Effector XY-axis Error Correlation: r={coef:.3f}')
plt.savefig(f'XY_correlation_{idx}.png')
plt.close()
elif axis == 'yz':
coef = corr_coef[1][2]
ax_yz.set_title(f'End Effector YZ-axis Error Correlation: r={coef:.3f}')
plt.savefig(f'YZ_correlation_{idx}.png')
plt.close()
elif axis == 'zx':
coef = corr_coef[2][0]
ax_zx.set_title(f'End Effector ZX-axis Error Correlation: r={coef:.3f}')
plt.savefig(f'ZX_correlation_{idx}.png')
plt.close()
def evaluate_ee_error(self):
mean_x_l2_all = []
mean_y_l2_all = []
mean_z_l2_all = []
mean_all_l2_all = []
std_x_l2_all = []
std_y_l2_all = []
std_z_l2_all = []
std_all_l2_all = []
max_x_l2_all = []
max_y_l2_all = []
max_z_l2_all = []
max_all_l2_all = []
for idx in range(self.num_files):
diff_l2_all = []
diff_l2_x = []
diff_l2_y = []
diff_l2_z = []
for i in range(self.ee_traj_len[idx]):
sim_traj = self.sim_ee_traj[idx][i]
sim_x = sim_traj[0][0]
sim_y = sim_traj[0][1]
sim_z = sim_traj[0][2]
measured_traj = self.measured_ee_traj[idx][i]
measured_x = measured_traj[0][0]
measured_y = measured_traj[0][1]
measured_z = measured_traj[0][2]
l2_x = np.sqrt(np.square(sim_x-measured_x))
l2_y = np.sqrt(np.square(sim_y-measured_y))
l2_z = np.sqrt(np.square(sim_z-measured_z))
l2_norm = np.sqrt(np.square(sim_x-measured_x)+np.square(sim_y-measured_y)+np.square(sim_z-measured_z))
diff_l2_x.append(l2_x)
diff_l2_y.append(l2_y)
diff_l2_z.append(l2_z)
diff_l2_all.append(l2_norm)
# Calculate mean
mean_l2_x = np.mean(diff_l2_x)
mean_l2_y = np.mean(diff_l2_y)
mean_l2_z = np.mean(diff_l2_z)
mean_l2_all = np.mean(diff_l2_all)
mean_x_l2_all.append(mean_l2_x)
mean_y_l2_all.append(mean_l2_y)
mean_z_l2_all.append(mean_l2_z)
mean_all_l2_all.append(mean_l2_all)
# Calculate std
std_l2_x = np.var(diff_l2_x)
std_l2_y = np.var(diff_l2_y)
std_l2_z = np.var(diff_l2_z)
std_l2_all = np.var(diff_l2_all)
std_x_l2_all.append(std_l2_x)
std_y_l2_all.append(std_l2_y)
std_z_l2_all.append(std_l2_z)
std_all_l2_all.append(std_l2_all)
# Calculate max
max_l2_x = np.max(diff_l2_x)
max_l2_y = np.max(diff_l2_y)
max_l2_z = np.max(diff_l2_z)
max_l2_all = np.max(diff_l2_all)
print('Mean difference in direction X:', mean_l2_x)
print('Mean difference in direction Y:', mean_l2_y)
print('Mean difference in direction Z:', mean_l2_z)
print('Mean difference: ', mean_l2_all)
print('Std difference in direction X:', std_l2_x)
print('Std difference in direction Y:', std_l2_y)
print('Std difference in direction Z:', std_l2_y)
print('Std difference:', std_l2_all)
print('Max difference in direction X:', max_l2_x)
print('Max difference in direction Y:', max_l2_y)
print('Max difference in direction Z:', max_l2_z)
print('Max difference:', max_l2_all)
### Visualize mean and std
all_in_one = True
# Visualize X direction
if all_in_one:
x_range = np.arange(1, self.num_files+1)
y_range = mean_x_l2_all
fig, ax = plt.subplots()
ax.set_title('End-Effector Position Error')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.2)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Mean Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=std_x_l2_all, fmt='-^', markersize=6, color='darkorange',
markeredgecolor='darkorange', ecolor='darkorange', capsize=4, label='X position')
# Visualize Y direction
x_range = np.arange(1, self.num_files+1)
y_range = mean_y_l2_all
ax.errorbar(x_range, y_range, yerr=std_y_l2_all, fmt='-d', markersize=6, color='chocolate',
markeredgecolor='chocolate', ecolor='chocolate', capsize=4, label='Y position')
# Visualize Z direction
x_range = np.arange(1, self.num_files+1)
y_range = mean_z_l2_all
ax.errorbar(x_range, y_range, yerr=std_z_l2_all, fmt='-o', markersize=6, color='olivedrab',
markeredgecolor='olivedrab', ecolor='olivedrab', capsize=4, label='Z position')
# Visualize All
x_range = np.arange(1, self.num_files+1)
y_range = mean_all_l2_all
ax.errorbar(x_range, y_range, yerr=std_all_l2_all, fmt='-*', markersize=6, color='midnightblue',
markeredgecolor='midnightblue', ecolor='midnightblue', capsize=4, label='XYZ position')
ax.legend(loc="upper right")
else:
x_range = np.arange(1, self.num_files+1)
y_range = mean_x_l2_all
fig, ax = plt.subplots()
ax.set_title('End Effector Mean Error in X Direction')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.2)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Mean Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=std_x_l2_all, fmt='-^', markersize=6, color='darkorange',
markeredgecolor='darkorange', ecolor='darkorange', capsize=4)
plt.show()
plt.close()
# Visualize Y direction
x_range = np.arange(1, self.num_files+1)
y_range = mean_y_l2_all
fig, ax = plt.subplots()
ax.set_title('End Effector Mean Error in Y Direction')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.2)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Mean Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=std_y_l2_all, fmt='-^', markersize=6, color='darkorange',
markeredgecolor='darkorange', ecolor='darkorange', capsize=4)
# Visualize Z direction
x_range = np.arange(1, self.num_files+1)
y_range = mean_z_l2_all
fig, ax = plt.subplots()
ax.set_title('End Effector Mean Error in Z Direction')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.2)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Mean Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=std_z_l2_all, fmt='-^', markersize=6, color='darkorange',
markeredgecolor='darkorange', ecolor='darkorange', capsize=4)
plt.show()
plt.close()
# Visualize All
x_range = np.arange(1, self.num_files+1)
y_range = mean_all_l2_all
fig, ax = plt.subplots()
ax.set_title('End Effector Mean Error')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.2)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Mean Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=std_all_l2_all, fmt='-^', markersize=6, color='darkorange',
markeredgecolor='darkorange', ecolor='darkorange', capsize=4)
plt.show()
plt.savefig('mea_error.png')
def evaluate_jt_error(self):
mean_joint_all = []
std_joint_all = []
max_joint_all = []
for idx in range(self.num_files):
mean_joint_each = []
std_joint_each = []
max_joint_each = []
for i in range(self.num_joints):
diff_each_joints = []
for j in range(self.jt_traj_len[idx]):
sim_joint = self.sim_joint_traj[idx][j, i]
measured_joint = self.measured_joint_traj[idx][j, i]
diff_joint = np.sqrt(np.square(sim_joint-measured_joint))
diff_each_joints.append(diff_joint)
mean_joint = np.mean(diff_each_joints)
std_joint = np.var(diff_each_joints)
max_joint = np.max(diff_each_joints)
print(f"Mean joint_{i} difference:", mean_joint)
print(f"Std joint_{i} difference:", std_joint)
print(f"Max joint_{i} difference:", max_joint)
mean_joint_each.append(mean_joint)
std_joint_each.append(std_joint)
max_joint_each.append(max_joint)
mean_joint_all.append(mean_joint_each)
std_joint_all.append(std_joint_each)
max_joint_all.append(max_joint_all)
# Visualize results
for i in range(self.num_joints):
if i == 0:
x_range = np.arange(1, self.num_files+1)
y_range = np.array(mean_joint_all).T[i]
fig, ax = plt.subplots()
ax.set_title('X Position Error')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.15)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Position Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=np.array(std_joint_all).T[i], fmt='-^', markersize=6, color='navy',
markeredgecolor='navy', ecolor='navy', capsize=4, label='X Position Error')
ax.legend(loc="upper right")
plt.savefig('joint_x_error.png')
plt.close()
elif i == 1:
x_range = np.arange(1, self.num_files+1)
y_range = np.array(mean_joint_all).T[i]
fig, ax = plt.subplots()
ax.set_title('Y Position Error')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.15)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Position Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=np.array(std_joint_all).T[i], fmt='-^', markersize=6, color='navy',
markeredgecolor='navy', ecolor='navy', capsize=4, label='Y Position Error')
ax.legend(loc="upper right")
plt.savefig('joint_y_error.png')
plt.close()
elif i == 3:
x_range = np.arange(1, self.num_files+1)
y_range = np.array(mean_joint_all).T[i]
fig, ax = plt.subplots()
ax.set_title('ArmLift Joint Error')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.15)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Position Error (m)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=np.array(std_joint_all).T[i], fmt='-^', markersize=6, color='navy',
markeredgecolor='navy', ecolor='navy', capsize=4, label='ArmLift Position Error')
ax.legend(loc="upper right")
plt.savefig('joint_armlift_error.png')
plt.close()
else:
x_range = np.arange(1, self.num_files+1)
y_range = np.array(mean_joint_all).T[i]
fig, ax = plt.subplots()
ax.set_title(f'{self.joint_name[str(i)]} Position Error')
ax.set_xlim(0.5, self.num_files+0.5)
ax.set_ylim(-0.05, 0.15)
ax.set_xlabel('Number of Trials')
ax.set_ylabel('Position Error (rad)')
ax.grid()
ax.errorbar(x_range, y_range, yerr=np.array(std_joint_all).T[i], fmt='-^', markersize=6, color='navy',
markeredgecolor='navy', ecolor='navy', capsize=4, label=f'{self.joint_name[str(i)]} Position Error')
ax.legend(loc="upper right")
plt.savefig(f'joint_{self.joint_name[str(i)].lower()}_error.png')
plt.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser('Visualize trajectory')
parser.add_argument('--index', type=int, default=0, help='set index')
parser.add_argument('--joint_index', type=int, default=None, help='set joint index')
parser.add_argument('--mode', type=str, default='both', help='set visualization mode')
parser.add_argument('--visualize', action='store_true', help='set visualization')
args = parser.parse_args()
if args.visualize:
at = AnalyzeTrajectory(idx=args.index, mode=args.mode, joint_index=args.joint_index)
at.visualize_ee_3d_traj()
at.visualize_joint_2d_traj()
else:
at = AnalyzeMultipleTrajectory()
at.evaluate_ee_error()
at.evaluate_jt_error()
at.evaluate_ee_error_correlation()
at.plot_ee_traj()
| 45,050 |
Python
| 45.684974 | 136 | 0.508746 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/hsr_py_interface.py
|
#!/usr/bin/env/python3
import sys
import rospy
import hsrb_interface
import numpy as np
from controller_manager_msgs.srv import ListControllers
class HSRPyInterface(object):
def __init__(self, standalone=False):
# Initialize ROS node
if standalone:
rospy.init_node('hsr_python_interface')
# Check server status
self.check_status()
self.robot = hsrb_interface.Robot()
self.omni_base = self.robot.get('omni_base')
self.gripper = self.robot.get('gripper')
self.whole_body = self.robot.get('whole_body')
def initialize_arm(self):
# Initialize arm position
self.whole_body.move_to_go()
def initialize_base(self):
# Initialize base position
self.omni_base.go_abs(0.0, 0.0, 0.0, 300.0)
def set_task_pose(self, grasp_type='side'):
# Set base to configuration position
self.omni_base.go_abs(-0.80, 0.75, np.pi/2, 300.0)
# Set arm to configuration pose
self.whole_body.move_to_neutral()
if grasp_type == 'side':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.3, y=0.0, z=0.0, ej=0.0),
], ref_frame_id='hand_palm_link')
elif grasp_type == 'top':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.3, y=0.0, z=0.0, ej=-1.57),
], ref_frame_id='hand_palm_link')
# Open gripper
self.gripper.command(1.2)
def fix_task_pose(self, diff_pose):
diff_x_pose, diff_y_pose, diff_z_pose = diff_pose[0], diff_pose[1], diff_pose[2]
if np.abs(diff_z_pose) < 0.1:
diff_z_pose = -0.12
else:
diff_z_pose = 0.0
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=0.0, y=diff_y_pose, z=diff_z_pose)
], ref_frame_id='hand_palm_link')
def check_status(self):
# Make sure the controller is running
rospy.wait_for_service('/hsrb/controller_manager/list_controllers')
list_controllers = rospy.ServiceProxy('/hsrb/controller_manager/list_controllers', ListControllers)
running = False
while running is False:
rospy.sleep(0.1)
for c in list_controllers().controller:
if c.name == 'arm_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'head_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'gripper_controller' and c.state == 'running':
running |= True
if c.name == 'omni_base_controller' and c.state == 'running':
running |= True
return running
def close_gripper(self, force=0.5):
self.gripper.apply_force(force)
def open_gripper(self, width=1.0):
self.gripper.command(width)
def insert_object(self, ee_mode):
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.03, y=0.0, z=0.0),
], ref_frame_id='hand_palm_link')
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=0.0, y=-0.03, z=0.0),
], ref_frame_id='hand_palm_link')
def grasp_gear(self, diff_ee_pose, pick_offset=0.1):
# Open gripper
self.open_gripper(0.5)
# Move to grasp
self.whole_body.move_end_effector_by_line((0, 0, 1), -pick_offset)
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[0],
y=diff_ee_pose[1],
ek=-np.pi/2
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((0, 0, 1), diff_ee_pose[2]+pick_offset)
# Close gripper
self.close_gripper(0.5)
if __name__ == '__main__':
hsr_py = HSRPyInterface()
hsr_py.initialize_arm()
hsr_py.initialize_base()
| 4,143 |
Python
| 33.823529 | 107 | 0.567946 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/tf_interface.py
|
#!/bin/env/python3
import tf
import rospy
import tf2_ros
import numpy as np
import tf2_geometry_msgs
from tf2_msgs.msg import TFMessage
from geometry_msgs.msg import TransformStamped
from scipy.spatial.transform import Rotation as R
class TfManager(object):
def __init__(self, standalone=False):
if standalone:
rospy.init_node('tf_manager')
# TF listener
self.tfBuffer = tf2_ros.Buffer()
self.listener = tf2_ros.TransformListener(self.tfBuffer)
# Publisher
self.tf_pub = rospy.Publisher('/tf', TFMessage, queue_size=1)
def get_link_pose(self, link_name='hand_palm_link'):
# Translate from map coordinate to arbitrary coordinate of robot.
ee_pose = tf2_geometry_msgs.PoseStamped()
ee_pose.header.frame_id = link_name
ee_pose.header.stamp = rospy.Time(0)
ee_pose.pose.orientation.w = 1.0
try:
# Get transform at current time
global_pose = self.tfBuffer.transform(ee_pose, 'map')
except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException) as e:
print(e)
return None
return global_pose
def get_init_pose(self, mocap_poses):
# Get red_shaft pose
gearbox_x = mocap_poses['green_gear'].pose.position.x
gearbox_y = mocap_poses['green_gear'].pose.position.y
gearbox_z = mocap_poses['green_gear'].pose.position.z
# Get current end effector pose
current_ee_pose_x = mocap_poses['end_effector'].pose.position.x
current_ee_pose_y = mocap_poses['end_effector'].pose.position.y
current_ee_pose_z = mocap_poses['end_effector'].pose.position.z
# Culculate difference pose
diff_x_pose = current_ee_pose_x - gearbox_x
diff_y_pose = current_ee_pose_y - gearbox_y
diff_z_pose = current_ee_pose_z - gearbox_z
init_base_pose = np.array([diff_x_pose, diff_y_pose, diff_z_pose])
return init_base_pose
# Transform target_pose on end effector coordinate to map coordinate
def transform_coordinate(self, target_pose):
# Initialize vector and matrix
trans_mat = np.zeros((4, 4))
qc_trans = np.zeros(4)
# Initialize map coordination
qc_trans[0] = target_pose[0]
qc_trans[1] = target_pose[1]
qc_trans[2] = target_pose[2]
qc_trans[3] = 1.0
ee_pose = self.get_link_pose()
if ee_pose is None:
return
# Initialize ee coordination
translation = np.array([
ee_pose.pose.position.x,
ee_pose.pose.position.y,
ee_pose.pose.position.z
])
rot = np.array([
ee_pose.pose.orientation.x,
ee_pose.pose.orientation.y,
ee_pose.pose.orientation.z,
ee_pose.pose.orientation.w
])
rot_mat = R.from_quat(rot).as_matrix()
# Calculate translation
trans_mat[3:, 3:] = 1.0
trans_mat[:3, 3] = translation
trans_mat[:3, :3] = rot_mat
qw_trans = trans_mat @ qc_trans
qw_trans = qw_trans[:3]
# Calculate rotation
qw_rot = np.array([
ee_pose.pose.orientation.x,
ee_pose.pose.orientation.y,
ee_pose.pose.orientation.z,
ee_pose.pose.orientation.w
])
return np.concatenate([qw_trans, qw_rot])
def publish_mocap_to_map(self, mocap_poses):
tf_list = []
for rigid_name, mocap_pose in mocap_poses.items():
t = TransformStamped()
t.header.frame_id = 'map'
t.header.stamp = rospy.Time.now()
t.child_frame_id = rigid_name
t.transform.translation.x = mocap_pose.pose.position.x
t.transform.translation.y = mocap_pose.pose.position.y
t.transform.translation.z = mocap_pose.pose.position.z
t.transform.rotation.x = mocap_pose.pose.rotation.x
t.transform.rotation.y = mocap_pose.pose.rotation.y
t.transform.rotation.z = mocap_pose.pose.rotation.z
t.transform.rotation.w = mocap_pose.pose.rotation.w
tf_list.append(t)
tfm = TFMessage(tf_list)
# Publish tf message
self.tf_pub.publish(tfm)
if __name__ == '__main__':
tf_manager = TfManager(standalone=True)
while not rospy.is_shutdown():
transform = tf_manager.get_link_pose('hand_palm_link')
test_pose1 = np.array([-0.5, 0.0, 0.0]) # -0.5 to z direction on map
test_pose1 = tf_manager.transform_coordinate(test_pose1)
test_pose2 = np.array([0.0, 1.0, 0.0]) # -1.0 to x direction on map
test_pose2 = tf_manager.transform_coordinate(test_pose2)
test_pose3 = np.array([-0.3, -1.0, 0.0])
test_pose3 = tf_manager.transform_coordinate(test_pose3)
ee_pose = tf_manager.get_link_pose()
if ee_pose is None:
continue
test_pose4 = np.array([
ee_pose.pose.position.x,
ee_pose.pose.position.y,
ee_pose.pose.position.z
])
test_pose4 = tf_manager.transform_coordinate(test_pose4)
test_pose5 = np.zeros(3)
test_pose5 = tf_manager.transform_coordinate(test_pose5)
print('test_1: ', test_pose1)
print('test_2: ', test_pose2)
print('test_3: ', test_pose3)
print('test_4: ', test_pose4)
print('test_5: ', test_pose5)
| 5,495 |
Python
| 32.512195 | 109 | 0.592903 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/mocap_interface.py
|
#!/bin/env/python3
import rospy
import numpy as np
from geometry_msgs.msg import PoseStamped
from scipy.spatial.transform import Rotation as R
class MocapInterface(object):
def __init__(self, standalone=False):
if standalone:
rospy.init_node('mocap_interface')
# Mocap list
self.rigid_body_list = (
"base",
"blue_gear",
"green_gear",
"red_gear",
"yellow_shaft",
"red_shaft",
"end_effector"
)
# Mocap to map
self.translation = np.array([0.0, 0.0, 0.0])
self.rotation = np.array([
[0.0, 0.0, 1.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0]
])
# Rigid body pose dictionary
self.rigid_posestamped = {
name: PoseStamped() for name in self.rigid_body_list
}
# Subscriber
self._mocap_sub = [
rospy.Subscriber('/mocap_pose_topic/{0}_pose'.format(self.rigid_body_list[i]), PoseStamped, self._mocap_cb, callback_args=i)
for i in range(len(self.rigid_body_list))
]
def _mocap_cb(self, mocap_data, id):
converted_pose = self.convert_mocap_to_map(mocap_data)
mocap_data.header.frame_id = 'map'
mocap_data.pose.position.x = converted_pose[0]
mocap_data.pose.position.y = converted_pose[1]
mocap_data.pose.position.z = converted_pose[2]
mocap_data.pose.orientation.x = converted_pose[3]
mocap_data.pose.orientation.y = converted_pose[4]
mocap_data.pose.orientation.z = converted_pose[5]
mocap_data.pose.orientation.w = converted_pose[6]
self.rigid_posestamped[self.rigid_body_list[id]] = mocap_data
def get_pose(self, name):
return self.rigid_posestamped[name]
def get_poses(self):
return self.rigid_posestamped
def convert_mocap_to_map(self, mocap_data):
# Initialize vector and matrix
trans_mat = np.zeros((4, 4))
qc_trans = np.zeros(4)
qc_rot = np.zeros(4)
# Calculate translation
qc_trans[0] = mocap_data.pose.position.x
qc_trans[1] = mocap_data.pose.position.y
qc_trans[2] = mocap_data.pose.position.z
qc_trans[3] = 1.0
trans_mat[3:, 3:] = 1.0
trans_mat[:3, 3] = self.translation
trans_mat[:3, :3] = self.rotation
qw_trans = trans_mat @ qc_trans
qw_trans = qw_trans[:3]
# Calculate rotation
qc_rot[0] = mocap_data.pose.orientation.x
qc_rot[1] = mocap_data.pose.orientation.y
qc_rot[2] = mocap_data.pose.orientation.z
qc_rot[3] = mocap_data.pose.orientation.w
qc_rot_mat = R.from_quat(qc_rot).as_matrix()
qw_rot_mat = self.rotation @ qc_rot_mat
qw_rot = R.from_matrix(qw_rot_mat).as_quat()
return np.concatenate([qw_trans, qw_rot])
if __name__ == '__main__':
mocap_interface = MocapInterface(standalone=True)
while not rospy.is_shutdown():
# Test each rigid body
base_pose = mocap_interface.get_pose('base')
print('base_pose: ', base_pose)
blue_gear_pose = mocap_interface.get_pose('blue_gear')
print('blue_gear_pose: ', blue_gear_pose)
green_gear_pose = mocap_interface.get_pose('green_gear')
print('green_gear_pose: ', green_gear_pose)
red_gear_pose = mocap_interface.get_pose('red_gear')
print('red_gear_pose: ', red_gear_pose)
yellow_shaft_pose = mocap_interface.get_pose('yellow_shaft')
print('yellow_shaft_pose: ', yellow_shaft_pose)
red_shaft_pose = mocap_interface.get_pose('red_shaft')
print('red_shaft_pose: ', red_shaft_pose)
end_effector_pose = mocap_interface.get_pose('end_effector')
print('end_effector_pose: ', end_effector_pose)
# Test all rigid bodies
rigid_poses = mocap_interface.get_poses()
print('rigid_poses: ', rigid_poses['blue_gear'])
| 4,000 |
Python
| 33.791304 | 136 | 0.5855 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/force_sensor_interface.py
|
import sys
import math
import rospy
from geometry_msgs.msg import WrenchStamped
class ForceSensorInterface(object):
def __init__(self, standalone=False):
if standalone:
rospy.init_node('force_torque_sensor_interface')
self._force_data_x = 0.0
self._force_data_y = 0.0
self._force_data_z = 0.0
# Subscribe force torque sensor data from HSRB
self._wrist_wrench_sub = rospy.Subscriber(
'/hsrb/wrist_wrench/raw', WrenchStamped, self._ft_sensor_callback
)
# Wait for connection
try:
rospy.wait_for_message('/hsrb/wrist_wrench/raw', WrenchStamped, timeout=10.0)
except Exception as e:
rospy.logerr(e)
sys.exit(1)
def _ft_sensor_callback(self, data):
self._force_data_x = data.wrench.force.x
self._force_data_y = data.wrench.force.y
self._force_data_z = data.wrench.force.z
def initialize_ft(self):
self._force_data_x = 0.0
self._force_data_y = 0.0
self._force_data_z = 0.0
def get_current_force(self):
return [self._force_data_x, self._force_data_y, self._force_data_z]
def compute_difference(self, pre_data_list, post_data_list, calc_type='l1'):
if (len(pre_data_list) != len(post_data_list)):
raise ValueError('Argument lists differ in length')
# Calcurate square sum of difference
if calc_type == 'l1':
l1_sums = sum([b - a for (a, b) in zip(pre_data_list, post_data_list)])
return l1_sums
elif calc_type == 'l2':
l2_sums = sum([math.pow(b - a, 2) for (a, b) in zip(pre_data_list, post_data_list)])
return math.sqrt(l2_sums)
if __name__ == '__main__':
ft_interface = ForceSensorInterface(standalone=True)
rate = rospy.Rate(50)
while not rospy.is_shutdown():
prev_ft_data = ft_interface.get_current_force()
input('wait_for_user')
curr_ft_data = ft_interface.get_current_force()
force_difference = ft_interface.compute_difference(prev_ft_data, curr_ft_data)
weight = round(force_difference / 9.81 * 1000, 1)
print('weight:', weight)
rate.sleep()
| 2,244 |
Python
| 32.014705 | 96 | 0.595365 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/planner/cross_entropy_method.py
|
import numpy as np
from planner import Planner
class CrossEntropyMethod(Planner):
def __init__(self):
super().__init__()
def compute_path(self):
pass
| 176 |
Python
| 16.699998 | 34 | 0.630682 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/planner/planner.py
|
import numpy as np
class Planner(object):
def __init__(self):
pass
@staticmethod
def compute_path(self):
raise NotImplementedError("Implement compute_path")
| 187 |
Python
| 17.799998 | 59 | 0.652406 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/planner/linear_interpolation.py
|
import numpy as np
from .planner import Planner
class LinearInterpolationPlanner(Planner):
def __init__(self):
super().__init__()
def compute_path(self, op_pose, num_steps=10):
# Compute linear interpolation path
assert num_steps > 1, "Too short to create waypoints"
traj_x = np.linspace(0.0, op_pose[0], num_steps)
traj_y = np.linspace(0.0, op_pose[1], num_steps)
traj_z = np.linspace(0.0, op_pose[2], num_steps)
trajectory = np.dstack((traj_x, traj_y, traj_z))
return trajectory
| 557 |
Python
| 29.999998 | 61 | 0.621185 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/planner/spline_interpolation.py
|
import numpy as np
from planner import Planner
class SplineInterpolationPlanner(Planner):
def __init__(self, offset):
super().__init__()
# Set parameters
self.offset = offset
def compute_path(self, op_pose, num_steps=10):
# Compute linear interpolation path
assert num_steps > 1, "Too short to create waypoints"
traj_x = np.linspace(0.0, op_pose[0], num_steps)
traj_y = np.linspace(0.0, op_pose[1], num_steps)
traj_z = np.linspace(0.0, op_pose[2], num_steps)
trajectory = np.dstack((traj_x, traj_y, traj_z))
return trajectory
| 619 |
Python
| 28.523808 | 61 | 0.615509 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/feedback/demo.py
|
#!/usr/bin/env/python3
import tf
import sys
import rospy
import moveit_commander
import numpy as np
from scipy.spatial.transform import Rotation as R
# TODO: fix
sys.path.append('/root/tamp-hsr/hsr_tamp/experiments/env_2d/')
sys.path.append('..')
from tamp_planner import TAMPPlanner
from hsr_py_interface import HSRPyInterface
from post_process import PlanModifier
from mocap_interface import MocapInterface
from tf_interface import TfManager
from geometry_msgs.msg import Pose
from controller_manager_msgs.srv import ListControllers
class ExecutePlan(object):
def __init__(self, grasp_type='side'):
# Initialize moveit
moveit_commander.roscpp_initialize(sys.argv)
# Initialize ROS node
rospy.init_node('execute_tamp_plan')
# Feedback rate
self.rate = rospy.Rate(10)
# Threshold
self.move_threshold = 0.05
self.pick_threshold = 0.05
self.place_threshold = 0.04 # 0.038
self.stack_threshold = 0.04 # 0.038
# Core module
self.tamp_planner = TAMPPlanner()
self.hsr_py = HSRPyInterface()
self.path_modifier = PlanModifier()
self.mocap_interface = MocapInterface()
self.tf_manager = TfManager()
# Initialize Robot
self.initialize_robot(grasp_type)
def initialize_robot(self, grasp_type='side'):
self.check_status()
# Set moveit commander
self.robot = moveit_commander.RobotCommander()
self.arm = moveit_commander.MoveGroupCommander('arm', wait_for_servers=0.0)
self.base = moveit_commander.MoveGroupCommander('base', wait_for_servers=0.0)
self.gripper = moveit_commander.MoveGroupCommander('gripper', wait_for_servers=0.0)
self.whole_body = moveit_commander.MoveGroupCommander('whole_body', wait_for_servers=0.0)
# Set planning parameters
self.set_planning_parameter()
# Set arm to configuration position
self.hsr_py.initialize_arm()
# Set base to configuration position
self.hsr_py.initialize_base()
# Move to neutral
self.hsr_py.set_task_pose(grasp_type)
def set_planning_parameter(self):
# Planning parameters
self.whole_body.allow_replanning(True)
self.whole_body.set_planning_time(3)
self.whole_body.set_pose_reference_frame('map')
# Scene parameters
self.scene = moveit_commander.PlanningSceneInterface()
self.scene.remove_world_object()
def check_status(self):
# Make sure the controller is running
rospy.wait_for_service('/hsrb/controller_manager/list_controllers')
list_controllers = rospy.ServiceProxy('/hsrb/controller_manager/list_controllers', ListControllers)
running = False
while running is False:
rospy.sleep(0.1)
for c in list_controllers().controller:
if c.name == 'arm_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'head_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'gripper_controller' and c.state == 'running':
running |= True
if c.name == 'omni_base_controller' and c.state == 'running':
running |= True
return running
def plan(self):
# Run TAMP
plan, _, _ = self.tamp_planner.plan()
return plan
def process(self, action_name, args):
# Get rigid body poses from mocap
mocap_poses = self.mocap_interface.get_poses()
# Modify plan
action_name, modified_action, ee_mode = self.path_modifier.post_process(action_name, args, mocap_poses)
return modified_action, ee_mode
def check_ee_mode(self):
# Get end effector pose
ee_pose = self.whole_body.get_current_pose()
ee_rot = np.array([
ee_pose.pose.orientation.x,
ee_pose.pose.orientation.y,
ee_pose.pose.orientation.z,
ee_pose.pose.orientation.w
])
ee_euler = R.from_quat(ee_rot).as_euler('xyz')
# Check whether end effector is vertical to ground plane, or horizontal
if -0.8 < ee_euler[1] and 0.8 > ee_euler[1]:
ee_mode = 'vertical'
elif -2.0 < ee_euler[1] and -1.0 > ee_euler[1]:
ee_mode = 'horizontal'
return ee_mode
def create_trajectory(self, diff_pose, num_steps=2):
# Temporally linear interpolation
assert num_steps > 1, "Too shot to create waypoints"
traj_x = np.linspace(0.0, diff_pose[0], num_steps)
traj_y = np.linspace(0.0, diff_pose[1], num_steps)
traj_z = np.linspace(0.0, diff_pose[2], num_steps)
trajectory = np.dstack((traj_x, traj_y, traj_z))
return trajectory
def set_target_pose(self, trajectory, move_mode='outward', ee_mode='horizontal'):
if move_mode == 'outward':
# Extract full trajectory
diff_ee_traj = trajectory[0]
goal_way_points = []
for i in range(1, len(diff_ee_traj)):
# Transform difference pose on end effector frame to map frame
target_map_pose = self.tf_manager.transform_coordinate(diff_ee_traj[i])
if ee_mode == 'horizontal':
goal_pose = Pose()
goal_pose.position.x = target_map_pose[0]
goal_pose.position.y = target_map_pose[1]
goal_pose.position.z = target_map_pose[2]
goal_pose.orientation.x = 0.5
goal_pose.orientation.y = 0.5
goal_pose.orientation.z = 0.5
goal_pose.orientation.w = -0.5
goal_way_points.append(goal_pose)
elif ee_mode == 'vertical':
goal_pose = Pose()
goal_pose.position.x = target_map_pose[0]
goal_pose.position.y = target_map_pose[1]
goal_pose.position.z = target_map_pose[2]
goal_pose.orientation.x = 0.0
goal_pose.orientation.y = 0.707106781
goal_pose.orientation.z = 0.707106781
goal_pose.orientation.w = 0.0
goal_way_points.append(goal_pose)
return goal_way_points
elif move_mode == 'return':
# Extract full trajectory
diff_ee_traj = trajectory[0]
goal_way_points = []
for i in range(1, len(diff_ee_traj)):
# Transform difference pose on end effector frame to map frame
target_map_pose = self.tf_manager.transform_coordinate(diff_ee_traj[i])
if ee_mode == 'horizontal':
goal_pose = Pose()
goal_pose.position.x = diff_ee_traj[i][0]
goal_pose.position.y = diff_ee_traj[i][1] - 0.12 # TODO: modify
goal_pose.position.z = diff_ee_traj[i][2]
goal_pose.orientation.x = 0.5
goal_pose.orientation.y = 0.5
goal_pose.orientation.z = 0.5
goal_pose.orientation.w = -0.5
goal_way_points.append(goal_pose)
elif ee_mode == 'vertical':
goal_pose = Pose()
goal_pose.position.x = diff_ee_traj[i][0]
goal_pose.position.y = diff_ee_traj[i][1] - 0.12 # TODO: modify
goal_pose.position.z = diff_ee_traj[i][2] - 0.2 # TODO: modify
goal_pose.orientation.x = 0.0
goal_pose.orientation.y = 0.707106781
goal_pose.orientation.z = 0.707106781
goal_pose.orientation.w = 0.0
goal_way_points.append(goal_pose)
return goal_way_points
def modify_pose(self, diff_ee_pose, ee_mode):
if ee_mode == 'horizontal':
return (diff_ee_pose[0], diff_ee_pose[1], diff_ee_pose[2])
elif ee_mode == 'vertical':
return (-diff_ee_pose[1], diff_ee_pose[0], diff_ee_pose[2])
def execute(self):
plan = self.plan()
if plan is None:
return None
for i, (action_name, args) in enumerate(plan):
print('action_name:', action_name)
if action_name == 'move':
(_, diff_ee_pose), _ = self.process(action_name, args)
# Set end effector mode
ee_mode = self.check_ee_mode()
# Move to next pose
diff_ee_pose = self.modify_pose(diff_ee_pose, ee_mode)
target_traj = self.create_trajectory(diff_ee_pose)
goal_pose = self.set_target_pose(target_traj, ee_mode=ee_mode)
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
elif action_name == 'pick':
finish = False
(init_ee_pose, _), _ = self.process(action_name, args)
while not finish:
(_, diff_ee_pose), ee_mode = self.process(action_name, args)
if ee_mode == 'horizontal':
# Crete trajectory
target_traj = self.create_trajectory(diff_ee_pose)
goal_pose = self.set_target_pose(target_traj, ee_mode=ee_mode)
# Move and plan to grasp pose
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
if np.sum(np.absolute(diff_ee_pose)) < self.pick_threshold:
finish = True
# Grasp object
self.hsr_py.close_gripper()
# Move to terminal pose
target_traj = self.create_trajectory(init_ee_pose)
goal_pose = self.set_target_pose(target_traj, move_mode='return')
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
elif ee_mode == 'vertical':
finish = True
# Move to target object & grasp object
self.hsr_py.grasp_gear(diff_ee_pose)
target_traj = self.create_trajectory(init_ee_pose)
goal_pose = self.set_target_pose(target_traj, move_mode='return', ee_mode='vertical')
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
# Sleep up to rate
self.rate.sleep()
elif action_name == 'place':
finish = False
(init_ee_pose, _), _ = self.process(action_name, args)
while not finish:
(_, diff_ee_pose), ee_mode = self.process(action_name, args)
# Crete trajectory
target_traj = self.create_trajectory(diff_ee_pose)
goal_pose = self.set_target_pose(target_traj, ee_mode=ee_mode)
# Move and plan to place pose
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
print('difference (place):', np.sum(np.absolute(diff_ee_pose)))
if np.sum(np.absolute(diff_ee_pose)) < self.place_threshold:
finish = True
# Sleep until stable
rospy.sleep(1.0)
# Put down end effector
self.hsr_py.insert_object(ee_mode)
# Release object
self.hsr_py.open_gripper()
# Move to terminal pose
target_traj = self.create_trajectory(init_ee_pose)
goal_pose = self.set_target_pose(target_traj, move_mode='return')
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
# Sleep up to rate
self.rate.sleep()
elif action_name == 'stack':
finish = False
(init_ee_pose, _), _ = self.process(action_name, args)
while not finish:
(_, diff_ee_pose), ee_mode = self.process(action_name, args)
# Crete trajectory
diff_ee_pose = self.modify_pose(diff_ee_pose, ee_mode)
target_traj = self.create_trajectory(diff_ee_pose)
goal_pose = self.set_target_pose(target_traj, ee_mode=ee_mode)
# Move and plan to stack pose
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
print('diff_ee_pose (stack):', diff_ee_pose)
if np.sum(np.absolute(diff_ee_pose)) < self.stack_threshold:
finish = True
# Sleep until stable
rospy.sleep(1.0)
# Put down end effector
self.hsr_py.insert_object(ee_mode)
# Release object
self.hsr_py.open_gripper()
# Move to terminal pose
target_traj = self.create_trajectory(init_ee_pose)
goal_pose = self.set_target_pose(target_traj, move_mode='return')
(plan, fraction) = self.whole_body.compute_cartesian_path(goal_pose, 0.01, 0.0, False)
self.whole_body.execute(plan, wait=True)
# Sleep up to rate
self.rate.sleep()
else:
continue
if __name__ == '__main__':
exec_plan = ExecutePlan()
exec_plan.execute()
| 14,549 |
Python
| 39.304709 | 114 | 0.530552 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/feedback/post_process.py
|
#!/usr/bin/env/python3
import numpy as np
class PlanModifier(object):
def __init__(self, x_offset=0.0, y_offset=-0.065, z_offset=-0.04):
self.mocap_x_offset = x_offset
self.mocap_y_offset = y_offset
self.mocap_z_offset = z_offset
self.left_hole_x = -0.10
self.left_hole_y = -0.18
self.left_hole_z = 0.125 # 0.135 # 0.125 # 0.12
self.right_hole_x = 0.095
self.right_hole_y = -0.18
self.right_hole_z = 0.142 # 0.15 # 0.145 # 0.14
self.x_scale = 0.0 # 0.0~0.1
self.y_scale = 0.065 # 0.0~0.1
self.z_scale = 0.0 # 0.0~0.0
self.ee_mode = 'horizontal'
self.block_rigid_map = {
'A' : 'red_shaft',
'B' : 'green_gear',
'C' : 'yellow_shaft',
'D' : 'blue_gear'
}
def post_process(self, action_name, args, mocap_poses, grasp_type='side'):
"""
Modify plan using sensor data.
Args:
plan (list): plan is trajectory of the tamp.
robot_pose (list): robot_pose consists of base_pose, end_effector_pose, gripper.
rigid_poses (dict): rigid_pose consists of captured rigid body poses
Returns:
commands (list): commands is modified plan
"""
ee_pose = mocap_poses['end_effector']
if grasp_type == 'side':
if action_name == 'move':
robot, init_robot_pose, way_point, term_robot_pose = args
# Modify end effector position from mocap marker attached position
if self.ee_mode == 'horizontal':
ee_pose_x = ee_pose.pose.position.x + self.mocap_x_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_z_offset
elif self.ee_mode == 'vertical':
ee_pose_x = ee_pose.pose.position.x - self.mocap_z_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_x_offset
# Get end effector orientation
ee_ori_x = ee_pose.pose.orientation.x
ee_ori_y = ee_pose.pose.orientation.y
ee_ori_z = ee_pose.pose.orientation.z
ee_ori_w = ee_pose.pose.orientation.w
# Initial pose
init_ee_pose = np.array([
ee_pose_x, ee_pose_y, ee_pose_z,
ee_ori_x, ee_ori_y, ee_ori_z, ee_ori_w
], dtype=np.float64)
# Calculate difference from target pose in configuration space
diff_ee_pose = np.array([
self.x_scale * 0.0,
self.y_scale * (term_robot_pose[0] - init_robot_pose[0]),
self.z_scale * (term_robot_pose[1] - init_robot_pose[1])
], dtype=np.float64)
new_command = (action_name, [init_ee_pose, diff_ee_pose], self.ee_mode)
elif action_name == 'pick':
robot, block, init_block_pose, grasp_diff_pose, term_robot_pose = args
# Set pick hyperparameters
if block == 'A':
ee_x_offset = 0.03
ee_y_offset = 0.0
ee_z_offset = 0.04
self.ee_mode = 'horizontal'
elif block == 'B':
ee_x_offset = -0.05
ee_y_offset = 0.0
ee_z_offset = 0.11
self.ee_mode = 'vertical'
elif block == 'C':
ee_x_offset = 0.03
ee_y_offset = 0.0
ee_z_offset = 0.04
self.ee_mode = 'horizontal'
elif block == 'D':
ee_x_offset = -0.05
ee_y_offset = 0.0
ee_z_offset = 0.13
self.ee_mode = 'vertical'
# Modify end effector position from mocap marker attached position
if self.ee_mode == 'horizontal':
ee_pose_x = ee_pose.pose.position.x + self.mocap_x_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_z_offset
elif self.ee_mode == 'vertical':
ee_pose_x = ee_pose.pose.position.x - self.mocap_z_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_x_offset
# Get end effector orientation
ee_ori_x = ee_pose.pose.orientation.x
ee_ori_y = ee_pose.pose.orientation.y
ee_ori_z = ee_pose.pose.orientation.z
ee_ori_w = ee_pose.pose.orientation.w
# Initial pose
init_ee_pose = np.array([
ee_pose_x, ee_pose_y, ee_pose_z,
ee_ori_x, ee_ori_y, ee_ori_z, ee_ori_w
], dtype=np.float64)
# Map symbolic block name to real block name
rigid_name = self.block_rigid_map[block]
rigid_pose = mocap_poses[rigid_name]
# Calculate grasp pose in configuration space
rigid_pose_x = rigid_pose.pose.position.x
rigid_pose_y = rigid_pose.pose.position.y
rigid_pose_z = rigid_pose.pose.position.z
diff_ee_pose = np.array([
rigid_pose_z - ee_pose_z - ee_x_offset,
rigid_pose_x - ee_pose_x - ee_y_offset,
rigid_pose_y - ee_pose_y - ee_z_offset,
], dtype=np.float64)
new_command = (action_name, [init_ee_pose, diff_ee_pose], self.ee_mode)
elif action_name == 'place':
robot, block, init_block_pose, grasp_diff_pose, term_robot_pose = args
# Get hole pose
base_pose = mocap_poses['base']
# Modify hole position from mocap marker
if block == 'A':
hole_pose_x = base_pose.pose.position.x + self.left_hole_x
hole_pose_y = base_pose.pose.position.y + self.left_hole_y
hole_pose_z = base_pose.pose.position.z + self.left_hole_z
self.ee_mode = 'horizontal'
elif block == 'B':
hole_pose_x = base_pose.pose.position.x + self.left_hole_x
hole_pose_y = base_pose.pose.position.y + self.left_hole_y
hole_pose_z = base_pose.pose.position.z + self.left_hole_z
self.ee_mode = 'vertical'
elif block == 'C':
hole_pose_x = base_pose.pose.position.x + self.right_hole_x
hole_pose_y = base_pose.pose.position.y + self.right_hole_y
hole_pose_z = base_pose.pose.position.z + self.right_hole_z
self.ee_mode = 'horizontal'
elif block == 'D':
hole_pose_x = base_pose.pose.position.x + self.right_hole_x
hole_pose_y = base_pose.pose.position.y + self.right_hole_y
hole_pose_z = base_pose.pose.position.z + self.right_hole_z
self.ee_mode = 'vertical'
# Modify end effector position from mocap marker attached position
if self.ee_mode == 'horizontal':
ee_pose_x = ee_pose.pose.position.x + self.mocap_x_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_z_offset
elif self.ee_mode == 'vertical':
ee_pose_x = ee_pose.pose.position.x - self.mocap_z_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_x_offset
# Get end effector orientation
ee_ori_x = ee_pose.pose.orientation.x
ee_ori_y = ee_pose.pose.orientation.y
ee_ori_z = ee_pose.pose.orientation.z
ee_ori_w = ee_pose.pose.orientation.w
# Initial pose
init_ee_pose = np.array([
ee_pose_x, ee_pose_y, ee_pose_z,
ee_ori_x, ee_ori_y, ee_ori_z, ee_ori_w
], dtype=np.float64)
# Map symbolic block name to real block name
rigid_name = self.block_rigid_map[block]
rigid_pose = mocap_poses[rigid_name]
# Calculate place pose in configuration space
rigid_pose_x = rigid_pose.pose.position.x
rigid_pose_y = rigid_pose.pose.position.y
rigid_pose_z = rigid_pose.pose.position.z
diff_ee_pose = np.array([
hole_pose_z - rigid_pose_z,
hole_pose_x - rigid_pose_x,
hole_pose_y - rigid_pose_y,
], dtype=np.float64)
new_command = (action_name, [init_ee_pose, diff_ee_pose], self.ee_mode)
elif action_name == 'stack':
robot, u_block, u_pose, grasp_diff_pose, \
term_robot_pose, l_block, l_pose = args
# Get hole pose
base_pose = mocap_poses['base']
# Modify hole position from mocap marker
if u_block == 'A':
hole_pose_x = base_pose.pose.position.x + self.left_hole_x
hole_pose_y = base_pose.pose.position.y + self.left_hole_y
hole_pose_z = base_pose.pose.position.z + self.left_hole_z - 0.01 # TODO: modify
self.ee_mode = 'horizontal'
elif u_block == 'B':
hole_pose_x = base_pose.pose.position.x + self.left_hole_x + 0.0175 # TODO: modify
hole_pose_y = base_pose.pose.position.y + self.left_hole_y
hole_pose_z = base_pose.pose.position.z + self.left_hole_z - 0.015 # TODO: modify
self.ee_mode = 'vertical'
elif u_block == 'C':
hole_pose_x = base_pose.pose.position.x + self.right_hole_x
hole_pose_y = base_pose.pose.position.y + self.right_hole_y
hole_pose_z = base_pose.pose.position.z + self.right_hole_z - 0.01 # TODO: modify
self.ee_mode = 'horizontal'
elif u_block == 'D':
hole_pose_x = base_pose.pose.position.x + self.right_hole_x + 0.0175 # TODO: modify
hole_pose_y = base_pose.pose.position.y + self.right_hole_y
hole_pose_z = base_pose.pose.position.z + self.right_hole_z - 0.015 # TODO: modify
self.ee_mode = 'vertical'
# Modify end effector position from mocap marker attached position
if self.ee_mode == 'horizontal':
ee_pose_x = ee_pose.pose.position.x + self.mocap_x_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_z_offset
elif self.ee_mode == 'vertical':
ee_pose_x = ee_pose.pose.position.x - self.mocap_z_offset
ee_pose_y = ee_pose.pose.position.y - self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_x_offset
# Get end effector orientation
ee_ori_x = ee_pose.pose.orientation.x
ee_ori_y = ee_pose.pose.orientation.y
ee_ori_z = ee_pose.pose.orientation.z
ee_ori_w = ee_pose.pose.orientation.w
# Initial pose
init_ee_pose = np.array([
ee_pose_x, ee_pose_y, ee_pose_z,
ee_ori_x, ee_ori_y, ee_ori_z, ee_ori_w
], dtype=np.float64)
# Map symbolic block name to real block name
u_rigid_name = self.block_rigid_map[u_block]
l_rigid_name = self.block_rigid_map[l_block]
u_rigid_pose = mocap_poses[u_rigid_name]
l_rigid_pose = mocap_poses[l_rigid_name]
# Calculate stack pose in configuration space
rigid_pose_x = u_rigid_pose.pose.position.x
rigid_pose_y = u_rigid_pose.pose.position.y
rigid_pose_z = u_rigid_pose.pose.position.z
diff_ee_pose = np.array([
hole_pose_z - rigid_pose_z,
hole_pose_x - rigid_pose_x,
hole_pose_y - rigid_pose_y,
], dtype=np.float64)
new_command = (action_name, [init_ee_pose, diff_ee_pose], self.ee_mode)
else:
pass
elif grasp_type == 'top':
ee_pose_x = ee_pose.pose.position.x + self.mocap_x_offset
ee_pose_y = ee_pose.pose.position.y + self.mocap_y_offset
ee_pose_z = ee_pose.pose.position.z + self.mocap_z_offset
if action_name == 'move':
robot, init_robot_pose, way_point, term_robot_pose = args
# Calculate grasp pose in configuration space
init_ee_pose = np.array([
ee_pose_x,
ee_pose_y,
ee_pose_z
])
diff_ee_pose = np.array([
self.x_scale * 0.0,
self.y_scale * (term_robot_pose[0] - init_robot_pose[0]),
self.z_scale * (term_robot_pose[1] - init_robot_pose[1])
])
term_ee_pose = init_ee_pose + diff_ee_pose
new_command = (action_name, [init_ee_pose, diff_ee_pose, term_ee_pose])
elif action_name == 'pick':
robot, block, init_block_pose, grasp_diff_pose, term_robot_pose = args
# Map symbolic block name to real block name
rigid_name = self.block_rigid_map[block]
rigid_pose = mocap_poses[rigid_name]
# Get curent end effector pose
init_ee_pose = np.array([
ee_pose_x,
ee_pose_y,
ee_pose_z
])
# Calculate grasp pose in configuration space
rigid_pose_x = rigid_pose.pose.position.x
rigid_pose_y = rigid_pose.pose.position.y
rigid_pose_z = rigid_pose.pose.position.z
diff_ee_pose = np.array([
ee_pose_y - rigid_pose_y,
ee_pose_x - rigid_pose_x,
ee_pose_z - rigid_pose_z
])
# Get terminal end effector pose as reverse of diff_ee_pose
term_ee_pose = -diff_ee_pose
new_command = (action_name, [init_ee_pose, diff_ee_pose, term_ee_pose])
elif action_name == 'place':
robot, block, init_block_pose, grasp_diff_pose, term_robot_pose = args
# Get hole pose
base_pose = mocap_poses['base']
if block == 'A' or block == 'B':
hole_pose_x = base_pose.pose.position.x + self.left_hole_x
hole_pose_y = base_pose.pose.position.y + self.left_hole_y
hole_pose_z = base_pose.pose.position.z + self.left_hole_z
elif block == 'C' or block == 'D':
hole_pose_x = base_pose.pose.position.x + self.right_hole_x
hole_pose_y = base_pose.pose.position.y + self.right_hole_y
hole_pose_z = base_pose.pose.position.z + self.right_hole_z
# Get curent end effector pose
init_ee_pose = np.array([
ee_pose_x,
ee_pose_y,
ee_pose_z
])
# Calculate place pose in configuration space
diff_ee_pose = np.array([
ee_pose_y - hole_pose_y,
ee_pose_x - hole_pose_x,
ee_pose_z - hole_pose_z
])
# Get terminal end effector pose as reverse of diff_ee_pose
term_ee_pose = -diff_ee_pose
new_command = (action_name, [init_ee_pose, diff_ee_pose, term_ee_pose])
elif action_name == 'stack':
robot, u_block, u_pose, grasp_diff_pose, \
term_robot_pose, l_block, l_pose = args
# Map symbolic block name to real block name
u_rigid_name = self.block_rigid_map[u_block]
l_rigid_name = self.block_rigid_map[l_block]
u_rigid_pose = mocap_poses[u_rigid_name]
l_rigid_pose = mocap_poses[l_rigid_name]
# Get hole pose
base_pose = mocap_poses['base']
if u_block == 'A' or u_block == 'B':
hole_pose_x = base_pose.pose.position.x + self.left_hole_x
hole_pose_y = base_pose.pose.position.y + self.left_hole_y
hole_pose_z = base_pose.pose.position.z + self.left_hole_z
elif u_block == 'C' or u_block == 'D':
hole_pose_x = base_pose.pose.position.x + self.right_hole_x
hole_pose_y = base_pose.pose.position.y + self.right_hole_y
hole_pose_z = base_pose.pose.position.z + self.right_hole_z
# Get curent end effector pose
init_ee_pose = np.array([
ee_pose_x,
ee_pose_y,
ee_pose_z
])
# Calculate stack pose in configuration space
diff_ee_pose = np.array([
ee_pose_y - hole_pose_y,
ee_pose_x - hole_pose_x,
ee_pose_z - hole_pose_z
])
# Get terminal end effector pose as reverse of diff_ee_pose
term_ee_pose = -diff_ee_pose
new_command = (action_name, [init_ee_pose, diff_ee_pose, term_ee_pose])
else:
pass
return new_command
| 18,528 |
Python
| 44.192683 | 103 | 0.489259 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/feedforward/execute_plan.py
|
#!/usr/bin/env/python3
import sys
import rospy
import hsrb_interface
import numpy as np
from scipy.spatial.transform import Rotation as R
# TODO: fix
sys.path.append('/root/tamp-hsr/hsr_tamp/experiments/env_2d/')
sys.path.append('..')
from tamp_planner import TAMPPlanner
from post_process import PlanModifier
from mocap_interface import MocapInterface
from tf_interface import TfManager
from controller_manager_msgs.srv import ListControllers
class ExecutePlan(object):
def __init__(self, grasp_type='side'):
# Initialize ROS node
rospy.init_node('execute_tamp_plan')
# Core module
self.tamp_planner = TAMPPlanner()
self.path_modifier = PlanModifier()
self.mocap_interface = MocapInterface()
self.tf_manager = TfManager()
# Initialize Robot
self.initialize_robot(grasp_type)
def initialize_robot(self, grasp_type='side'):
self.check_status()
# Get hsr python interface
self.robot = hsrb_interface.Robot()
self.omni_base = self.robot.get('omni_base')
self.gripper = self.robot.get('gripper')
self.whole_body = self.robot.get('whole_body')
# Initialize arm position
self.whole_body.move_to_go()
# Initialize base position
self.omni_base.go_abs(0.0, 0.0, 0.0, 300.0)
# Set base to configuration position
self.omni_base.go_abs(-0.8, 0.80, np.pi/2, 300.0)
# Set arm to neutral
self.whole_body.move_to_neutral()
# Set hsr to configuration pose
if grasp_type == 'side':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.25, y=0.0, z=0.0, ej=0.0),
], ref_frame_id='hand_palm_link')
# Fix base position using mocap data
gearbox_poses = self.mocap_interface.get_poses()
initial_pose = self.tf_manager.get_init_pose(gearbox_poses)
diff_x_pose, diff_y_pose, diff_z_pose = initial_pose[1], initial_pose[0], initial_pose[2]
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=0.0, y=-diff_y_pose, z=0.0)
], ref_frame_id='hand_palm_link')
elif grasp_type == 'top':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.25, y=0.0, z=0.0, ej=-np.pi/2),
], ref_frame_id='hand_palm_link')
# Fix base position using mocap data
gearbox_poses = self.mocap_interface.get_poses()
initial_pose = self.tf_manager.get_init_pose(gearbox_poses)
diff_x_pose, diff_y_pose, diff_z_pose = initial_pose[0], initial_pose[1], initial_pose[2]
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-diff_x_pose, y=-diff_y_pose, z=0.0)
], ref_frame_id='hand_palm_link')
# Open gripper
self.gripper.command(1.2)
def check_status(self):
# Make sure the controller is running
rospy.wait_for_service('/hsrb/controller_manager/list_controllers')
list_controllers = rospy.ServiceProxy('/hsrb/controller_manager/list_controllers', ListControllers)
running = False
while running is False:
rospy.sleep(0.1)
for c in list_controllers().controller:
if c.name == 'arm_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'head_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'gripper_controller' and c.state == 'running':
running |= True
if c.name == 'omni_base_controller' and c.state == 'running':
running |= True
return running
def plan(self):
# Run TAMP
plan, _, _ = self.tamp_planner.plan()
return plan
def process(self, action_name, args, grasp_type='side'):
# Get rigid body poses from mocap
mocap_poses = self.mocap_interface.get_poses()
# Modify plan
action_name, modified_action, ee_mode = self.path_modifier.post_process(action_name, args, mocap_poses, grasp_type)
return action_name, modified_action, ee_mode
def check_ee_mode(self):
# Get end effector pose
ee_pose = self.whole_body.get_end_effector_pose()
ee_rot = np.array([
ee_pose.ori.x,
ee_pose.ori.y,
ee_pose.ori.z,
ee_pose.ori.w
])
ee_euler = R.from_quat(ee_rot).as_euler('xyz')
# Check whether end effector is vertical to ground plane, or horizontal
if -0.8 < ee_euler[1] and 0.8 > ee_euler[1]:
ee_mode = 'vertical'
elif -2.0 < ee_euler[1] and -1.0 > ee_euler[1]:
ee_mode = 'horizontal'
return ee_mode
def execute(self, grasp_type='side'):
plan = self.plan()
if plan is None:
return None
for i, (action_name, args) in enumerate(plan):
# Post process TAMP commands to hsr executable actions
action_name, diff_ee_pose, ee_mode = self.process(action_name, args, grasp_type)
if action_name == 'move':
# Set end effector mode
ee_mode = self.check_ee_mode()
# Move to next pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[0],
y=diff_ee_pose[1],
z=diff_ee_pose[2]
),
], ref_frame_id='hand_palm_link')
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=-diff_ee_pose[1],
y=diff_ee_pose[0],
z=diff_ee_pose[2]
),
], ref_frame_id='hand_palm_link')
elif action_name == 'pick':
# Set impedance
self.whole_body.impedance_config = 'compliance_hard'
# Move to grasp pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[0],
y=diff_ee_pose[1],
),
], ref_frame_id='hand_palm_link')
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[0],
y=diff_ee_pose[1],
ek=-np.pi/2
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((0, 0, 1), diff_ee_pose[2])
# Grasp object
self.gripper.apply_force(0.8)
# Move to terminal pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_by_line((1, 0, 0), -diff_ee_pose[0])
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_by_line((0, 1, 0), -diff_ee_pose[0])
# Remove impedance
self.whole_body.impedance_config = None
elif action_name == 'place':
# Set impedance
self.whole_body.impedance_config = 'compliance_hard'
# Move to grasp pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
y=diff_ee_pose[1],
z=diff_ee_pose[2],
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((1, 0, 0), diff_ee_pose[0])
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=-diff_ee_pose[1],
z=diff_ee_pose[2],
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((0, 1, 0), diff_ee_pose[0])
# Release object
self.gripper.command(0.5)
# Move to terminal pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_by_line((1, 0, 0), -diff_ee_pose[0])
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
y=-diff_ee_pose[1],
z=-diff_ee_pose[2]-0.15,
),
], ref_frame_id='hand_palm_link')
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_by_line((0, 1, 0), -diff_ee_pose[0])
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[1],
z=-diff_ee_pose[2]-0.15,
ek=np.pi/2
),
], ref_frame_id='hand_palm_link')
# Remove impedance
self.whole_body.impedance_config = None
elif action_name == 'stack':
# Set impedance
self.whole_body.impedance_config = 'compliance_hard'
# Move to grasp pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
y=diff_ee_pose[1],
z=diff_ee_pose[2],
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((0, 1, 0), diff_ee_pose[0])
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=-diff_ee_pose[1],
z=diff_ee_pose[2],
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((0, 1, 0), diff_ee_pose[0])
# Release object
self.gripper.command(1.2)
# Move to terminal pose
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_by_line((1, 0, 0), -diff_ee_pose[0])
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
y=-diff_ee_pose[1],
z=-diff_ee_pose[2]-0.15,
),
], ref_frame_id='hand_palm_link')
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_by_line((0, 1, 0), -diff_ee_pose[0])
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[1],
z=-diff_ee_pose[2]-0.15,
ek=np.pi/2
),
], ref_frame_id='hand_palm_link')
# Remove impedance
self.whole_body.impedance_config = None
else:
continue
if __name__ == '__main__':
exec_plan = ExecutePlan()
exec_plan.execute()
| 12,041 |
Python
| 38.611842 | 123 | 0.487584 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/controller/ik_solver.py
|
import os
import sys
import glob
import random
import numpy as np
from scipy.spatial.transform import Rotation as R
from .utils import multiply, invert, all_between, compute_forward_kinematics, \
compute_inverse_kinematics, select_solution, USE_ALL, USE_CURRENT
from .hsrb_utils import get_link_pose, get_joint_positions, get_custom_limits
BASE_FRAME = 'base_footprint'
TORSO_JOINT = 'torso_lift_joint'
ROTATION_JOINT = 'joint_rz'
LIFT_JOINT = 'arm_lift_joint'
HSR_TOOL_FRAMES = {'arm': 'hand_palm_link'}
IK_FRAME = {'arm': 'hand_palm_link'}
def get_ik_lib():
lib_path = os.environ['PYTHONPATH'].split(':')[1] # TODO: modify
ik_lib_path = glob.glob(os.path.join(lib_path, '**/hsrb'), recursive=True)
return ik_lib_path[0]
#####################################
def get_tool_pose(arm):
sys.path.append(get_ik_lib())
from ikArm import armFK
arm_fk = {'arm': armFK}
ik_joints = ['world_joint', 'arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
conf = get_joint_positions(ik_joints)
assert len(conf) == 8
base_from_tool = compute_forward_kinematics(arm_fk[arm], conf)
world_from_base = get_link_pose(BASE_FRAME)
return multiply(world_from_base, base_from_tool)
#####################################
def get_ik_generator(arm, ik_pose, custom_limits={}):
sys.path.append(get_ik_lib())
from ikArm import armIK
arm_ik = {'arm': armIK}
base_joints = ['odom_x', 'odom_y', 'odom_t']
arm_joints = ['arm_lift_joint', 'arm_flex_joint', 'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
min_limits, max_limits = get_custom_limits(base_joints, arm_joints, custom_limits)
arm_rot = R.from_quat(ik_pose[1]).as_euler('xyz')[0]
sampled_limits = [(arm_rot-np.pi, arm_rot-np.pi), (0.0, 0.34)]
while True:
sampled_values = [random.uniform(*limits) for limits in sampled_limits]
confs = compute_inverse_kinematics(arm_ik[arm], ik_pose, sampled_values)
solutions = [q for q in confs if all_between(min_limits, q, max_limits)]
yield solutions
if all(lower == upper for lower, upper in sampled_limits):
break
def get_tool_from_ik(arm):
world_from_tool = get_link_pose(HSR_TOOL_FRAMES[arm])
world_from_ik = get_link_pose(IK_FRAME[arm])
return multiply(invert(world_from_tool), world_from_ik)
def sample_tool_ik(arm, tool_pose, nearby_conf=USE_CURRENT, max_attempts=100, **kwargs):
generator = get_ik_generator(arm, tool_pose, **kwargs)
whole_body_joints = ['world_joint', 'arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
for _ in range(max_attempts):
try:
solutions = next(generator)
if solutions:
return select_solution(whole_body_joints, solutions, nearby_conf=nearby_conf)
except StopIteration:
break
return None
def hsr_inverse_kinematics(arm, gripper_pose, custom_limits={}, **kwargs):
base_arm_conf = sample_tool_ik(arm, gripper_pose, custom_limits=custom_limits, **kwargs)
if base_arm_conf is None:
return None
return base_arm_conf
if __name__ == '__main__':
# test forward kinematics
fk_pose = get_tool_pose('arm')
print('fk_pose:', fk_pose)
# test inverse kinematics
import numpy as np
pos_x = 0.0
pos_y = 0.0
pos_z = 0.6
foward = (0.70710678, 0.0, 0.70710678, 0.0)
back = (0.0, -0.70710678, 0.0, 0.70710678)
right = (0.5, -0.5, 0.5, 0.5)
left = (0.5, 0.5, 0.5, -0.5)
pose = ((pos_x, pos_y, pos_z), foward)
print('pose:', pose)
ik_pose = hsr_inverse_kinematics('arm', pose)
print('ik_pose:', ik_pose)
# test inverse kinematics generator
import time
for i in range(100):
start = time.time()
pose_x = 2.5
pose_y = 2.0
pose_z = 0.6
tool_pose = ((pose_x, pose_y, pose_z), (0.707107, 0.0, 0.707107, 0.0))
generator = get_ik_generator('arm', tool_pose)
solutions = next(generator)
print(solutions)
print('Loop Hz:', 1/(time.time()-start))
| 4,179 |
Python
| 33.545454 | 111 | 0.615219 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/controller/hsrb_utils.py
|
import rospy
import numpy as np
import hsrb_interface
from scipy.spatial.transform import Rotation as R
robot = hsrb_interface.Robot()
base = robot.get('omni_base')
gripper = robot.get('gripper')
whole_body = robot.get('whole_body')
def get_link_pose(link):
tf_pose = whole_body._tf2_buffer.lookup_transform('map', link, rospy.Time(0))
link_pose = ((tf_pose.transform.translation.x,
tf_pose.transform.translation.y,
tf_pose.transform.translation.z),
(tf_pose.transform.rotation.x,
tf_pose.transform.rotation.y,
tf_pose.transform.rotation.z,
tf_pose.transform.rotation.w))
return link_pose
def get_joint_limits(joint):
if joint == 'odom_x':
limit = (-10.0, 10.0)
elif joint == 'odom_y':
limit = (-10.0, 10.0)
elif joint == 'odom_t':
limit = (-10.0, 10.0)
else:
limit = whole_body.joint_limits[joint]
return limit
def get_custom_limits(base_joints, arm_joints, custom_limits={}):
joint_limits = []
for joint in base_joints:
if joint in custom_limits:
joint_limits.append(custom_limits[joint])
else:
joint_limits.append(get_joint_limits(joint))
for joint in arm_joints:
if joint in custom_limits:
joint_limits.append(custom_limits[joint])
else:
joint_limits.append(get_joint_limits(joint))
return zip(*joint_limits)
def get_distance(p1, p2, **kwargs):
assert len(p1) == len(p2)
diff = np.array(p2) - np.array(p1)
return np.linalg.norm(diff, ord=2)
def get_joint_position(joint):
if joint == 'world_joint':
joint_position = base.pose
else:
joint_position = whole_body.joint_positions[joint]
return joint_position
def get_joint_positions(jonits):
joint_positions = []
for joint in jonits:
if joint == 'world_joint':
base_pose = base._tf2_buffer.lookup_transform('map', 'base_footprint', rospy.Time(0))
joint_positions.append(base_pose.transform.translation.x)
joint_positions.append(base_pose.transform.translation.y)
base_quat = np.array([base_pose.transform.rotation.x,
base_pose.transform.rotation.y,
base_pose.transform.rotation.z,
base_pose.transform.rotation.w])
base_rz = R.from_quat(base_quat).as_euler('xyz')[2]
joint_positions.append(base_rz)
else:
joint_positions.append(whole_body.joint_positions[joint])
return joint_positions
if __name__ == '__main__':
# Test get_link_pose
base_link_pose = get_link_pose('base_footprint')
print('base_link_pose:', base_link_pose)
hand_palm_link_pose = get_link_pose('hand_palm_link')
print('hand_palm_link_pose:', hand_palm_link_pose)
# Test get_custom_limits
base_joints = ['odom_x', 'odom_y', 'odom_t']
arm_joints = ['arm_lift_joint', 'arm_flex_joint', 'arm_roll_joint',
'wrist_flex_joint', 'wrist_roll_joint']
custom_limits = get_custom_limits(base_joints, arm_joints)
print('custom_limits:', custom_limits)
# Test get_joint_limits
for b_joint in base_joints:
joint_limit = get_joint_limits(b_joint)
print('joint_limit:', joint_limit)
for a_joint in arm_joints:
joint_limit = get_joint_limits(a_joint)
print('joint_limit:', joint_limit)
# Test get_joint_position
ik_joints = ['world_joint', 'arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
for joint in ik_joints:
joint_position = get_joint_position(joint)
print('joint_position:', joint_position)
# Test get_joint_positions
joint_positions = get_joint_positions(ik_joints)
print('joint_positions:', joint_positions)
| 3,904 |
Python
| 35.495327 | 97 | 0.615523 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/controller/ik_controller.py
|
import rospy
import numpy as np
from .controller import Controller
from .ik_solver import get_tool_pose, get_ik_generator, hsr_inverse_kinematics
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
class IKController(Controller):
def __init__(self):
super(IKController, self).__init__()
# Publisher
self.arm_pub = rospy.Publisher('/hsrb/arm_trajectory_controller/command', JointTrajectory, queue_size=10)
self.base_pub = rospy.Publisher('/hsrb/omni_base_controller/command', JointTrajectory, queue_size=10)
# Wait for publisher has built
while self.base_pub.get_num_connections() == 0:
rospy.sleep(0.1)
while self.arm_pub.get_num_connections() == 0:
rospy.sleep(0.1)
def set_pose(self, base_pose, joint_pose):
base_traj = JointTrajectory()
arm_traj = JointTrajectory()
base_traj.joint_names = ['odom_x', 'odom_y', 'odom_t']
arm_traj.joint_names = ['arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
# Set base trajectory
assert len(base_pose) == 3, "Does not match the size of base pose"
base_p = JointTrajectoryPoint()
base_p.positions = base_pose
base_p.velocities = np.zeros(len(base_pose))
base_p.time_from_start = rospy.Duration(1)
base_traj.points = [base_p]
# Set arm trajectory
assert len(joint_pose) == 5, "Does not match the size of base pose"
arm_p = JointTrajectoryPoint()
arm_p.positions = joint_pose
arm_p.velocities = np.zeros(len(joint_pose))
arm_p.time_from_start = rospy.Duration(1)
arm_traj.points = [arm_p]
return base_traj, arm_traj
def control(self, pose):
# Inverse kinematics
ik_pose = hsr_inverse_kinematics('arm', pose) # pose must be contain (pos, quat)
if ik_pose is None:
return
else:
base_pose, arm_pose = ik_pose[:3], ik_pose[3:]
# Set target pose
base_traj, arm_traj = self.set_pose(base_pose, arm_pose)
# Publish target pose
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
if __name__ == '__main__':
ik_controller = IKController()
rate = rospy.Rate(50)
pose_x = 0.0
pose_y = 0.0
pose_z = 0.5
foward = (0.70710678, 0.0, 0.70710678, 0.0)
back = (0.0, -0.70710678, 0.0, 0.70710678)
right = (0.5, -0.5, 0.5, 0.5)
left = (0.5, 0.5, 0.5, -0.5)
while not rospy.is_shutdown():
# Test forward kinematics
fk_pose = get_tool_pose('arm')
# Test inverse kinematics
tool_pose = ((pose_x, pose_y, pose_z), foward)
ik_controller.control(tool_pose)
# Sleep
rate.sleep()
| 2,848 |
Python
| 32.517647 | 113 | 0.596559 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/controller/controller.py
|
import rospy
import numpy as np
class Controller(object):
def __init__(self):
pass
def set_pose(self):
raise NotImplementedError("Implement set_pose method")
def control(self):
raise NotImplementedError("Implement control method")
| 271 |
Python
| 18.42857 | 62 | 0.671587 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_2d/script/controller/utils.py
|
import random
import numpy as np
import pybullet as p
from collections import namedtuple
from scipy.spatial.transform import Rotation as R
from .hsrb_utils import get_joint_limits, get_joint_position, get_joint_positions, get_distance
IKFastInfo = namedtuple('IKFastInfo', ['module_name', 'base_link', 'ee_link', 'free_joints'])
USE_ALL = False
USE_CURRENT = None
############ Mathematics
def invert(pose):
point, quat = pose
return p.invertTransform(point, quat) # TODO: modify
def multiply(*poses):
pose = poses[0]
for next_pose in poses[1:]:
pose = p.multiplyTransforms(pose[0], pose[1], *next_pose) # TODO: modify
return pose
##############
def all_between(lower_limits, values, upper_limits):
assert len(lower_limits) == len(values)
assert len(values) == len(upper_limits)
return np.less_equal(lower_limits, values).all() and \
np.less_equal(values, upper_limits).all()
def compute_forward_kinematics(fk_fn, conf):
pose = fk_fn(list(conf))
pos, rot = pose
quat = R.from_matrix(rot).as_quat()
return pos, quat
def compute_inverse_kinematics(ik_fn, pose, sampled=[]):
pos, quat = pose[0], pose[1]
rot = R.from_quat(quat).as_matrix().tolist()
if len(sampled) == 0:
solutions = ik_fn(list(rot), list(pos))
else:
solutions = ik_fn(list(rot), list(pos), list(sampled))
if solutions is None:
return []
return solutions
def get_ik_limits(joint, limits=USE_ALL):
if limits is USE_ALL:
return get_joint_limits(joint)
elif limits is USE_CURRENT:
value = get_joint_position(joint)
return value, value
return limits
def select_solution(joints, solutions, nearby_conf=USE_ALL, **kwargs):
if not solutions:
return None
if nearby_conf is USE_ALL:
return random.choice(solutions)
if nearby_conf is USE_CURRENT:
nearby_conf = get_joint_positions(joints)
return min(solutions, key=lambda conf: get_distance(nearby_conf, conf, **kwargs))
| 2,034 |
Python
| 26.133333 | 95 | 0.656834 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/hsr_interface.py
|
#!/usr/bin/env/python3
import rospy
import hsrb_interface
import numpy as np
from scipy.spatial.transform import Rotation as R
from controller_manager_msgs.srv import ListControllers
from control_msgs.msg import JointTrajectoryControllerState
class HSRInterface(object):
def __init__(self, standalone=False):
# Initialize ROS node
if standalone:
rospy.init_node('hsr_interface')
# Check server status
self.check_status()
self.robot = hsrb_interface.Robot()
self.omni_base = self.robot.get('omni_base')
self.gripper = self.robot.get('gripper')
self.whole_body = self.robot.get('whole_body')
self.base_sub = rospy.Subscriber('/hsrb/omni_base_controller/state', JointTrajectoryControllerState, self.base_callback)
self.arm_sub = rospy.Subscriber('/hsrb/arm_trajectory_controller/state', JointTrajectoryControllerState, self.arm_callback)
self.base_pos, self.base_vel, self.base_acc = None, None, None
self.arm_pos, self.arm_vel, self.arm_acc = None, None, None
self.base_joints = ['joint_x', 'joint_y', 'joint_rz']
self.arm_joints = ['arm_lift_joint', 'arm_flex_joint', 'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
self.joint_ids_to_name = {'joint_x': 0, 'joint_y': 1, 'joint_rz': 2,
'arm_lift_joint': 0, 'arm_flex_joint': 1, 'arm_roll_joint': 2,
'wrist_flex_joint': 3, 'wrist_roll_joint': 4}
def initialize_arm(self):
# Initialize arm position
self.whole_body.move_to_go()
# Set TAMP pose
self.whole_body.move_to_joint_positions({
'arm_lift_joint': 0.1,
'arm_flex_joint': -np.pi/2,
'arm_roll_joint': 0.0,
'wrist_flex_joint': 0.0,
'wrist_roll_joint': 0.0,
})
def initialize_base(self):
# Initialize base position
self.omni_base.go_abs(0.0, 0.0, 0.0, 300.0)
def set_task_pose(self, grasp_type='side'):
# Set base to configuration position
self.omni_base.go_abs(-0.80, 0.75, np.pi/2, 300.0)
# Set arm to configuration pose
self.whole_body.move_to_neutral()
if grasp_type == 'side':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.3, y=0.0, z=0.0, ej=0.0),
], ref_frame_id='hand_palm_link')
elif grasp_type == 'top':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.3, y=0.0, z=0.0, ej=-1.57),
], ref_frame_id='hand_palm_link')
# Open gripper
self.gripper.command(1.2)
def fix_task_pose(self, diff_pose):
diff_x_pose, diff_y_pose, diff_z_pose = diff_pose[0], diff_pose[1], diff_pose[2]
if np.abs(diff_z_pose) < 0.1:
diff_z_pose = -0.12
else:
diff_z_pose = 0.0
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=0.0, y=diff_y_pose, z=diff_z_pose)
], ref_frame_id='hand_palm_link')
def check_status(self):
# Make sure the controller is running
rospy.wait_for_service('/hsrb/controller_manager/list_controllers')
list_controllers = rospy.ServiceProxy('/hsrb/controller_manager/list_controllers', ListControllers)
running = False
while running is False:
rospy.sleep(0.1)
for c in list_controllers().controller:
if c.name == 'arm_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'head_trajectory_controller' and c.state == 'running':
running |= True
if c.name == 'gripper_controller' and c.state == 'running':
running |= True
if c.name == 'omni_base_controller' and c.state == 'running':
running |= True
return running
def close_gripper(self, force=0.5):
self.gripper.apply_force(force)
def open_gripper(self, width=1.0):
self.gripper.command(width)
def insert_object(self, ee_mode):
if ee_mode == 'horizontal':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=-0.03, y=0.0, z=0.0),
], ref_frame_id='hand_palm_link')
elif ee_mode == 'vertical':
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(x=0.0, y=-0.03, z=0.0),
], ref_frame_id='hand_palm_link')
def grasp_gear(self, diff_ee_pose, pick_offset=0.1):
# Open gripper
self.open_gripper(0.5)
# Move to grasp
self.whole_body.move_end_effector_by_line((0, 0, 1), -pick_offset)
self.whole_body.move_end_effector_pose([
hsrb_interface.geometry.pose(
x=diff_ee_pose[0],
y=diff_ee_pose[1],
ek=-np.pi/2
),
], ref_frame_id='hand_palm_link')
self.whole_body.move_end_effector_by_line((0, 0, 1), diff_ee_pose[2]+pick_offset)
# Close gripper
self.close_gripper(0.5)
def get_link_pose(self, link):
tf_pose = self.whole_body._tf2_buffer.lookup_transform('map', link, rospy.Time(0))
link_pose = [[tf_pose.transform.translation.x,
tf_pose.transform.translation.y,
tf_pose.transform.translation.z],
[tf_pose.transform.rotation.x,
tf_pose.transform.rotation.y,
tf_pose.transform.rotation.z,
tf_pose.transform.rotation.w]]
return link_pose
def get_joint_limits(self, joint):
if joint == 'odom_x':
limit = (-10.0, 10.0)
elif joint == 'odom_y':
limit = (-10.0, 10.0)
elif joint == 'odom_t':
limit = (-10.0, 10.0)
else:
limit = self.whole_body.joint_limits[joint]
return limit
def get_custom_limits(self, base_joints, arm_joints, custom_limits={}):
joint_limits = []
for joint in base_joints:
if joint in custom_limits:
joint_limits.append(custom_limits[joint])
else:
joint_limits.append(self.get_joint_limits(joint))
for joint in arm_joints:
if joint in custom_limits:
joint_limits.append(custom_limits[joint])
else:
joint_limits.append(self.get_joint_limits(joint))
return zip(*joint_limits)
def get_distance(self, p1, p2, **kwargs):
assert len(p1) == len(p2)
diff = np.array(p2) - np.array(p1)
return np.linalg.norm(diff, ord=2)
def get_joint_position(self, joint, group=None):
if group == 'base':
joint_position = self.base_pos[self.joint_ids_to_name[joint]]
elif group == 'arm':
joint_position = self.arm_pos[self.joint_ids_to_name[joint]]
else:
raise ValueError(joint)
return joint_position
def get_joint_positions(self, group=None):
joint_positions = []
if group == 'base':
for base_joint in self.base_joints:
base_pos = self.get_joint_position(base_joint, 'base')
joint_positions.append(base_pos)
elif group == 'arm':
for arm_joint in self.arm_joints:
arm_pos = self.get_joint_position(arm_joint, 'arm')
joint_positions.append(arm_pos)
else:
for base_joint in self.base_joints:
base_pos = self.get_joint_position(base_joint, 'base')
joint_positions.append(base_pos)
for arm_joint in self.arm_joints:
arm_pos = self.get_joint_position(arm_joint, 'arm')
joint_positions.append(arm_pos)
return joint_positions
def get_joint_velocity(self, joint, group=None):
if group == 'base':
joint_velocity = self.base_vel[self.joint_ids_to_name[joint]]
elif group == 'arm':
joint_velocity = self.arm_vel[self.joint_ids_to_name[joint]]
else:
raise ValueError(joint)
return joint_velocity
def get_joint_velocities(self, group=None):
joint_velocities = []
if group == 'base':
for base_joint in self.base_joints:
joint_vel = self.get_joint_velocity(base_joint, 'base')
joint_velocities.append(joint_vel)
elif group == 'arm':
for arm_joint in self.arm_joints:
joint_vel = self.get_joint_velocity(arm_joint, 'arm')
joint_velocities.append(joint_vel)
else:
for base_joint in self.base_joints:
joint_vel = self.get_joint_velocity(base_joint, 'base')
joint_velocities.append(joint_vel)
for arm_joint in self.arm_joints:
joint_vel = self.get_joint_velocity(arm_joint, 'arm')
joint_velocities.append(joint_vel)
return joint_velocities
def get_joint_acceleration(self, joint, group=None):
if group == 'base':
joint_acceleration = self.base_acc[self.joint_ids_to_name[joint]]
elif group == 'arm':
joint_acceleration = self.arm_acc[self.joint_ids_to_name[joint]]
else:
raise ValueError(joint)
return joint_acceleration
def get_joint_accelerations(self, group=None):
joint_acceralataions = []
if group == 'base':
for base_joint in self.base_joints:
joint_acc = self.get_joint_acceleration(base_joint, 'base')
joint_acceralataions.append(joint_acc)
elif group == 'arm':
for arm_joint in self.arm_joints:
joint_acc = self.get_joint_acceleration(arm_joint, 'arm')
joint_acceralataions.append(joint_acc)
else:
for base_joint in self.base_joints:
joint_acc = self.get_joint_acceleration(base_joint, 'base')
joint_acceralataions.append(joint_acc)
for arm_joint in self.arm_joints:
joint_acc = self.get_joint_acceleration(arm_joint, 'arm')
joint_acceralataions.append(joint_acc)
return joint_acceralataions
def base_callback(self, data):
self.base_pos = data.actual.positions
self.base_vel = data.actual.velocities
self.base_acc = data.actual.accelerations
def arm_callback(self, data):
self.arm_pos = data.actual.positions
self.arm_vel = data.actual.velocities
self.arm_acc = data.actual.accelerations
if __name__ == '__main__':
hsr_interface = HSRInterface()
hsr_interface.initialize_arm()
hsr_interface.initialize_base()
print('positions:', hsr_interface.get_joint_positions())
print('velocities:', hsr_interface.get_joint_velocities())
| 11,059 |
Python
| 38.784173 | 131 | 0.570757 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/mocap_interface.py
|
#!/bin/env/python3
import rospy
import numpy as np
from ros_numpy import numpify
from geometry_msgs.msg import PoseStamped
from scipy.spatial.transform import Rotation as R
class MocapInterface(object):
def __init__(self, standalone=False):
if standalone:
rospy.init_node('mocap_interface')
# Mocap list
self.rigid_body_list = (
"base",
"gear1",
"gear2",
"gear3",
"shaft1",
"shaft2",
"end_effector"
)
# Mocap to map
self.translation = np.array([0.0, 0.0, 0.0])
self.rotation = np.array([
[0.0, 0.0, 1.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0]
])
# Rigid body pose dictionary
self.rigid_posestamped = {
name: PoseStamped() for name in self.rigid_body_list
}
# Subscriber
self._mocap_sub = [
rospy.Subscriber('/mocap_pose_topic/{0}_pose'.format(self.rigid_body_list[i]), PoseStamped, self._mocap_cb, callback_args=i)
for i in range(len(self.rigid_body_list))
]
def _mocap_cb(self, mocap_data, id):
converted_pose = self.convert_mocap_to_map(mocap_data)
mocap_data.header.frame_id = 'map'
mocap_data.pose.position.x = converted_pose[0]
mocap_data.pose.position.y = converted_pose[1]
mocap_data.pose.position.z = converted_pose[2]
mocap_data.pose.orientation.x = converted_pose[3]
mocap_data.pose.orientation.y = converted_pose[4]
mocap_data.pose.orientation.z = converted_pose[5]
mocap_data.pose.orientation.w = converted_pose[6]
self.rigid_posestamped[self.rigid_body_list[id]] = mocap_data
def get_pose(self, name):
pos = numpify(self.rigid_posestamped[name].pose.position)
orn = numpify(self.rigid_posestamped[name].pose.orientation)
return [pos, orn]
def get_poses(self):
rigid_poses = {}
for name, pose_stamped in self.rigid_posestamped.items():
pos = numpify(pose_stamped.pose.position)
orn = numpify(pose_stamped.pose.orientation)
rigid_poses[name] = [pos, orn]
return rigid_poses
def convert_mocap_to_map(self, mocap_data):
# Initialize vector and matrix
trans_mat = np.zeros((4, 4))
qc_trans = np.zeros(4)
qc_rot = np.zeros(4)
# Calculate translation
qc_trans[0] = mocap_data.pose.position.x
qc_trans[1] = mocap_data.pose.position.y
qc_trans[2] = mocap_data.pose.position.z
qc_trans[3] = 1.0
trans_mat[3:, 3:] = 1.0
trans_mat[:3, 3] = self.translation
trans_mat[:3, :3] = self.rotation
qw_trans = trans_mat @ qc_trans
qw_trans = qw_trans[:3]
# Calculate rotation
qc_rot[0] = mocap_data.pose.orientation.x
qc_rot[1] = mocap_data.pose.orientation.y
qc_rot[2] = mocap_data.pose.orientation.z
qc_rot[3] = mocap_data.pose.orientation.w
qc_rot_mat = R.from_quat(qc_rot).as_matrix()
qw_rot_mat = self.rotation @ qc_rot_mat
qw_rot = R.from_matrix(qw_rot_mat).as_quat()
return np.concatenate([qw_trans, qw_rot])
if __name__ == '__main__':
mocap_interface = MocapInterface(standalone=True)
while not rospy.is_shutdown():
# Test each rigid body
base_pose = mocap_interface.get_pose('base')
print('base_pose: ', base_pose)
green_gear_pose = mocap_interface.get_pose('gear1')
print('green_gear_pose: ', green_gear_pose)
blue_gear_pose = mocap_interface.get_pose('gear2')
print('blue_gear_pose: ', blue_gear_pose)
red_gear_pose = mocap_interface.get_pose('gear3')
print('red_gear_pose: ', red_gear_pose)
red_shaft_pose = mocap_interface.get_pose('shaft1')
print('red_shaft_pose: ', red_shaft_pose)
yellow_shaft_pose = mocap_interface.get_pose('shaft2')
print('yellow_shaft_pose: ', yellow_shaft_pose)
end_effector_pose = mocap_interface.get_pose('end_effector')
print('end_effector_pose: ', end_effector_pose)
# Test all rigid bodies
rigid_poses = mocap_interface.get_poses()
print('rigid_poses: ', rigid_poses['gear1'])
| 4,331 |
Python
| 34.219512 | 136 | 0.587162 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/feedback/test_plan.py
|
#!/usr/bin/env/python3
import sys
import rospy
import numpy as np
from scipy.spatial.transform import Rotation as R
# TODO: fix
sys.path.append('/root/tamp-hsr/hsr_tamp/experiments/env_3d/')
sys.path.append('..')
from tamp_planner import TAMPPlanner
from hsr_interface import HSRInterface
from force_sensor_interface import ForceSensorInterface
from post_process import PlanModifier
from mocap_interface import MocapInterface
from tf_interface import TfManager
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
class ExecutePlan(object):
def __init__(self):
# Initialize ROS node
rospy.init_node('execute_tamp_plan')
# Feedback rate
self.control_freq = 3
self.rate = rospy.Rate(self.control_freq)
# Threshold
self.move_threshold = 0.05
self.pick_threshold = 0.05
self.place_threshold = 0.04
self.stack_threshold = 0.032
self.weight_threshold = 500
# Core module
self.tamp_planner = TAMPPlanner()
self.hsr_interface = HSRInterface()
self.tf_manager = TfManager()
self.path_modifier = PlanModifier()
self.mocap_interface = MocapInterface()
self.ft_interface = ForceSensorInterface()
# Publisher
self.arm_pub = rospy.Publisher('/hsrb/arm_trajectory_controller/command', JointTrajectory, queue_size=10)
self.base_pub = rospy.Publisher('/hsrb/omni_base_controller/command', JointTrajectory, queue_size=10)
# Initialize Robot
self.initialize_robot()
# Initialize TAMP
self.initialize_tamp()
# Reset dataset
self.reset_dataset()
def reset_dataset(self):
self.measured_ee_traj = []
self.measured_joint_traj = []
def initialize_robot(self):
self.check_status()
# Set gripper to configuration position
self.hsr_interface.open_gripper()
# Set arm to configuration position
self.hsr_interface.initialize_arm()
# Set base to configuration position
self.hsr_interface.initialize_base()
def initialize_tamp(self):
# Get object poses
object_poses = self.mocap_interface.get_poses()
# Get robot poses
self.robot_joints = ['joint_x', 'joint_y', 'joint_rz', 'arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
robot_poses = self.hsr_interface.get_joint_positions()
# Initialize tamp simulator
observations = (robot_poses, object_poses)
self.tamp_planner.initialize(observations)
def set_base_pose(self, base_pose):
base_traj = JointTrajectory()
base_traj.joint_names = ['odom_x', 'odom_y', 'odom_t']
# Set base trajectory
assert len(base_pose) == 3, "Does not match the size of base pose"
base_p = JointTrajectoryPoint()
base_p.positions = base_pose
base_p.velocities = np.zeros(len(base_pose))
base_p.time_from_start = rospy.Duration(1)
base_traj.points = [base_p]
return base_traj
def set_arm_pose(self, arm_pose):
arm_traj = JointTrajectory()
arm_traj.joint_names = ['arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
# Set arm trajectory
assert len(arm_pose) == 5, "Does not match the size of base pose"
arm_p = JointTrajectoryPoint()
arm_p.positions = arm_pose
arm_p.velocities = np.zeros(len(arm_pose))
arm_p.time_from_start = rospy.Duration(1)
arm_traj.points = [arm_p]
return arm_traj
def check_status(self):
# Wait for publisher has built
while self.base_pub.get_num_connections() == 0:
rospy.sleep(0.1)
while self.arm_pub.get_num_connections() == 0:
rospy.sleep(0.1)
def plan(self):
# Run TAMP
plan, _, _ = self.tamp_planner.plan()
return plan
def process(self, action_name, args):
# Modify plan
action_name, modified_action = self.path_modifier.post_process(action_name, args)
return action_name, modified_action
def calculate_base_command(self, target_pose):
curr_pose = self.hsr_interface.get_joint_positions(group='base')
curr_vel = self.hsr_interface.get_joint_velocities(group='base')
delta_pose = np.array(target_pose) - np.array(curr_pose)
kp = 1.0
D = 1.0
kd = 2 * np.sqrt(kp) * D
command = kp * delta_pose + kd * curr_vel
command += np.array(curr_pose)
return command
def calculate_arm_command(self, target_pose):
curr_pose = self.hsr_interface.get_joint_positions(group='arm')
curr_vel = self.hsr_interface.get_joint_velocities(group='arm')
delta_pose = np.array(target_pose) - np.array(curr_pose)
kp = 1.0
D = 1.0
kd = 2 * np.sqrt(kp) * D
command = kp * delta_pose + kd * curr_vel
command += np.array(curr_pose)
return command
def execute(self):
plan = self.plan()
if plan is None:
return None
for i, (action_name, args) in enumerate(plan):
# Post process TAMP commands to hsr executable actions
action_name, modified_action = self.process(action_name, args)
if action_name == 'move_base':
for target_pose in modified_action:
target_base_pose = self.calculate_base_command(target_pose[:3])
base_traj = self.set_base_pose(target_base_pose)
self.base_pub.publish(base_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
elif action_name == 'pick':
pick_traj, return_traj = modified_action
for target_pose in pick_traj: # pick
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
# rospy.sleep(5.0)
# self.hsr_interface.close_gripper()
for target_pose in return_traj: # return
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
elif action_name == 'place':
place_traj = modified_action
for target_pose in place_traj: # place
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
elif action_name == 'insert':
insert_traj, depart_traj, return_traj = modified_action
for target_pose in insert_traj: # insert
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
# rospy.sleep(5.0)
# self.hsr_interface.open_gripper()
for target_pose in depart_traj: # depart
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
for target_pose in return_traj: # return
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
# Get measured/true EE traj
measured_ee_pose = self.hsr_interface.get_link_pose('hand_palm_link')
self.measured_ee_traj.append(measured_ee_pose)
# Get measured joint traj
measured_joint_pos = self.hsr_interface.get_joint_positions()
self.measured_joint_traj.append(measured_joint_pos)
self.rate.sleep()
else:
continue
self.save_traj()
def save_traj(self):
np.save(f'measured_ee_traj', self.measured_ee_traj)
np.save(f'measured_joint_traj', self.measured_joint_traj)
if __name__ == '__main__':
exec_plan = ExecutePlan()
exec_plan.execute()
| 12,401 |
Python
| 38.496815 | 113 | 0.569148 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/feedback/post_process.py
|
#!/usr/bin/env/python3
import numpy as np
class PlanModifier(object):
def __init__(self):
self.block_rigid_map = {
'A' : 'red_shaft',
'B' : 'green_gear',
'C' : 'yellow_shaft',
'D' : 'blue_gear',
'E' : 'red_gear'
}
def post_process(self, action_name, args):
"""
Modify plan using sensor data.
Args:
plan (list): plan is trajectory of the tamp.
robot_pose (list): robot_pose consists of base_pose, end_effector_pose, gripper.
rigid_poses (dict): rigid_pose consists of captured rigid body poses
Returns:
commands (list): commands is modified plan
"""
if action_name == 'move_base':
# Parse TAMP returns
start_pose, end_pose, traj = args
base_traj = []
for commands in traj.commands:
for path in commands.path:
base_traj.append(path.values)
new_command = (action_name, base_traj)
elif action_name == 'pick':
arm, block, init_block_pose, grasp_pose, term_robot_pose, traj = args
[traj_pick] = traj.commands
pick_traj = []
for path in traj_pick.path:
pick_traj.append(path.values)
return_traj = []
for path in traj_pick.reverse().path:
return_traj.append(path.values)
new_command = (action_name, (pick_traj, return_traj))
elif action_name == 'place':
arm, block1, block2, init_block_pose, grasp_pose, term_robot_pose, traj = args
[traj_place] = traj.commands
place_traj = []
for path in traj_place.path:
place_traj.append(path.values)
new_command = (action_name, (place_traj))
elif action_name == 'insert':
arm, block1, block2, block_pose1, block_pose2, grasp_pose, _, _, traj = args
[traj_insert, traj_depart, traj_return] = traj.commands
insert_traj = []
for path in traj_insert.path:
insert_traj.append(path.values)
depart_traj = []
for path in traj_depart.path:
depart_traj.append(path.values)
return_traj = []
for path in traj_return.reverse().path:
return_traj.append(path.values)
new_command = (action_name, (insert_traj, depart_traj, return_traj))
else:
pass
return new_command
| 2,576 |
Python
| 30.426829 | 92 | 0.522904 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/rl_policy/rl_agent.py
|
#!/usr/bin/env python3
import gym
import copy
import torch
import numpy as np
from rl_games.algos_torch import model_builder, torch_ext
def rescale_actions(low, high, action):
d = (high - low) / 2.0
m = (high + low) / 2.0
scaled_action = action * d + m
return scaled_action
class ResidualRL(object):
def __init__(self, params):
builder = model_builder.ModelBuilder()
self.network = builder.load(params)
self.states = None
self.batch_size = 1
self.config = params['config']
self.clip_actions = self.config['clip_actions']
self.normalize_input = self.config['normalize_input']
self.normalize_value = self.config['normalize_value']
self.device = 'cuda'
self.num_actions = self.config['num_actions']
self.num_observations = self.config['num_observations']
self.action_space = gym.spaces.Box(np.ones(self.num_actions) * -1.0, np.ones(self.num_actions) * 1.0)
self.actions_num = self.action_space.shape[0]
self.actions_low = torch.from_numpy(self.action_space.low.copy()).float().to(self.device)
self.actions_high = torch.from_numpy(self.action_space.high.copy()).float().to(self.device)
self.mask = [False]
self.observation_space = gym.spaces.Box(np.ones(self.num_observations) * -np.Inf, np.ones(self.num_observations) * np.Inf)
obs_shape = self.observation_space.shape
config = {
'actions_num' : self.actions_num,
'input_shape' : obs_shape,
'num_seqs' : self.config['num_actors'],
'value_size': self.config.get('value_size', 1),
'normalize_value': self.normalize_value,
'normalize_input': self.normalize_input,
}
self.model = self.network.build(config)
self.model.to(self.device)
self.model.eval()
self.is_rnn = self.model.is_rnn()
def get_action(self, obs, is_determenistic=True):
obs = self.unsqueeze_obs(obs)
obs = self.preprocess_obs(obs)
input_dict = {
'is_train': False,
'prev_actions': None,
'obs' : obs,
'rnn_states' : self.states
}
with torch.no_grad():
res_dict = self.model(input_dict)
mu = res_dict['mus']
action = res_dict['actions']
self.states = res_dict['rnn_states']
if is_determenistic:
current_action = mu
else:
current_action = action
if self.clip_actions:
return rescale_actions(self.actions_low, self.actions_high, torch.clamp(current_action, -1.0, 1.0))
else:
return current_action
def unsqueeze_obs(self, obs):
if type(obs) is dict:
for k, v in obs.items():
obs[k] = self.unsqueeze_obs(v)
else:
if len(obs.size()) > 1 or obs.size()[0] > 1:
obs = obs.unsqueeze(0)
return obs
def preprocess_obs(self, obs):
if type(obs) is dict:
obs = copy.copy(obs)
for k, v in obs.items():
if v.dtype == torch.uint8:
obs[k] = v.float() / 255.0
else:
obs[k] = v.float()
else:
if obs.dtype == torch.uint8:
obs = obs.float() / 255.0
return obs
def restore(self, fn):
checkpoint = torch_ext.load_checkpoint(fn)
self.model.load_state_dict(checkpoint['model'])
if self.normalize_input and 'running_mean_std' in checkpoint:
self.model.running_mean_std.load_state_dict(checkpoint['running_mean_std'])
def init_rnn(self):
if self.is_rnn:
rnn_states = self.model.get_default_rnn_state()
self.states = [torch.zeros((s.size()[0], self.batch_size, s.size()[2]),
dtype=torch.float32).to(self.device) for s in rnn_states]
def reset(self):
self.init_rnn()
| 4,007 |
Python
| 34.157894 | 130 | 0.564512 |
makolon/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/rl_policy/execute_plan.py
|
# Copyright (c) 2018-2022, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#!/usr/bin/env/python3
import os
import sys
import yaml
import rospy
import torch
import numpy as np
from typing import Union
from scipy.spatial.transform import Rotation as R
# TODO: fix
sys.path.append('/root/tamp-hsr/hsr_tamp/experiments/env_3d/')
sys.path.append('..')
from tamp_planner import TAMPPlanner
from hsr_interface import HSRInterface
from force_sensor_interface import ForceSensorInterface
from post_process import PlanModifier
from mocap_interface import MocapInterface
from tf_interface import TfManager
from rl_agent import ResidualRL
sys.path.append('/root/tamp-hsr/')
from hsr_rl.utils.hydra_cfg.reformat import omegaconf_to_dict
from hsr_rl.tasks.utils.pinoc_utils import HSRIKSolver
from hsr_rl.tasks.utils.ik_utils import DifferentialInverseKinematicsCfg, DifferentialInverseKinematics
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
def load_config(policy_name: str = 'pick'):
file_name = os.path.join('.', 'config', policy_name + '_config.yaml')
with open(file_name, 'r') as f:
config = yaml.load(f, Loader=yaml.SafeLoader)
return config
def norm_diff_pos(p1: torch.Tensor, p2: torch.Tensor) -> torch.Tensor:
# Calculate norm
diff_norm = torch.norm(p1 - p2, p=2, dim=-1)
return diff_norm
def norm_diff_xy(p1: torch.Tensor, p2: torch.Tensor) -> torch.Tensor:
# Calculate norm
diff_norm = torch.norm(p1[:2] - p2[:2], p=2, dim=-1)
return diff_norm
def norm_diff_rot(q1: torch.Tensor, q2: torch.Tensor) -> torch.Tensor:
# Calculate norm
diff_norm1 = torch.norm(q1 - q2, p=2, dim=-1)
diff_norm2 = torch.norm(q2 - q1, p=2, dim=-1)
diff_norm = torch.min(diff_norm1, diff_norm2)
return diff_norm
def normalize(x, eps: float = 1e-9):
return x / x.norm(p=2, dim=-1).clamp(min=eps, max=None).unsqueeze(-1)
def quaternion_multiply(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
aw, ax, ay, az = torch.unbind(a, -1)
bw, bx, by, bz = torch.unbind(b, -1)
ow = aw * bw - ax * bx - ay * by - az * bz
ox = aw * bx + ax * bw + ay * bz - az * by
oy = aw * by - ax * bz + ay * bw + az * bx
oz = aw * bz + ax * by - ay * bx + az * bw
return torch.stack((ow, ox, oy, oz), -1)
def calc_diff_pos(p1, p2):
return p1 - p2
def calc_diff_rot(q1, q2):
q1 = normalize(q1)
q2 = normalize(q2)
scaling = torch.tensor([1, -1, -1, -1], device=q1.device)
q1_inv = q1 * scaling
q_diff = quaternion_multiply(q2, q1_inv)
return q_diff
class ExecutePlan(object):
def __init__(self, standalone=False):
# Initialize ROS node
rospy.init_node('execute_tamp_plan')
# Feedback rate
self.control_freq = 3.0
self.rate = rospy.Rate(self.control_freq)
self._device = 'cuda'
self._command_type = 'position_rel'
self._pd_control = False
self._dt = torch.tensor(1.0, device=self._device)
self._clip_obs = torch.tensor(5.0, device=self._device)
# Core module
self.tamp_planner = TAMPPlanner()
self.hsr_interface = HSRInterface()
self.tf_manager = TfManager()
self.path_modifier = PlanModifier()
self.mocap_interface = MocapInterface()
self.ft_interface = ForceSensorInterface()
self.hsr_ik_utils = HSRIKSolver()
# Publisher
self.arm_pub = rospy.Publisher('/hsrb/arm_trajectory_controller/command', JointTrajectory, queue_size=10)
self.base_pub = rospy.Publisher('/hsrb/omni_base_controller/command', JointTrajectory, queue_size=10)
pick_yaml = load_config('pick')
place_yaml = load_config('place')
insert_yaml = load_config('insert')
pick_policy_cfg = omegaconf_to_dict(pick_yaml)
place_policy_cfg = omegaconf_to_dict(place_yaml)
insert_policy_cfg = omegaconf_to_dict(insert_yaml)
# Skill based residual policy agents
self.pick_agent = ResidualRL(pick_policy_cfg.get("params"))
self.place_agent = ResidualRL(place_policy_cfg.get("params"))
self.insert_agent = ResidualRL(insert_policy_cfg.get("params"))
# Restore learned params
self.pick_agent.restore(pick_policy_cfg["params"]["load_path"])
self.place_agent.restore(place_policy_cfg["params"]["load_path"])
self.insert_agent.restore(insert_policy_cfg["params"]["load_path"])
# Get action scales for each skills
self.pick_action_scale = torch.tensor(pick_policy_cfg["params"]["config"]["action_scale"], device=self._device)
self.place_action_scale = torch.tensor(place_policy_cfg["params"]["config"]["action_scale"], device=self._device)
self.insert_action_scale = torch.tensor(insert_policy_cfg["params"]["config"]["action_scale"], device=self._device)
# Set ik controller
self.ik_controller = self.set_ik_controller()
# Initialize Robot
self.initialize_robot()
# Initialize TAMP
self.initialize_tamp()
def initialize_robot(self):
self.check_status()
# Set gripper to configuration position
self.hsr_interface.open_gripper()
# Set arm to configuration position
self.hsr_interface.initialize_arm()
# Set base to configuration position
self.hsr_interface.initialize_base()
def initialize_tamp(self):
# Get object poses
object_poses = self.mocap_interface.get_poses()
# Get robot poses
robot_poses = self.hsr_interface.get_joint_positions()
# Initialize tamp simulator
observations = (robot_poses, object_poses)
self.tamp_planner.initialize(observations)
#########################
#### ROS utils ####
#########################
def set_base_pose(self, base_pose):
base_traj = JointTrajectory()
base_traj.joint_names = ['odom_x', 'odom_y', 'odom_t']
# Set base trajectory
assert len(base_pose) == 3, "Does not match the size of base pose"
base_p = JointTrajectoryPoint()
base_p.positions = base_pose
base_p.velocities = np.zeros(len(base_pose)) # TODO: modify velocity
base_p.time_from_start = rospy.Duration(1)
base_traj.points = [base_p]
return base_traj
def set_arm_pose(self, arm_pose):
arm_traj = JointTrajectory()
arm_traj.joint_names = ['arm_lift_joint', 'arm_flex_joint',
'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint']
# Set arm trajectory
assert len(arm_pose) == 5, "Does not match the size of base pose"
arm_p = JointTrajectoryPoint()
arm_p.positions = arm_pose
arm_p.velocities = np.zeros(len(arm_pose)) # TODO: modify velocity
arm_p.time_from_start = rospy.Duration(1)
arm_traj.points = [arm_p]
return arm_traj
def check_status(self):
# Wait for publisher has built
while self.base_pub.get_num_connections() == 0:
rospy.sleep(0.1)
while self.arm_pub.get_num_connections() == 0:
rospy.sleep(0.1)
##########################
#### TAMP utils ####
##########################
def plan(self):
# Run TAMP
plan, _, _ = self.tamp_planner.plan()
return plan
def process(self, action_name, args):
# Get object names
object_names = self.tamp_planner.tamp_problem.body_names
# Modify plan
action_name, object_name, modified_action = self.path_modifier.post_process(action_name, object_names, args)
return action_name, object_name, modified_action
#########################
#### RL utils ####
#########################
def get_pick_observation(self, obj_name, pick_pose, target_obj_pose) -> torch.Tensor:
# Get joint pose
joint_pose = self.hsr_interface.get_joint_positions(group='arm')
# Get end effector and target object pose
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
obj_pos, obj_rot = self.mocap_interface.get_pose(obj_name)
# Calculate target end effector and object pose
target_ee_pos, target_ee_rot = pick_pose[0], pick_pose[1]
target_obj_pos, target_obj_rot = target_obj_pose[0], target_obj_pose[1]
# To Tensor
joint_pose = torch.tensor(joint_pose)
ee_pos, ee_rot = torch.tensor(ee_pos), torch.tensor(ee_rot) # TODO: -torch.tensor(ee_rot)
obj_pos, obj_rot = torch.tensor(obj_pos), torch.tensor(obj_rot)
target_ee_pos, target_ee_rot = torch.tensor(target_ee_pos), torch.tensor(target_ee_rot)
target_obj_pos, target_obj_rot = torch.tensor(target_obj_pos), torch.tensor(target_obj_rot)
diff_ee_pos = calc_diff_pos(ee_pos, target_ee_pos) # difference ee_pos and pick_pos
diff_ee_rot = calc_diff_rot(ee_rot, target_ee_rot) # difference ee_rot and pick_rot
diff_obj_pos = calc_diff_pos(obj_pos, target_obj_pos) # difference obj_pos and target_pos
diff_obj_rot = calc_diff_rot(obj_rot, target_obj_rot) # difference obj_rot and target_rot
obs = torch.cat((joint_pose, diff_ee_pos, diff_ee_rot, diff_obj_pos, diff_obj_rot))
obs = self._process_data(obs)
return obs
def get_place_observation(self, obj_name, target_obj_pose) -> torch.Tensor:
# Get joint pose
joint_pose = self.hsr_interface.get_joint_positions(group='arm')
# Get end effector and target object pose
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
obj_pos, obj_rot = self.mocap_interface.get_pose(obj_name)
# Calculate target pose from base pose
target_obj_pos, target_obj_rot = target_obj_pose[0], target_obj_pose[1]
# To Tensor
joint_pose = torch.tensor(joint_pose)
ee_pos, ee_rot = torch.tensor(ee_pos), torch.tensor(ee_rot) # TODO: -torch.tensor(ee_rot)
obj_pos, obj_rot = torch.tensor(obj_pos), torch.tensor(obj_rot)
target_obj_pos, target_obj_rot = torch.tensor(target_obj_pos), torch.tensor(target_obj_rot)
diff_ee_pos = calc_diff_pos(ee_pos, obj_pos) # difference ee_pos and obj_pos
diff_ee_rot = calc_diff_rot(ee_rot, obj_rot) # difference ee_rot and obj_rot
diff_obj_pos = calc_diff_pos(obj_pos, target_obj_pos) # difference obj_pos and target_pos
diff_obj_rot = calc_diff_rot(obj_rot, target_obj_rot) # difference obj_rot and target_rot
obs = torch.cat((joint_pose, diff_ee_pos, diff_ee_rot, diff_obj_pos, diff_obj_rot))
obs = self._process_data(obs)
return obs
def get_insert_observation(self, obj_name, target_obj_pose) -> torch.Tensor:
# Get joint pose
joint_pose = self.hsr_interface.get_joint_positions(group='arm')
# Get end effector and target object pose
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
obj_pos, obj_rot = self.mocap_interface.get_pose(obj_name)
# Calculate target pose from base pose
target_obj_pos, target_obj_rot = target_obj_pose[0], target_obj_pose[1]
# To Tensor
joint_pose = torch.tensor(joint_pose)
ee_pos, ee_rot = torch.tensor(ee_pos), torch.tensor(ee_rot) # TODO: -torch.tensor(ee_rot)
obj_pos, obj_rot = torch.tensor(obj_pos), torch.tensor(obj_rot)
target_obj_pos, target_obj_rot = torch.tensor(target_obj_pos), torch.tensor(target_obj_rot)
diff_ee_pos = calc_diff_pos(ee_pos, obj_pos) # difference ee_pos and obj_pos
diff_ee_rot = calc_diff_rot(ee_rot, obj_rot) # difference ee_rot and obj_rot
diff_obj_pos = calc_diff_pos(obj_pos, target_obj_pos) # difference obj_pos and target_pos
diff_obj_rot = calc_diff_rot(obj_rot, target_obj_rot) # difference obj_rot and target_rot
obs = torch.cat((joint_pose, diff_ee_pos, diff_ee_rot, diff_obj_pos, diff_obj_rot))
obs = self._process_data(obs)
return obs
def _process_data(self, obs: torch.Tensor) -> torch.Tensor:
# To device
obs = obs.to(self._device)
# To torch.float32
obs = obs.to(torch.float32)
# Clamp observation
obs = torch.clamp(obs, -self._clip_obs, self._clip_obs).to(self._device).clone()
return obs
def check_pick_status(self, obj_name):
obj_pos, obj_rot = self.mocap_interface.get_pose(obj_name)
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
obj_pos, obj_rot = torch.tensor(obj_pos), torch.tensor(obj_rot)
ee_pos, ee_rot = torch.tensor(ee_pos), torch.tensor(ee_rot)
# Calculate norm distance
pos_dist = norm_diff_pos(ee_pos, obj_pos)
print('pick distance:', pos_dist)
pick_success = torch.where(
pos_dist < torch.tensor([0.1]),
torch.ones((1,)),
torch.zeros((1,))
)
return True
def check_place_status(self, obj_name, target_obj_pose):
obj_pos, obj_rot = self.mocap_interface.get_pose(obj_name)
target_pos, target_rot = target_obj_pose[0], target_obj_pose[1]
obj_pos, obj_rot = torch.tensor(obj_pos), torch.tensor(obj_rot)
target_pos, target_rot = torch.tensor(target_pos), torch.tensor(target_rot)
# Calculate norm distance
pos_dist = norm_diff_pos(obj_pos, target_pos)
print('place distance:', pos_dist)
place_success = torch.where(
pos_dist < torch.tensor([0.03]),
torch.ones((1,)),
torch.zeros((1,))
)
return True
def check_insert_status(self, obj_name, target_obj_pose):
obj_pos, obj_rot = self.mocap_interface.get_pose(obj_name)
target_pos, target_rot = target_obj_pose[0], target_obj_pose[1]
obj_pos, obj_rot = torch.tensor(obj_pos), torch.tensor(obj_rot)
target_pos, target_rot = torch.tensor(target_pos), torch.tensor(target_rot)
# Calculate norm distance
pos_dist = norm_diff_pos(obj_pos, target_pos)
print('insert distance:', pos_dist)
insert_success = torch.where(
pos_dist < torch.tensor([0.02]),
torch.ones((1,)),
torch.zeros((1,))
)
return insert_success
##########################
#### Real Robot utils ####
##########################
def set_ik_controller(self):
ik_control_cfg = DifferentialInverseKinematicsCfg(
command_type=self._command_type,
ik_method="dls",
position_offset=(0.0, 0.0, 0.0),
rotation_offset=(1.0, 0.0, 0.0, 0.0),
)
return DifferentialInverseKinematics(ik_control_cfg, 1, self._device)
def calculate_base_command(self, target_pose):
curr_pose = self.hsr_interface.get_joint_positions(group='base')
curr_vel = self.hsr_interface.get_joint_velocities(group='base')
diff_pose = np.array(target_pose) - np.array(curr_pose)
diff_vel = np.array(curr_vel)
kp = 1.25
kd = 0.1
command = kp * diff_pose + kd * diff_vel
command += np.array(curr_pose)
return command
def calculate_arm_command(self, target_pose):
curr_pose = self.hsr_interface.get_joint_positions(group='arm')
curr_vel = self.hsr_interface.get_joint_velocities(group='arm')
diff_pose = np.array(target_pose) - np.array(curr_pose)
diff_vel = np.array(curr_vel)
kp = 1.25
kd = 0.1
command = kp * diff_pose + kd * diff_vel
command += np.array(curr_pose)
return command
def execute(self):
plan = self.plan()
if plan is None:
return None
for i, (action_name, args) in enumerate(plan):
# Post process TAMP commands to hsr executable actions
action_name, object_name, modified_action = self.process(action_name, args)
if action_name == 'move_base':
for target_pose in modified_action:
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
else:
target_base_pose = target_pose[:3]
base_traj = self.set_base_pose(target_base_pose)
self.base_pub.publish(base_traj)
self.rate.sleep()
elif action_name == 'pick':
finish = False
pick_traj, return_traj = modified_action
for target_pose in pick_traj:
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
else:
target_base_pose = target_pose[:3]
target_arm_pose = target_pose[3:]
# Get observation
obs = self.get_pick_observation(object_name, pick_pose, target_obj_pose)
# Residual action
with torch.no_grad():
actions = self.pick_agent.get_action(obs)
# Multiply target 6D pose and residual 6D pose
ik_action = self._dt * self.pick_action_scale * actions.to(self._device) # (dx, dy, dz)
self.ik_controller.set_command(ik_action)
# Calculate robot jacobian
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
joint_positions = np.array(self.hsr_interface.get_joint_positions())
robot_jacobian = self.hsr_ik_utils.get_jacobian(joint_positions)
# To tensor and device
ee_pos = torch.tensor(ee_pos, dtype=torch.float32, device=self._device).view(1, 3)
ee_rot = -torch.tensor(ee_rot, dtype=torch.float32, device=self._device).view(1, 4)
robot_jacobian = torch.tensor(robot_jacobian, dtype=torch.float32, device=self._device).view(1, -1, 8)
# Calcurate delta pose
delta_pose = self.ik_controller.compute_delta(ee_pos, ee_rot, robot_jacobian)
delta_pose = torch.squeeze(delta_pose, dim=0)
delta_pose = delta_pose.to('cpu').detach().numpy().copy() # 8 dim
# Add delta pose to reference trajectory
target_base_pose += delta_pose[:3]
target_arm_pose += delta_pose[3:]
# Set target pose
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
# Publish command
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
self.rate.sleep()
rospy.sleep(2.0)
self.hsr_interface.close_gripper()
for target_pose in return_traj: # return
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
else:
target_base_pose = target_pose[:3]
target_arm_pose = target_pose[3:]
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
self.rate.sleep()
elif action_name == 'place':
finish = False
place_traj = modified_action
for target_pose in place_traj:
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
else:
target_base_pose = target_pose[:3]
target_arm_pose = target_pose[3:]
# Get observation
obs = self.get_place_observation(object_name, target_obj_pose)
# Residual action
with torch.no_grad():
actions = self.place_agent.get_action(obs)
# Multiply target 6D pose and residual 6D pose
ik_action = self._dt * self.place_action_scale * actions.to(self._device) # (dx, dy, dz)
self.ik_controller.set_command(ik_action)
# Calculate robot jacobian
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
joint_positions = np.array(self.hsr_interface.get_joint_positions())
robot_jacobian = self.hsr_ik_utils.get_jacobian(joint_positions)
# To tensor and device
ee_pos = torch.tensor(ee_pos, dtype=torch.float32, device=self._device).view(1, 3)
ee_rot = -torch.tensor(ee_rot, dtype=torch.float32, device=self._device).view(1, 4)
robot_jacobian = torch.tensor(robot_jacobian, dtype=torch.float32, device=self._device).view(1, -1, 8)
# Calcurate delta pose
delta_pose = self.ik_controller.compute_delta(ee_pos, ee_rot, robot_jacobian)
delta_pose = torch.squeeze(delta_pose, dim=0)
delta_pose = delta_pose.to('cpu').detach().numpy().copy() # 8 dim
# Add delta pose to reference trajectory
target_base_pose += delta_pose[:3]
target_arm_pose += delta_pose[3:]
# Set target pose
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
# Publish command
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
self.rate.sleep()
elif action_name == 'insert':
finish = False
loop_count = 0
insert_traj, depart_traj, return_traj = modified_action
while not finish: # insert
target_pose = insert_traj[loop_count]
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
else:
target_base_pose = target_pose[:3]
target_arm_pose = target_pose[3:]
# Get observation
obs = self.get_insert_observation(object_name, target_obj_pose)
# Residual action
with torch.no_grad():
actions = self.insert_agent.get_action(obs)
# Multiply target 6D pose and residual 6D pose
ik_action = self._dt * self.insert_action_scale * actions.to(self._device) # (dx, dy, dz)
self.ik_controller.set_command(ik_action)
# Calculate robot jacobian
ee_pos, ee_rot = self.hsr_interface.get_link_pose('hand_palm_link')
joint_positions = np.array(self.hsr_interface.get_joint_positions())
robot_jacobian = self.hsr_ik_utils.get_jacobian(joint_positions)
# To tensor and device
ee_pos = torch.tensor(ee_pos, dtype=torch.float32, device=self._device).view(1, 3)
ee_rot = -torch.tensor(ee_rot, dtype=torch.float32, device=self._device).view(1, 4)
robot_jacobian = torch.tensor(robot_jacobian, dtype=torch.float32, device=self._device).view(1, -1, 8)
# Calcurate delta pose
delta_pose = self.ik_controller.compute_delta(ee_pos, ee_rot, robot_jacobian)
delta_pose = torch.squeeze(delta_pose, dim=0)
delta_pose = delta_pose.to('cpu').detach().numpy().copy() # 8 dim
# Add delta pose to reference trajectory
target_base_pose += delta_pose[:3]
target_arm_pose += delta_pose[3:]
# Set target pose
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
prev_ft_data = self.ft_interface.get_current_force()
# Publish command
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
self.rate.sleep()
loop_count += 1
if loop_count >= len(insert_traj):
loop_count = len(insert_traj)-1
current_ft_data = self.ft_interface.get_current_force()
force_difference = self.ft_interface.compute_difference(prev_ft_data, current_ft_data)
weight = round(force_difference / 9.81 * 1000, 1)
finish = bool(self.check_insert_status(object_name))
finish |= True if weight > 500 else False
rospy.sleep(2.0)
self.hsr_interface.open_gripper()
for target_pose in depart_traj: # depart
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
else:
target_base_pose = target_pose[:3]
target_arm_pose = target_pose[3:]
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
self.rate.sleep()
for target_pose in return_traj: # return
if self._pd_control:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
else:
target_base_pose = target_pose[:3]
target_arm_pose = target_pose[3:]
base_traj = self.set_base_pose(target_base_pose)
arm_traj = self.set_arm_pose(target_arm_pose)
self.base_pub.publish(base_traj)
self.arm_pub.publish(arm_traj)
self.rate.sleep()
else:
continue
if __name__ == '__main__':
exec_plan = ExecutePlan()
exec_plan.execute()
| 28,687 |
Python
| 41.188235 | 123 | 0.578799 |
makolon/hsr_isaac_tamp/hsr_rl/README.md
|
# HSR-RL
| 9 |
Markdown
| 3.999998 | 8 | 0.555555 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/example/hsr_place.py
|
# Copyright (c) 2018-2022, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from hsr_rl.tasks.base.rl_task import RLTask
from hsr_rl.robots.articulations.hsr import HSR
from hsr_rl.robots.articulations.views.hsr_view import HSRView
from omni.isaac.core.utils.prims import get_prim_at_path
from omni.isaac.core.utils.stage import get_current_stage
from omni.isaac.core.prims.rigid_prim_view import RigidPrimView
from omni.isaac.core.prims.geometry_prim_view import GeometryPrimView
from omni.isaac.core.articulations.articulation_view import ArticulationView
from omni.isaac.core.utils.torch.transformations import *
from omni.isaac.core.utils.torch.rotations import *
from omni.isaac.core.utils.stage import print_stage_prim_paths
from omni.isaac.core.simulation_context import SimulationContext
from omni.isaac.core.objects import DynamicSphere, DynamicCuboid, FixedCuboid
from omni.isaac.sensor import _sensor
import re
import torch
from pxr import Usd, UsdGeom
class HSRExamplePlaceTask(RLTask):
def __init__(
self,
name,
sim_config,
env,
) -> None:
self._sim_config = sim_config
self._cfg = sim_config.config
self._task_cfg = sim_config.task_config
self._device = self._cfg["sim_device"]
self._num_envs = self._task_cfg["env"]["numEnvs"]
self._env_spacing = self._task_cfg["env"]["envSpacing"]
self._dt = torch.tensor(self._task_cfg["sim"]["dt"] * self._task_cfg["env"]["controlFrequencyInv"], device=self._device)
self._num_observations = self._task_cfg["env"]["num_observations"]
self._num_actions = self._task_cfg["env"]["num_actions"]
self._num_props = self._task_cfg["env"]["numProps"]
self._table_height = 0.2
self._table_width = 0.65
self._table_depth = 1.2
self._table_size = 1.0
self._prop_size = 0.04
self._hsr_position = torch.tensor([0.0, 0.0, 0.03], device=self._device)
self._hsr_rotation = torch.tensor([1.0, 0.0, 0.0, 0.0], device=self._device)
self._table_position = torch.tensor([1.5, 0.0, self._table_height/2], device=self._device)
self._table_rotation = torch.tensor([1.0, 0.0, 0.0, 0.0], device=self._device)
self._prop_position = torch.tensor([1.3, 0.0, self._table_height+self._prop_size/2], device=self._device)
self._prop_rotation = torch.tensor([1.0, 0.0, 0.0, 0.0], device=self._device)
self._action_speed_scale = self._task_cfg["env"]["actionSpeedScale"]
self._max_episode_length = self._task_cfg["env"]["maxEpisodeLength"]
# Start at 'home' positions
self.torso_start = torch.tensor([0.1], device=self._device)
self.base_start = torch.tensor([0.0, 0.0, 0.0], device=self._device)
self.arm_start = torch.tensor([0.1, -1.570796, 0.0, -0.392699, 0.0], device=self._device)
self.gripper_proximal_start = torch.tensor([0.75, 0.75], device=self._device)
self.initial_dof_positions = torch.tensor([0.0, 0.0, 0.0, 0.1, 0.1, -1.570796, 0.0, 0.0, 0.0, -0.392699, 0.0, 0.75, 0.75, 0.0, 0.0], device=self._device)
# Joint & body names
self._torso_joint_name = ["torso_lift_joint"]
self._base_joint_names = ["joint_x", "joint_y", "joint_rz"]
self._arm_names = ["arm_lift_joint", "arm_flex_joint", "arm_roll_joint", "wrist_flex_joint", "wrist_roll_joint"]
self._gripper_proximal_names = ["hand_l_proximal_joint", "hand_r_proximal_joint"]
# Values are set in post_reset after model is loaded
self.torso_dof_idx = []
self.base_dof_idxs = []
self.arm_dof_idxs = []
self.gripper_proximal_dof_idxs = []
# Dof joint position limits
self.torso_dof_lower = []
self.torso_dof_upper = []
self.base_dof_lower = []
self.base_dof_upper = []
self.arm_dof_lower = []
self.arm_dof_upper = []
self.gripper_p_dof_lower = []
self.gripper_p_dof_upper = []
# Add contact sensor
self._contact_sensor_interface = _sensor.acquire_contact_sensor_interface()
self.is_collided = torch.zeros(self._num_envs, device=self._device, dtype=torch.long)
self.is_success = torch.zeros(self._num_envs, device=self._device, dtype=torch.long)
RLTask.__init__(self, name, env)
return
def set_up_scene(self, scene) -> None:
self.add_hsr()
self.add_prop()
self.add_table()
# Set up scene
super().set_up_scene(scene)
# Add robot to scene
self._robots = HSRView(prim_paths_expr="/World/envs/.*/hsrb", name="hsrb_view")
scene.add(self._robots)
scene.add(self._robots._hands)
scene.add(self._robots._lfingers)
scene.add(self._robots._rfingers)
scene.add(self._robots._fingertip_centered)
# Add prop to scene
self._props = RigidPrimView(prim_paths_expr="/World/envs/.*/prop", name="prop_view", reset_xform_properties=False)
scene.add(self._props)
def add_hsr(self):
hsrb = HSR(prim_path=self.default_zero_env_path + "/hsrb",
name="hsrb",
translation=self._hsr_position,
orientation=self._hsr_rotation)
self._sim_config.apply_articulation_settings("hsrb", get_prim_at_path(hsrb.prim_path), self._sim_config.parse_actor_config("hsrb"))
def add_prop(self):
prop = DynamicCuboid(prim_path=self.default_zero_env_path + "/prop",
name="prop",
translation=self._prop_position,
orientation=self._prop_rotation,
size=self._prop_size,
color=torch.tensor([0.2, 0.4, 0.6]),
mass=0.1,
density=100.0)
self._sim_config.apply_articulation_settings("prop", get_prim_at_path(prop.prim_path), self._sim_config.parse_actor_config("prop"))
def add_table(self):
table = FixedCuboid(prim_path=self.default_zero_env_path + "/table",
name="table",
translation=self._table_position,
orientation=self._table_rotation,
size=self._table_size,
color=torch.tensor([0.75, 0.75, 0.75]),
scale=torch.tensor([self._table_width, self._table_depth, self._table_height]))
self._sim_config.apply_articulation_settings("table", get_prim_at_path(table.prim_path), self._sim_config.parse_actor_config("table"))
def get_observations(self):
# Get prop positions and orientations
prop_positions, prop_orientations = self._props.get_world_poses(clone=False)
prop_positions = prop_positions[:, 0:3] - self._env_pos
# Get prop velocities
prop_velocities = self._props.get_velocities(clone=False)
prop_linvels = prop_velocities[:, 0:3]
prop_angvels = prop_velocities[:, 3:6]
# Get end effector positions and orientations
end_effector_positions, end_effector_orientations = self._robots._fingertip_centered.get_world_poses(clone=False)
end_effector_positions = end_effector_positions[:, 0:3] - self._env_pos
# Get end effector velocities
end_effector_velocities = self._robots._fingertip_centered.get_velocities(clone=False)
end_effector_linvels = end_effector_velocities[:, 0:3]
end_effector_angvels = end_effector_velocities[:, 3:6]
self.prop_positions = prop_positions
self.prop_linvels = prop_linvels
dof_pos = self._robots.get_joint_positions(clone=False)
dof_vel = self._robots.get_joint_velocities(clone=False)
self.obs_buf[..., 0:8] = dof_pos[..., self.actuated_dof_indices]
self.obs_buf[..., 8:16] = dof_vel[..., self.actuated_dof_indices]
self.obs_buf[..., 16:19] = end_effector_positions
self.obs_buf[..., 19:23] = end_effector_orientations
self.obs_buf[..., 23:26] = end_effector_linvels
self.obs_buf[..., 26:29] = end_effector_angvels
self.obs_buf[..., 29:32] = prop_positions
self.obs_buf[..., 32:36] = prop_orientations
observations = {
self._robots.name: {
"obs_buf": self.obs_buf
}
}
return observations
def pre_physics_step(self, actions) -> None:
if not self._env._world.is_playing():
return
reset_env_ids = self.reset_buf.nonzero(as_tuple=False).squeeze(-1)
if len(reset_env_ids) > 0:
self.reset_idx(reset_env_ids)
# Update position targets from actions
self.dof_position_targets[..., self.actuated_dof_indices] += self._dt * self._action_speed_scale * actions.to(self.device)
self.dof_position_targets[:] = tensor_clamp(
self.dof_position_targets, self.robot_dof_lower_limits, self.robot_dof_upper_limits
)
# Modify torso joint positions
dof_pos = self._robots.get_joint_positions()
arm_pos = dof_pos[:, self.arm_dof_idxs]
scaled_arm_lift_pos = arm_pos[:, 0] / self.arm_dof_upper[0]
scaled_torso_lift_pos = scaled_arm_lift_pos * self.torso_dof_upper[0]
self.dof_position_targets[:, self.torso_dof_idx] = scaled_torso_lift_pos.unsqueeze(dim=1)
# reset position targets for reset envs
self.dof_position_targets[reset_env_ids] = self.initial_dof_positions
self._robots.set_joint_positions(self.dof_position_targets)
def reset_idx(self, env_ids):
num_resets = len(env_ids)
env_ids_32 = env_ids.type(torch.int32)
env_ids_64 = env_ids.type(torch.int64)
min_d = -0.01 # min horizontal dist from origin
max_d = 0.01 # max horizontal dist from origin
min_height = 0.01
max_height = 0.02
dists = torch_rand_float(min_d, max_d, (num_resets, 1), self._device)
dirs = torch_random_dir_2((num_resets, 1), self._device)
hpos = dists * dirs
# Prop pos / rot, velocities
self.prop_pos = self.initial_prop_pos.clone()
self.prop_rot = self.initial_prop_rot.clone()
# position
self.prop_pos[env_ids_64, 0:2] += hpos[..., 0:2]
self.prop_pos[env_ids_64, 2] += torch_rand_float(min_height, max_height, (num_resets, 1), self._device).squeeze()
# rotation
self.prop_rot[env_ids_64, 0] = 1
self.prop_rot[env_ids_64, 1:] = 0
# reset root state for props in selected envs
self._props.set_world_poses(self.prop_pos[env_ids_64], self.prop_rot[env_ids_64], indices=env_ids_32)
# reset root state for robots in selected envs
self._robots.set_world_poses(self.initial_robot_pos[env_ids_64], self.initial_robot_rot[env_ids_64], indices=env_ids_32)
# reset DOF states for robots in selected envs
self._robots.set_joint_positions(self.initial_dof_positions, indices=env_ids_32)
# bookkeeping
self.reset_buf[env_ids] = 0
self.progress_buf[env_ids] = 0
self.extras[env_ids] = 0
self.is_collided[env_ids] = 0
def post_reset(self):
self.set_dof_idxs()
self.set_dof_limits()
self.set_default_state()
# reset prop pos / rot, and velocities
self.initial_robot_pos, self.initial_robot_rot = self._robots.get_world_poses()
self.initial_robot_velocities = self._robots.get_velocities()
# reset prop pos / rot, and velocities
self.initial_prop_pos, self.initial_prop_rot = self._props.get_world_poses()
self.initial_prop_velocities = self._props.get_velocities()
def calculate_metrics(self) -> None:
# Distance from hand to the box
dist_hand = torch.norm(self.obs_buf[..., 29:32] - self.obs_buf[..., 16:19], p=2, dim=-1)
# Distance from left gripper to the box
lfinger_pos, _ = self._robots._lfingers.get_world_poses(clone=False)
lfinger_pos -= self._env_pos
dist_lf = torch.norm(self.obs_buf[..., 29:32] - lfinger_pos, p=2, dim=-1)
# Distance from right gripper to the box
rfinger_pos, _ = self._robots._rfingers.get_world_poses(clone=False)
rfinger_pos -= self._env_pos
dist_rf = torch.norm(self.obs_buf[..., 29:32] - rfinger_pos, p=2, dim=-1)
dist_reward = 1.0 - torch.tanh(10.0 * (dist_hand + dist_lf + dist_rf) / 3)
self.rew_buf[:] = dist_reward
# In this policy, episode length is constant across all envs
is_last_step = (self.progress_buf[0] == self._max_episode_length - 1)
if is_last_step:
# Check if nut is picked up and above table
lift_success = self._check_lift_success(height_threashold=0.24)
self.rew_buf[:] += lift_success * self._task_cfg['rl']['success_bonus']
self.extras['successes'] = torch.mean(lift_success.float())
def is_done(self) -> None:
# prop height index is 31, NOTE: modify according to observation
self.reset_buf = torch.where(
self.obs_buf[:, 31] <= self._table_height,
torch.ones_like(self.reset_buf),
self.reset_buf
)
self.reset_buf = torch.where(
self.progress_buf[:] >= self._max_episode_length - 1,
torch.ones_like(self.reset_buf),
self.reset_buf
)
def post_physics_step(self):
"""Step buffers. Refresh tensors. Compute observations and reward. Reset environments."""
self.progress_buf[:] += 1
if self._env._world.is_playing():
# In this policy, episode length is constant
is_last_step = (self.progress_buf[0] == self._max_episode_length - 1)
if is_last_step:
self._close_gripper(sim_steps=self._task_cfg['env']['num_gripper_close_sim_steps'])
self._lift_gripper(sim_steps=self._task_cfg['env']['num_gripper_lift_sim_steps'])
self.get_observations()
self.get_states()
self.calculate_metrics()
self.is_done()
self.get_extras()
return self.obs_buf, self.rew_buf, self.reset_buf, self.extras
def set_dof_idxs(self):
[self.torso_dof_idx.append(self._robots.get_dof_index(name)) for name in self._torso_joint_name]
[self.base_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._base_joint_names]
[self.arm_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._arm_names]
[self.gripper_proximal_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._gripper_proximal_names]
# Movable joints
self.actuated_dof_indices = torch.LongTensor(self.base_dof_idxs+self.arm_dof_idxs).to(self._device) # torch.LongTensor([0, 1, 2, 3, 5, 7, 9, 10]).to(self._device)
def set_dof_limits(self): # dof position limits
# (num_envs, num_dofs, 2)
dof_limits = self._robots.get_dof_limits()
dof_limits_lower = dof_limits[0, :, 0].to(self._device)
dof_limits_upper = dof_limits[0, :, 1].to(self._device)
# Set relevant joint position limit values
self.torso_dof_lower = dof_limits_lower[self.torso_dof_idx]
self.torso_dof_upper = dof_limits_upper[self.torso_dof_idx]
self.base_dof_lower = dof_limits_lower[self.base_dof_idxs]
self.base_dof_upper = dof_limits_upper[self.base_dof_idxs]
self.arm_dof_lower = dof_limits_lower[self.arm_dof_idxs]
self.arm_dof_upper = dof_limits_upper[self.arm_dof_idxs]
self.gripper_p_dof_lower = dof_limits_lower[self.gripper_proximal_dof_idxs]
self.gripper_p_dof_upper = dof_limits_upper[self.gripper_proximal_dof_idxs]
self.robot_dof_lower_limits, self.robot_dof_upper_limits = torch.t(dof_limits[0].to(device=self._device))
def set_default_state(self):
# Set default joint state
joint_states = self._robots.get_joints_default_state()
jt_pos = joint_states.positions
jt_pos[:, self.torso_dof_idx] = self.torso_start
jt_pos[:, self.base_dof_idxs] = self.base_start
jt_pos[:, self.arm_dof_idxs] = self.arm_start
jt_pos[:, self.gripper_proximal_dof_idxs] = self.gripper_proximal_start
jt_vel = joint_states.velocities
jt_vel[:, self.torso_dof_idx] = torch.zeros_like(self.torso_start, device=self._device)
jt_vel[:, self.base_dof_idxs] = torch.zeros_like(self.base_start, device=self._device)
jt_vel[:, self.arm_dof_idxs] = torch.zeros_like(self.arm_start, device=self._device)
jt_vel[:, self.gripper_proximal_dof_idxs] = torch.zeros_like(self.gripper_proximal_start, device=self._device)
self._robots.set_joints_default_state(positions=jt_pos, velocities=jt_vel)
# Initialize target positions
self.dof_position_targets = jt_pos
def _get_keypoint_dist(self):
# end effector pose indices are 0:3, and prop pose indices are 13:16
keypoint_dist = torch.sum(torch.norm(self.obs_buf[:, 0:3] - self.obs_buf[:, 13:16], p=2, dim=-1), dim=-1)
return keypoint_dist
def _close_gripper(self, sim_steps=10):
gripper_dof_pos = torch.tensor([-1.75, -1.75], device=self._device)
# Step sim
for _ in range(sim_steps):
self._robots.set_joint_velocity_targets(gripper_dof_pos, joint_indices=self.gripper_proximal_dof_idxs)
SimulationContext.step(self._env._world, render=True)
def _lift_gripper(self, sim_steps=10):
lift_dof_pos = torch.tensor([0.0, 0.0, 0.0, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], device=self._device)
# Step sim
for _ in range(sim_steps):
self._robots.set_joint_velocity_targets(lift_dof_pos)
SimulationContext.step(self._env._world, render=True)
def _check_lift_success(self, height_threashold):
lift_success = torch.where(
self.prop_pos[:, 2] > height_threashold,
torch.ones((self.num_envs,), device=self._device),
torch.zeros((self.num_envs,), device=self._device))
return lift_success
def _check_robot_collisions(self):
# Check if the robot collided with an object
for obst_prim in self._tables._prim_paths:
match = re.search(r'\d+', obst_prim)
env_id = int(match.group())
raw_readings = self._contact_sensor_interface.get_contact_sensor_raw_data(obst_prim + "/Contact_Sensor")
if raw_readings.shape[0]:
for reading in raw_readings:
if "hsrb" in str(self._contact_sensor_interface.decode_body_name(reading["body1"])):
self.is_collided[env_id] = True
if "hsrb" in str(self._contact_sensor_interface.decode_body_name(reading["body0"])):
self.is_collided[env_id] = True
collide_penalty = torch.where(
self.is_collided == True,
torch.ones((self.num_envs,), device=self._device),
torch.zeros((self.num_envs,), device=self._device))
return collide_penalty
| 20,725 |
Python
| 45.68018 | 170 | 0.623836 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/example/hsr_cabinet.py
|
# Copyright (c) 2018-2022, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from hsr_rl.tasks.base.rl_task import RLTask
from hsr_rl.robots.articulations.hsr import HSR
from hsr_rl.robots.articulations.cabinet import Cabinet
from hsr_rl.robots.articulations.views.hsr_view import HSRView
from hsr_rl.robots.articulations.views.cabinet_view import CabinetView
from omni.isaac.core.objects import DynamicCuboid
from omni.isaac.core.prims.rigid_prim_view import RigidPrimView
from omni.isaac.core.utils.prims import get_prim_at_path
from omni.isaac.core.utils.stage import get_current_stage
from omni.isaac.core.utils.torch.transformations import *
from omni.isaac.core.utils.torch.rotations import *
from omni.isaac.cloner import Cloner
import math
import torch
import numpy as np
from pxr import Usd, UsdGeom
# Whole Body example task with holonomic robot base
class HSRExampleCabinetTask(RLTask):
def __init__(
self,
name,
sim_config,
env,
offset=None
) -> None:
self._sim_config = sim_config
self._cfg = sim_config.config
self._task_cfg = sim_config.task_config
self._num_envs = self._task_cfg["env"]["numEnvs"]
self._env_spacing = self._task_cfg["env"]["envSpacing"]
self._max_episode_length = self._task_cfg["env"]["episodeLength"]
self.action_scale = self._task_cfg["env"]["actionScale"]
self.start_position_noise = self._task_cfg["env"]["startPositionNoise"]
self.start_rotation_noise = self._task_cfg["env"]["startRotationNoise"]
self.num_props = self._task_cfg["env"]["numProps"]
self.dof_vel_scale = self._task_cfg["env"]["dofVelocityScale"]
self.dist_reward_scale = self._task_cfg["env"]["distRewardScale"]
self.rot_reward_scale = self._task_cfg["env"]["rotRewardScale"]
self.around_handle_reward_scale = self._task_cfg["env"]["aroundHandleRewardScale"]
self.open_reward_scale = self._task_cfg["env"]["openRewardScale"]
self.finger_dist_reward_scale = self._task_cfg["env"]["fingerDistRewardScale"]
self.action_penalty_scale = self._task_cfg["env"]["actionPenaltyScale"]
self.finger_close_reward_scale = self._task_cfg["env"]["fingerCloseRewardScale"]
self.distX_offset = 0.04
self.dt = 1/60.
self._num_observations = 35
self._num_actions = 15
RLTask.__init__(self, name, env)
self.hsr_position = torch.tensor([1.5, 0.0, 0.03])
self.hsr_rotation = torch.tensor([0.0, 0.0, 0.0, 1.0])
return
def set_up_scene(self, scene) -> None:
self.add_hsr()
self.add_cabinet()
if self.num_props > 0:
self.add_props()
# Set up scene
super().set_up_scene(scene)
# Add robot to scene
self._robots = HSRView(prim_paths_expr="/World/envs/.*/hsrb", name="hsrb_view")
self._cabinets = CabinetView(prim_paths_expr="/World/envs/.*/cabinet", name="cabinet_view")
scene.add(self._robots)
scene.add(self._robots._hands)
scene.add(self._robots._lfingers)
scene.add(self._robots._rfingers)
scene.add(self._robots._fingertip_centered)
scene.add(self._cabinets)
scene.add(self._cabinets._drawers)
if self.num_props > 0:
self._props = RigidPrimView(prim_paths_expr="/World/envs/.*/prop/.*", name="prop_view", reset_xform_properties=False)
scene.add(self._props)
self.init_data()
return
def add_hsr(self):
hsrb = HSR(prim_path=self.default_zero_env_path + "/hsrb", name="hsrb", translation=self.hsr_position, orientation=self.hsr_rotation)
self._sim_config.apply_articulation_settings("hsrb", get_prim_at_path(hsrb.prim_path), self._sim_config.parse_actor_config("hsrb"))
def add_cabinet(self):
cabinet = Cabinet(self.default_zero_env_path + "/cabinet", name="cabinet")
self._sim_config.apply_articulation_settings("cabinet", get_prim_at_path(cabinet.prim_path), self._sim_config.parse_actor_config("cabinet"))
def add_props(self):
prop_cloner = Cloner()
drawer_pos = torch.tensor([0.0515, 0.0, 0.7172])
prop_color = torch.tensor([0.2, 0.4, 0.6])
props_per_row = int(math.ceil(math.sqrt(self.num_props)))
prop_size = 0.04
prop_spacing = 0.09
xmin = -0.5 * prop_spacing * (props_per_row - 1)
zmin = -0.5 * prop_spacing * (props_per_row - 1)
prop_count = 0
prop_pos = []
for j in range(props_per_row):
prop_up = zmin + j * prop_spacing
for k in range(props_per_row):
if prop_count >= self.num_props:
break
propx = xmin + k * prop_spacing
prop_pos.append([propx, prop_up, 0.0])
prop_count += 1
prop = DynamicCuboid(
prim_path=self.default_zero_env_path + "/prop/prop_0",
name="prop",
color=prop_color,
size=prop_size,
density=100.0
)
self._sim_config.apply_articulation_settings("prop", get_prim_at_path(prop.prim_path), self._sim_config.parse_actor_config("prop"))
prop_paths = [f"{self.default_zero_env_path}/prop/prop_{j}" for j in range(self.num_props)]
prop_cloner.clone(
source_prim_path=self.default_zero_env_path + "/prop/prop_0",
prim_paths=prop_paths,
positions=np.array(prop_pos)+drawer_pos.numpy(),
replicate_physics=False
)
def init_data(self) -> None:
def get_env_local_pose(env_pos, xformable, device):
"""Compute pose in env-local coordinates"""
world_transform = xformable.ComputeLocalToWorldTransform(0)
world_pos = world_transform.ExtractTranslation()
world_quat = world_transform.ExtractRotationQuat()
px = world_pos[0] - env_pos[0]
py = world_pos[1] - env_pos[1]
pz = world_pos[2] - env_pos[2]
qx = world_quat.imaginary[0]
qy = world_quat.imaginary[1]
qz = world_quat.imaginary[2]
qw = world_quat.real
return torch.tensor([px, py, pz, qw, qx, qy, qz], device=device, dtype=torch.float)
stage = get_current_stage()
hand_pose = get_env_local_pose(self._env_pos[0], UsdGeom.Xformable(stage.GetPrimAtPath("/World/envs/env_0/hsrb/hand_palm_link")), self._device)
lfinger_pose = get_env_local_pose(
self._env_pos[0], UsdGeom.Xformable(stage.GetPrimAtPath("/World/envs/env_0/hsrb/hand_l_proximal_link")), self._device
)
rfinger_pose = get_env_local_pose(
self._env_pos[0], UsdGeom.Xformable(stage.GetPrimAtPath("/World/envs/env_0/hsrb/hand_r_proximal_link")), self._device
)
finger_pose = torch.zeros(7, device=self._device)
finger_pose[0:3] = (lfinger_pose[0:3] + rfinger_pose[0:3]) / 2.0
finger_pose[3:7] = lfinger_pose[3:7]
hand_pose_inv_rot, hand_pose_inv_pos = (tf_inverse(hand_pose[3:7], hand_pose[0:3]))
grasp_pose_axis = 1
hsr_local_grasp_pose_rot, hsr_local_pose_pos = tf_combine(hand_pose_inv_rot, hand_pose_inv_pos, finger_pose[3:7], finger_pose[0:3])
hsr_local_pose_pos += torch.tensor([0, 0.04, 0], device=self._device)
self.hsr_local_grasp_pos = hsr_local_pose_pos.repeat((self._num_envs, 1))
self.hsr_local_grasp_rot = hsr_local_grasp_pose_rot.repeat((self._num_envs, 1))
drawer_local_grasp_pose = torch.tensor([0.3, 0.01, 0.0, 1.0, 0.0, 0.0, 0.0], device=self._device)
self.drawer_local_grasp_pos = drawer_local_grasp_pose[0:3].repeat((self._num_envs, 1))
self.drawer_local_grasp_rot = drawer_local_grasp_pose[3:7].repeat((self._num_envs, 1))
self.gripper_forward_axis = torch.tensor([0, 0, 1], device=self._device, dtype=torch.float).repeat((self._num_envs, 1))
self.drawer_inward_axis = torch.tensor([-1, 0, 0], device=self._device, dtype=torch.float).repeat((self._num_envs, 1))
self.gripper_up_axis = torch.tensor([0, 1, 0], device=self._device, dtype=torch.float).repeat((self._num_envs, 1))
self.drawer_up_axis = torch.tensor([0, 0, 1], device=self._device, dtype=torch.float).repeat((self._num_envs, 1))
self.hsr_default_dof_pos = torch.tensor(
[0.0, 0.0, 0.0, 0.1, 0.1, -1.570796, 0.0, 0.0, 0.0, -0.392699, 0.0, 0.75, 0.75, 0.0, 0.0], device=self._device
)
self.actions = torch.zeros((self._num_envs, self.num_actions), device=self._device)
def get_observations(self):
hand_pos, hand_rot = self._robots._hands.get_world_poses(clone=False)
drawer_pos, drawer_rot = self._cabinets._drawers.get_world_poses(clone=False)
hsr_dof_pos = self._robots.get_joint_positions(clone=False)
hsr_dof_vel = self._robots.get_joint_velocities(clone=False)
self.cabinet_dof_pos = self._cabinets.get_joint_positions(clone=False)
self.cabinet_dof_vel = self._cabinets.get_joint_velocities(clone=False)
self.hsr_dof_pos = hsr_dof_pos
self.hsr_grasp_rot, self.hsr_grasp_pos, self.drawer_grasp_rot, self.drawer_grasp_pos = self.compute_grasp_transforms(
hand_rot,
hand_pos,
self.hsr_local_grasp_rot,
self.hsr_local_grasp_pos,
drawer_rot,
drawer_pos,
self.drawer_local_grasp_rot,
self.drawer_local_grasp_pos,
)
self.hsr_lfinger_pos, self.hsr_lfinger_rot = self._robots._lfingers.get_world_poses(clone=False)
self.hsr_rfinger_pos, self.hsr_rfinger_rot = self._robots._lfingers.get_world_poses(clone=False)
dof_pos_scaled = (
2.0
* (hsr_dof_pos - self.hsr_dof_lower_limits)
/ (self.hsr_dof_upper_limits - self.hsr_dof_lower_limits)
- 1.0
)
to_target = self.drawer_grasp_pos - self.hsr_grasp_pos
self.obs_buf = torch.cat(
(
dof_pos_scaled,
hsr_dof_vel * self.dof_vel_scale,
to_target,
self.cabinet_dof_pos[:, 3].unsqueeze(-1),
self.cabinet_dof_vel[:, 3].unsqueeze(-1),
),
dim=-1,
)
observations = {
self._robots.name: {
"obs_buf": self.obs_buf
}
}
return observations
def pre_physics_step(self, actions) -> None:
if not self._env._world.is_playing():
return
reset_env_ids = self.reset_buf.nonzero(as_tuple=False).squeeze(-1)
if len(reset_env_ids) > 0:
self.reset_idx(reset_env_ids)
self.actions = actions.clone().to(self._device)
targets = self.hsr_dof_targets + self.hsr_dof_speed_scales * self.dt * self.actions * self.action_scale
self.hsr_dof_targets[:] = tensor_clamp(targets, self.hsr_dof_lower_limits, self.hsr_dof_upper_limits)
env_ids_int32 = torch.arange(self._robots.count, dtype=torch.int32, device=self._device)
self._robots.set_joint_positions(self.hsr_dof_targets, indices=env_ids_int32)
def reset_idx(self, env_ids):
indices = env_ids.to(dtype=torch.int32)
num_indices = len(indices)
# reset hsr
pos = tensor_clamp(
self.hsr_default_dof_pos.unsqueeze(0)
+ 0.25 * (torch.rand((len(env_ids), self.num_hsr_dofs), device=self._device) - 0.5),
self.hsr_dof_lower_limits,
self.hsr_dof_upper_limits,
)
dof_pos = torch.zeros((num_indices, self._robots.num_dof), device=self._device)
dof_vel = torch.zeros((num_indices, self._robots.num_dof), device=self._device)
dof_pos[:, :] = pos
self.hsr_dof_targets[env_ids, :] = pos
self.hsr_dof_pos[env_ids, :] = pos
# reset cabinet
self._cabinets.set_joint_positions(torch.zeros_like(self._cabinets.get_joint_positions(clone=False)[env_ids]), indices=indices)
self._cabinets.set_joint_velocities(torch.zeros_like(self._cabinets.get_joint_velocities(clone=False)[env_ids]), indices=indices)
# reset props
if self.num_props > 0:
self._props.set_world_poses(
self.default_prop_pos[self.prop_indices[env_ids].flatten()],
self.default_prop_rot[self.prop_indices[env_ids].flatten()],
self.prop_indices[env_ids].flatten().to(torch.int32)
)
self._robots.set_joint_position_targets(self.hsr_dof_targets[env_ids], indices=indices)
self._robots.set_joint_positions(dof_pos, indices=indices)
self._robots.set_joint_velocities(dof_vel, indices=indices)
# bookkeeping
self.reset_buf[env_ids] = 0
self.progress_buf[env_ids] = 0
def post_reset(self):
self.num_hsr_dofs = self._robots.num_dof
self.hsr_dof_pos = torch.zeros((self.num_envs, self.num_hsr_dofs), device=self._device)
dof_limits = self._robots.get_dof_limits()
self.hsr_dof_lower_limits = dof_limits[0, :, 0].to(device=self._device)
self.hsr_dof_upper_limits = dof_limits[0, :, 1].to(device=self._device)
self.hsr_dof_speed_scales = torch.ones_like(self.hsr_dof_lower_limits)
self.hsr_dof_speed_scales[self._robots.gripper_indices] = 0.1
self.hsr_dof_targets = torch.zeros(
(self._num_envs, self.num_hsr_dofs), dtype=torch.float, device=self._device
)
if self.num_props > 0:
self.default_prop_pos, self.default_prop_rot = self._props.get_world_poses()
self.prop_indices = torch.arange(self._num_envs * self.num_props, device=self._device).view(
self._num_envs, self.num_props
)
# randomize all envs
indices = torch.arange(self._num_envs, dtype=torch.int64, device=self._device)
self.reset_idx(indices)
def calculate_metrics(self) -> None:
self.rew_buf[:] = self.compute_hsr_reward(
self.reset_buf, self.progress_buf, self.actions, self.cabinet_dof_pos,
self.hsr_grasp_pos, self.drawer_grasp_pos, self.hsr_grasp_rot, self.drawer_grasp_rot,
self.hsr_lfinger_pos, self.hsr_rfinger_pos,
self.gripper_forward_axis, self.drawer_inward_axis, self.gripper_up_axis, self.drawer_up_axis,
self._num_envs, self.dist_reward_scale, self.rot_reward_scale, self.around_handle_reward_scale, self.open_reward_scale,
self.finger_dist_reward_scale, self.action_penalty_scale, self.distX_offset, self._max_episode_length, self.hsr_dof_pos,
self.finger_close_reward_scale,
)
def is_done(self) -> None:
# reset if drawer is open or max length reached
self.reset_buf = torch.where(self.cabinet_dof_pos[:, 3] > 0.39, torch.ones_like(self.reset_buf), self.reset_buf)
self.reset_buf = torch.where(self.progress_buf >= self._max_episode_length - 1, torch.ones_like(self.reset_buf), self.reset_buf)
def compute_grasp_transforms(
self,
hand_rot,
hand_pos,
hsr_local_grasp_rot,
hsr_local_grasp_pos,
drawer_rot,
drawer_pos,
drawer_local_grasp_rot,
drawer_local_grasp_pos,
):
global_hsr_rot, global_hsr_pos = tf_combine(
hand_rot, hand_pos, hsr_local_grasp_rot, hsr_local_grasp_pos
)
global_drawer_rot, global_drawer_pos = tf_combine(
drawer_rot, drawer_pos, drawer_local_grasp_rot, drawer_local_grasp_pos
)
return global_hsr_rot, global_hsr_pos, global_drawer_rot, global_drawer_pos
def compute_hsr_reward(
self, reset_buf, progress_buf, actions, cabinet_dof_pos,
hsr_grasp_pos, drawer_grasp_pos, hsr_grasp_rot, drawer_grasp_rot,
hsr_lfinger_pos, hsr_rfinger_pos,
gripper_forward_axis, drawer_inward_axis, gripper_up_axis, drawer_up_axis,
num_envs, dist_reward_scale, rot_reward_scale, around_handle_reward_scale, open_reward_scale,
finger_dist_reward_scale, action_penalty_scale, distX_offset, max_episode_length, joint_positions, finger_close_reward_scale
):
# type: (Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, int, float, float, float, float, float, float, float, float, Tensor) -> Tuple[Tensor, Tensor]
# distance from hand to the drawer
d = torch.norm(hsr_grasp_pos - drawer_grasp_pos, p=2, dim=-1)
dist_reward = 1.0 / (1.0 + d ** 2)
dist_reward *= dist_reward
dist_reward = torch.where(d <= 0.02, dist_reward * 2, dist_reward)
axis1 = tf_vector(hsr_grasp_rot, gripper_forward_axis)
axis2 = tf_vector(drawer_grasp_rot, drawer_inward_axis)
axis3 = tf_vector(hsr_grasp_rot, gripper_up_axis)
axis4 = tf_vector(drawer_grasp_rot, drawer_up_axis)
dot1 = torch.bmm(axis1.view(num_envs, 1, 3), axis2.view(num_envs, 3, 1)).squeeze(-1).squeeze(-1) # alignment of forward axis for gripper
dot2 = torch.bmm(axis3.view(num_envs, 1, 3), axis4.view(num_envs, 3, 1)).squeeze(-1).squeeze(-1) # alignment of up axis for gripper
# reward for matching the orientation of the hand to the drawer (fingers wrapped)
rot_reward = 0.5 * (torch.sign(dot1) * dot1 ** 2 + torch.sign(dot2) * dot2 ** 2)
# bonus if left finger is above the drawer handle and right below
around_handle_reward = torch.zeros_like(rot_reward)
around_handle_reward = torch.where(hsr_lfinger_pos[:, 2] > drawer_grasp_pos[:, 2],
torch.where(hsr_rfinger_pos[:, 2] < drawer_grasp_pos[:, 2],
around_handle_reward + 0.5, around_handle_reward), around_handle_reward)
# reward for distance of each finger from the drawer
finger_dist_reward = torch.zeros_like(rot_reward)
lfinger_dist = torch.abs(hsr_lfinger_pos[:, 2] - drawer_grasp_pos[:, 2])
rfinger_dist = torch.abs(hsr_rfinger_pos[:, 2] - drawer_grasp_pos[:, 2])
finger_dist_reward = torch.where(hsr_lfinger_pos[:, 2] > drawer_grasp_pos[:, 2],
torch.where(hsr_rfinger_pos[:, 2] < drawer_grasp_pos[:, 2],
(0.04 - lfinger_dist) + (0.04 - rfinger_dist), finger_dist_reward), finger_dist_reward)
finger_close_reward = torch.zeros_like(rot_reward)
finger_close_reward = torch.where(d <=0.03, (0.04 - joint_positions[:, 7]) + (0.04 - joint_positions[:, 8]), finger_close_reward)
# regularization on the actions (summed for each environment)
action_penalty = torch.sum(actions ** 2, dim=-1)
# how far the cabinet has been opened out
open_reward = cabinet_dof_pos[:, 3] * around_handle_reward + cabinet_dof_pos[:, 3] # drawer_top_joint
rewards = dist_reward_scale * dist_reward + rot_reward_scale * rot_reward \
+ around_handle_reward_scale * around_handle_reward + open_reward_scale * open_reward \
+ finger_dist_reward_scale * finger_dist_reward - action_penalty_scale * action_penalty + finger_close_reward * finger_close_reward_scale
# bonus for opening drawer properly
rewards = torch.where(cabinet_dof_pos[:, 3] > 0.01, rewards + 0.5, rewards)
rewards = torch.where(cabinet_dof_pos[:, 3] > 0.2, rewards + around_handle_reward, rewards)
rewards = torch.where(cabinet_dof_pos[:, 3] > 0.39, rewards + (2.0 * around_handle_reward), rewards)
return rewards
| 21,223 |
Python
| 47.346241 | 222 | 0.625077 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/example/hsr_reach.py
|
# Copyright (c) 2018-2022, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import torch
from hsr_rl.tasks.base.rl_task import RLTask
from hsr_rl.robots.articulations.hsr import HSR
from hsr_rl.robots.articulations.views.hsr_view import HSRView
from omni.isaac.core.utils.prims import get_prim_at_path
from omni.isaac.core.utils.stage import get_current_stage
from omni.isaac.core.prims.rigid_prim_view import RigidPrimView
from omni.isaac.core.utils.torch.maths import tensor_clamp, torch_rand_float, torch_random_dir_2
from omni.isaac.core.objects import DynamicSphere
# Whole Body example task with holonomic robot base
class HSRExampleReachTask(RLTask):
def __init__(
self,
name,
sim_config,
env
) -> None:
self._sim_config = sim_config
self._cfg = sim_config.config
self._task_cfg = sim_config.task_config
self._device = self._cfg["sim_device"]
self._num_envs = self._task_cfg["env"]["numEnvs"]
self._env_spacing = self._task_cfg["env"]["envSpacing"]
self._dt = torch.tensor(self._sim_config.task_config["sim"]["dt"] * self._sim_config.task_config["env"]["controlFrequencyInv"], device=self._device)
self._num_observations = self._task_cfg["env"]["num_observations"]
self._num_actions = self._task_cfg["env"]["num_actions"]
self._hsr_position = torch.tensor([0.0, 0.0, 0.01], device=self._device)
# ball properties
self._ball_position = torch.tensor([1.5, 0.0, 0.045], device=self._device)
self._ball_radius = torch.tensor([0.05], device=self._device)
self._action_speed_scale = self._task_cfg["env"]["actionSpeedScale"]
self._max_episode_length = self._task_cfg["env"]["maxEpisodeLength"]
# Start at 'home' positions
self.torso_start = torch.tensor([0.1], device=self._device)
self.base_start = torch.tensor([0.0, 0.0, 0.0], device=self._device)
self.arm_start = torch.tensor([0.1, -1.570796, 0.0, -0.392699, 0], device=self._device)
self.gripper_proximal_start = torch.tensor([0.75, 0.75], device=self._device) # Opened gripper by default
# joint & body names
self._torso_joint_name = ["torso_lift_joint"]
self._base_joint_names = ["joint_x", "joint_y", "joint_rz"]
self._arm_names = ["arm_lift_joint", "arm_flex_joint", "arm_roll_joint", "wrist_flex_joint", "wrist_roll_joint"]
self._gripper_proximal_names = ["hand_l_proximal_joint", "hand_r_proximal_joint"]
# values are set in post_reset after model is loaded
self.torso_dof_idx = []
self.base_dof_idxs = []
self.arm_dof_idxs = []
self.gripper_proximal_dof_idxs = []
# dof joint position limits
self.torso_dof_lower = []
self.torso_dof_upper = []
self.base_dof_lower = []
self.base_dof_upper = []
self.arm_dof_lower = []
self.arm_dof_upper = []
self.gripper_p_dof_lower = []
self.gripper_p_dof_upper = []
RLTask.__init__(self, name, env)
return
def set_up_scene(self, scene) -> None:
self.add_hsr()
self.add_ball()
# Set up scene
super().set_up_scene(scene)
# Add robot to scene
self._robots = HSRView(prim_paths_expr="/World/envs/.*/hsrb", name="hsrb_view") # ArticulationView(prim_paths_expr="/World/envs/.*/hsrb", name="hsrb_view", reset_xform_properties=False)
scene.add(self._robots)
scene.add(self._robots._hands)
scene.add(self._robots._lfingers)
scene.add(self._robots._rfingers)
scene.add(self._robots._fingertip_centered)
# Add ball to scene
self._balls = RigidPrimView(prim_paths_expr="/World/envs/.*/Ball/ball", name="ball_view", reset_xform_properties=False)
scene.add(self._balls)
return
def add_hsr(self):
hsrb = HSR(prim_path=self.default_zero_env_path + "/hsrb", name="hsrb", translation=self._hsr_position)
self._sim_config.apply_articulation_settings("hsrb", get_prim_at_path(hsrb.prim_path), self._sim_config.parse_actor_config("hsrb"))
def add_ball(self):
ball = DynamicSphere(
prim_path=self.default_zero_env_path + "/Ball/ball",
translation=self._ball_position,
name="ball_0",
radius=0.05,
color=torch.tensor([0.2, 0.4, 0.6]),
)
self._sim_config.apply_articulation_settings("ball", get_prim_at_path(ball.prim_path), self._sim_config.parse_actor_config("ball"))
def get_observations(self):
# Get ball positions and orientations
ball_positions, ball_orientations = self._balls.get_world_poses(clone=False)
ball_positions = ball_positions[:, 0:3] - self._env_pos
# Get ball velocities
ball_velocities = self._balls.get_velocities(clone=False)
ball_linvels = ball_velocities[:, 0:3]
ball_angvels = ball_velocities[:, 3:6]
# Get end effector positions and orientations
end_effector_positions, end_effector_orientations = self._robots._fingertip_centered.get_world_poses(clone=False)
end_effector_positions = end_effector_positions[:, 0:3] - self._env_pos
# Get end effector velocities
end_effector_velocities = self._robots._fingertip_centered.get_velocities(clone=False)
end_effector_linvels = end_effector_velocities[:, 0:3]
end_effector_angvels = end_effector_velocities[:, 3:6]
dof_pos = self._robots.get_joint_positions(clone=False)
dof_vel = self._robots.get_joint_velocities(clone=False)
self.obs_buf[..., 0:8] = dof_pos[..., self.actuated_dof_indices]
self.obs_buf[..., 8:16] = dof_vel[..., self.actuated_dof_indices]
self.obs_buf[..., 16:19] = end_effector_positions
self.obs_buf[..., 19:22] = end_effector_linvels
self.obs_buf[..., 22:25] = ball_positions
self.obs_buf[..., 25:28] = ball_linvels
self.ball_positions = ball_positions
self.ball_linvels = ball_linvels
observations = {
"hsr_reach": {
"obs_buf": self.obs_buf
}
}
return observations
def pre_physics_step(self, actions) -> None:
if not self._env._world.is_playing():
return
reset_env_ids = self.reset_buf.nonzero(as_tuple=False).squeeze(-1)
if len(reset_env_ids) > 0:
self.reset_idx(reset_env_ids)
# update position targets from actions
self.dof_position_targets[..., self.actuated_dof_indices] += self._dt * self._action_speed_scale * actions.to(self.device)
self.dof_position_targets[:] = tensor_clamp(
self.dof_position_targets, self.robot_dof_lower_limits, self.robot_dof_upper_limits
)
dof_pos = self._robots.get_joint_positions()
arm_pos = dof_pos[:, self.arm_dof_idxs]
scaled_arm_lift_pos = arm_pos[:, 0] / self.arm_dof_upper[0]
scaled_torso_lift_pos = scaled_arm_lift_pos * self.torso_dof_upper[0]
self.dof_position_targets[:, self.torso_dof_idx] = scaled_torso_lift_pos.unsqueeze(dim=1)
# reset position targets for reset envs
self.dof_position_targets[reset_env_ids] = 0
self._robots.set_joint_positions(self.dof_position_targets)
def reset_idx(self, env_ids):
num_resets = len(env_ids)
env_ids_32 = env_ids.type(torch.int32)
env_ids_64 = env_ids.type(torch.int64)
min_d = 0.001 # min horizontal dist from origin
max_d = 0.4 # max horizontal dist from origin
min_height = 0.0
max_height = 0.2
min_horizontal_speed = 0
max_horizontal_speed = 2
dists = torch_rand_float(min_d, max_d, (num_resets, 1), self._device)
dirs = torch_random_dir_2((num_resets, 1), self._device)
hpos = dists * dirs
speedscales = (dists - min_d) / (max_d - min_d)
hspeeds = torch_rand_float(min_horizontal_speed, max_horizontal_speed, (num_resets, 1), self._device)
hvels = -speedscales * hspeeds * dirs
vspeeds = -torch_rand_float(5.0, 5.0, (num_resets, 1), self._device).squeeze()
ball_pos = self.initial_ball_pos.clone()
ball_rot = self.initial_ball_rot.clone()
# position
ball_pos[env_ids_64, 0:2] += hpos[..., 0:2]
ball_pos[env_ids_64, 2] += torch_rand_float(min_height, max_height, (num_resets, 1), self._device).squeeze()
# rotation
ball_rot[env_ids_64, 0] = 1
ball_rot[env_ids_64, 1:] = 0
ball_velocities = self.initial_ball_velocities.clone()
# linear
ball_velocities[env_ids_64, 0:2] = hvels[..., 0:2]
ball_velocities[env_ids_64, 2] = vspeeds
# angular
ball_velocities[env_ids_64, 3:6] = 0
# reset root state for bbots and balls in selected envs
self._balls.set_world_poses(ball_pos[env_ids_64], ball_rot[env_ids_64], indices=env_ids_32)
self._balls.set_velocities(ball_velocities[env_ids_64], indices=env_ids_32)
# reset root pose and velocity
self._robots.set_world_poses(self.initial_robot_pos[env_ids_64].clone(), self.initial_robot_rot[env_ids_64].clone(), indices=env_ids_32)
self._robots.set_velocities(self.initial_robot_velocities[env_ids_64].clone(), indices=env_ids_32)
# reset DOF states for bbots in selected envs
self._robots.set_joint_positions(self.initial_dof_positions[env_ids_64].clone(), indices=env_ids_32)
# bookkeeping
self.reset_buf[env_ids] = 0
self.progress_buf[env_ids] = 0
self.extras[env_ids] = 0
def post_reset(self):
self.set_dof_idxs()
self.set_dof_limits()
self.set_default_state()
dof_limits = self._robots.get_dof_limits()
self.robot_dof_lower_limits, self.robot_dof_upper_limits = torch.t(dof_limits[0].to(device=self._device))
# reset ball pos / rot, and velocities
self.initial_dof_positions = self._robots.get_joint_positions()
self.initial_robot_pos, self.initial_robot_rot = self._robots.get_world_poses()
self.initial_robot_velocities = self._robots.get_velocities()
self.initial_ball_pos, self.initial_ball_rot = self._balls.get_world_poses()
self.initial_ball_velocities = self._balls.get_velocities()
self.dof_position_targets = self._robots.get_joints_default_state().positions
self.actuated_dof_indices = torch.LongTensor([0, 1, 2, 3, 5, 7, 9, 10]).to(self._device)
def calculate_metrics(self) -> None:
# Distance from hand to the ball
dist = torch.norm(self.obs_buf[..., 22:25] - self.obs_buf[..., 16:19], p=2, dim=-1)
dist_reward = 1.0 / (1.0 + dist ** 2)
dist_reward *= dist_reward
dist_reward = torch.where(dist <= 0.02, dist_reward * 2, dist_reward)
self.rew_buf[:] = dist_reward
def is_done(self) -> None:
reset = torch.where(
self.progress_buf >= self._max_episode_length - 1, torch.ones_like(self.reset_buf), self.reset_buf
)
reset = torch.where(self.ball_positions[..., 2] < self._ball_radius * 1.5, torch.ones_like(self.reset_buf), reset)
self.reset_buf[:] = reset
def set_dof_idxs(self):
[self.torso_dof_idx.append(self._robots.get_dof_index(name)) for name in self._torso_joint_name]
[self.base_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._base_joint_names]
[self.arm_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._arm_names]
[self.gripper_proximal_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._gripper_proximal_names]
def set_dof_limits(self): # dof position limits
# (num_envs, num_dofs, 2)
dof_limits = self._robots.get_dof_limits()
dof_limits_lower = dof_limits[0, :, 0].to(self._device)
dof_limits_upper = dof_limits[0, :, 1].to(self._device)
# Set relevant joint position limit values
self.torso_dof_lower = dof_limits_lower[self.torso_dof_idx]
self.torso_dof_upper = dof_limits_upper[self.torso_dof_idx]
self.base_dof_lower = dof_limits_lower[self.base_dof_idxs]
self.base_dof_upper = dof_limits_upper[self.base_dof_idxs]
self.arm_dof_lower = dof_limits_lower[self.arm_dof_idxs]
self.arm_dof_upper = dof_limits_upper[self.arm_dof_idxs]
self.gripper_p_dof_lower = dof_limits_lower[self.gripper_proximal_dof_idxs]
self.gripper_p_dof_upper = dof_limits_upper[self.gripper_proximal_dof_idxs]
def set_default_state(self):
# Set default joint state
joint_states = self._robots.get_joints_default_state()
jt_pos = joint_states.positions
jt_pos[:, self.torso_dof_idx] = self.torso_start
jt_pos[:, self.base_dof_idxs] = self.base_start
jt_pos[:, self.arm_dof_idxs] = self.arm_start
jt_pos[:, self.gripper_proximal_dof_idxs] = self.gripper_proximal_start
jt_vel = joint_states.velocities
jt_vel[:, self.torso_dof_idx] = torch.zeros_like(self.torso_start, device=self._device)
jt_vel[:, self.base_dof_idxs] = torch.zeros_like(self.base_start, device=self._device)
jt_vel[:, self.arm_dof_idxs] = torch.zeros_like(self.arm_start, device=self._device)
jt_vel[:, self.gripper_proximal_dof_idxs] = torch.zeros_like(self.gripper_proximal_start, device=self._device)
self._robots.set_joints_default_state(positions=jt_pos, velocities=jt_vel)
| 15,063 |
Python
| 45.637771 | 193 | 0.642701 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/base/hsr_task.py
|
# Copyright (c) 2018-2022, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import carb
import hydra
import torch
from hsr_rl.robots.articulations.hsr import HSR
from hsr_rl.robots.articulations.views.hsr_view import HSRView
from hsr_rl.tasks.base.rl_task import RLTask
from hsr_rl.tasks.utils.ik_utils import DifferentialInverseKinematics, DifferentialInverseKinematicsCfg
from omni.isaac.core.utils.prims import get_prim_at_path
from omni.isaac.core.utils.stage import get_current_stage
from omni.isaac.core.utils.torch.rotations import quat_diff_rad, quat_mul, normalize
from omni.isaac.core.objects import FixedCuboid
from omni.isaac.core.simulation_context import SimulationContext
from omni.physx.scripts import utils, physicsUtils
class HSRBaseTask(RLTask):
def __init__(
self,
name,
sim_config,
env
) -> None:
self._sim_config = sim_config
self._cfg = sim_config.config
self._task_cfg = sim_config.task_config
self._device = self._cfg["sim_device"]
self._num_envs = self._task_cfg["env"]["numEnvs"]
self._env_spacing = self._task_cfg["env"]["envSpacing"]
# Get dt for integrating velocity commands and checking limit violations
self._dt = torch.tensor(self._sim_config.task_config["sim"]["dt"] * self._sim_config.task_config["env"]["controlFrequencyInv"], device=self._device)
# Set environment properties
self._table_height = self._task_cfg["env"]["table_height"]
self._table_width = self._task_cfg["env"]["table_width"]
self._table_depth = self._task_cfg["env"]["table_depth"]
# Set physics parameters for gripper
self._gripper_mass = self._sim_config.task_config["sim"]["gripper"]["mass"]
self._gripper_density = self._sim_config.task_config["sim"]["gripper"]["density"]
self._gripper_static_friction = self._sim_config.task_config["sim"]["gripper"]["static_friction"]
self._gripper_dynamic_friction = self._sim_config.task_config["sim"]["gripper"]["dynamic_friction"]
self._gripper_restitution = self._sim_config.task_config["sim"]["gripper"]["restitution"]
# Choose num_obs and num_actions based on task.
self._num_observations = self._task_cfg["env"]["num_observations"]
self._num_actions = self._task_cfg["env"]["num_actions"]
# Set inverse kinematics configurations
self._action_type = self._task_cfg["env"]["action_type"]
self._target_space = self._task_cfg["env"]["target_space"]
# Set up environment from loaded demonstration
self._hsr_position = torch.tensor([0.0, 0.0, 0.01], device=self._device)
self._hsr_rotation = torch.tensor([1.0, 0.0, 0.0, 0.0], device=self._device)
self._table_position = torch.tensor([1.2, -0.2, self._table_height/2], device=self._device)
self._table_rotation = torch.tensor([1.0, 0.0, 0.0, 0.0], device=self._device)
# Dof joint gains
self.joint_kps = torch.tensor([1e9, 1e9, 5.7296e10, 1e9, 1e9, 5.7296e10, 5.7296e10, 5.7296e10,
5.7296e10, 5.7296e10, 5.7296e10, 2.8648e4, 2.8648e4, 5.7296e10, 5.7296e10], device=self._device)
self.joint_kds = torch.tensor([1.4, 1.4, 80.2141, 1.4, 0.0, 80.2141, 0.0, 80.2141, 0.0, 80.2141,
80.2141, 17.1887, 17.1887, 17.1887, 17.1887], device=self._device)
# Dof joint friction coefficients
self.joint_friction_coefficients = torch.tensor([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], device=self._device)
# Joint & body names
self._torso_joint_name = ["torso_lift_joint"]
self._base_joint_names = ["joint_x", "joint_y", "joint_rz"]
self._arm_names = ["arm_lift_joint", "arm_flex_joint", "arm_roll_joint", "wrist_flex_joint", "wrist_roll_joint"]
self._gripper_proximal_names = ["hand_l_proximal_joint", "hand_r_proximal_joint"]
# Values are set in post_reset after model is loaded
self.torso_dof_idx = []
self.base_dof_idxs = []
self.arm_dof_idxs = []
self.gripper_proximal_dof_idxs = []
# Dof joint position limits
self.torso_dof_lower = []
self.torso_dof_upper = []
self.base_dof_lower = []
self.base_dof_upper = []
self.arm_dof_lower = []
self.arm_dof_upper = []
self.gripper_proximal_dof_lower = []
self.gripper_proximal_dof_upper = []
# Gripper settings
self.gripper_close = torch.zeros(self._num_envs, device=self._device, dtype=torch.bool)
self.gripper_open = torch.zeros(self._num_envs, device=self._device, dtype=torch.bool)
self.gripper_hold = torch.zeros(self._num_envs, device=self._device, dtype=torch.bool)
# Load ik controller
self.ik_controller = self.set_ik_controller()
RLTask.__init__(self, name, env)
return
def set_up_environment(self) -> None:
raise NotImplementedError
def set_up_scene(self, scene) -> None:
# Create gripper materials
self.create_gripper_material()
# Import before environment parallelization
self.add_hsr()
self.add_table()
# Set up scene
super().set_up_scene(scene, replicate_physics=False)
# Add robot to scene
self._robots = HSRView(prim_paths_expr="/World/envs/.*/hsrb", name="hsrb_view")
scene.add(self._robots)
scene.add(self._robots._hands)
scene.add(self._robots._lfingers)
scene.add(self._robots._rfingers)
scene.add(self._robots._fingertip_centered)
def add_hsr(self):
# Add HSR
hsrb = HSR(prim_path=self.default_zero_env_path + "/hsrb",
name="hsrb",
translation=self._hsr_position,
orientation=self._hsr_rotation)
self._sim_config.apply_articulation_settings("hsrb", get_prim_at_path(hsrb.prim_path), self._sim_config.parse_actor_config("hsrb"))
def add_table(self):
# Add table
table = FixedCuboid(prim_path=self.default_zero_env_path + "/table",
name="table",
translation=self._table_position,
orientation=self._table_rotation,
size=self._table_size,
color=torch.tensor([0.75, 0.75, 0.75]),
scale=torch.tensor([self._table_width, self._table_depth, self._table_height]))
self._sim_config.apply_articulation_settings("table", get_prim_at_path(table.prim_path), self._sim_config.parse_actor_config("table"))
def create_gripper_material(self):
self._stage = get_current_stage()
self.gripperPhysicsMaterialPath = "/World/Physics_Materials/GripperMaterial"
utils.addRigidBodyMaterial(
self._stage,
self.gripperPhysicsMaterialPath,
density=self._gripper_density,
staticFriction=self._gripper_static_friction,
dynamicFriction=self._gripper_dynamic_friction,
restitution=self._gripper_restitution
)
def get_observations(self):
raise NotImplementedError()
def pre_physics_step(self, actions) -> None:
raise NotImplementedError()
def reset_idx(self, env_ids):
raise NotImplementedError()
def post_reset(self):
raise NotImplementedError()
def calculate_metrics(self) -> None:
raise NotImplementedError()
def is_done(self) -> None:
raise NotImplementedError()
def post_physics_step(self):
raise NotImplementedError()
def load_dataset(self):
raise NotImplementedError()
def set_dof_idxs(self):
[self.torso_dof_idx.append(self._robots.get_dof_index(name)) for name in self._torso_joint_name]
[self.base_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._base_joint_names]
[self.arm_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._arm_names]
[self.gripper_proximal_dof_idxs.append(self._robots.get_dof_index(name)) for name in self._gripper_proximal_names]
# Movable joints
self.actuated_dof_indices = torch.LongTensor(self.base_dof_idxs+self.arm_dof_idxs+self.gripper_proximal_dof_idxs).to(self._device) # torch.LongTensor([0, 1, 2, 3, 5, 7, 9, 10, 11, 12]).to(self._device)
self.movable_dof_indices = torch.LongTensor(self.base_dof_idxs+self.arm_dof_idxs).to(self._device) # torch.LongTensor([0, 1, 2, 3, 5, 7, 9, 10]).to(self._device)
def set_dof_limits(self): # dof position limits
# (num_envs, num_dofs, 2)
dof_limits = self._robots.get_dof_limits()
dof_limits_lower = dof_limits[0, :, 0].to(self._device)
dof_limits_upper = dof_limits[0, :, 1].to(self._device)
# Set relevant joint position limit values
self.torso_dof_lower = dof_limits_lower[self.torso_dof_idx]
self.torso_dof_upper = dof_limits_upper[self.torso_dof_idx]
self.base_dof_lower = dof_limits_lower[self.base_dof_idxs]
self.base_dof_upper = dof_limits_upper[self.base_dof_idxs]
self.arm_dof_lower = dof_limits_lower[self.arm_dof_idxs]
self.arm_dof_upper = dof_limits_upper[self.arm_dof_idxs]
self.gripper_proximal_dof_lower = dof_limits_lower[self.gripper_proximal_dof_idxs]
self.gripper_proximal_dof_upper = dof_limits_upper[self.gripper_proximal_dof_idxs]
self.robot_dof_lower_limits, self.robot_dof_upper_limits = torch.t(dof_limits[0].to(device=self._device))
def set_default_state(self):
# Start at 'home' positions
self.torso_start = self.initial_dof_positions[:, self.torso_dof_idx]
self.base_start = self.initial_dof_positions[:, self.base_dof_idxs]
self.arm_start = self.initial_dof_positions[:, self.arm_dof_idxs]
self.gripper_proximal_start = self.initial_dof_positions[:, self.gripper_proximal_dof_idxs]
# Set default joint state
joint_states = self._robots.get_joints_default_state()
jt_pos = joint_states.positions
jt_pos[:, self.torso_dof_idx] = self.torso_start.float()
jt_pos[:, self.base_dof_idxs] = self.base_start.float()
jt_pos[:, self.arm_dof_idxs] = self.arm_start.float()
jt_pos[:, self.gripper_proximal_dof_idxs] = self.gripper_proximal_start.float()
jt_vel = joint_states.velocities
jt_vel[:, self.torso_dof_idx] = torch.zeros_like(self.torso_start, device=self._device, dtype=torch.float)
jt_vel[:, self.base_dof_idxs] = torch.zeros_like(self.base_start, device=self._device, dtype=torch.float)
jt_vel[:, self.arm_dof_idxs] = torch.zeros_like(self.arm_start, device=self._device, dtype=torch.float)
jt_vel[:, self.gripper_proximal_dof_idxs] = torch.zeros_like(self.gripper_proximal_start, device=self._device, dtype=torch.float)
self._robots.set_joints_default_state(positions=jt_pos, velocities=jt_vel)
# Initialize target positions
self.dof_position_targets = jt_pos
def set_joint_gains(self):
self._robots.set_gains(kps=self.joint_kps, kds=self.joint_kds)
def set_joint_frictions(self):
self._robots.set_friction_coefficients(self.joint_friction_coefficients)
def _close_gripper(self, env_ids, sim_steps=1):
env_ids_32 = env_ids.type(torch.int32)
env_ids_64 = env_ids.type(torch.int64)
gripper_dof_pos = torch.tensor([-50., -50.], device=self._device)
# Step sim
for _ in range(sim_steps):
self._robots.set_joint_efforts(gripper_dof_pos, indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
SimulationContext.step(self._env._world, render=True)
self.dof_position_targets[env_ids_64[:, None], self.gripper_proximal_dof_idxs] = self._robots.get_joint_positions(indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
self.gripper_hold[env_ids_64] = True
def _open_gripper(self, env_ids, sim_steps=1):
env_ids_32 = env_ids.type(torch.int32)
env_ids_64 = env_ids.type(torch.int64)
gripper_dof_effort = torch.tensor([0., 0.], device=self._device)
self._robots.set_joint_efforts(gripper_dof_effort, indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
gripper_dof_pos = torch.tensor([0.5, 0.5], device=self._device)
# Step sim
for _ in range(sim_steps):
self._robots.set_joint_position_targets(gripper_dof_pos, indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
SimulationContext.step(self._env._world, render=True)
self.dof_position_targets[env_ids_64[:, None], self.gripper_proximal_dof_idxs] = self._robots.get_joint_positions(indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
self.gripper_hold[env_ids_64] = False
def _hold_gripper(self, env_ids):
env_ids_32 = env_ids.type(torch.int32)
env_ids_64 = env_ids.type(torch.int64)
gripper_dof_pos = torch.tensor([-30., -30.], device=self._device)
self._robots.set_joint_efforts(gripper_dof_pos, indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
self.dof_position_targets[env_ids_64[:, None], self.gripper_proximal_dof_idxs] = self._robots.get_joint_positions(indices=env_ids_32, joint_indices=self.gripper_proximal_dof_idxs)
def set_ik_controller(self):
command_type = "pose_rel" if self._action_type == 'relative' else "pose_abs"
ik_control_cfg = DifferentialInverseKinematicsCfg(
command_type=command_type,
ik_method="dls",
position_offset=(0.0, 0.0, 0.0),
rotation_offset=(1.0, 0.0, 0.0, 0.0),
)
return DifferentialInverseKinematics(ik_control_cfg, self._num_envs, self._device)
def enable_gravity(self):
"""Enable gravity."""
gravity = [0.0, 0.0, -9.81]
self._env._world._physics_sim_view.set_gravity(carb.Float3(gravity[0], gravity[1], gravity[2]))
def disable_gravity(self):
"""Disable gravity."""
gravity = [0.0, 0.0, 0.0]
self._env._world._physics_sim_view.set_gravity(carb.Float3(gravity[0], gravity[1], gravity[2]))
@torch.jit.script
def norm_diff_pos(p1: torch.Tensor, p2: torch.Tensor) -> torch.Tensor:
# Calculate norm
diff_norm = torch.norm(p1 - p2, p=2, dim=-1)
return diff_norm
@torch.jit.script
def norm_diff_rot(q1: torch.Tensor, q2: torch.Tensor) -> torch.Tensor:
# Calculate norm
diff_norm1 = torch.norm(q1 - q2, p=2, dim=-1)
diff_norm2 = torch.norm(q2 - q1, p=2, dim=-1)
diff_norm = torch.min(diff_norm1, diff_norm2)
return diff_norm
@torch.jit.script
def quaternion_multiply(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
aw, ax, ay, az = torch.unbind(a, -1)
bw, bx, by, bz = torch.unbind(b, -1)
ow = aw * bw - ax * bx - ay * by - az * bz
ox = aw * bx + ax * bw + ay * bz - az * by
oy = aw * by - ax * bz + ay * bw + az * bx
oz = aw * bz + ax * by - ay * bx + az * bw
return torch.stack((ow, ox, oy, oz), -1)
@torch.jit.script
def calc_diff_pos(p1, p2):
return p1 - p2
@torch.jit.script
def calc_diff_rot(q1, q2):
# Normalize the input quaternions
q1 = normalize(q1)
q2 = normalize(q2)
# Calculate the quaternion product between q2 and the inverse of q1
scaling = torch.tensor([1, -1, -1, -1], device=q1.device)
q1_inv = q1 * scaling
q_diff = quaternion_multiply(q2, q1_inv)
return q_diff
| 17,085 |
Python
| 44.684492 | 209 | 0.650454 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/robot_utils.py
|
import random
import numpy as np
import pybullet as p
from collections import namedtuple
from scipy.spatial.transform import Rotation as R
IKFastInfo = namedtuple('IKFastInfo', ['module_name', 'base_link', 'ee_link', 'free_joints'])
USE_ALL = False
USE_CURRENT = True
############ Mathematics
def invert(pose):
point, quat = pose
return p.invertTransform(point, quat) # TODO: modify
def multiply(*poses):
pose = poses[0]
for next_pose in poses[1:]:
pose = p.multiplyTransforms(pose[0], pose[1], *next_pose) # TODO: modify
return pose
##############
def get_distance(p1, p2, **kwargs):
assert len(p1) == len(p2)
diff = np.array(p2) - np.array(p1)
return np.linalg.norm(diff, ord=2)
def all_between(lower_limits, values, upper_limits):
assert len(lower_limits) == len(values)
assert len(values) == len(upper_limits)
return np.less_equal(lower_limits, values).all() and \
np.less_equal(values, upper_limits).all()
def compute_forward_kinematics(fk_fn, conf):
pose = fk_fn(list(conf))
pos, rot = pose
quat = R.from_matrix(rot).as_quat()
return pos, quat
def compute_inverse_kinematics(ik_fn, pose, sampled=[]):
pos, quat = pose[0], pose[1]
rot = R.from_quat(quat).as_matrix().tolist()
if len(sampled) == 0:
solutions = ik_fn(list(rot), list(pos))
else:
solutions = ik_fn(list(rot), list(pos), list(sampled))
if solutions is None:
return []
return solutions
def select_solution(joints, solutions, curr_joints, nearby_conf=USE_ALL, **kwargs):
if not solutions:
return None
if nearby_conf is USE_ALL:
return random.choice(solutions)
if nearby_conf is USE_CURRENT:
nearby_conf = curr_joints
return min(solutions, key=lambda conf: get_distance(nearby_conf, conf, **kwargs))
| 1,849 |
Python
| 26.205882 | 93 | 0.646836 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/array_utils.py
|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Utilities for working with different array backends."""
import numpy as np
import torch
from typing import Optional, Sequence, Union
import warp as wp
__all__ = ["TENSOR_TYPES", "TENSOR_TYPE_CONVERSIONS", "convert_to_torch"]
TENSOR_TYPES = {
"numpy": np.ndarray,
"torch": torch.Tensor,
"warp": wp.array,
}
"""A dictionary containing the types for each backend.
The keys are the name of the backend ("numpy", "torch", "warp") and the values are the corresponding type
(``np.ndarray``, ``torch.Tensor``, ``wp.array``).
"""
TENSOR_TYPE_CONVERSIONS = {
"numpy": {wp.array: lambda x: x.numpy(), torch.Tensor: lambda x: x.detach().cpu().numpy()},
"torch": {wp.array: lambda x: wp.torch.to_torch(x), np.ndarray: lambda x: torch.from_numpy(x)},
"warp": {np.array: lambda x: wp.array(x), torch.Tensor: lambda x: wp.torch.from_torch(x)},
}
"""A nested dictionary containing the conversion functions for each backend.
The keys of the outer dictionary are the name of target backend ("numpy", "torch", "warp"). The keys of the
inner dictionary are the source backend (``np.ndarray``, ``torch.Tensor``, ``wp.array``).
"""
def convert_to_torch(
array: Sequence[float],
dtype: torch.dtype = None,
device: Optional[Union[torch.device, str]] = None,
) -> torch.Tensor:
"""Converts a given array into a torch tensor.
The function tries to convert the array to a torch tensor. If the array is a numpy/warp arrays, or python
list/tuples, it is converted to a torch tensor. If the array is already a torch tensor, it is returned
directly.
If ``device`` is :obj:`None`, then the function deduces the current device of the data. For numpy arrays,
this defaults to "cpu", for torch tensors it is "cpu" or "cuda", and for warp arrays it is "cuda".
Args:
array (Sequence[float]): The input array. It can be a numpy array, warp array, python list/tuple, or torch tensor.
dtype (torch.dtype, optional): Target data-type for the tensor.
device (Optional[Union[torch.device, str]], optional): The target device for the tensor. Defaults to None.
Returns:
torch.Tensor: The converted array as torch tensor.
"""
# Convert array to tensor
if isinstance(array, torch.Tensor):
tensor = array
elif isinstance(array, np.ndarray):
tensor = torch.from_numpy(array)
elif isinstance(array, wp.array):
tensor = wp.to_torch(array)
else:
tensor = torch.Tensor(array)
# Convert tensor to the right device
if device is not None and str(tensor.device) != str(device):
tensor = tensor.to(device)
# Convert dtype of tensor if requested
if dtype is not None and tensor.dtype != dtype:
tensor = tensor.type(dtype)
return tensor
| 2,943 |
Python
| 37.233766 | 122 | 0.678899 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/math_utils.py
|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Provides utilities for math operations.
Some of these are imported from the module `omni.isaac.core.utils.torch` for convenience.
"""
import numpy as np
import torch
import torch.nn.functional
from typing import Optional, Sequence, Tuple, Union
from omni.isaac.core.utils.torch.maths import normalize, scale_transform, unscale_transform
from omni.isaac.core.utils.torch.rotations import (
quat_apply,
quat_conjugate,
quat_from_angle_axis,
quat_mul,
quat_rotate,
quat_rotate_inverse,
)
__all__ = [
# General
"wrap_to_pi",
"saturate",
"copysign",
# General-Isaac Sim
"normalize",
"scale_transform",
"unscale_transform",
# Rotation
"matrix_from_quat",
"quat_inv",
"quat_from_euler_xyz",
"quat_apply_yaw",
"quat_box_minus",
"euler_xyz_from_quat",
"axis_angle_from_quat",
# Rotation-Isaac Sim
"quat_apply",
"quat_from_angle_axis",
"quat_mul",
"quat_conjugate",
"quat_rotate",
"quat_rotate_inverse",
# Transformations
"combine_frame_transforms",
"subtract_frame_transforms",
"compute_pose_error",
"apply_delta_pose",
# Sampling
"default_orientation",
"random_orientation",
"random_yaw_orientation",
"sample_triangle",
"sample_uniform",
]
"""
General
"""
@torch.jit.script
def wrap_to_pi(angles: torch.Tensor) -> torch.Tensor:
"""Wraps input angles (in radians) to the range [-pi, pi].
Args:
angles (torch.Tensor): Input angles.
Returns:
torch.Tensor: Angles in the range [-pi, pi].
"""
angles %= 2 * np.pi
angles -= 2 * np.pi * (angles > np.pi)
return angles
@torch.jit.script
def saturate(x: torch.Tensor, lower: torch.Tensor, upper: torch.Tensor) -> torch.Tensor:
"""Clamps a given input tensor to (lower, upper).
It uses pytorch broadcasting functionality to deal with batched input.
Args:
x: Input tensor of shape (N, dims).
lower: The minimum value of the tensor. Shape (dims,)
upper: The maximum value of the tensor. Shape (dims,)
Returns:
Clamped transform of the tensor. Shape (N, dims)
"""
return torch.max(torch.min(x, upper), lower)
@torch.jit.script
def copysign(mag: float, other: torch.Tensor) -> torch.Tensor:
"""Create a new floating-point tensor with the magnitude of input and the sign of other, element-wise.
Note:
The implementation follows from `torch.copysign`. The function allows a scalar magnitude.
Args:
mag (float): The magnitude scalar.
other (torch.Tensor): The tensor containing values whose signbits are applied to magnitude.
Returns:
torch.Tensor: The output tensor.
"""
mag = torch.tensor(mag, device=other.device, dtype=torch.float).repeat(other.shape[0])
return torch.abs(mag) * torch.sign(other)
"""
Rotation
"""
@torch.jit.script
def matrix_from_quat(quaternions: torch.Tensor) -> torch.Tensor:
"""Convert rotations given as quaternions to rotation matrices.
Args:
quaternions: quaternions with real part first,
as tensor of shape (..., 4).
Returns:
Rotation matrices as tensor of shape (..., 3, 3).
Reference:
Based on PyTorch3D (https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/transforms/rotation_conversions.py#L41-L70)
"""
r, i, j, k = torch.unbind(quaternions, -1)
# pyre-fixme[58]: `/` is not supported for operand types `float` and `Tensor`.
two_s = 2.0 / (quaternions * quaternions).sum(-1)
o = torch.stack(
(
1 - two_s * (j * j + k * k),
two_s * (i * j - k * r),
two_s * (i * k + j * r),
two_s * (i * j + k * r),
1 - two_s * (i * i + k * k),
two_s * (j * k - i * r),
two_s * (i * k - j * r),
two_s * (j * k + i * r),
1 - two_s * (i * i + j * j),
),
-1,
)
return o.reshape(quaternions.shape[:-1] + (3, 3))
def convert_quat(
quat: Union[torch.tensor, Sequence[float]], to: Optional[str] = "xyzw"
) -> Union[torch.tensor, np.ndarray]:
"""Converts quaternion from one convention to another.
The convention to convert TO is specified as an optional argument. If to == 'xyzw',
then the input is in 'wxyz' format, and vice-versa.
Args:
quat (Union[torch.tensor, Sequence[float]]): Input quaternion of shape (..., 4).
to (Optional[str], optional): Convention to convert quaternion to.. Defaults to "xyzw".
Raises:
ValueError: Invalid input argument `to`, i.e. not "xyzw" or "wxyz".
ValueError: Invalid shape of input `quat`, i.e. not (..., 4,).
Returns:
Union[torch.tensor, np.ndarray]: The converted quaternion in specified convention.
"""
# convert to numpy (sanity check)
if not isinstance(quat, torch.Tensor):
quat = np.asarray(quat)
# check input is correct
if quat.shape[-1] != 4:
msg = f"convert_quat(): Expected input quaternion shape mismatch: {quat.shape} != (..., 4)."
raise ValueError(msg)
# convert to specified quaternion type
if to == "xyzw":
return quat[..., [1, 2, 3, 0]]
elif to == "wxyz":
return quat[..., [3, 0, 1, 2]]
else:
raise ValueError("convert_quat(): Choose a valid `to` argument (xyzw or wxyz).")
@torch.jit.script
def quat_inv(q: torch.Tensor) -> torch.Tensor:
"""Compute the inverse of a quaternion.
Args:
q (torch.Tensor): The input quaternion (w, x, y, z).
Returns:
torch.Tensor: The inverse quaternion (w, x, y, z).
"""
return normalize(quat_conjugate(q))
@torch.jit.script
def quat_from_euler_xyz(roll: torch.Tensor, pitch: torch.Tensor, yaw: torch.Tensor) -> torch.Tensor:
"""Convert rotations given as Euler angles in radians to Quaternions.
Note:
The euler angles are assumed in XYZ convention.
Args:
roll: Rotation around x-axis (in radians). Shape: [N,]
pitch: Rotation around y-axis (in radians). Shape: [N,]
yaw: Rotation around z-axis (in radians). Shape: [N,]
Returns:
torch.Tensor: Quaternion with real part in the start. Shape: [N, 4,]
"""
cy = torch.cos(yaw * 0.5)
sy = torch.sin(yaw * 0.5)
cr = torch.cos(roll * 0.5)
sr = torch.sin(roll * 0.5)
cp = torch.cos(pitch * 0.5)
sp = torch.sin(pitch * 0.5)
# compute quaternion
qw = cy * cr * cp + sy * sr * sp
qx = cy * sr * cp - sy * cr * sp
qy = cy * cr * sp + sy * sr * cp
qz = sy * cr * cp - cy * sr * sp
return torch.stack([qw, qx, qy, qz], dim=-1)
@torch.jit.script
def euler_xyz_from_quat(quat: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
"""
Convert rotations given as quaternions to Euler angles in radians.
Note:
The euler angles are assumed in XYZ convention.
Reference:
https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
Args:
quat: Quaternion with real part in the start. Shape: [N, 4,]
Returns:
Tuple[torch.Tensor, torch.Tensor, torch.Tensor]: A tuple containing roll-pitch-yaw.
"""
q_w, q_x, q_y, q_z = quat[:, 0], quat[:, 1], quat[:, 2], quat[:, 3]
# roll (x-axis rotation)
sin_roll = 2.0 * (q_w * q_x + q_y * q_z)
cos_roll = 1 - 2 * (q_x * q_x + q_y * q_y)
roll = torch.atan2(sin_roll, cos_roll)
# pitch (y-axis rotation)
sin_pitch = 2.0 * (q_w * q_y - q_z * q_x)
pitch = torch.where(torch.abs(sin_pitch) >= 1, copysign(np.pi / 2.0, sin_pitch), torch.asin(sin_pitch))
# yaw (z-axis rotation)
sin_yaw = 2.0 * (q_w * q_z + q_x * q_y)
cos_yaw = 1 - 2 * (q_y * q_y + q_z * q_z)
yaw = torch.atan2(sin_yaw, cos_yaw)
return roll % (2 * np.pi), pitch % (2 * np.pi), yaw % (2 * np.pi)
@torch.jit.script
def quat_apply_yaw(quat: torch.Tensor, vec: torch.Tensor) -> torch.Tensor:
"""Rotate a vector only around the yaw-direction.
Args:
quat (torch.Tensor): Input orientation to extract yaw from.
vec (torch.Tensor): Input vector.
Returns:
torch.Tensor: Rotated vector.
"""
quat_yaw = quat.clone().view(-1, 4)
quat_yaw[:, 1:3] = 0.0 # set x, y components as zero
quat_yaw = normalize(quat_yaw)
return quat_apply(quat_yaw, vec)
@torch.jit.script
def quat_box_minus(q1: torch.Tensor, q2: torch.Tensor) -> torch.Tensor:
"""Implements box-minus operator (quaternion difference).
Args:
q1 (torch.Tensor): A (N, 4) tensor for quaternion (x, y, z, w)
q2 (torch.Tensor): A (N, 4) tensor for quaternion (x, y, z, w)
Returns:
torch.Tensor: q1 box-minus q2
Reference:
https://docs.leggedrobotics.com/kindr/cheatsheet_latest.pdf
"""
quat_diff = quat_mul(q1, quat_conjugate(q2)) # q1 * q2^-1
re = quat_diff[:, 0] # real part, q = [w, x, y, z] = [re, im]
im = quat_diff[:, 1:] # imaginary part
norm_im = torch.norm(im, dim=1)
scale = 2.0 * torch.where(norm_im > 1.0e-7, torch.atan(norm_im / re) / norm_im, torch.sign(re))
return scale.unsqueeze(-1) * im
@torch.jit.script
def axis_angle_from_quat(quat: torch.Tensor, eps: float = 1.0e-6) -> torch.Tensor:
"""Convert rotations given as quaternions to axis/angle.
Args:
quat (torch.Tensor): quaternions with real part first, as tensor of shape (..., 4).
eps (float): The tolerance for Taylor approximation. Defaults to 1.0e-6.
Returns:
torch.Tensor: Rotations given as a vector in axis angle form, as a tensor
of shape (..., 3), where the magnitude is the angle turned
anti-clockwise in radians around the vector's direction.
Reference:
Based on PyTorch3D (https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/transforms/rotation_conversions.py#L526-L554)
"""
# Modified to take in quat as [q_w, q_x, q_y, q_z]
# Quaternion is [q_w, q_x, q_y, q_z] = [cos(theta/2), n_x * sin(theta/2), n_y * sin(theta/2), n_z * sin(theta/2)]
# Axis-angle is [a_x, a_y, a_z] = [theta * n_x, theta * n_y, theta * n_z]
# Thus, axis-angle is [q_x, q_y, q_z] / (sin(theta/2) / theta)
# When theta = 0, (sin(theta/2) / theta) is undefined
# However, as theta --> 0, we can use the Taylor approximation 1/2 - theta^2 / 48
quat = quat * (1.0 - 2.0 * (quat[..., 0:1] < 0.0))
mag = torch.linalg.norm(quat[..., 1:], dim=1)
half_angle = torch.atan2(mag, quat[..., 0])
angle = 2.0 * half_angle
# check whether to apply Taylor approximation
sin_half_angles_over_angles = torch.where(
torch.abs(angle.abs()) > eps, torch.sin(half_angle) / angle, 0.5 - angle * angle / 48
)
return quat[..., 1:4] / sin_half_angles_over_angles.unsqueeze(-1)
"""
Transformations
"""
@torch.jit.script
def combine_frame_transforms(
t01: torch.Tensor, q01: torch.Tensor, t12: torch.Tensor = None, q12: torch.Tensor = None
) -> Tuple[torch.Tensor, torch.Tensor]:
r"""Combine transformations between two reference frames into a stationary frame.
It performs the following transformation operation: :math:`T_{02} = T_{01} \times T_{12}`,
where :math:`T_{AB}` is the homogeneous transformation matrix from frame A to B.
Args:
t01 (torch.Tensor): Position of frame 1 w.r.t. frame 0.
q01 (torch.Tensor): Quaternion orientation of frame 1 w.r.t. frame 0.
t12 (torch.Tensor): Position of frame 2 w.r.t. frame 1.
q12 (torch.Tensor): Quaternion orientation of frame 2 w.r.t. frame 1.
Returns:
Tuple[torch.Tensor, torch.Tensor]: A tuple containing the position and orientation of
frame 2 w.r.t. frame 0.
"""
# compute orientation
if q12 is not None:
q02 = quat_mul(q01, q12)
else:
q02 = q01
# compute translation
if t12 is not None:
t02 = t01 + quat_apply(q01, t12)
else:
t02 = t01
return t02, q02
@torch.jit.script
def subtract_frame_transforms(
t01: torch.Tensor, q01: torch.Tensor, t02: torch.Tensor, q02: torch.Tensor
) -> Tuple[torch.Tensor, torch.Tensor]:
r"""Subtract transformations between two reference frames into a stationary frame.
It performs the following transformation operation: :math:`T_{12} = T_{01}^{-1} \times T_{02}`,
where :math:`T_{AB}` is the homogeneous transformation matrix from frame A to B.
Args:
t01 (torch.Tensor): Position of frame 1 w.r.t. frame 0.
q01 (torch.Tensor): Quaternion orientation of frame 1 w.r.t. frame 0 in (w, x, y, z).
t02 (torch.Tensor): Position of frame 2 w.r.t. frame 0.
q02 (torch.Tensor): Quaternion orientation of frame 2 w.r.t. frame 0 in (w, x, y, z).
Returns:
Tuple[torch.Tensor, torch.Tensor]: A tuple containing the position and orientation of
frame 2 w.r.t. frame 1.
"""
# compute orientation
q10 = quat_inv(q01)
q12 = quat_mul(q10, q02)
# compute translation
t12 = quat_apply(q10, t02 - t01)
return t12, q12
@torch.jit.script
def compute_pose_error(t01: torch.Tensor, q01: torch.Tensor, t02: torch.Tensor, q02: torch.Tensor, rot_error_type: str):
"""Compute the position and orientation error between source and target frames.
Args:
t01 (torch.Tensor): Position of source frame.
q01 (torch.Tensor): Quaternion orientation of source frame.
t02 (torch.Tensor): Position of target frame.
q02 (torch.Tensor): Quaternion orientation of target frame.
rot_error_type (str): The rotation error type to return: "quat", "axis_angle".
Returns:
Tuple[torch.Tensor, torch.Tensor]: A tuple containing position and orientation error.
"""
# Compute quaternion error (i.e., difference quaternion)
# Reference: https://personal.utdallas.edu/~sxb027100/dock/quaternion.html
# q_current_norm = q_current * q_current_conj
source_quat_norm = quat_mul(q01, quat_conjugate(q01))[:, 0]
# q_current_inv = q_current_conj / q_current_norm
source_quat_inv = quat_conjugate(q01) / source_quat_norm.unsqueeze(-1)
# q_error = q_target * q_current_inv
quat_error = quat_mul(q02, source_quat_inv)
# Compute position error
pos_error = t02 - t01
# return error based on specified type
if rot_error_type == "quat":
return pos_error, quat_error
elif rot_error_type == "axis_angle":
# Convert to axis-angle error
axis_angle_error = axis_angle_from_quat(quat_error)
return pos_error, axis_angle_error
else:
raise ValueError(f"Unsupported orientation error type: {rot_error_type}. Valid: 'quat', 'axis_angle'.")
@torch.jit.script
def apply_delta_pose(
source_pos: torch.Tensor, source_rot, delta_pose: torch.Tensor, eps: float = 1.0e-6
) -> Tuple[torch.Tensor, torch.Tensor]:
"""Applies delta pose transformation on source pose.
The first three elements of `delta_pose` are interpreted as cartesian position displacement.
The remaining three elements of `delta_pose` are interpreted as orientation displacement
in the angle-axis format.
Args:
frame_pos (torch.Tensor): Position of source frame. Shape: [N, 3]
frame_rot (torch.Tensor): Quaternion orientation of source frame in (w, x, y,z).
delta_pose (torch.Tensor): Position and orientation displacements. Shape [N, 6].
eps (float): The tolerance to consider orientation displacement as zero.
Returns:
torch.Tensor: A tuple containing the displaced position and orientation frames. Shape: ([N, 3], [N, 4])
"""
# number of poses given
num_poses = source_pos.shape[0]
device = source_pos.device
# interpret delta_pose[:, 0:3] as target position displacements
target_pos = source_pos + delta_pose[:, 0:3]
# interpret delta_pose[:, 3:6] as target rotation displacements
rot_actions = delta_pose[:, 3:6]
angle = torch.linalg.vector_norm(rot_actions, dim=1)
axis = rot_actions / angle.unsqueeze(-1)
# change from axis-angle to quat convention
identity_quat = torch.tensor([1.0, 0.0, 0.0, 0.0], device=device).repeat(num_poses, 1)
rot_delta_quat = torch.where(
angle.unsqueeze(-1).repeat(1, 4) > eps, quat_from_angle_axis(angle, axis), identity_quat
)
# TODO: Check if this is the correct order for this multiplication.
target_rot = quat_mul(rot_delta_quat, source_rot)
return target_pos, target_rot
"""
Sampling
"""
@torch.jit.script
def default_orientation(num: int, device: str) -> torch.Tensor:
"""Returns identity rotation transform.
Args:
num (int): The number of rotations to sample.
device (str): Device to create tensor on.
Returns:
torch.Tensor: Identity quaternion (w, x, y, z).
"""
quat = torch.zeros((num, 4), dtype=torch.float, device=device)
quat[..., 0] = 1.0
return quat
@torch.jit.script
def random_orientation(num: int, device: str) -> torch.Tensor:
"""Returns sampled rotation in 3D as quaternion.
Reference:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.random.html
Args:
num (int): The number of rotations to sample.
device (str): Device to create tensor on.
Returns:
torch.Tensor: Sampled quaternion (w, x, y, z).
"""
# sample random orientation from normal distribution
quat = torch.randn((num, 4), dtype=torch.float, device=device)
# normalize the quaternion
return torch.nn.functional.normalize(quat, p=2.0, dim=-1, eps=1e-12)
@torch.jit.script
def random_yaw_orientation(num: int, device: str) -> torch.Tensor:
"""Returns sampled rotation around z-axis.
Args:
num (int): The number of rotations to sample.
device (str): Device to create tensor on.
Returns:
torch.Tensor: Sampled quaternion (w, x, y, z).
"""
roll = torch.zeros(num, dtype=torch.float, device=device)
pitch = torch.zeros(num, dtype=torch.float, device=device)
yaw = 2 * np.pi * torch.rand(num, dtype=torch.float, device=device)
return quat_from_euler_xyz(roll, pitch, yaw)
def sample_triangle(lower: float, upper: float, size: Union[int, Tuple[int, ...]], device: str) -> torch.Tensor:
"""Randomly samples tensor from a triangular distribution.
Args:
lower (float): The lower range of the sampled tensor.
upper (float): The upper range of the sampled tensor.
size (Union[int, Tuple[int, ...]]): The shape of the tensor.
device (str): Device to create tensor on.
Returns:
torch.Tensor: Sampled tensor of shape :obj:`size`.
"""
# convert to tuple
if isinstance(size, int):
size = (size,)
# create random tensor in the range [-1, 1]
r = 2 * torch.rand(*size, device=device) - 1
# convert to triangular distribution
r = torch.where(r < 0.0, -torch.sqrt(-r), torch.sqrt(r))
# rescale back to [0, 1]
r = (r + 1.0) / 2.0
# rescale to range [lower, upper]
return (upper - lower) * r + lower
def sample_uniform(
lower: Union[torch.Tensor, float], upper: Union[torch.Tensor, float], size: Union[int, Tuple[int, ...]], device: str
) -> torch.Tensor:
"""Sample uniformly within a range.
Args:
lower (Union[torch.Tensor, float]): Lower bound of uniform range.
upper (Union[torch.Tensor, float]): Upper bound of uniform range.
size (Union[int, Tuple[int, ...]]): The shape of the tensor.
device (str): Device to create tensor on.
Returns:
torch.Tensor: Sampled tensor of shape :obj:`size`.
"""
# convert to tuple
if isinstance(size, int):
size = (size,)
# return tensor
return torch.rand(*size, device=device) * (upper - lower) + lower
def sample_cylinder(
radius: float, h_range: Tuple[float, float], size: Union[int, Tuple[int, ...]], device: str
) -> torch.Tensor:
"""Sample 3D points uniformly on a cylinder's surface.
The cylinder is centered at the origin and aligned with the z-axis. The height of the cylinder is
sampled uniformly from the range :obj:`h_range`, while the radius is fixed to :obj:`radius`.
The sampled points are returned as a tensor of shape :obj:`(*size, 3)`, i.e. the last dimension
contains the x, y, and z coordinates of the sampled points.
Args:
radius (float): The radius of the cylinder.
h_range (Tuple[float, float]): The minimum and maximum height of the cylinder.
size (Union[int, Tuple[int, ...]]): The shape of the tensor.
device (str): Device to create tensor on.
Returns:
torch.Tensor: Sampled tensor of shape :obj:`(*size, 3)`.
"""
# sample angles
angles = (torch.rand(size, device=device) * 2 - 1) * np.pi
h_min, h_max = h_range
# add shape
if isinstance(size, int):
size = (size, 3)
else:
size += (3,)
# allocate a tensor
xyz = torch.zeros(size, device=device)
xyz[..., 0] = radius * torch.cos(angles)
xyz[..., 1] = radius * torch.sin(angles)
xyz[..., 2].uniform_(h_min, h_max)
# return positions
return xyz
| 21,379 |
Python
| 33.153355 | 139 | 0.627391 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/dict_utils.py
|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Utilities for working with dictionaries."""
import collections.abc
import importlib
import inspect
from typing import Any, Callable, Dict, Iterable, Mapping
from hsr_rl.tasks.utils.array_utils import TENSOR_TYPE_CONVERSIONS, TENSOR_TYPES
__all__ = ["class_to_dict", "update_class_from_dict", "convert_dict_to_backend", "update_dict", "print_dict"]
"""
Dictionary <-> Class operations.
"""
def class_to_dict(obj: object) -> Dict[str, Any]:
"""Convert an object into dictionary recursively.
Note:
Ignores all names starting with "__" (i.e. built-in methods).
Args:
obj (object): An instance of a class to convert.
Raises:
ValueError: When input argument is not an object.
Returns:
Dict[str, Any]: Converted dictionary mapping.
"""
# check that input data is class instance
if not hasattr(obj, "__class__"):
raise ValueError(f"Expected a class instance. Received: {type(obj)}.")
# convert object to dictionary
if isinstance(obj, dict):
obj_dict = obj
else:
obj_dict = obj.__dict__
# convert to dictionary
data = dict()
for key, value in obj_dict.items():
# disregard builtin attributes
if key.startswith("__"):
continue
# check if attribute is callable -- function
if callable(value):
data[key] = f"{value.__module__}:{value.__name__}"
# check if attribute is a dictionary
elif hasattr(value, "__dict__") or isinstance(value, dict):
data[key] = class_to_dict(value)
else:
data[key] = value
return data
def update_class_from_dict(obj, data: Dict[str, Any], _ns: str = "") -> None:
"""Reads a dictionary and sets object variables recursively.
This function performs in-place update of the class member attributes.
Args:
obj (object): An instance of a class to update.
data (Dict[str, Any]): Input dictionary to update from.
_ns (str): Namespace of the current object. This is useful for nested configuration
classes or dictionaries. Defaults to "".
Raises:
TypeError: When input is not a dictionary.
ValueError: When dictionary has a value that does not match default config type.
KeyError: When dictionary has a key that does not exist in the default config type.
"""
for key, value in data.items():
# key_ns is the full namespace of the key
key_ns = _ns + "/" + key
# check if key is present in the object
if hasattr(obj, key):
obj_mem = getattr(obj, key)
if isinstance(obj_mem, Mapping):
# Note: We don't handle two-level nested dictionaries. Just use configclass if this is needed.
# iterate over the dictionary to look for callable values
for k, v in obj_mem.items():
if callable(v):
value[k] = _string_to_callable(value[k])
setattr(obj, key, value)
elif isinstance(value, Mapping):
# recursively call if it is a dictionary
update_class_from_dict(obj_mem, value, _ns=key_ns)
elif isinstance(value, Iterable) and not isinstance(value, str):
# check length of value to be safe
if len(obj_mem) != len(value) and obj_mem is not None:
raise ValueError(
f"[Config]: Incorrect length under namespace: {key_ns}. Expected: {len(obj_mem)}, Received: {len(value)}."
)
# set value
setattr(obj, key, value)
elif callable(obj_mem):
# update function name
value = _string_to_callable(value)
setattr(obj, key, value)
elif isinstance(value, type(obj_mem)):
# check that they are type-safe
setattr(obj, key, value)
else:
raise ValueError(
f"[Config]: Incorrect type under namespace: {key_ns}. Expected: {type(obj_mem)}, Received: {type(value)}."
)
else:
raise KeyError(f"[Config]: Key not found under namespace: {key_ns}.")
"""
Dictionary operations.
"""
def convert_dict_to_backend(
data: dict, backend: str = "numpy", array_types: Iterable[str] = ("numpy", "torch", "warp")
) -> dict:
"""Convert all arrays or tensors in a dictionary to a given backend.
This function iterates over the dictionary, converts all arrays or tensors with the given types to
the desired backend, and stores them in a new dictionary. It also works with nested dictionaries.
Currently supported backends are "numpy", "torch", and "warp".
Note:
This function only converts arrays or tensors. Other types of data are left unchanged. Mutable types
(e.g. lists) are referenced by the new dictionary, so they are not copied.
Args:
data (dict): An input dict containing array or tensor data as values.
backend(str): The backend ("numpy", "torch", "warp") to which arrays in this dict should be converted.
Defaults to "numpy".
array_types(Iterable[str]): A list containing the types of arrays that should be converted to
the desired backend. Defaults to ("numpy", "torch", "warp").
Raises:
ValueError: If the specified ``backend`` or ``array_types`` are unknown, i.e. not in the list of supported
backends ("numpy", "torch", "warp").
Returns:
dict: The updated dict with the data converted to the desired backend.
"""
# THINK: Should we also support converting to a specific device, e.g. "cuda:0"?
# Check the backend is valid.
if backend not in TENSOR_TYPE_CONVERSIONS:
raise ValueError(f"Unknown backend '{backend}'. Supported backends are 'numpy', 'torch', and 'warp'.")
# Define the conversion functions for each backend.
tensor_type_conversions = TENSOR_TYPE_CONVERSIONS[backend]
# Parse the array types and convert them to the corresponding types: "numpy" -> np.ndarray, etc.
parsed_types = list()
for t in array_types:
# Check type is valid.
if t not in TENSOR_TYPES:
raise ValueError(f"Unknown array type: '{t}'. Supported array types are 'numpy', 'torch', and 'warp'.")
# Exclude types that match the backend, since we do not need to convert these.
if t == backend:
continue
# Convert the string types to the corresponding types.
parsed_types.append(TENSOR_TYPES[t])
# Convert the data to the desired backend.
output_dict = dict()
for key, value in data.items():
# Obtain the data type of the current value.
data_type = type(value)
# -- arrays
if data_type in parsed_types:
# check if we have a known conversion.
if data_type not in tensor_type_conversions:
raise ValueError(f"No registered conversion for data type: {data_type} to {backend}!")
# convert the data to the desired backend.
output_dict[key] = tensor_type_conversions[data_type](value)
# -- nested dictionaries
elif isinstance(data[key], dict):
output_dict[key] = convert_dict_to_backend(value)
# -- everything else
else:
output_dict[key] = value
return output_dict
def update_dict(orig_dict: dict, new_dict: collections.abc.Mapping) -> dict:
"""Updates existing dictionary with values from a new dictionary.
This function mimics the dict.update() function. However, it works for
nested dictionaries as well.
Reference:
https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth
Args:
orig_dict (dict): The original dictionary to insert items to.
new_dict (collections.abc.Mapping): The new dictionary to insert items from.
Returns:
dict: The updated dictionary.
"""
for keyname, value in new_dict.items():
if isinstance(value, collections.abc.Mapping):
orig_dict[keyname] = update_dict(orig_dict.get(keyname, {}), value)
else:
orig_dict[keyname] = value
return orig_dict
def print_dict(val, nesting: int = -4, start: bool = True):
"""Outputs a nested dictionary."""
if type(val) == dict:
if not start:
print("")
nesting += 4
for k in val:
print(nesting * " ", end="")
print(k, end=": ")
print_dict(val[k], nesting, start=False)
else:
# deal with functions in print statements
if callable(val) and val.__name__ == "<lambda>":
print("lambda", inspect.getsourcelines(val)[0][0].strip().split("lambda")[1].strip()[:-1])
elif callable(val):
print(f"{val.__module__}:{val.__name__}")
else:
print(val)
"""
Private helper functions.
"""
def _string_to_callable(name: str) -> Callable:
"""Resolves the module and function names to return the function.
Args:
name (str): The function name. The format should be 'module:attribute_name'.
Raises:
ValueError: When the resolved attribute is not a function.
ValueError: _description_
Returns:
Callable: The function loaded from the module.
"""
try:
mod_name, attr_name = name.split(":")
mod = importlib.import_module(mod_name)
callable_object = getattr(mod, attr_name)
# check if attribute is callable
if callable(callable_object):
return callable_object
else:
raise ValueError(f"The imported object is not callable: '{name}'")
except AttributeError as e:
msg = (
"While updating the config from a dictionary, we could not interpret the entry"
"as a callable object. The format of input should be 'module:attribute_name'\n"
f"While processing input '{name}', received the error:\n {e}."
)
raise ValueError(msg)
| 10,319 |
Python
| 37.364312 | 130 | 0.612462 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/pinoc_utils.py
|
from __future__ import print_function
import os
import numpy as np
import pinocchio as pin
from scipy.spatial.transform import Rotation as R
def get_se3_err(pos_first, quat_first, pos_second, quat_second):
# Retruns 6 dimensional log.SE3 error between two poses expressed as position and quaternion rotation
rot_first = R.from_quat(np.array([quat_first[1],quat_first[2],quat_first[3],quat_first[0]])).as_matrix() # Quaternion in scalar last format!!!
rot_second = R.from_quat(np.array([quat_second[1],quat_second[2],quat_second[3],quat_second[0]])).as_matrix() # Quaternion in scalar last format!!!
oMfirst = pin.SE3(rot_first, pos_first)
oMsecond = pin.SE3(rot_second, pos_second)
firstMsecond = oMfirst.actInv(oMsecond)
return pin.log(firstMsecond).vector # log gives us a spatial vector (exp co-ords)
class HSRIKSolver(object):
def __init__(
self,
include_torso: bool = False, # Use torso in th IK solution
include_base: bool = True, # Use base in th IK solution
max_rot_vel: float = 1.0472
) -> None:
# Settings
self.damp = 1e-10
self._include_torso = include_torso
self._include_base = include_base
self.max_rot_vel = max_rot_vel
# Load urdf # TODO: fix
urdf_file = "/root/tamp-hsr/hsr_rl/models/urdf/hsrb_description/hsrb4s.urdf"
self.model = pin.buildModelFromUrdf(urdf_file)
# Choose joints
name_end_effector = "hand_palm_link"
jointsOfInterest = ['arm_lift_joint', 'arm_flex_joint', 'arm_roll_joint',
'wrist_flex_joint', 'wrist_roll_joint']
# Add torso joints
if self._include_torso:
jointsOfInterest = ['torso_lift_joint'] + jointsOfInterest
# Add base joints
if self._include_base:
jointsOfInterest = ['joint_x', 'joint_y', 'joint_rz'] + jointsOfInterest
remove_ids = list()
for jnt in jointsOfInterest:
if self.model.existJointName(jnt):
remove_ids.append(self.model.getJointId(jnt))
else:
print('[IK WARNING]: joint ' + str(jnt) + ' does not belong to the model!')
jointIdsToExclude = np.delete(np.arange(0, self.model.njoints), remove_ids)
# Lock extra joints except joint 0 (root)
reference_configuration=pin.neutral(self.model)
if not self._include_torso:
reference_configuration[4] = 0.1 # lock torso_lift_joint at 0.1
self.model = pin.buildReducedModel(self.model, jointIdsToExclude[1:].tolist(),
reference_configuration=reference_configuration)
assert (len(self.model.joints)==(len(jointsOfInterest)+1)), "[IK Error]: Joints != nDoFs"
self.model_data = self.model.createData()
# Define Joint-Limits
self.joint_pos_min = np.array([-2.617, -1.919, -1.919, -1.919])
self.joint_pos_max = np.array([+0.0, +3.665, +1.221, +3.665])
if self._include_torso:
self.joint_pos_min = np.hstack((np.array([+0.0]), self.joint_pos_min))
self.joint_pos_max = np.hstack((np.array([+0.69]), self.joint_pos_max))
if self._include_base:
self.joint_pos_min = np.hstack((np.array([-10.0, -10.0, -10.0]), self.joint_pos_min))
self.joint_pos_max = np.hstack((np.array([+10.0, +10.0, +10.0]), self.joint_pos_max))
self.joint_pos_mid = (self.joint_pos_max + self.joint_pos_min) / 2.0
# Get End Effector Frame ID
self.id_EE = self.model.getFrameId(name_end_effector)
def get_jacobian(self, curr_conf):
# Compute Jacobian
J = pin.computeFrameJacobian(self.model, self.model_data, curr_conf, self.id_EE)
return J
def solve_fk_hsr(self, curr_joints):
pin.framesForwardKinematics(self.model, self.model_data, curr_joints)
oMf = self.model_data.oMf[self.id_EE]
ee_pos = oMf.translation
ee_quat = pin.Quaternion(oMf.rotation)
return ee_pos, np.array([ee_quat.w, ee_quat.x, ee_quat.y, ee_quat.z])
def solve_ik_pos_hsr(self, des_pos, des_quat, curr_joints=None, n_trials=7, dt=0.1, pos_threshold=0.05, angle_threshold=15.*np.pi/180, verbose=True):
# Get IK positions for hsr robot
damp = 1e-10
success = False
if des_quat is not None:
# quaternion to rot matrix
des_rot = R.from_quat(np.array([des_quat[1], des_quat[2], des_quat[3], des_quat[0]])).as_matrix() # Quaternion in scalar last format!!!
oMdes = pin.SE3(des_rot, des_pos)
else:
# 3D position error only
des_rot = None
if curr_joints is None:
q = np.random.uniform(self.joint_pos_min, self.joint_pos_max)
for n in range(n_trials):
for i in range(800):
pin.framesForwardKinematics(self.model, self.model_data, q)
oMf = self.model_data.oMf[self.id_EE]
if des_rot is None:
oMdes = pin.SE3(oMf.rotation, des_pos) # Set rotation equal to current rotation to exclude this error
dMf = oMdes.actInv(oMf)
err = pin.log(dMf).vector
if (np.linalg.norm(err[0:3]) < pos_threshold) and (np.linalg.norm(err[3:6]) < angle_threshold):
success = True
break
J = pin.computeFrameJacobian(self.model, self.model_data, q, self.id_EE)
if des_rot is None:
J = J[:3, :] # Only pos errors
err = err[:3]
v = - J.T.dot(np.linalg.solve(J.dot(J.T) + damp * np.eye(6), err))
q = pin.integrate(self.model, q, v*dt)
# Clip q to within joint limits
q = np.clip(q, self.joint_pos_min, self.joint_pos_max)
if verbose:
if not i % 100:
print('Trial %d: iter %d: error = %s' % (n+1, i, err.T))
i += 1
if success:
best_q = np.array(q)
else:
# Save current solution
best_q = np.array(q)
# Reset q to random configuration
q = np.random.uniform(self.joint_pos_min, self.joint_pos_max)
if verbose:
if success:
print("[[[[IK: Convergence achieved!]]]")
else:
print("[Warning: the IK iterative algorithm has not reached convergence to the desired precision]")
return success, best_q
if __name__ == '__main__':
hsr_ik_solver = HSRIKSolver()
success, best_q = hsr_ik_solver.solve_ik_pos_hsr(np.array([0.5, 0.1, 0.3]), np.array([0., 0., 0., 1.0]))
print('best_q: ', best_q)
| 6,825 |
Python
| 39.630952 | 153 | 0.57348 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/annotation_utils.py
|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Wrapper around the Python 3.7 onwards `dataclasses` module."""
from copy import deepcopy
from dataclasses import Field, dataclass, field
from typing import Any, Callable, ClassVar, Dict
from hsr_rl.tasks.utils.dict_utils import class_to_dict, update_class_from_dict
# List of all methods provided by sub-module.
__all__ = ["configclass"]
"""
Wrapper around dataclass.
"""
def __dataclass_transform__():
"""Add annotations decorator for PyLance."""
return lambda a: a
@__dataclass_transform__()
def configclass(cls, **kwargs):
"""Wrapper around `dataclass` functionality to add extra checks and utilities.
As of Python3.8, the standard dataclasses have two main issues which makes them non-generic for configuration use-cases.
These include:
1. Requiring a type annotation for all its members.
2. Requiring explicit usage of :meth:`field(default_factory=...)` to reinitialize mutable variables.
This function wraps around :class:`dataclass` utility to deal with the above two issues.
Usage:
.. code-block:: python
from dataclasses import MISSING
from omni.isaac.orbit.utils.configclass import configclass
@configclass
class ViewerCfg:
eye: list = [7.5, 7.5, 7.5] # field missing on purpose
lookat: list = field(default_factory=[0.0, 0.0, 0.0])
@configclass
class EnvCfg:
num_envs: int = MISSING
episode_length: int = 2000
viewer: ViewerCfg = ViewerCfg()
# create configuration instance
env_cfg = EnvCfg(num_envs=24)
# print information
print(env_cfg.to_dict())
Reference:
https://docs.python.org/3/library/dataclasses.html#dataclasses.Field
"""
# add type annotations
_add_annotation_types(cls)
# add field factory
_process_mutable_types(cls)
# copy mutable members
setattr(cls, "__post_init__", _custom_post_init)
# add helper functions for dictionary conversion
setattr(cls, "to_dict", _class_to_dict)
setattr(cls, "from_dict", _update_class_from_dict)
# wrap around dataclass
cls = dataclass(cls, **kwargs)
# return wrapped class
return cls
"""
Dictionary <-> Class operations.
These are redefined here to add new docstrings.
"""
def _class_to_dict(obj: object) -> Dict[str, Any]:
"""Convert an object into dictionary recursively.
Returns:
Dict[str, Any]: Converted dictionary mapping.
"""
return class_to_dict(obj)
def _update_class_from_dict(obj, data: Dict[str, Any]) -> None:
"""Reads a dictionary and sets object variables recursively.
This function performs in-place update of the class member attributes.
Args:
data (Dict[str, Any]): Input (nested) dictionary to update from.
Raises:
TypeError: When input is not a dictionary.
ValueError: When dictionary has a value that does not match default config type.
KeyError: When dictionary has a key that does not exist in the default config type.
"""
return update_class_from_dict(obj, data, _ns="")
"""
Private helper functions.
"""
def _add_annotation_types(cls):
"""Add annotations to all elements in the dataclass.
By definition in Python, a field is defined as a class variable that has a type annotation.
In case type annotations are not provided, dataclass ignores those members when :func:`__dict__()` is called.
This function adds these annotations to the class variable to prevent any issues in case the user forgets to
specify the type annotation.
This makes the following a feasible operation:
@dataclass
class State:
pos = (0.0, 0.0, 0.0)
^^
If the function is NOT used, the following type-error is returned:
TypeError: 'pos' is a field but has no type annotation
"""
# Note: Do not change this line. `cls.__dict__.get("__annotations__", {})` is different from `cls.__annotations__` because of inheritance.
cls.__annotations__ = cls.__dict__.get("__annotations__", {})
# cls.__annotations__ = dict()
for key in dir(cls):
# skip dunder members
if key.startswith("__"):
continue
# skip class functions
if key in ["from_dict", "to_dict"]:
continue
# add type annotations for members that are not functions
var = getattr(cls, key)
if not isinstance(var, type):
if key not in cls.__annotations__:
cls.__annotations__[key] = type(var)
def _process_mutable_types(cls):
"""Initialize all mutable elements through :obj:`dataclasses.Field` to avoid unnecessary complaints.
By default, dataclass requires usage of :obj:`field(default_factory=...)` to reinitialize mutable objects every time a new
class instance is created. If a member has a mutable type and it is created without specifying the `field(default_factory=...)`,
then Python throws an error requiring the usage of `default_factory`.
Additionally, Python only explicitly checks for field specification when the type is a list, set or dict. This misses the
use-case where the type is class itself. Thus, the code silently carries a bug with it which can lead to undesirable effects.
This function deals with this issue
This makes the following a feasible operation:
@dataclass
class State:
pos: list = [0.0, 0.0, 0.0]
^^
If the function is NOT used, the following value-error is returned:
ValueError: mutable default <class 'list'> for field pos is not allowed: use default_factory
"""
def _return_f(f: Any) -> Callable[[], Any]:
"""Returns default function for creating mutable/immutable variables."""
def _wrap():
if isinstance(f, Field):
return f.default_factory
else:
return f
return _wrap
for key in dir(cls):
# skip dunder members
if key.startswith("__"):
continue
# skip class functions
if key in ["from_dict", "to_dict"]:
continue
# do not create field for class variables
if key in cls.__annotations__:
origin = getattr(cls.__annotations__[key], "__origin__", None)
if origin is ClassVar:
continue
# define explicit field for data members
f = getattr(cls, key)
if not isinstance(f, type):
f = field(default_factory=_return_f(f))
setattr(cls, key, f)
def _custom_post_init(obj):
"""Deepcopy all elements to avoid shared memory issues for mutable objects in dataclasses initialization.
This function is called explicitly instead of as a part of :func:`_process_mutable_types()` to prevent mapping
proxy type i.e. a read only proxy for mapping objects. The error is thrown when using hierarchical data-classes
for configuration.
"""
for key in dir(obj):
# skip dunder members
if key.startswith("__"):
continue
# duplicate data members
var = getattr(obj, key)
if not callable(var):
setattr(obj, key, deepcopy(var))
| 7,468 |
Python
| 32.644144 | 142 | 0.64301 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/ik_utils.py
|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import torch
from dataclasses import MISSING
from typing import Dict, Optional, Tuple
from hsr_rl.tasks.utils.annotation_utils import configclass
from hsr_rl.tasks.utils.transform_utils import (
apply_delta_pose,
combine_frame_transforms,
compute_pose_error,
quat_apply,
quat_inv
)
@configclass
class DifferentialInverseKinematicsCfg:
"""Configuration for inverse differential kinematics controller."""
command_type: str = MISSING
"""Type of command: "position_abs", "position_rel", "pose_abs", "pose_rel"."""
ik_method: str = MISSING
"""Method for computing inverse of Jacobian: "pinv", "svd", "trans", "dls"."""
ik_params: Optional[Dict[str, float]] = None
"""Parameters for the inverse-kinematics method. (default: obj:`None`).
- Moore-Penrose pseudo-inverse ("pinv"):
- "k_val": Scaling of computed delta-dof positions (default: 1.0).
- Adaptive Singular Value Decomposition ("svd"):
- "k_val": Scaling of computed delta-dof positions (default: 1.0).
- "min_singular_value": Single values less than this are suppressed to zero (default: 1e-5).
- Jacobian transpose ("trans"):
- "k_val": Scaling of computed delta-dof positions (default: 1.0).
- Damped Moore-Penrose pseudo-inverse ("dls"):
- "lambda_val": Damping coefficient (default: 0.1).
"""
position_offset: Tuple[float, float, float] = (0.0, 0.0, 0.0)
"""Position offset from parent body to end-effector frame in parent body frame."""
rotation_offset: Tuple[float, float, float, float] = (1.0, 0.0, 0.0, 0.0)
"""Rotational offset from parent body to end-effector frame in parent body frame."""
position_command_scale: Tuple[float, float, float] = (1.0, 1.0, 1.0)
"""Scaling of the position command received. Used only in relative mode."""
rotation_command_scale: Tuple[float, float, float] = (1.0, 1.0, 1.0)
"""Scaling of the rotation command received. Used only in relative mode."""
class DifferentialInverseKinematics:
"""Inverse differential kinematics controller.
This controller uses the Jacobian mapping from joint-space velocities to end-effector velocities
to compute the delta-change in the joint-space that moves the robot closer to a desired end-effector
position.
To deal with singularity in Jacobian, the following methods are supported for computing inverse of the Jacobian:
- "pinv": Moore-Penrose pseudo-inverse
- "svd": Adaptive singular-value decomposition (SVD)
- "trans": Transpose of matrix
- "dls": Damped version of Moore-Penrose pseudo-inverse (also called Levenberg-Marquardt)
Note: We use the quaternions in the convention: [w, x, y, z].
Reference:
[1] https://ethz.ch/content/dam/ethz/special-interest/mavt/robotics-n-intelligent-systems/rsl-dam/documents/RobotDynamics2017/RD_HS2017script.pdf
[2] https://www.cs.cmu.edu/~15464-s13/lectures/lecture6/iksurvey.pdf
"""
_DEFAULT_IK_PARAMS = {
"pinv": {"k_val": 1.0},
"svd": {"k_val": 1.0, "min_singular_value": 1e-5},
"trans": {"k_val": 1.0},
"dls": {"lambda_val": 0.1},
}
"""Default parameters for different inverse kinematics approaches."""
def __init__(self, cfg: DifferentialInverseKinematicsCfg, num_robots: int, device: str):
"""Initialize the controller.
Args:
cfg (DifferentialInverseKinematicsCfg): The configuration for the controller.
num_robots (int): The number of robots to control.
device (str): The device to use for computations.
Raises:
ValueError: When configured IK-method is not supported.
ValueError: When configured command type is not supported.
"""
# store inputs
self.cfg = cfg
self.num_robots = num_robots
self._device = device
# check valid input
if self.cfg.ik_method not in ["pinv", "svd", "trans", "dls"]:
raise ValueError(f"Unsupported inverse-kinematics method: {self.cfg.ik_method}.")
if self.cfg.command_type not in ["position_abs", "position_rel", "pose_abs", "pose_rel"]:
raise ValueError(f"Unsupported inverse-kinematics command: {self.cfg.command_type}.")
# update parameters for IK-method
self._ik_params = self._DEFAULT_IK_PARAMS[self.cfg.ik_method].copy()
if self.cfg.ik_params is not None:
self._ik_params.update(self.cfg.ik_params)
# end-effector offsets
# -- position
tool_child_link_pos = torch.tensor(self.cfg.position_offset, device=self._device)
self._tool_child_link_pos = tool_child_link_pos.repeat(self.num_robots, 1)
# -- orientation
tool_child_link_rot = torch.tensor(self.cfg.rotation_offset, device=self._device)
self._tool_child_link_rot = tool_child_link_rot.repeat(self.num_robots, 1)
# transform from tool -> parent frame
self._tool_parent_link_rot = quat_inv(self._tool_child_link_rot)
self._tool_parent_link_pos = -quat_apply(self._tool_parent_link_rot, self._tool_child_link_pos)
# scaling of command
self._position_command_scale = torch.diag(torch.tensor(self.cfg.position_command_scale, device=self._device))
self._rotation_command_scale = torch.diag(torch.tensor(self.cfg.rotation_command_scale, device=self._device))
# create buffers
self.desired_ee_pos = torch.zeros(self.num_robots, 3, device=self._device)
self.desired_ee_rot = torch.zeros(self.num_robots, 4, device=self._device)
# -- input command
self._command = torch.zeros(self.num_robots, self.num_actions, device=self._device)
"""
Properties.
"""
@property
def num_actions(self) -> int:
"""Dimension of the action space of controller."""
if "position" in self.cfg.command_type:
return 3
elif self.cfg.command_type == "pose_rel":
return 6
elif self.cfg.command_type == "pose_abs":
return 7
else:
raise ValueError(f"Invalid control command: {self.cfg.command_type}.")
"""
Operations.
"""
def initialize(self):
"""Initialize the internals."""
pass
def reset_idx(self, robot_ids: torch.Tensor = None):
"""Reset the internals."""
pass
def set_command(self, command: torch.Tensor):
"""Set target end-effector pose command."""
# check input size
if command.shape != (self.num_robots, self.num_actions):
raise ValueError(
f"Invalid command shape '{command.shape}'. Expected: '{(self.num_robots, self.num_actions)}'."
)
# store command
self._command[:] = command
def compute(
self,
current_ee_pos: torch.Tensor,
current_ee_rot: torch.Tensor,
jacobian: torch.Tensor,
joint_positions: torch.Tensor,
) -> torch.Tensor:
"""Performs inference with the controller.
Returns:
torch.Tensor: The target joint positions commands.
"""
# compute the desired end-effector pose
if "position_rel" in self.cfg.command_type:
# scale command
self._command @= self._position_command_scale
# compute targets
self.desired_ee_pos = current_ee_pos + self._command
self.desired_ee_rot = current_ee_rot
elif "position_abs" in self.cfg.command_type:
# compute targets
self.desired_ee_pos = self._command
self.desired_ee_rot = current_ee_rot
elif "pose_rel" in self.cfg.command_type:
# scale command
self._command[:, 0:3] @= self._position_command_scale
self._command[:, 3:6] @= self._rotation_command_scale
# compute targets
self.desired_ee_pos, self.desired_ee_rot = apply_delta_pose(current_ee_pos, current_ee_rot, self._command)
elif "pose_abs" in self.cfg.command_type:
# compute targets
self.desired_ee_pos = self._command[:, 0:3]
self.desired_ee_rot = self._command[:, 3:7]
else:
raise ValueError(f"Invalid control command: {self.cfg.command_type}.")
# transform from ee -> parent
# TODO: Make this optional to reduce overhead?
desired_parent_pos, desired_parent_rot = combine_frame_transforms(
self.desired_ee_pos, self.desired_ee_rot, self._tool_parent_link_pos, self._tool_parent_link_rot
)
# transform from ee -> parent
# TODO: Make this optional to reduce overhead?
current_parent_pos, current_parent_rot = combine_frame_transforms(
current_ee_pos, current_ee_rot, self._tool_parent_link_pos, self._tool_parent_link_rot
)
# compute pose error between current and desired
position_error, axis_angle_error = compute_pose_error(
current_parent_pos, current_parent_rot, desired_parent_pos, desired_parent_rot, rot_error_type="axis_angle"
)
# compute the delta in joint-space
if "position" in self.cfg.command_type:
jacobian_pos = jacobian[:, 0:3]
delta_joint_positions = self._compute_delta_dof_pos(delta_pose=position_error, jacobian=jacobian_pos)
else:
pose_error = torch.cat((position_error, axis_angle_error), dim=1)
delta_joint_positions = self._compute_delta_dof_pos(delta_pose=pose_error, jacobian=jacobian)
# return the desired joint positions
return joint_positions + delta_joint_positions
def compute_delta(
self,
current_ee_pos: torch.Tensor,
current_ee_rot: torch.Tensor,
jacobian: torch.Tensor,
) -> torch.Tensor:
"""Performs inference with the controller.
Returns:
torch.Tensor: The target joint positions commands.
"""
# compute the desired end-effector pose
if "position_rel" in self.cfg.command_type:
# scale command
self._command @= self._position_command_scale
# compute targets
self.desired_ee_pos = current_ee_pos + self._command
self.desired_ee_rot = current_ee_rot
elif "position_abs" in self.cfg.command_type:
# compute targets
self.desired_ee_pos = self._command
self.desired_ee_rot = current_ee_rot
elif "pose_rel" in self.cfg.command_type:
# scale command
self._command[:, 0:3] @= self._position_command_scale
self._command[:, 3:6] @= self._rotation_command_scale
# compute targets
self.desired_ee_pos, self.desired_ee_rot = apply_delta_pose(current_ee_pos, current_ee_rot, self._command)
elif "pose_abs" in self.cfg.command_type:
# compute targets
self.desired_ee_pos = self._command[:, 0:3]
self.desired_ee_rot = self._command[:, 3:7]
else:
raise ValueError(f"Invalid control command: {self.cfg.command_type}.")
# transform from ee -> parent
# TODO: Make this optional to reduce overhead?
desired_parent_pos, desired_parent_rot = combine_frame_transforms(
self.desired_ee_pos, self.desired_ee_rot, self._tool_parent_link_pos, self._tool_parent_link_rot
)
# transform from ee -> parent
# TODO: Make this optional to reduce overhead?
current_parent_pos, current_parent_rot = combine_frame_transforms(
current_ee_pos, current_ee_rot, self._tool_parent_link_pos, self._tool_parent_link_rot
)
# compute pose error between current and desired
position_error, axis_angle_error = compute_pose_error(
current_parent_pos, current_parent_rot, desired_parent_pos, desired_parent_rot, rot_error_type="axis_angle"
)
# compute the delta in joint-space
if "position" in self.cfg.command_type:
jacobian_pos = jacobian[:, 0:3]
delta_joint_positions = self._compute_delta_dof_pos(delta_pose=position_error, jacobian=jacobian_pos)
else:
pose_error = torch.cat((position_error, axis_angle_error), dim=1)
delta_joint_positions = self._compute_delta_dof_pos(delta_pose=pose_error, jacobian=jacobian)
# return the desired joint positions
return delta_joint_positions
"""
Helper functions.
"""
def _compute_delta_dof_pos(self, delta_pose: torch.Tensor, jacobian: torch.Tensor) -> torch.Tensor:
"""Computes the change in dos-position that yields the desired change in pose.
The method uses the Jacobian mapping from joint-space velocities to end-effector velocities
to compute the delta-change in the joint-space that moves the robot closer to a desired end-effector
position.
Args:
delta_pose (torch.Tensor): The desired delta pose in shape [N, 3 or 6].
jacobian (torch.Tensor): The geometric jacobian matrix in shape [N, 3 or 6, num-dof]
Returns:
torch.Tensor: The desired delta in joint space.
"""
if self.cfg.ik_method == "pinv": # Jacobian pseudo-inverse
# parameters
k_val = self._ik_params["k_val"]
# computation
jacobian_pinv = torch.linalg.pinv(jacobian)
delta_dof_pos = k_val * jacobian_pinv @ delta_pose.unsqueeze(-1)
delta_dof_pos = delta_dof_pos.squeeze(-1)
elif self.cfg.ik_method == "svd": # adaptive SVD
# parameters
k_val = self._ik_params["k_val"]
min_singular_value = self._ik_params["min_singular_value"]
# computation
# U: 6xd, S: dxd, V: d x num-dof
U, S, Vh = torch.linalg.svd(jacobian)
S_inv = 1.0 / S
S_inv = torch.where(S > min_singular_value, S_inv, torch.zeros_like(S_inv))
jacobian_pinv = (
torch.transpose(Vh, dim0=1, dim1=2)[:, :, :6]
@ torch.diag_embed(S_inv)
@ torch.transpose(U, dim0=1, dim1=2)
)
delta_dof_pos = k_val * jacobian_pinv @ delta_pose.unsqueeze(-1)
delta_dof_pos = delta_dof_pos.squeeze(-1)
elif self.cfg.ik_method == "trans": # Jacobian transpose
# parameters
k_val = self._ik_params["k_val"]
# computation
jacobian_T = torch.transpose(jacobian, dim0=1, dim1=2)
delta_dof_pos = k_val * jacobian_T @ delta_pose.unsqueeze(-1)
delta_dof_pos = delta_dof_pos.squeeze(-1)
elif self.cfg.ik_method == "dls": # damped least squares
# parameters
lambda_val = self._ik_params["lambda_val"]
# computation
jacobian_T = torch.transpose(jacobian, dim0=1, dim1=2)
lambda_matrix = (lambda_val**2) * torch.eye(n=jacobian.shape[1], device=self._device)
delta_dof_pos = jacobian_T @ torch.inverse(jacobian @ jacobian_T + lambda_matrix) @ delta_pose.unsqueeze(-1)
delta_dof_pos = delta_dof_pos.squeeze(-1)
else:
raise ValueError(f"Unsupported inverse-kinematics method: {self.cfg.ik_method}")
return delta_dof_pos
| 15,553 |
Python
| 39.824147 | 153 | 0.618852 |
makolon/hsr_isaac_tamp/hsr_rl/tasks/utils/scene_utils.py
|
import os
import torch
import numpy as np
from typing import Optional
from pxr import Gf
from omni.isaac.core.prims.rigid_prim import RigidPrim
from omni.isaac.core.prims.xform_prim import XFormPrim
from omni.isaac.core.prims.geometry_prim import GeometryPrim
from omni.physx.scripts import utils
from pxr import UsdGeom
from hsr_rl.utils.files import get_usd_path
from omni.isaac.core.utils.prims import get_prim_at_path, is_prim_path_valid
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.core.utils.torch.rotations import euler_angles_to_quats
def spawn_obstacle(name, prim_path, device):
object_translation = torch.tensor([1.7, 0.0, 0.055], device=device)
object_orientation = torch.tensor([1.0, 0.0, 0.0, 0.0], device=device)
# Spawn object model from usd path
object_usd_path = os.path.join(get_usd_path(), 'gearbox', name, name+'.usd')
add_reference_to_stage(object_usd_path, prim_path+"/obstacle/"+name)
obst_prim = XFormPrim(
prim_path=prim_path+"/obstacle/"+name,
translation=object_translation,
orientation=object_orientation
)
return obst_prim
def spawn_dynamic_object(name, prim_path, object_translation, object_orientation):
# Spawn object model from usd path
object_usd_path = os.path.join(get_usd_path(), 'gearbox_dynamic', name, name+'.usd')
add_reference_to_stage(object_usd_path, prim_path+"/"+name)
obj_prim = XFormPrim(
prim_path=prim_path+"/"+name,
translation=object_translation,
orientation=object_orientation
)
return obj_prim
def spawn_static_object(name, prim_path, object_translation, object_orientation):
# Spawn object model from usd path
object_usd_path = os.path.join(get_usd_path(), 'gearbox_static', name, name+'.usd')
add_reference_to_stage(object_usd_path, prim_path+"/"+name)
obj_prim = XFormPrim(
prim_path=prim_path+"/"+name,
translation=object_translation,
orientation=object_orientation
)
return obj_prim
def setup_gearbox_scene(env_ids, indices, obstacles, obstacles_state, grasp_objs, grasp_objs_state, device):
# Place all grasp objects on the tabular obstacle (without overlaps)
for idx, _ in enumerate(obstacles):
obst_position = obstacles_state[idx][env_ids, :3]
obst_orientation = obstacles_state[idx][env_ids, 3:]
obstacles[idx].set_world_poses(positions=obst_position,
orientations=obst_orientation,
indices=indices)
for idx, _ in enumerate(grasp_objs):
grasp_obj_position = grasp_objs_state[idx][env_ids, :3]
grsap_obj_orientation = grasp_objs_state[idx][env_ids, 3:]
grasp_objs[idx].set_world_poses(positions=grasp_obj_position,
orientations=grsap_obj_orientation,
indices=indices)
# Pick one object to be the grasp object and compute its grasp:
goal_obj_index = np.random.randint(len(grasp_objs))
return grasp_objs[goal_obj_index]
class DynamicObject(RigidPrim, GeometryPrim):
"""Creates and adds a prim to stage from USD reference path, and wraps the prim with RigidPrim and GeometryPrim to
provide access to APIs for rigid body attributes, physics materials and collisions. Please note that this class
assumes the object has only a single mesh prim defining its geometry.
Args:
usd_path (str): USD reference path the Prim refers to.
prim_path (str): prim path of the Prim to encapsulate or create.
mesh_path (str): prim path of the underlying mesh Prim.
name (str, optional): shortname to be used as a key by Scene class. Note: needs to be unique if the object is
added to the Scene. Defaults to "dynamic_object".
position (Optional[np.ndarray], optional): position in the world frame of the prim. Shape is (3, ). Defaults to
None, which means left unchanged.
translation (Optional[np.ndarray], optional): translation in the local frame of the prim (with respect to its
parent prim). Shape is (3, ). Defaults to None, which means left
unchanged.
orientation (Optional[np.ndarray], optional): quaternion orientation in the world/local frame of the prim
(depends if translation or position is specified). Quaternion is
scalar-first (w, x, y, z). Shape is (4, ). Defaults to None, which
means left unchanged.
scale (Optional[np.ndarray], optional): local scale to be applied to the prim's dimensions. Shape is (3, ).
Defaults to None, which means left unchanged.
visible (bool, optional): set to false for an invisible prim in the stage while rendering. Defaults to True.
mass (Optional[float], optional): mass in kg. Defaults to None.
linear_velocity (Optional[np.ndarray], optional): linear velocity in the world frame. Defaults to None.
angular_velocity (Optional[np.ndarray], optional): angular velocity in the world frame. Defaults to None.
"""
def __init__(
self,
usd_path: str,
prim_path: str,
mesh_path: str,
name: str = "dynamic_object",
position: Optional[np.ndarray] = None,
translation: Optional[np.ndarray] = None,
orientation: Optional[np.ndarray] = None,
scale: Optional[np.ndarray] = None,
visible: bool = True,
mass: Optional[float] = None,
linear_velocity: Optional[np.ndarray] = None,
angular_velocity: Optional[np.ndarray] = None,
) -> None:
if is_prim_path_valid(mesh_path):
prim = get_prim_at_path(mesh_path)
if not prim.IsA(UsdGeom.Mesh):
raise Exception("The prim at path {} cannot be parsed as a Mesh object".format(mesh_path))
self.usd_path = usd_path
add_reference_to_stage(usd_path=usd_path, prim_path=prim_path)
GeometryPrim.__init__(
self,
prim_path=mesh_path,
name=name,
translation=translation,
orientation=orientation,
visible=visible,
collision=True,
)
self.set_collision_approximation("convexHull")
RigidPrim.__init__(
self,
prim_path=prim_path,
name=name,
position=position,
translation=translation,
orientation=orientation,
scale=scale,
visible=visible,
mass=mass,
linear_velocity=linear_velocity,
angular_velocity=angular_velocity,
)
| 7,020 |
Python
| 44.296774 | 121 | 0.618946 |
makolon/hsr_isaac_tamp/hsr_rl/cfg/task/HSRExampleReach.yaml
|
# used to create the object
name: HSRExampleReach
physics_engine: ${..physics_engine}
# if given, will override the device setting in gym.
env:
numEnvs: ${resolve_default:4096,${...num_envs}}
envSpacing: 5.0
resetDist: 1.0
maxEffort: 400.0
controlFrequencyInv: 2 # 60 Hz
maxEpisodeLength: 600
actionSpeedScale: 1
enableDebugVis: False
clipObservations: 5.0
clipActions: 1.0
startPositionNoise: 0.0
startRotationNoise: 0.0
numProps: 4
aggregateMode: 3
actionScale: 7.5
dofVelocityScale: 0.1
distRewardScale: 2.0
rotRewardScale: 0.5
aroundHandleRewardScale: 10.0
openRewardScale: 7.5
fingerDistRewardScale: 100.0
actionPenaltyScale: 0.01
fingerCloseRewardScale: 10.0
gamma: 0.999
horizon: 600
# Move group to be used
move_group: "whole_body" # String. Can be arm_left or arm_right
use_gripper: True
randomize_robot_on_reset: False
# Set custom state and action space limits
max_rot_vel: 0.5236 # 1.0472 # in radians (default is 60 degrees per second)
max_base_xy_vel: 0.1 # metres per second
max_base_rz_vel: 0.5236 # metres per second
# Hybrid action space
num_actions: 8 # base and arm
# Observation space
num_observations: 28
sim:
dt: 0.0083 # 1/120 s
action_base_scale: 0.05
action_arm_scale: 0.05
action_gripper_scale: 0.05
use_gpu_pipeline: ${eq:${...pipeline},"gpu"}
gravity: [0.0, 0.0, -9.81]
add_ground_plane: True
add_distant_light: True
use_flatcache: True
enable_scene_query_support: True
disable_contact_processing: False
enable_cameras: False # set to True if you use camera sensors in the environment
default_physics_material:
static_friction: 1.0
dynamic_friction: 1.0
restitution: 0.0
physx:
worker_thread_count: ${....num_threads}
solver_type: ${....solver_type}
use_gpu: ${eq:${....sim_device},"gpu"}
solver_position_iteration_count: 12
solver_velocity_iteration_count: 1
contact_offset: 0.005
rest_offset: 0.001
bounce_threshold_velocity: 0.2
friction_offset_threshold: 0.04
friction_correlation_distance: 0.025
enable_sleeping: True
enable_stabilization: True
max_depenetration_velocity: 1.0
# GPU buffers
gpu_max_rigid_contact_count: 524288
gpu_max_rigid_patch_count: 33554432
gpu_found_lost_pairs_capacity: 17060160 # 524288
gpu_found_lost_aggregate_pairs_capacity: 17060160 # 262144
gpu_total_aggregate_pairs_capacity: 1048576
gpu_max_soft_body_contacts: 1048576
gpu_max_particle_contacts: 1048576
gpu_heap_capacity: 33554432
gpu_temp_buffer_capacity: 16777216
gpu_max_num_partitions: 8
# sim asset configs here
hsrb:
# -1 to use default values
override_usd_defaults: False
enable_self_collisions: False
enable_gyroscopic_forces: True
# also in stage params
# per-actor
solver_position_iteration_count: 12
solver_velocity_iteration_count: 1
sleep_threshold: 0.005
stabilization_threshold: 0.001
# per-body
density: -1
max_depenetration_velocity: 1.0
# per-shape
contact_offset: 0.02
rest_offset: 0.001
ball:
# -1 to use default values
override_usd_defaults: False
make_kinematic: True
enable_self_collisions: False
enable_gyroscopic_forces: True
# also in stage params
# per-actor
solver_position_iteration_count: 12
solver_velocity_iteration_count: 1
sleep_threshold: 0.005
stabilization_threshold: 0.001
# per-body
density: 1
max_depenetration_velocity: 1000.0
# per-shape
contact_offset: 0.005
rest_offset: 0.0
| 3,593 |
YAML
| 26.646154 | 82 | 0.697189 |
makolon/hsr_isaac_tamp/hsr_rl/scripts/demo_rlgames.py
|
from hsr_rl.utils.hydra_cfg.hydra_utils import *
from hsr_rl.utils.hydra_cfg.reformat import omegaconf_to_dict, print_dict
from hsr_rl.utils.task_utils import initialize_task
from hsr_rl.envs.isaac_env_rlgames import IsaacEnvRlgames
from hsr_rl.scripts.train_rlgames import RLGTrainer
import hydra
from omegaconf import DictConfig
import datetime
import os
import torch
class RLGDemo(RLGTrainer):
def __init__(self, cfg, cfg_dict):
RLGTrainer.__init__(self, cfg, cfg_dict)
self.cfg.test = True
@hydra.main(config_name="config", config_path="../cfg")
def parse_hydra_configs(cfg: DictConfig):
time_str = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
headless = cfg.headless
render = not headless
sim_app_cfg_path = cfg.sim_app_cfg_path
env = IsaacEnvRlgames(headless=headless, render=render, sim_app_cfg_path=sim_app_cfg_path)
# ensure checkpoints can be specified as relative paths
from hsr_rl.utils.config_utils.path_utils import retrieve_checkpoint_path
if cfg.checkpoint:
cfg.checkpoint = retrieve_checkpoint_path(cfg.checkpoint)
if cfg.checkpoint is None:
quit()
cfg_dict = omegaconf_to_dict(cfg)
print_dict(cfg_dict)
# sets seed. if seed is -1 will pick a random one
from omni.isaac.core.utils.torch.maths import set_seed
cfg.seed = set_seed(cfg.seed, torch_deterministic=cfg.torch_deterministic)
cfg_dict['seed'] = cfg.seed
task = initialize_task(cfg_dict, env)
if cfg.wandb_activate:
# Make sure to install WandB if you actually use this.
import wandb
run_name = f"{cfg.wandb_name}_{time_str}"
wandb.init(
project=cfg.wandb_project,
group=cfg.wandb_group,
entity=cfg.wandb_entity,
config=cfg_dict,
sync_tensorboard=True,
id=run_name,
resume="allow",
monitor_gym=True,
)
rlg_trainer = RLGDemo(cfg, cfg_dict)
rlg_trainer.launch_rlg_hydra(env)
rlg_trainer.run()
env.close()
if cfg.wandb_activate:
wandb.finish()
if __name__ == '__main__':
parse_hydra_configs()
| 2,169 |
Python
| 28.726027 | 94 | 0.658368 |
makolon/hsr_isaac_tamp/hsr_rl/scripts/test_rlgames.py
|
import os
import sys
import yaml
import time
import torch
import hydra
import numpy as np
from omegaconf import DictConfig
from hsr_rl.utils.hydra_cfg.hydra_utils import *
from hsr_rl.utils.hydra_cfg.reformat import omegaconf_to_dict, print_dict
from hsr_rl.utils.task_utils import initialize_task
from hsr_rl.envs.isaac_env_rlgames import IsaacEnvRlgames
# TODO: modify
sys.path.append('/root/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/')
sys.path.append('/root/hsr_isaac_tamp/hsr_ros/hsr_ws/src/env_3d/script/rl_policy/')
sys.path.append('..')
from tamp_planner import TAMPPlanner
from post_process import PlanModifier
from rl_agent import ResidualRL
def load_config(task_name='HSRExample', policy_name='Pick', algo_name='PPO'):
skill_name = task_name + policy_name + algo_name + '.yaml'
file_name = os.path.join('/root/hsr_isaac_tamp/hsr_rl/cfg/train', skill_name)
with open(file_name, 'r') as f:
config = yaml.load(f, Loader=yaml.SafeLoader)
return config
class ExecutePlan(object):
def __init__(self):
self.tamp_planner = TAMPPlanner()
self.path_modifier = PlanModifier()
# Load policy
self.load_policy()
def load_policy(self):
# Load policies
pick_yaml = load_config('Pick')
place_yaml = load_config('Place')
insert_yaml = load_config('Insert')
# Load configs
pick_policy_cfg = omegaconf_to_dict(pick_yaml)
place_policy_cfg = omegaconf_to_dict(place_yaml)
insert_policy_cfg = omegaconf_to_dict(insert_yaml)
# Set action scale
self.pick_action_scale = torch.tensor(pick_policy_cfg["params"]["config"]["action_scale"], device='cuda:0')
self.place_action_scale = torch.tensor(place_policy_cfg["params"]["config"]["action_scale"], device='cuda:0')
self.insert_action_scale = torch.tensor(insert_policy_cfg["params"]["config"]["action_scale"], device='cuda:0')
# Skill based residual policy agents
self.pick_agent = ResidualRL(pick_policy_cfg.get('params'))
self.place_agent = ResidualRL(place_policy_cfg.get('params'))
self.insert_agent = ResidualRL(insert_policy_cfg.get('params'))
# Restore learned params
self.pick_agent.restore(pick_policy_cfg["params"]["load_path"])
self.place_agent.restore(place_policy_cfg["params"]["load_path"])
self.insert_agent.restore(insert_policy_cfg["params"]["load_path"])
def get_object_poses(self):
# Add parts
object_poses = {}
for object_name, parts in self.env._task._parts.items():
object_pos, object_rot = parts.get_world_poses(clone=False)
object_pos = object_pos.squeeze(dim=0).to('cpu').detach().numpy().copy()
object_rot = object_rot.squeeze(dim=0).to('cpu').detach().numpy().copy()
object_poses[object_name] = (object_pos, object_rot)
return object_poses
def get_robot_poses(self):
# Get robot poses
robot_poses = self.env._task._robots.get_joint_positions(
joint_indices=self.env._task.movable_dof_indices, clone=False)
# To cpu
robot_poses = robot_poses.squeeze(dim=0).to('cpu').detach().numpy().copy()
return robot_poses
def initialize_tamp(self):
object_poses = self.get_object_poses()
robot_poses = self.get_robot_poses()
observations = (robot_poses, object_poses)
# Initialize problem
self.tamp_planner.initialize(observations)
def calculate_base_command(self, target_base_pos, pd_control=False):
# PD control
curr_base_pos = self.env._task._robots.get_joint_positions(
joint_indices=self.env._task.base_dof_idxs, clone=False).squeeze(dim=0)
curr_base_vel = self.env._task._robots.get_joint_velocities(
joint_indices=self.env._task.base_dof_idxs, clone=False).squeeze(dim=0)
# To gpu
target_base_pos = torch.tensor(target_base_pos, device='cuda:0')
# Calculate pd commands
diff_pos = target_base_pos - curr_base_pos
diff_vel = diff_pos * self.dt
kp, kd = torch.tensor([0.1], device='cuda:0'), torch.tensor([0.01], device='cuda:0')
command = kp * diff_pos + kd * diff_vel
command += curr_base_pos
if pd_control:
return command
else:
return target_base_pos
def calculate_arm_command(self, target_arm_pos, pd_control=False):
# PD control
curr_arm_pos = self.env._task._robots.get_joint_positions(
joint_indices=self.env._task.arm_dof_idxs, clone=False).squeeze(dim=0)
curr_arm_vel = self.env._task._robots.get_joint_velocities(
joint_indices=self.env._task.arm_dof_idxs, clone=False).squeeze(dim=0)
# To gpu
target_arm_pos = torch.tensor(target_arm_pos, device='cuda:0')
# Calculate pd commands
diff_pos = target_arm_pos - curr_arm_pos
diff_vel = diff_pos * self.dt
kp, kd = torch.tensor([0.1], device='cuda:0'), torch.tensor([0.01], device='cuda:0')
command = kp * diff_pos + kd * diff_vel
command += curr_arm_pos
if pd_control:
return command
else:
return target_arm_pos
def plan(self):
# Run TAMP
plan, _, _ = self.tamp_planner.plan()
return plan
def augment_plan(self, plan):
# Replay_trajectory
return self.tamp_planner.execute(plan)
def process(self, action_name, args):
# Get object names
object_names = self.tamp_planner.tamp_problem.body_names
# Modify plan
action_name, object_name, modified_action = self.path_modifier.post_process(action_name, object_names, args)
return action_name, object_name, modified_action
def execute(self, sim_cfg):
# IsaacEnv settings
rank = int(os.getenv("LOCAL_RANK", "0"))
sim_cfg.task_name = 'HSRExample'
sim_cfg.device_id = rank
sim_cfg.rl_device = f'cuda:{rank}'
enable_viewport = "enable_cameras" in sim_cfg.task.sim and sim_cfg.task.sim.enable_cameras
self.dt = sim_cfg.task.sim.dt * sim_cfg.task.env.controlFrequencyInv
self.env = IsaacEnvRlgames(headless=False, sim_device=sim_cfg.device_id, enable_livestream=sim_cfg.enable_livestream, enable_viewport=enable_viewport)
# Parse hydra config to dict
cfg_dict = omegaconf_to_dict(sim_cfg)
print_dict(cfg_dict)
# Sets seed, if seed is -1 will pick a random one
from omni.isaac.core.utils.torch.maths import set_seed
sim_cfg.seed = set_seed(sim_cfg.seed, torch_deterministic=sim_cfg.torch_deterministic)
cfg_dict['seed'] = sim_cfg.seed
initialize_task(cfg_dict, self.env)
# Initialize TAMP
self.initialize_tamp()
# Execute planning
plan = self.plan()
if plan is None:
return None
# Augment plan
pick_metadata, place_metadata, insert_metadata = self.augment_plan(plan)
# For metadata
pick_cnt, place_cnt, insert_cnt = 0, 0, 0
# Execute trajectory
while self.env._simulation_app.is_running():
if self.env._world.is_playing():
if self.env._world.current_time_step_index == 0:
self.env._world.reset(soft=True)
# Disable all physics properties
for parts_name in self.env._task._parts.keys():
self.env._task.disable_physics(parts_name)
for i, (action_name, args) in enumerate(plan):
action_name, object_name, modified_action = self.process(action_name, args)
# Move_base action
if action_name == 'move_base':
for target_pose in modified_action:
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.env._task._robots.get_joint_positions(
joint_indices=self.env._task.arm_dof_idxs, clone=False).squeeze(dim=0)
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name)
# Pick action
elif action_name == 'pick':
pick_traj, return_traj = modified_action
# Enable physics properties
self.env._task.enable_physics(object_name)
# Get target poses from pick_metadata
target_ee_pose = pick_metadata['target_robot_pose'][pick_cnt]
target_parts_pose = pick_metadata['target_object_pose'][pick_cnt]
# Execute pick trajectory
for target_pose in pick_traj: # pick
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
# Get observation
obs = self.env._task.get_pick_observations(target_ee_pose, target_parts_pose, object_name)
# Residual action
with torch.no_grad():
actions = self.pick_agent.get_action(obs)
# Multiply target 6D pose and residual 6D pose
ik_action = self.dt * self.pick_action_scale * actions.to('cuda:0') # (dx, dy, dz)
delta_pose = self.env._task.get_delta_pose(ik_action).squeeze(dim=0)
# Add delta pose to reference trajectory
target_base_pose += delta_pose[:3]
target_arm_pose += delta_pose[3:]
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name, object_name=object_name,
target_ee_pose=target_ee_pose, target_parts_pose=target_parts_pose)
# Simulate close gripper steps
self.env._task._close_gripper()
for target_pose in return_traj: # return
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name, object_name=object_name,
target_ee_pose=target_ee_pose, target_parts_pose=target_parts_pose)
# Check pick success
pick_success = self.env._task._check_pick_success(object_name).squeeze(dim=0)
print('pick_scucess:', pick_success)
# Add pick count
pick_cnt += 1
# Place action
elif action_name == 'place':
place_traj = modified_action
# Get target poses from place_metadata
target_ee_pose = place_metadata['target_robot_pose'][place_cnt]
target_parts_pose = place_metadata['target_object_pose'][place_cnt]
# Execute place trajectory
for target_pose in place_traj: # place
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
# Get observation
obs = self.env._task.get_place_observations(target_parts_pose, object_name)
# Residual action
with torch.no_grad():
actions = self.place_agent.get_action(obs)
# Multiply target 6D pose and residual 6D pose
ik_action = self.dt * self.place_action_scale * actions.to('cuda:0') # (dx, dy, dz)
delta_pose = self.env._task.get_delta_pose(ik_action).squeeze(dim=0)
# Add delta pose to reference trajectory
target_base_pose += delta_pose[:3]
target_arm_pose += delta_pose[3:]
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name, object_name=object_name, target_parts_pose=target_parts_pose)
# Check place success
place_success = self.env._task._check_place_success(target_parts_pose, object_name).squeeze(dim=0)
print('place_success:', place_success)
# Add place count
place_cnt += 1
# Insert action
elif action_name == 'insert':
insert_traj, depart_traj, return_traj = modified_action
# Get target poses from insert_metadata
target_ee_pose = insert_metadata['target_robot_pose'][insert_cnt]
target_parts_pose = insert_metadata['target_object_pose'][insert_cnt]
# Execute insert trajectory
for target_pose in insert_traj: # insert
# Add anchor
if place_success:
self.env._task.add_anchor(object_name)
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
# Get observation
obs = self.env._task.get_insert_observations(target_parts_pose, object_name)
# Residual action
with torch.no_grad():
actions = self.insert_agent.get_action(obs)
# Multiply target 6D pose and residual 6D pose
ik_action = self.dt * self.insert_action_scale * actions.to('cuda:0') # (dx, dy, dz)
delta_pose = self.env._task.get_delta_pose(ik_action).squeeze(dim=0)
# Add delta pose to reference trajectory
target_base_pose += delta_pose[:3]
target_arm_pose += delta_pose[3:]
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name, object_name=object_name, target_parts_pose=target_parts_pose)
# Remove anchor
self.env._task.remove_anchor()
# Simulate open gripper steps
self.env._task._open_gripper()
for target_pose in depart_traj: # depart
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name, object_name=object_name, target_parts_pose=target_parts_pose)
# Sleep
time.sleep(self.dt)
for target_pose in return_traj: # return
target_base_pose = self.calculate_base_command(target_pose[:3])
target_arm_pose = self.calculate_arm_command(target_pose[3:])
action = torch.cat((target_base_pose, target_arm_pose), dim=0).to(torch.float32)
# Step simulation
self.env._task.pre_physics_step(action)
self.env._world.step(render=True)
self.env.sim_frame_count += 1
self.env._task.post_physics_step(action_name, object_name=object_name, target_parts_pose=target_parts_pose)
# Check insert success
insert_success = self.env._task._check_insert_success(target_parts_pose, object_name).squeeze(dim=0)
print('insert_success:', insert_success)
# Disable physics properties
if insert_success:
self.env._task.disable_physics(object_name)
# Add insert count
insert_cnt += 1
else:
self.env._world.step(render=True)
self.env._simulation_app.close()
@hydra.main(config_name="config", config_path="../cfg")
def main(cfg: DictConfig):
exec_plan = ExecutePlan()
exec_plan.execute(cfg)
if __name__ == '__main__':
main()
| 18,952 |
Python
| 44.560096 | 158 | 0.534033 |
makolon/hsr_isaac_tamp/hsr_rl/scripts/replay_dataset.py
|
import os
import torch
import hydra
import numpy as np
from omegaconf import DictConfig
from hsr_rl.utils.hydra_cfg.hydra_utils import *
from hsr_rl.utils.hydra_cfg.reformat import omegaconf_to_dict, print_dict
from hsr_rl.utils.task_utils import initialize_task
from hsr_rl.utils.dataset_utils import load_dataset, load_skill_dataset
from hsr_rl.envs.isaac_env_rlgames import IsaacEnvRlgames
@hydra.main(config_name="config", config_path="../cfg")
def parse_hydra_configs(cfg: DictConfig):
headless = cfg.headless
render = not headless
rank = int(os.getenv("LOCAL_RANK", "0"))
if cfg.multi_gpu:
cfg.device_id = rank
cfg.rl_device = f'cuda:{rank}'
enable_viewport = "enable_cameras" in cfg.task.sim and cfg.task.sim.enable_cameras
env = IsaacEnvRlgames(headless=headless, sim_device=cfg.device_id, enable_livestream=cfg.enable_livestream, enable_viewport=enable_viewport)
cfg_dict = omegaconf_to_dict(cfg)
print_dict(cfg_dict)
action_replay = load_skill_dataset(cfg_dict['num_envs'], 'pick')
# sets seed. if seed is -1 will pick a random one
from omni.isaac.core.utils.torch.maths import set_seed
cfg.seed = set_seed(cfg.seed, torch_deterministic=cfg.torch_deterministic)
cfg_dict['seed'] = cfg.seed
task = initialize_task(cfg_dict, env)
while env._simulation_app.is_running():
if env._world.is_playing():
if env._world.current_time_step_index == 0:
env._world.reset(soft=True)
if env.sim_frame_count >= len(action_replay):
actions = torch.tensor([np.random.uniform(env.action_space.low, env.action_space.high) for _ in range(env.num_envs)], dtype=torch.float, device=task.rl_device)
else:
actions = torch.tensor([action_replay[env.sim_frame_count] for _ in range(env.num_envs)], device=task.rl_device)
env._task.pre_physics_step(actions)
env._world.step(render=render)
env.sim_frame_count += 1
env._task.post_physics_step()
else:
env._world.step(render=render)
env._simulation_app.close()
if __name__ == '__main__':
parse_hydra_configs()
| 2,191 |
Python
| 39.592592 | 175 | 0.670014 |
makolon/hsr_isaac_tamp/hsr_rl/models/urdf/hsrb_description/hsrb_meshes/CHANGELOG.rst
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package hsrb_meshes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1.0.0 (2020-08-24)
-------------------
* Initial commit
* Contributors: Nobuyuki Matsuno, Takashi Yamamoto, Yasukata Yokochi, Yuka Hashiguchi
| 245 |
reStructuredText
| 26.33333 | 85 | 0.506122 |
makolon/hsr_isaac_tamp/hsr_rl/models/urdf/hsrb_description/hsrb_meshes/README.md
|
hsrb_meshes
============
Toyota HSR - 3D mesh files
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
| 452 |
Markdown
| 63.714277 | 397 | 0.723451 |
makolon/hsr_isaac_tamp/hsr_rl/utils/wandb_utils.py
|
import numpy as np
import wandb
class wandbLogger:
def __init__(self, exp_config, run_name, group_name, disabled=False):
if disabled:
mode="disabled"
else:
mode=None
wandb.init(project="xyz", entity="irosa-ias", group=group_name, id=run_name, config=exp_config,
reinit=True, resume="allow", settings=wandb.Settings(start_method="fork"), mode=mode)
def run_log_wandb(self,success_rate, J, R, E, avg_episode_length, q_loss):
wandb.log({"success_rate": success_rate, "J": J, "R": R, "entropy": E,
"avg_episode_length": avg_episode_length, "q_loss": q_loss})
def vid_log_wandb(self,img_dataset):
np_video = np.expand_dims(np.moveaxis(img_dataset[0][0],-1,0), axis=0)
for tup in img_dataset:
np_video = np.vstack((np_video, np.expand_dims(np.moveaxis(tup[0],-1,0), axis=0)))
wandb.log({"video": wandb.Video(np_video, fps=60, format="gif")})
| 1,008 |
Python
| 47.047617 | 103 | 0.58631 |
makolon/hsr_isaac_tamp/hsr_rl/utils/files.py
|
import hsr_rl
from pathlib import Path
# get paths
def get_root_path():
path = Path(hsr_rl.__path__[0]).resolve() / '..' / '..'
return path
def get_urdf_path():
path = get_root_path() / 'urdf'
return path
def get_urdf_path():
path = Path(hsr_rl.__path__[0]).resolve()/ 'models' / 'urdf'
return path
def get_usd_path():
path = Path(hsr_rl.__path__[0]).resolve()/ 'models' / 'usd'
return path
def get_cfg_path():
path = path = Path(hsr_rl.__path__[0]).resolve()/ 'cfg'
return
| 523 |
Python
| 18.407407 | 64 | 0.571702 |
makolon/hsr_isaac_tamp/hsr_rl/utils/dataset_utils.py
|
import os
import json
import math
import numpy as np
from scipy.spatial.transform import Rotation as R
def load_dataset(problem_name, action_type='absolute', target_space='joint'):
dataset_dir = os.path.join('/root/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/dataset', problem_name, 'full')
# Trajectory and metadata directory per skill
traj_dir = os.path.join(dataset_dir, 'trajectory')
meta_dir = os.path.join(dataset_dir, 'metadata')
# Calculate number of files
num_traj_files = sum(os.path.isfile(os.path.join(traj_dir, name)) for name in os.listdir(traj_dir))
num_meta_files = sum(os.path.isfile(os.path.join(meta_dir, name)) for name in os.listdir(meta_dir))
# Get trajectory
dataset_list = []
for i in range(num_traj_files):
data_name = 'trajectory_' + str(i) + '.json'
dataset_path = os.path.join(traj_dir, data_name)
with open(dataset_path, 'rb') as f:
dataset = json.load(f)
dataset_list.append(dataset)
# Get metadata
metadata_list = []
for i in range(num_meta_files):
metadata_name = 'metadata_' + str(i) + '.json'
metadata_path = os.path.join(meta_dir, metadata_name)
with open(metadata_path, 'rb') as f:
metadata = json.load(f)
metadata_list.append(metadata)
action_dataset, _ = post_process(dataset_list, action_type, target_space)
metadata = parse_metadata(metadata_list)
return action_dataset, metadata
def load_skill_dataset(problem_name, skill_name, action_type='absolute', target_space='joint'):
dataset_dir = os.path.join('/root/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/dataset', problem_name, skill_name)
# Trajectory and metadata directory per skill
traj_dir = os.path.join(dataset_dir, 'trajectory')
meta_dir = os.path.join(dataset_dir, 'metadata')
# Calculate number of files
num_traj_files = sum(os.path.isfile(os.path.join(traj_dir, name)) for name in os.listdir(traj_dir))
num_meta_files = sum(os.path.isfile(os.path.join(meta_dir, name)) for name in os.listdir(meta_dir))
# Get trajectory
dataset_list = []
for i in range(num_traj_files):
data_name = 'trajectory_' + str(i) + '.json'
dataset_path = os.path.join(traj_dir, data_name)
with open(dataset_path, 'rb') as f:
dataset = json.load(f)
dataset_list.append(dataset)
# Get metadata
metadata_list = []
for i in range(num_meta_files):
metadata_name = 'metadata_' + str(i) + '.json'
metadata_path = os.path.join(meta_dir, metadata_name)
with open(metadata_path, 'rb') as f:
metadata = json.load(f)
metadata_list.append(metadata)
action_dataset, _ = post_skill_process(dataset_list, action_type, target_space)
metadata = parse_skill_metadata(metadata_list)
return action_dataset, metadata
def post_process(dataset, action_type='absolute', target_space='joint'):
action_dataset = []
object_dataset = []
for data in dataset:
# Get data for robot
robot_poses = data['robot_pose'] # 10 joints
gripper_poses = data['gripper_pose'] # 2 joints
ee_poses = data['ee_pose'] # 7 dimensions
diff_robot_poses = data['diff_robot_pose'] # 10 joints
diff_gripper_poses = data['diff_gripper_pose'] # 2 joints
diff_ee_poses = data['diff_ee_pose'] # 7 dimensions
# Prepare action_dataset
robot_traj = []
if target_space == 'joint':
if action_type == 'relative':
for drp in diff_robot_poses:
robot_traj.append(drp) # 10 dimensions
elif action_type == 'absolute':
for rp in robot_poses:
robot_traj.append(rp) # 10 dimensions
elif target_space == 'task':
if action_type == 'relative':
for dep, dgp in zip(diff_ee_poses, diff_gripper_poses):
action = dep + dgp
robot_traj.append(action) # 8 dimensions
elif action_type == 'absolute':
for ep, gp in zip(ee_poses, gripper_poses):
action = ep[0] + transpose(ep[1]) + gp
robot_traj.append(action) # 9 dimensions
# Get data for object
object_poses = data['object_pose']
# Prepare object_dataset
object_traj = []
for op in object_poses:
object_traj.append(op)
action_dataset.append(robot_traj)
object_dataset.append(object_traj)
return action_dataset, object_dataset
def post_skill_process(dataset, action_type='absolute', target_space='joint'):
action_dataset = []
object_dataset = []
for action_name, data in dataset:
# Get data for robot
robot_poses = data['robot_pose'] # 10 joints
gripper_poses = data['gripper_pose'] # 2 joints
ee_poses = data['ee_pose'] # 7 dimensions
diff_robot_poses = data['diff_robot_pose'] # 10 joints
diff_gripper_poses = data['diff_gripper_pose'] # 2 joints
diff_ee_poses = data['diff_ee_pose'] # 7 dimensions
# Prepare action_dataset
robot_traj = []
if target_space == 'joint':
if action_type == 'relative':
for drp in diff_robot_poses:
robot_traj.append(drp) # 10 dimensions
elif action_type == 'absolute':
for rp in robot_poses:
robot_traj.append(rp) # 10 dimensions
elif target_space == 'task':
if action_type == 'relative':
for dep, dgp in zip(diff_ee_poses, diff_gripper_poses):
action = dep + dgp
robot_traj.append(action) # 8 dimensions
elif action_type == 'absolute':
for ep, gp in zip(ee_poses, gripper_poses):
action = ep[0] + transpose(ep[1]) + gp
robot_traj.append(action) # 9 dimensions
# Get data for object
object_poses = data['object_pose']
# Prepare object_dataset
object_traj = []
for op in object_poses:
object_traj.append(op)
action_dataset.append([action_name, robot_traj])
object_dataset.append([action_name, object_traj])
return action_dataset, object_dataset
def parse_metadata(metadataset):
env_info = {'initial_robot_pose': [],
'initial_object_pose': [],
'goal_robot_pose': [],
'goal_object_pose': [],
'target_object_name': [],
'skill_name': []}
for metadata in metadataset:
# Get target objects
target_object_name = metadata['target_object_name']
env_info['target_object_name'].append(target_object_name)
# Get data for object / Prepare object_dataset
object_init_poses = metadata['object_init_pose']
env_info['initial_object_pose'].append(object_init_poses)
object_goal_poses = metadata['object_goal_pose']
env_info['goal_object_pose'].append(object_goal_poses)
# Get initial pose of robot / Prepare action_datase
robot_init_poses = metadata['robot_init_pose'] # 10 joints
env_info['initial_robot_pose'].append(robot_init_poses)
robot_goal_poses = metadata['robot_goal_pose'] # 10 joints
env_info['goal_robot_pose'].append(robot_goal_poses)
env_info['skill_name'].append(metadata['skill_name'])
return env_info
def parse_skill_metadata(metadataset):
env_info = {'initial_robot_pose': [],
'initial_object_pose': [],
'goal_robot_pose': [],
'goal_object_pose': [],
'target_robot_pose': [],
'target_object_name': [],
'fixed_object_name': []}
for metadata in metadataset:
# Get target objects
target_object_name = metadata['target_object_name']
env_info['target_object_name'].append(target_object_name)
# Get fixed objects
fixed_object_name = metadata['fixed_object_name']
env_info['fixed_object_name'].append(fixed_object_name)
# Get data for object / Prepare object_dataset
object_init_poses = metadata['object_init_pose']
env_info['initial_object_pose'].append(object_init_poses)
object_goal_poses = metadata['object_goal_pose']
env_info['goal_object_pose'].append(object_goal_poses)
# Get initial pose of robot / Prepare action_datase
robot_init_poses = metadata['robot_init_pose'] # 10 joints
env_info['initial_robot_pose'].append(np.array(robot_init_poses))
robot_goal_poses = metadata['robot_goal_pose'] # 10 joints
env_info['goal_robot_pose'].append(np.array(robot_goal_poses))
robot_target_poses = metadata['robot_target_pose'] # 7 dim
env_info['target_robot_pose'].append(np.array(robot_target_poses))
return env_info
def transpose(quat):
x, y, z, w = quat
return [w, x, y, z]
def calculate_delta_theta(delta_quat):
# Transform quaternion to rotation matrix
rotation_matrix = np.zeros((3, 3))
x, y, z, w = delta_quat
rotation_matrix[0, 0] = 1 - 2 * (y**2 + z**2)
rotation_matrix[0, 1] = 2 * (x*y - z*w)
rotation_matrix[0, 2] = 2 * (x*z + y*w)
rotation_matrix[1, 0] = 2 * (x*y + z*w)
rotation_matrix[1, 1] = 1 - 2 * (x**2 + z**2)
rotation_matrix[1, 2] = 2 * (y*z - x*w)
rotation_matrix[2, 0] = 2 * (x*z - y*w)
rotation_matrix[2, 1] = 2 * (y*z + x*w)
rotation_matrix[2, 2] = 1 - 2 * (x**2 + y**2)
# Transform rotation matrix to euler angle
roll = math.atan2(rotation_matrix[2, 1], rotation_matrix[2, 2])
pitch = math.atan2(-rotation_matrix[2, 0], math.sqrt(rotation_matrix[2, 1]**2 + rotation_matrix[2, 2]**2))
yaw = math.atan2(rotation_matrix[1, 0], rotation_matrix[0, 0])
# Reults of euler angle
delta_euler = [roll, pitch, yaw]
return delta_euler
| 10,014 |
Python
| 37.817829 | 116 | 0.596964 |
makolon/hsr_isaac_tamp/hsr_rl/utils/usd_utils/create_parent_xforms.py
|
from omniisaacgymenvs.utils.usd_utils.create_instanceable_assets import create_parent_xforms
create_parent_xforms(
asset_usd_path='/root/tamp-hsr/hsr_rl/models/usd/hsrb4s/hsrb4s.usd',
source_prim_path='/hsrb',
save_as_path='/root/tamp-hsr/hsr_rl/models/usd/hsrb4s/hsrb4s_xforms.usd'
)
| 297 |
Python
| 41.571423 | 92 | 0.757576 |
makolon/hsr_isaac_tamp/hsr_rl/utils/usd_utils/create_instanceable_usd.py
|
from omniisaacgymenvs.utils.usd_utils.create_instanceable_assets import convert_asset_instanceable
convert_asset_instanceable(
asset_usd_path='/root/tamp-hsr/hsr_rl/models/usd/ver3/gear1.usd',
source_prim_path='/gear1',
save_as_path='/root/tamp-hsr/hsr_rl/models/usd/gearbox/gear1.usd'
)
| 302 |
Python
| 36.874995 | 98 | 0.758278 |
makolon/hsr_isaac_tamp/hsr_rl/utils/usd_utils/convert_urdf.py
|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""
Utility to convert a URDF into USD format.
Unified Robot Description Format (URDF) is an XML file format used in ROS to describe all elements of
a robot. For more information, see: http://wiki.ros.org/urdf
This script uses the URDF importer extension from Isaac Sim (``omni.isaac.urdf_importer``) to convert a
URDF asset into USD format. It is designed as a convenience script for command-line use. For more
information on the URDF importer, see the documentation for the extension:
https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/ext_omni_isaac_urdf.html
positional arguments:
input The path to the input URDF file.
output The path to store the USD file.
optional arguments:
-h, --help show this help message and exit
--headless Force display off at all times. (default: False)
--merge_joints, -m Consolidate links that are connected by fixed joints. (default: False)
--fix_base, -f Fix the base to where it is imported. (default: False)
--gym, -g Make the asset instanceable for efficient cloning. (default: False)
"""
"""Launch Isaac Sim Simulator first."""
import argparse
import contextlib
# omni-isaac
from omni.isaac.kit import SimulationApp
# add argparse arguments
parser = argparse.ArgumentParser("Utility to convert a URDF into USD format.")
parser.add_argument("input", type=str, help="The path to the input URDF file.")
parser.add_argument("output", type=str, help="The path to store the USD file.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument(
"--merge_joints",
"-m",
action="store_true",
default=False,
help="Consolidate links that are connected by fixed joints.",
)
parser.add_argument(
"--fix_base", "-f", action="store_true", default=False, help="Fix the base to where it is imported."
)
parser.add_argument(
"--gym", "-g", action="store_true", default=False, help="Make the asset instanceable for efficient cloning."
)
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
"""Rest everything follows."""
import os
import carb
import omni.isaac.core.utils.stage as stage_utils
import omni.kit.commands
from omni.isaac.core.simulation_context import SimulationContext
import io
import omni.client
import omni.isaac.core.utils.nucleus as nucleus_utils
# check nucleus connection
if nucleus_utils.get_assets_root_path() is None:
msg = (
"Unable to perform Nucleus login on Omniverse. Assets root path is not set.\n"
"\tPlease check: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/overview.html#omniverse-nucleus"
)
carb.log_error(msg)
raise RuntimeError(msg)
ISAAC_NUCLEUS_DIR = f"{nucleus_utils.get_assets_root_path()}/Isaac"
"""Path to the `Isaac` directory on the NVIDIA Nucleus Server."""
ISAAC_ORBIT_NUCLEUS_DIR = f"{nucleus_utils.get_assets_root_path()}/Isaac/Samples/Orbit"
"""Path to the `Isaac/Samples/Orbit` directory on the NVIDIA Nucleus Server."""
def check_file_path(path: str) -> int:
"""Checks if a file exists on the Nucleus Server or locally.
Args:
path (str): The path to the file.
Returns:
int: The status of the file. Possible values are: :obj:`0` if the file does not exist
:obj:`1` if the file exists locally, or :obj:`2` if the file exists on the Nucleus Server.
"""
if os.path.isfile(path):
return 1
elif omni.client.stat(path)[0] == omni.client.Result.OK:
return 2
else:
return 0
def read_file(path: str) -> io.BytesIO:
"""Reads a file from the Nucleus Server or locally.
Args:
path (str): The path to the file.
Raises:
FileNotFoundError: When the file not found locally or on Nucleus Server.
Returns:
io.BytesIO: The content of the file.
"""
# check file status
file_status = check_file_path(path)
if file_status == 1:
with open(path, "rb") as f:
return io.BytesIO(f.read())
elif file_status == 2:
file_content = omni.client.read_file(path)[2]
return io.BytesIO(memoryview(file_content).tobytes())
else:
raise FileNotFoundError(f"Unable to find the file: {path}")
_DRIVE_TYPE = {
"none": 0,
"position": 1,
"velocity": 2,
}
"""Mapping from drive name to URDF importer drive number."""
_NORMALS_DIVISION = {
"catmullClark": 0,
"loop": 1,
"bilinear": 2,
"none": 3,
}
"""Mapping from normals division name to URDF importer normals division number."""
def main():
# check valid file path
urdf_path = args_cli.input
if not os.path.isabs(urdf_path):
urdf_path = os.path.abspath(urdf_path)
if not check_file_path(urdf_path):
raise ValueError(f"Invalid file path: {urdf_path}")
# create destination path
dest_path = args_cli.output
if not os.path.isabs(dest_path):
dest_path = os.path.abspath(dest_path)
if os.path.exists(dest_path):
carb.log_warn(f"Destination file already exists: {dest_path}. Overwriting...")
if not os.path.exists(os.path.dirname(dest_path)):
os.makedirs(os.path.dirname(dest_path))
# Import URDF config
_, urdf_config = omni.kit.commands.execute("URDFCreateImportConfig")
# Set URDF config
# -- stage settings -- dont need to change these.
urdf_config.set_distance_scale(1.0)
urdf_config.set_up_vector(0, 0, 1)
urdf_config.set_create_physics_scene(False)
urdf_config.set_make_default_prim(True)
# -- instancing settings
urdf_config.set_make_instanceable(args_cli.gym)
urdf_config.set_instanceable_usd_path("instanceable_meshes.usd")
# -- asset settings
urdf_config.set_density(0.0)
urdf_config.set_import_inertia_tensor(True)
urdf_config.set_convex_decomp(False)
urdf_config.set_subdivision_scheme(_NORMALS_DIVISION["bilinear"])
# -- physics settings
urdf_config.set_fix_base(args_cli.fix_base)
urdf_config.set_self_collision(False)
urdf_config.set_merge_fixed_joints(args_cli.merge_joints)
# -- drive settings
# note: we set these to none because we want to use the default drive settings.
urdf_config.set_default_drive_type(_DRIVE_TYPE["position"])
urdf_config.set_default_drive_strength(0.0)# (1e7)
urdf_config.set_default_position_drive_damping(1e5)
# Print info
print("-" * 80)
print("-" * 80)
print(f"Input URDF file: {urdf_path}")
print(f"Saving USD file: {dest_path}")
print("URDF importer config:")
for key in dir(urdf_config):
if not key.startswith("__"):
try:
# get attribute
attr = getattr(urdf_config, key)
# check if attribute is a function
if callable(attr):
continue
# print attribute
print(f"\t{key}: {attr}")
except TypeError:
# this is only the case for subdivison scheme
pass
print("-" * 80)
print("-" * 80)
# Import URDF file
omni.kit.commands.execute(
"URDFParseAndImportFile", urdf_path=urdf_path, import_config=urdf_config, dest_path=dest_path
)
# Simulate scene (if not headless)
if not args_cli.headless:
# Open the stage with USD
stage_utils.open_stage(dest_path)
# Load kit helper
sim = SimulationContext()
# stage_utils.add_reference_to_stage(dest_path, "/Robot")
# Reinitialize the simulation
# Run simulation
with contextlib.suppress(KeyboardInterrupt):
while True:
# perform step
sim.step()
if __name__ == "__main__":
# Run cloning example
main()
# Close the simulator
simulation_app.close()
| 8,064 |
Python
| 33.029536 | 117 | 0.660838 |
makolon/hsr_isaac_tamp/hsr_rl/robots/articulations/hsr.py
|
# Copyright (c) 2018-2022, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import math
import torch
import carb
import numpy as np
from typing import Optional
from omni.isaac.core.robots.robot import Robot
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.prims import get_prim_at_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from hsr_rl.tasks.utils.usd_utils import set_drive
from hsr_rl.utils.files import get_usd_path
from pxr import PhysxSchema
class HSR(Robot):
def __init__(
self,
prim_path: str,
name: Optional[str] = "hsrb",
usd_path: Optional[str] = None,
translation: Optional[np.ndarray] = None,
orientation: Optional[np.ndarray] = None,
) -> None:
self._usd_path = usd_path
self._name = name
if self._usd_path is None:
self._usd_path = (get_usd_path() / 'hsrb4s' / 'hsrb4s.usd').as_posix()
add_reference_to_stage(self._usd_path, prim_path)
super().__init__(
prim_path=prim_path,
name=name,
translation=translation,
orientation=orientation,
articulation_controller=None,
)
dof_paths = [
"base_footprint/joint_x",
"link_x/joint_y",
"link_y/joint_rz",
"base_link/arm_lift_joint",
"arm_lift_link/arm_flex_joint",
"arm_flex_link/arm_roll_joint",
"arm_roll_link/wrist_flex_joint",
"wrist_flex_link/wrist_roll_joint",
"hand_palm_link/hand_l_proximal_joint",
"hand_palm_link/hand_r_proximal_joint"
]
drive_type = ["linear", "linear", "angular", "linear", "angular", "angular", "angular", "angular", "angular", "angular"]
default_dof_pos = [0.0] * 10
stiffness = [1e9] * 8 + [500] * 2 # (base, arm, gripper)
damping = [1.4] * 8 + [0.3] * 2 # (base, arm, gripper)
max_force = [5e6] * 3 + [10000.0] * 5 + [360*np.pi/180] * 2 # (base, arm, gripper)
max_velocity = [5e6] * 3 + [10000.0] * 5 + [math.degrees(2.175)] * 2 # (base, arm, gripper)
for i, dof in enumerate(dof_paths):
set_drive(
prim_path=f"{self.prim_path}/{dof}",
drive_type=drive_type[i],
target_type="position",
target_value=default_dof_pos[i],
stiffness=stiffness[i],
damping=damping[i],
max_force=max_force[i]
)
PhysxSchema.PhysxJointAPI(get_prim_at_path(f"{self.prim_path}/{dof}")).CreateMaxJointVelocityAttr().Set(max_velocity[i])
additional_dof_paths = [
"base_link/torso_lift_joint",
"torso_lift_link/head_pan_joint",
"head_pan_link/head_tilt_joint",
"hand_l_mimic_distal_link/hand_l_distal_joint",
"hand_r_mimic_distal_link/hand_r_distal_joint",
]
drive_type = ["linear", "angular", "angular", "angular", "angular"]
default_dof_pos = [0.0, 0.0, 0.0, 0.0, 0.0]
stiffness = [1e9, 1e9, 1e9, 1e9, 1e9]
damping = [0.0, 0.0, 0.0, 0.0, 0.0]
max_force = [10000.0, 10000.0, 10000.0, 10000.0, 10000.0]
max_velocity = [10000.0, 10000.0, 10000.0, 10000.0, 10000.0]
for i, dof in enumerate(additional_dof_paths):
set_drive(
prim_path=f"{self.prim_path}/{dof}",
drive_type=drive_type[i],
target_type="position",
target_value=default_dof_pos[i],
stiffness=stiffness[i],
damping=damping[i],
max_force=max_force[i]
)
PhysxSchema.PhysxJointAPI(get_prim_at_path(f"{self.prim_path}/{dof}")).CreateMaxJointVelocityAttr().Set(max_velocity[i])
| 5,348 |
Python
| 40.465116 | 132 | 0.620793 |
makolon/hsr_isaac_tamp/hsr_rl/robots/articulations/views/hsr_view.py
|
from typing import Optional
from omni.isaac.core.articulations import ArticulationView
from omni.isaac.core.prims import RigidPrimView
class HSRView(ArticulationView):
def __init__(
self,
prim_paths_expr: str,
name: Optional[str] = "HSRView",
) -> None:
"""[summary]
"""
super().__init__(
prim_paths_expr=prim_paths_expr,
name=name,
reset_xform_properties=False
)
self._hands = RigidPrimView(prim_paths_expr="/World/envs/.*/hsrb/wrist_roll_link", name="hands_view", reset_xform_properties=False)
self._lfingers = RigidPrimView(prim_paths_expr="/World/envs/.*/hsrb/hand_l_distal_link", name="lfingers_view", reset_xform_properties=False)
self._rfingers = RigidPrimView(prim_paths_expr="/World/envs/.*/hsrb/hand_r_distal_link", name="rfingers_view", reset_xform_properties=False)
self._fingertip_centered = RigidPrimView(prim_paths_expr="/World/envs/.*/hsrb/hand_palm_link", name="fingertips_view", reset_xform_properties=False)
def initialize(self, physics_sim_view):
super().initialize(physics_sim_view)
self._gripper_indices = [self.get_dof_index("hand_l_proximal_joint"), self.get_dof_index("hand_r_proximal_joint")]
@property
def gripper_indices(self):
return self._gripper_indices
| 1,360 |
Python
| 39.029411 | 156 | 0.660294 |
makolon/hsr_isaac_tamp/docker/docker_openrave/wrapper.xml
|
<robot file="hsrb4s.dae">
<Manipulator name="hsrb">
<base>base_footprint</base>
<effector>hand_palm_link</effector>
</Manipulator>
</robot>
| 152 |
XML
| 20.85714 | 39 | 0.671053 |
makolon/hsr_isaac_tamp/docker/docker_openrave/ros_package/hsrb_description/README.rst
|
Overview
++++++++
This package manages the HSR-B robot model.
Gazebo simulator configurations are also included.。
Folder structure
+++++++++++++++++
- **launch**
Contains a launch file for performing confirmation (visualization) of a robot model.
- **urdf**
The xacro files that include common macros are directly under this directory.
Each part is separated into folders named ${PARTNAME}_${VERSION}.
When a major change such as a model revision is caused by hardware repairs, the version is increased by one and a new folder is created.
Basically, the version is attached to the part name and is of the form of v0, v1, v2, etc.
- **robots**
The URDF description file of the entire robot configured using the URDF of each part is placed in this directory.
There are multiple robot models depending on the version of various hardware parts.
xacro file variables
+++++++++++++++++++++
- **personal_name**
A namespace to set to allow one gazebo world to display several HSRs.
personal_name contains the value that is set as an argument in namespace when the launch file is started. The default value is "".
- **robot_name**
The model name used as the topic name or the service name of the robot. The default is "hsrb".
The model name assigned here and the model name actually used are not necessarily the same.
LICENSE
++++++++++++
This software is released under the BSD 3-Clause Clear License, see LICENSE.txt.
| 1,476 |
reStructuredText
| 28.539999 | 140 | 0.71748 |
makolon/hsr_isaac_tamp/docker/docker_openrave/ros_package/hsrb_description/package.xml
|
<package>
<name>hsrb_description</name>
<version>1.0.0</version>
<description>HSRのロボット定義ファイル</description>
<maintainer email="xr-hsr-support@mail.toyota.co.jp">HSR Support</maintainer>
<license>BSD 3-clause Clear License</license>
<url type="website">None</url>
<author>Akiyoshi Ochiai</author>
<author>Hiromichi Nakashima</author>
<author>Kazuhito Tanaka</author>
<author>Kazuto Murase</author>
<author>Keisuke Takeshita</author>
<author>Koji Terada</author>
<author>Koki Kataoka</author>
<author>Minori Higuchi</author>
<author>Satoru Onoda</author>
<author>Takafumi Mizuno</author>
<author>Takuya Ikeda</author>
<author>Tamaki Nishino</author>
<author>Yoshimi Iyoda</author>
<author>Yusuke Ota</author>
<author>Yuto Mori</author>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>xacro</build_depend>
<build_depend>rosbash</build_depend>
<build_depend>hsrb_meshes</build_depend>
<run_depend>xacro</run_depend>
<run_depend>rviz</run_depend>
<run_depend>hsrb_meshes</run_depend>
<test_depend>liburdfdom-tools</test_depend>
<test_depend>urdfdom_py</test_depend>
<test_depend>robot_state_publisher</test_depend>
<test_depend>joint_state_publisher</test_depend>
<test_depend>roslaunch</test_depend>
</package>
| 1,289 |
XML
| 28.999999 | 79 | 0.730799 |
makolon/hsr_isaac_tamp/docker/docker_openrave/ros_package/hsrb_description/test/test_urdf.py
|
#!/usr/bin/env python
# vim: fileencoding=utf-8 :
# Copyright (c) 2016 TOYOTA MOTOR CORPORATION
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Toyota Motor Corporation nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import glob
import os
import subprocess
import tempfile
from nose.tools import eq_, ok_
try:
import xml.etree.cElementTree as etree
except Exception:
import xml.etree.ElementTree as etree
PACKAGE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ROBOTS_DIR = os.path.join(PACKAGE_DIR, "robots")
URDF_DIR = os.path.join(PACKAGE_DIR, "urdf")
def test_generator_robot_urdf():
def test_robot_urdf(path):
u"""XACROで変換した後に、URDFとして正しく読めるかを確認するテスト"""
with tempfile.NamedTemporaryFile() as f:
args = ['rosrun', 'xacro', 'xacro', '--inorder', source]
eq_(subprocess.call(args, stdout=f), 0)
args = ['check_urdf', f.name]
subprocess.check_output(args)
matched = glob.glob(ROBOTS_DIR + "/*.urdf.xacro")
sources = [os.path.abspath(path) for path in matched]
for source in sources:
yield test_robot_urdf, source
def test_generator_integrity():
def check_integrity(source):
args = ['rosrun', 'xacro', 'xacro', '--inorder', source]
urdf = subprocess.check_output(args)
root = etree.fromstring(urdf)
links = []
for link in root.findall('link'):
name = link.get('name')
ok_(name is not None, "link({0})".format(name))
links.append(name)
joints = []
for joint in root.findall('joint'):
name = joint.get('name')
ok_(name is not None, "joint({0})".format(name))
joints.append(name)
parent = joint.find('parent')
ok_(parent.get('link') in links, "joint({0})".format(name))
child = joint.find('child')
ok_(child.get('link') in links, "joint({0})".format(name))
for trans in root.findall('transmission'):
name = trans.get('name')
joint = trans.find('joint')
ok_(joint.get('name') in joints, "transmission({0})".format(name))
for gazebo in root.findall('gazebo'):
ref = gazebo.get('reference')
if ref is None:
# When reference is None, <gazebo> tag is added to <robot>.
continue
ok_(ref in links + joints,
"Unresolvable reference '{0}':\n{1}".format(
ref, etree.tostring(gazebo)))
matched = glob.glob(ROBOTS_DIR + "/*.urdf.xacro")
sources = [os.path.abspath(path) for path in matched]
for source in sources:
yield check_integrity, source
| 4,092 |
Python
| 38.737864 | 78 | 0.660557 |
makolon/hsr_isaac_tamp/docker/docker_openrave/ros_package/hsrb_parts_description/package.xml
|
<package>
<name>hsrb_parts_description</name>
<version>0.21.0</version>
<description>HSRのロボット定義共通ファイル</description>
<maintainer email="keisuke_takeshita@mail.toyota.co.jp">Keisuke Takeshita</maintainer>
<license>TMC</license>
<url type="website">None</url>
<author>Tamaki Nishino</author>
<author>Akiyoshi Ochiai</author>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>xacro</build_depend>
<build_depend>rosbash</build_depend>
<run_depend>xacro</run_depend>
<test_depend>liburdfdom-tools</test_depend>
<test_depend>urdfdom_py</test_depend>
</package>
| 598 |
XML
| 22.959999 | 88 | 0.730769 |
makolon/hsr_isaac_tamp/docker/docker_openrave/output/hsrb/ikfast.h
|
// -*- coding: utf-8 -*-
// Copyright (C) 2012-2014 Rosen Diankov <rosen.diankov@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/** \brief Header file for all ikfast c++ files/shared objects.
The ikfast inverse kinematics compiler is part of OpenRAVE.
The file is divided into two sections:
- <b>Common</b> - the abstract classes section that all ikfast share regardless of their settings
- <b>Library Specific</b> - the library-specific definitions, which depends on the precision/settings that the library was compiled with
The defines are as follows, they are also used for the ikfast C++ class:
- IKFAST_HEADER_COMMON - common classes
- IKFAST_HAS_LIBRARY - if defined, will include library-specific functions. by default this is off
- IKFAST_CLIBRARY - Define this linking statically or dynamically to get correct visibility.
- IKFAST_NO_MAIN - Remove the ``main`` function, usually used with IKFAST_CLIBRARY
- IKFAST_ASSERT - Define in order to get a custom assert called when NaNs, divides by zero, and other invalid conditions are detected.
- IKFAST_REAL - Use to force a custom real number type for IkReal.
- IKFAST_NAMESPACE - Enclose all functions and classes in this namespace, the ``main`` function is excluded.
*/
#include <vector>
#include <list>
#include <stdexcept>
#include <cmath>
#ifndef IKFAST_HEADER_COMMON
#define IKFAST_HEADER_COMMON
/// should be the same as ikfast.__version__
/// if 0x10000000 bit is set, then the iksolver assumes 6D transforms are done without the manipulator offset taken into account (allows to reuse IK when manipulator offset changes)
#define IKFAST_VERSION 0x10000048
namespace ikfast {
/// \brief holds the solution for a single dof
template <typename T>
class IkSingleDOFSolutionBase
{
public:
IkSingleDOFSolutionBase() : fmul(0), foffset(0), freeind(-1), maxsolutions(1) {
indices[0] = indices[1] = indices[2] = indices[3] = indices[4] = -1;
}
T fmul, foffset; ///< joint value is fmul*sol[freeind]+foffset
signed char freeind; ///< if >= 0, mimics another joint
unsigned char jointtype; ///< joint type, 0x01 is revolute, 0x11 is slider
unsigned char maxsolutions; ///< max possible indices, 0 if controlled by free index or a free joint itself
unsigned char indices[5]; ///< unique index of the solution used to keep track on what part it came from. sometimes a solution can be repeated for different indices. store at least another repeated root
};
/// \brief The discrete solutions are returned in this structure.
///
/// Sometimes the joint axes of the robot can align allowing an infinite number of solutions.
/// Stores all these solutions in the form of free variables that the user has to set when querying the solution. Its prototype is:
template <typename T>
class IkSolutionBase
{
public:
virtual ~IkSolutionBase() {
}
/// \brief gets a concrete solution
///
/// \param[out] solution the result
/// \param[in] freevalues values for the free parameters \se GetFree
virtual void GetSolution(T* solution, const T* freevalues) const = 0;
/// \brief std::vector version of \ref GetSolution
virtual void GetSolution(std::vector<T>& solution, const std::vector<T>& freevalues) const {
solution.resize(GetDOF());
GetSolution(&solution.at(0), freevalues.size() > 0 ? &freevalues.at(0) : NULL);
}
/// \brief Gets the indices of the configuration space that have to be preset before a full solution can be returned
///
/// 0 always points to the first value accepted by the ik function.
/// \return vector of indices indicating the free parameters
virtual const std::vector<int>& GetFree() const = 0;
/// \brief the dof of the solution
virtual const int GetDOF() const = 0;
};
/// \brief manages all the solutions
template <typename T>
class IkSolutionListBase
{
public:
virtual ~IkSolutionListBase() {
}
/// \brief add one solution and return its index for later retrieval
///
/// \param vinfos Solution data for each degree of freedom of the manipulator
/// \param vfree If the solution represents an infinite space, holds free parameters of the solution that users can freely set. The indices are of the configuration that the IK solver accepts rather than the entire robot, ie 0 points to the first value accepted.
virtual size_t AddSolution(const std::vector<IkSingleDOFSolutionBase<T> >& vinfos, const std::vector<int>& vfree) = 0;
/// \brief returns the solution pointer
virtual const IkSolutionBase<T>& GetSolution(size_t index) const = 0;
/// \brief returns the number of solutions stored
virtual size_t GetNumSolutions() const = 0;
/// \brief clears all current solutions, note that any memory addresses returned from \ref GetSolution will be invalidated.
virtual void Clear() = 0;
};
/// \brief holds function pointers for all the exported functions of ikfast
template <typename T>
class IkFastFunctions
{
public:
IkFastFunctions() : _ComputeIk(NULL), _ComputeIk2(NULL), _ComputeFk(NULL), _GetNumFreeParameters(NULL), _GetFreeParameters(NULL), _GetNumJoints(NULL), _GetIkRealSize(NULL), _GetIkFastVersion(NULL), _GetIkType(NULL), _GetKinematicsHash(NULL) {
}
virtual ~IkFastFunctions() {
}
typedef bool (*ComputeIkFn)(const T*, const T*, const T*, IkSolutionListBase<T>&);
ComputeIkFn _ComputeIk;
typedef bool (*ComputeIk2Fn)(const T*, const T*, const T*, IkSolutionListBase<T>&, void*);
ComputeIk2Fn _ComputeIk2;
typedef void (*ComputeFkFn)(const T*, T*, T*);
ComputeFkFn _ComputeFk;
typedef int (*GetNumFreeParametersFn)();
GetNumFreeParametersFn _GetNumFreeParameters;
typedef int* (*GetFreeParametersFn)();
GetFreeParametersFn _GetFreeParameters;
typedef int (*GetNumJointsFn)();
GetNumJointsFn _GetNumJoints;
typedef int (*GetIkRealSizeFn)();
GetIkRealSizeFn _GetIkRealSize;
typedef const char* (*GetIkFastVersionFn)();
GetIkFastVersionFn _GetIkFastVersion;
typedef int (*GetIkTypeFn)();
GetIkTypeFn _GetIkType;
typedef const char* (*GetKinematicsHashFn)();
GetKinematicsHashFn _GetKinematicsHash;
};
// Implementations of the abstract classes, user doesn't need to use them
/// \brief Default implementation of \ref IkSolutionBase
template <typename T>
class IkSolution : public IkSolutionBase<T>
{
public:
IkSolution(const std::vector<IkSingleDOFSolutionBase<T> >& vinfos, const std::vector<int>& vfree) {
_vbasesol = vinfos;
_vfree = vfree;
}
virtual void GetSolution(T* solution, const T* freevalues) const {
for(std::size_t i = 0; i < _vbasesol.size(); ++i) {
if( _vbasesol[i].freeind < 0 )
solution[i] = _vbasesol[i].foffset;
else {
solution[i] = freevalues[_vbasesol[i].freeind]*_vbasesol[i].fmul + _vbasesol[i].foffset;
if( solution[i] > T(3.14159265358979) ) {
solution[i] -= T(6.28318530717959);
}
else if( solution[i] < T(-3.14159265358979) ) {
solution[i] += T(6.28318530717959);
}
}
}
}
virtual void GetSolution(std::vector<T>& solution, const std::vector<T>& freevalues) const {
solution.resize(GetDOF());
GetSolution(&solution.at(0), freevalues.size() > 0 ? &freevalues.at(0) : NULL);
}
virtual const std::vector<int>& GetFree() const {
return _vfree;
}
virtual const int GetDOF() const {
return static_cast<int>(_vbasesol.size());
}
virtual void Validate() const {
for(size_t i = 0; i < _vbasesol.size(); ++i) {
if( _vbasesol[i].maxsolutions == (unsigned char)-1) {
throw std::runtime_error("max solutions for joint not initialized");
}
if( _vbasesol[i].maxsolutions > 0 ) {
if( _vbasesol[i].indices[0] >= _vbasesol[i].maxsolutions ) {
throw std::runtime_error("index >= max solutions for joint");
}
if( _vbasesol[i].indices[1] != (unsigned char)-1 && _vbasesol[i].indices[1] >= _vbasesol[i].maxsolutions ) {
throw std::runtime_error("2nd index >= max solutions for joint");
}
}
if( !std::isfinite(_vbasesol[i].foffset) ) {
throw std::runtime_error("foffset was not finite");
}
}
}
virtual void GetSolutionIndices(std::vector<unsigned int>& v) const {
v.resize(0);
v.push_back(0);
for(int i = (int)_vbasesol.size()-1; i >= 0; --i) {
if( _vbasesol[i].maxsolutions != (unsigned char)-1 && _vbasesol[i].maxsolutions > 1 ) {
for(size_t j = 0; j < v.size(); ++j) {
v[j] *= _vbasesol[i].maxsolutions;
}
size_t orgsize=v.size();
if( _vbasesol[i].indices[1] != (unsigned char)-1 ) {
for(size_t j = 0; j < orgsize; ++j) {
v.push_back(v[j]+_vbasesol[i].indices[1]);
}
}
if( _vbasesol[i].indices[0] != (unsigned char)-1 ) {
for(size_t j = 0; j < orgsize; ++j) {
v[j] += _vbasesol[i].indices[0];
}
}
}
}
}
std::vector< IkSingleDOFSolutionBase<T> > _vbasesol; ///< solution and their offsets if joints are mimiced
std::vector<int> _vfree;
};
/// \brief Default implementation of \ref IkSolutionListBase
template <typename T>
class IkSolutionList : public IkSolutionListBase<T>
{
public:
virtual size_t AddSolution(const std::vector<IkSingleDOFSolutionBase<T> >& vinfos, const std::vector<int>& vfree)
{
size_t index = _listsolutions.size();
_listsolutions.push_back(IkSolution<T>(vinfos,vfree));
return index;
}
virtual const IkSolutionBase<T>& GetSolution(size_t index) const
{
if( index >= _listsolutions.size() ) {
throw std::runtime_error("GetSolution index is invalid");
}
typename std::list< IkSolution<T> >::const_iterator it = _listsolutions.begin();
std::advance(it,index);
return *it;
}
virtual size_t GetNumSolutions() const {
return _listsolutions.size();
}
virtual void Clear() {
_listsolutions.clear();
}
protected:
std::list< IkSolution<T> > _listsolutions;
};
}
#endif // OPENRAVE_IKFAST_HEADER
// The following code is dependent on the C++ library linking with.
#ifdef IKFAST_HAS_LIBRARY
// defined when creating a shared object/dll
#ifdef IKFAST_CLIBRARY
#ifdef _MSC_VER
#define IKFAST_API extern "C" __declspec(dllexport)
#else
#define IKFAST_API extern "C"
#endif
#else
#define IKFAST_API
#endif
#ifdef IKFAST_NAMESPACE
namespace IKFAST_NAMESPACE {
#endif
#ifdef IKFAST_REAL
typedef IKFAST_REAL IkReal;
#else
typedef double IkReal;
#endif
/** \brief Computes all IK solutions given a end effector coordinates and the free joints.
- ``eetrans`` - 3 translation values. For iktype **TranslationXYOrientation3D**, the z-axis is the orientation.
- ``eerot``
- For **Transform6D** it is 9 values for the 3x3 rotation matrix.
- For **Direction3D**, **Ray4D**, and **TranslationDirection5D**, the first 3 values represent the target direction.
- For **TranslationXAxisAngle4D**, **TranslationYAxisAngle4D**, and **TranslationZAxisAngle4D** the first value represents the angle.
- For **TranslationLocalGlobal6D**, the diagonal elements ([0],[4],[8]) are the local translation inside the end effector coordinate system.
*/
IKFAST_API bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, ikfast::IkSolutionListBase<IkReal>& solutions);
/** \brief Similar to ComputeIk except takes OpenRAVE boost::shared_ptr<RobotBase::Manipulator>*
*/
IKFAST_API bool ComputeIk2(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, ikfast::IkSolutionListBase<IkReal>& solutions, void* pOpenRAVEManip);
/// \brief Computes the end effector coordinates given the joint values. This function is used to double check ik.
IKFAST_API void ComputeFk(const IkReal* joints, IkReal* eetrans, IkReal* eerot);
/// \brief returns the number of free parameters users has to set apriori
IKFAST_API int GetNumFreeParameters();
/// \brief the indices of the free parameters indexed by the chain joints
IKFAST_API int* GetFreeParameters();
/// \brief the total number of indices of the chain
IKFAST_API int GetNumJoints();
/// \brief the size in bytes of the configured number type
IKFAST_API int GetIkRealSize();
/// \brief the ikfast version used to generate this file
IKFAST_API const char* GetIkFastVersion();
/// \brief the ik type ID
IKFAST_API int GetIkType();
/// \brief a hash of all the chain values used for double checking that the correct IK is used.
IKFAST_API const char* GetKinematicsHash();
#ifdef IKFAST_NAMESPACE
}
#endif
#endif // IKFAST_HAS_LIBRARY
| 13,643 |
C
| 39.01173 | 266 | 0.667155 |
makolon/hsr_isaac_tamp/docker/docker_openrave/output/hsrb/ikfast0x10000049.Transform6D.0_1_4_5_6_7_f2_3.cpp
|
/// autogenerated analytical inverse kinematics code from ikfast program part of OpenRAVE
/// \author Rosen Diankov
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// ikfast version 0x10000049 generated on 2023-05-14 01:55:20.712870
/// To compile with gcc:
/// gcc -lstdc++ ik.cpp
/// To compile without any main function as a shared object (might need -llapack):
/// gcc -fPIC -lstdc++ -DIKFAST_NO_MAIN -DIKFAST_CLIBRARY -shared -Wl,-soname,libik.so -o libik.so ik.cpp
#define IKFAST_HAS_LIBRARY
#include "ikfast.h" // found inside share/openrave-X.Y/python/ikfast.h
using namespace ikfast;
// check if the included ikfast version matches what this file was compiled with
#define IKFAST_COMPILE_ASSERT(x) extern int __dummy[(int)x]
IKFAST_COMPILE_ASSERT(IKFAST_VERSION==0x10000049);
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
#include <complex>
#ifndef IKFAST_ASSERT
#include <stdexcept>
#include <sstream>
#include <iostream>
#ifdef _MSC_VER
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __FUNCDNAME__
#endif
#endif
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __func__
#endif
#define IKFAST_ASSERT(b) { if( !(b) ) { std::stringstream ss; ss << "ikfast exception: " << __FILE__ << ":" << __LINE__ << ": " <<__PRETTY_FUNCTION__ << ": Assertion '" << #b << "' failed"; throw std::runtime_error(ss.str()); } }
#endif
#if defined(_MSC_VER)
#define IKFAST_ALIGNED16(x) __declspec(align(16)) x
#else
#define IKFAST_ALIGNED16(x) x __attribute((aligned(16)))
#endif
#define IK2PI ((IkReal)6.28318530717959)
#define IKPI ((IkReal)3.14159265358979)
#define IKPI_2 ((IkReal)1.57079632679490)
#ifdef _MSC_VER
#ifndef isnan
#define isnan _isnan
#endif
#ifndef isinf
#define isinf _isinf
#endif
//#ifndef isfinite
//#define isfinite _isfinite
//#endif
#endif // _MSC_VER
// lapack routines
extern "C" {
void dgetrf_ (const int* m, const int* n, double* a, const int* lda, int* ipiv, int* info);
void zgetrf_ (const int* m, const int* n, std::complex<double>* a, const int* lda, int* ipiv, int* info);
void dgetri_(const int* n, const double* a, const int* lda, int* ipiv, double* work, const int* lwork, int* info);
void dgesv_ (const int* n, const int* nrhs, double* a, const int* lda, int* ipiv, double* b, const int* ldb, int* info);
void dgetrs_(const char *trans, const int *n, const int *nrhs, double *a, const int *lda, int *ipiv, double *b, const int *ldb, int *info);
void dgeev_(const char *jobvl, const char *jobvr, const int *n, double *a, const int *lda, double *wr, double *wi,double *vl, const int *ldvl, double *vr, const int *ldvr, double *work, const int *lwork, int *info);
}
using namespace std; // necessary to get std math routines
#ifdef IKFAST_NAMESPACE
namespace IKFAST_NAMESPACE {
#endif
inline float IKabs(float f) { return fabsf(f); }
inline double IKabs(double f) { return fabs(f); }
inline float IKsqr(float f) { return f*f; }
inline double IKsqr(double f) { return f*f; }
inline float IKlog(float f) { return logf(f); }
inline double IKlog(double f) { return log(f); }
// allows asin and acos to exceed 1. has to be smaller than thresholds used for branch conds and evaluation
#ifndef IKFAST_SINCOS_THRESH
#define IKFAST_SINCOS_THRESH ((IkReal)1e-7)
#endif
// used to check input to atan2 for degenerate cases. has to be smaller than thresholds used for branch conds and evaluation
#ifndef IKFAST_ATAN2_MAGTHRESH
#define IKFAST_ATAN2_MAGTHRESH ((IkReal)1e-7)
#endif
// minimum distance of separate solutions
#ifndef IKFAST_SOLUTION_THRESH
#define IKFAST_SOLUTION_THRESH ((IkReal)1e-6)
#endif
// there are checkpoints in ikfast that are evaluated to make sure they are 0. This threshold speicfies by how much they can deviate
#ifndef IKFAST_EVALCOND_THRESH
#define IKFAST_EVALCOND_THRESH ((IkReal)0.00001)
#endif
inline float IKasin(float f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return float(-IKPI_2);
else if( f >= 1 ) return float(IKPI_2);
return asinf(f);
}
inline double IKasin(double f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return -IKPI_2;
else if( f >= 1 ) return IKPI_2;
return asin(f);
}
// return positive value in [0,y)
inline float IKfmod(float x, float y)
{
while(x < 0) {
x += y;
}
return fmodf(x,y);
}
// return positive value in [0,y)
inline double IKfmod(double x, double y)
{
while(x < 0) {
x += y;
}
return fmod(x,y);
}
inline float IKacos(float f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return float(IKPI);
else if( f >= 1 ) return float(0);
return acosf(f);
}
inline double IKacos(double f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return IKPI;
else if( f >= 1 ) return 0;
return acos(f);
}
inline float IKsin(float f) { return sinf(f); }
inline double IKsin(double f) { return sin(f); }
inline float IKcos(float f) { return cosf(f); }
inline double IKcos(double f) { return cos(f); }
inline float IKtan(float f) { return tanf(f); }
inline double IKtan(double f) { return tan(f); }
inline float IKsqrt(float f) { if( f <= 0.0f ) return 0.0f; return sqrtf(f); }
inline double IKsqrt(double f) { if( f <= 0.0 ) return 0.0; return sqrt(f); }
inline float IKatan2Simple(float fy, float fx) {
return atan2f(fy,fx);
}
inline float IKatan2(float fy, float fx) {
if( isnan(fy) ) {
IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
return float(IKPI_2);
}
else if( isnan(fx) ) {
return 0;
}
return atan2f(fy,fx);
}
inline double IKatan2Simple(double fy, double fx) {
return atan2(fy,fx);
}
inline double IKatan2(double fy, double fx) {
if( isnan(fy) ) {
IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
return IKPI_2;
}
else if( isnan(fx) ) {
return 0;
}
return atan2(fy,fx);
}
template <typename T>
struct CheckValue
{
T value;
bool valid;
};
template <typename T>
inline CheckValue<T> IKatan2WithCheck(T fy, T fx, T epsilon)
{
CheckValue<T> ret;
ret.valid = false;
ret.value = 0;
if( !isnan(fy) && !isnan(fx) ) {
if( IKabs(fy) >= IKFAST_ATAN2_MAGTHRESH || IKabs(fx) > IKFAST_ATAN2_MAGTHRESH ) {
ret.value = IKatan2Simple(fy,fx);
ret.valid = true;
}
}
return ret;
}
inline float IKsign(float f) {
if( f > 0 ) {
return float(1);
}
else if( f < 0 ) {
return float(-1);
}
return 0;
}
inline double IKsign(double f) {
if( f > 0 ) {
return 1.0;
}
else if( f < 0 ) {
return -1.0;
}
return 0;
}
template <typename T>
inline CheckValue<T> IKPowWithIntegerCheck(T f, int n)
{
CheckValue<T> ret;
ret.valid = true;
if( n == 0 ) {
ret.value = 1.0;
return ret;
}
else if( n == 1 )
{
ret.value = f;
return ret;
}
else if( n < 0 )
{
if( f == 0 )
{
ret.valid = false;
ret.value = (T)1.0e30;
return ret;
}
if( n == -1 ) {
ret.value = T(1.0)/f;
return ret;
}
}
int num = n > 0 ? n : -n;
if( num == 2 ) {
ret.value = f*f;
}
else if( num == 3 ) {
ret.value = f*f*f;
}
else {
ret.value = 1.0;
while(num>0) {
if( num & 1 ) {
ret.value *= f;
}
num >>= 1;
f *= f;
}
}
if( n < 0 ) {
ret.value = T(1.0)/ret.value;
}
return ret;
}
/// solves the forward kinematics equations.
/// \param pfree is an array specifying the free joints of the chain.
IKFAST_API void ComputeFk(const IkReal* j, IkReal* eetrans, IkReal* eerot) {
IkReal x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36,x37,x38;
x0=IKcos(j[2]);
x1=IKcos(j[4]);
x2=IKcos(j[5]);
x3=IKsin(j[2]);
x4=IKsin(j[5]);
x5=IKsin(j[7]);
x6=IKcos(j[6]);
x7=IKcos(j[7]);
x8=IKsin(j[6]);
x9=IKsin(j[4]);
x10=((0.1405)*x9);
x11=((0.012)*x9);
x12=((1.0)*x2);
x13=((0.1405)*x4);
x14=((0.1405)*x2);
x15=((1.0)*x6);
x16=((1.0)*x9);
x17=((0.012)*x6);
x18=((0.012)*x4);
x19=((0.012)*x2);
x20=(x0*x6);
x21=(x3*x8);
x22=(x1*x6);
x23=(x1*x3);
x24=(x0*x1);
x25=(x0*x8);
x26=(x0*x4);
x27=(x1*x8);
x28=(x3*x9);
x29=(x4*x9);
x30=((1.0)*x3*x4);
x31=(x16*x25);
x32=(x16*x21);
x33=((((-1.0)*x30))+((x2*x24)));
x34=(((x2*x23))+x26);
x35=((((1.0)*x23*x4))+(((-1.0)*x0*x12)));
x36=((((1.0)*x24*x4))+((x12*x3)));
x37=(((x12*x6*x9))+(((1.0)*x27)));
x38=(x33*x6);
eerot[0]=(((x7*((x31+(((-1.0)*x15*x33))))))+((x36*x5)));
eerot[1]=(((x5*(((((-1.0)*x31))+x38))))+((x36*x7)));
eerot[2]=(((x8*(((((-1.0)*x12*x24))+x30))))+(((-1.0)*x0*x15*x9)));
IkReal x39=((1.0)*x24);
eetrans[0]=((((-0.078)*x3))+((x8*(((((-1.0)*x14*x39))+((x13*x3))))))+(((-0.345)*x0*x9))+((x5*(((((-1.0)*x19*x3))+(((-1.0)*x18*x39))))))+(((-1.0)*x10*x20))+(((0.141)*x0))+(((0.005)*x24))+((x7*((((x17*x33))+(((-1.0)*x11*x25))))))+j[0]);
eerot[3]=(((x35*x5))+((x7*((x32+(((-1.0)*x15*x34)))))));
eerot[4]=(((x35*x7))+((x5*(((((-1.0)*x32))+((x34*x6)))))));
eerot[5]=((((-1.0)*x15*x28))+((x8*(((((-1.0)*x12*x23))+(((-1.0)*x26)))))));
IkReal x40=((1.0)*x23);
eetrans[1]=((((-0.345)*x28))+(((0.078)*x0))+(((-1.0)*x10*x3*x6))+((x5*((((x0*x19))+(((-1.0)*x18*x40))))))+((x7*((((x17*x34))+(((-1.0)*x11*x21))))))+(((0.141)*x3))+(((0.005)*x23))+j[1]+((x8*(((((-1.0)*x0*x13))+(((-1.0)*x14*x40)))))));
eerot[6]=(((x29*x5))+(((-1.0)*x37*x7)));
eerot[7]=(((x29*x7))+((x37*x5)));
eerot[8]=((((-1.0)*x12*x8*x9))+x22);
eetrans[2]=((0.34)+(((0.345)*x1))+(((0.1405)*x22))+(((0.005)*x9))+(((-1.0)*x10*x2*x8))+(((-1.0)*x11*x4*x5))+j[3]+((x7*(((((0.012)*x27))+((x11*x2*x6)))))));
}
IKFAST_API int GetNumFreeParameters() { return 2; }
IKFAST_API int* GetFreeParameters() { static int freeparams[] = {2, 3}; return freeparams; }
IKFAST_API int GetNumJoints() { return 8; }
IKFAST_API int GetIkRealSize() { return sizeof(IkReal); }
IKFAST_API int GetIkType() { return 0x67000001; }
class IKSolver {
public:
IkReal j0,cj0,sj0,htj0,j0mul,j1,cj1,sj1,htj1,j1mul,j4,cj4,sj4,htj4,j4mul,j5,cj5,sj5,htj5,j5mul,j6,cj6,sj6,htj6,j6mul,j7,cj7,sj7,htj7,j7mul,j2,cj2,sj2,htj2,j3,cj3,sj3,htj3,new_r00,r00,rxp0_0,new_r01,r01,rxp0_1,new_r02,r02,rxp0_2,new_r10,r10,rxp1_0,new_r11,r11,rxp1_1,new_r12,r12,rxp1_2,new_r20,r20,rxp2_0,new_r21,r21,rxp2_1,new_r22,r22,rxp2_2,new_px,px,npx,new_py,py,npy,new_pz,pz,npz,pp;
unsigned char _ij0[2], _nj0,_ij1[2], _nj1,_ij4[2], _nj4,_ij5[2], _nj5,_ij6[2], _nj6,_ij7[2], _nj7,_ij2[2], _nj2,_ij3[2], _nj3;
IkReal j100, cj100, sj100;
unsigned char _ij100[2], _nj100;
bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions) {
j0=numeric_limits<IkReal>::quiet_NaN(); _ij0[0] = -1; _ij0[1] = -1; _nj0 = -1; j1=numeric_limits<IkReal>::quiet_NaN(); _ij1[0] = -1; _ij1[1] = -1; _nj1 = -1; j4=numeric_limits<IkReal>::quiet_NaN(); _ij4[0] = -1; _ij4[1] = -1; _nj4 = -1; j5=numeric_limits<IkReal>::quiet_NaN(); _ij5[0] = -1; _ij5[1] = -1; _nj5 = -1; j6=numeric_limits<IkReal>::quiet_NaN(); _ij6[0] = -1; _ij6[1] = -1; _nj6 = -1; j7=numeric_limits<IkReal>::quiet_NaN(); _ij7[0] = -1; _ij7[1] = -1; _nj7 = -1; _ij2[0] = -1; _ij2[1] = -1; _nj2 = 0; _ij3[0] = -1; _ij3[1] = -1; _nj3 = 0;
for(int dummyiter = 0; dummyiter < 1; ++dummyiter) {
solutions.Clear();
j2=pfree[0]; cj2=cos(pfree[0]); sj2=sin(pfree[0]), htj2=tan(pfree[0]*0.5);
j3=pfree[1]; cj3=cos(pfree[1]); sj3=sin(pfree[1]), htj3=tan(pfree[1]*0.5);
r00 = eerot[0*3+0];
r01 = eerot[0*3+1];
r02 = eerot[0*3+2];
r10 = eerot[1*3+0];
r11 = eerot[1*3+1];
r12 = eerot[1*3+2];
r20 = eerot[2*3+0];
r21 = eerot[2*3+1];
r22 = eerot[2*3+2];
px = eetrans[0]; py = eetrans[1]; pz = eetrans[2];
new_r00=r20;
new_r01=r21;
new_r02=((-1.0)*r22);
new_px=((((-0.012)*r20))+(((0.1405)*r22))+(((-1.0)*pz)));
new_r10=((-1.0)*r10);
new_r11=((-1.0)*r11);
new_r12=r12;
new_py=((((-0.1405)*r12))+(((0.012)*r10))+py);
new_r20=((-1.0)*r00);
new_r21=((-1.0)*r01);
new_r22=r02;
new_pz=((((-0.1405)*r02))+(((0.012)*r00))+px);
r00 = new_r00; r01 = new_r01; r02 = new_r02; r10 = new_r10; r11 = new_r11; r12 = new_r12; r20 = new_r20; r21 = new_r21; r22 = new_r22; px = new_px; py = new_py; pz = new_pz;
IkReal x41=((1.0)*px);
IkReal x42=((1.0)*pz);
IkReal x43=((1.0)*py);
pp=((px*px)+(py*py)+(pz*pz));
npx=(((px*r00))+((py*r10))+((pz*r20)));
npy=(((px*r01))+((py*r11))+((pz*r21)));
npz=(((px*r02))+((py*r12))+((pz*r22)));
rxp0_0=((((-1.0)*r20*x43))+((pz*r10)));
rxp0_1=(((px*r20))+(((-1.0)*r00*x42)));
rxp0_2=((((-1.0)*r10*x41))+((py*r00)));
rxp1_0=((((-1.0)*r21*x43))+((pz*r11)));
rxp1_1=(((px*r21))+(((-1.0)*r01*x42)));
rxp1_2=((((-1.0)*r11*x41))+((py*r01)));
rxp2_0=((((-1.0)*r22*x43))+((pz*r12)));
rxp2_1=((((-1.0)*r02*x42))+((px*r22)));
rxp2_2=((((-1.0)*r12*x41))+((py*r02)));
{
IkReal j4array[2], cj4array[2], sj4array[2];
bool j4valid[2]={false};
_nj4 = 2;
if( (((0.985403764752504)+(((2.89824636691913)*j3))+(((2.89824636691913)*px)))) < -1-IKFAST_SINCOS_THRESH || (((0.985403764752504)+(((2.89824636691913)*j3))+(((2.89824636691913)*px)))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x44=IKasin(((0.985403764752504)+(((2.89824636691913)*j3))+(((2.89824636691913)*px))));
j4array[0]=((-1.5563045877294)+(((-1.0)*x44)));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
j4array[1]=((1.5852880658604)+x44);
sj4array[1]=IKsin(j4array[1]);
cj4array[1]=IKcos(j4array[1]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
if( j4array[1] > IKPI )
{
j4array[1]-=IK2PI;
}
else if( j4array[1] < -IKPI )
{ j4array[1]+=IK2PI;
}
j4valid[1] = true;
for(int ij4 = 0; ij4 < 2; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 2; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
j0array[0]=((((0.078)*sj2))+(((0.345)*cj2*sj4))+pz+(((-0.005)*cj2*cj4))+(((-0.141)*cj2)));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
j1array[0]=((((-0.005)*cj4*sj2))+(((-0.141)*sj2))+py+(((-0.078)*cj2))+(((0.345)*sj2*sj4)));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
rotationfunction0(solutions);
}
}
}
}
}
}
}
return solutions.GetNumSolutions()>0;
}
inline void rotationfunction0(IkSolutionListBase<IkReal>& solutions) {
for(int rotationiter = 0; rotationiter < 1; ++rotationiter) {
IkReal x45=(cj4*sj2);
IkReal x46=((1.0)*sj2);
IkReal x47=(cj2*cj4);
IkReal x48=((1.0)*sj4);
IkReal x49=((1.0)*cj4);
new_r00=(((r20*x47))+(((-1.0)*r00*x48))+((r10*x45)));
new_r01=((((-1.0)*r01*x48))+((r11*x45))+((r21*x47)));
new_r02=((((-1.0)*r02*x48))+((r22*x47))+((r12*x45)));
new_r10=((((-1.0)*r20*x46))+((cj2*r10)));
new_r11=((((-1.0)*r21*x46))+((cj2*r11)));
new_r12=(((cj2*r12))+(((-1.0)*r22*x46)));
new_r20=((((-1.0)*cj2*r20*x48))+(((-1.0)*r10*sj4*x46))+(((-1.0)*r00*x49)));
new_r21=((((-1.0)*r01*x49))+(((-1.0)*cj2*r21*x48))+(((-1.0)*r11*sj4*x46)));
new_r22=((((-1.0)*r12*sj4*x46))+(((-1.0)*r02*x49))+(((-1.0)*cj2*r22*x48)));
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
cj6array[0]=new_r22;
if( cj6array[0] >= -1-IKFAST_SINCOS_THRESH && cj6array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j6valid[0] = j6valid[1] = true;
j6array[0] = IKacos(cj6array[0]);
sj6array[0] = IKsin(j6array[0]);
cj6array[1] = cj6array[0];
j6array[1] = -j6array[0];
sj6array[1] = -sj6array[0];
}
else if( isnan(cj6array[0]) )
{
// probably any value will work
j6valid[0] = true;
cj6array[0] = 1; sj6array[0] = 0; j6array[0] = 0;
}
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal j7eval[3];
j7eval[0]=sj6;
j7eval[1]=IKsign(sj6);
j7eval[2]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(j7eval[0]) < 0.0000010000000000 || IKabs(j7eval[1]) < 0.0000010000000000 || IKabs(j7eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
j5eval[0]=sj6;
j5eval[1]=((IKabs(new_r12))+(IKabs(new_r02)));
j5eval[2]=IKsign(sj6);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
j5eval[0]=new_r12;
j5eval[1]=sj6;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j6))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
IkReal j7mul = 1;
j7=0;
j5mul=-1.0;
if( IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r01))+IKsqr(new_r00)-1) <= IKFAST_SINCOS_THRESH )
continue;
j5=IKatan2(((-1.0)*new_r01), new_r00);
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].fmul = j5mul;
vinfos[5].freeind = 0;
vinfos[5].maxsolutions = 0;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].fmul = j7mul;
vinfos[7].freeind = 0;
vinfos[7].maxsolutions = 0;
std::vector<int> vfree(1);
vfree[0] = 7;
solutions.AddSolution(vinfos,vfree);
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j6)))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
IkReal j7mul = 1;
j7=0;
j5mul=1.0;
if( IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r01))+IKsqr(((-1.0)*new_r00))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5=IKatan2(((-1.0)*new_r01), ((-1.0)*new_r00));
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].fmul = j5mul;
vinfos[5].freeind = 0;
vinfos[5].maxsolutions = 0;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].fmul = j7mul;
vinfos[7].freeind = 0;
vinfos[7].maxsolutions = 0;
std::vector<int> vfree(1);
vfree[0] = 7;
solutions.AddSolution(vinfos,vfree);
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
IkReal x50=new_r22*new_r22;
IkReal x51=((16.0)*new_r10);
IkReal x52=((16.0)*new_r01);
IkReal x53=((16.0)*new_r22);
IkReal x54=((8.0)*new_r11);
IkReal x55=((8.0)*new_r00);
IkReal x56=(x50*x51);
IkReal x57=(x50*x52);
j5eval[0]=((IKabs((x51+(((-1.0)*x56)))))+(IKabs(((((16.0)*new_r00))+(((-32.0)*new_r00*x50))+((new_r11*x53)))))+(IKabs((x56+(((-1.0)*x51)))))+(IKabs((((new_r22*x54))+(((-1.0)*x55)))))+(IKabs(((((16.0)*new_r11*x50))+(((-32.0)*new_r11))+((new_r00*x53)))))+(IKabs((x52+(((-1.0)*x57)))))+(IKabs((x57+(((-1.0)*x52)))))+(IKabs((((new_r22*x55))+(((-1.0)*x50*x54))))));
if( IKabs(j5eval[0]) < 0.0000000010000000 )
{
continue; // no branches [j5, j7]
} else
{
IkReal op[4+1], zeror[4];
int numroots;
IkReal j5evalpoly[1];
IkReal x58=new_r22*new_r22;
IkReal x59=((16.0)*new_r10);
IkReal x60=(new_r11*new_r22);
IkReal x61=(x58*x59);
IkReal x62=((((8.0)*x60))+(((-8.0)*new_r00)));
op[0]=x62;
op[1]=(x59+(((-1.0)*x61)));
op[2]=((((16.0)*x60))+(((16.0)*new_r00))+(((-32.0)*new_r00*x58)));
op[3]=(x61+(((-1.0)*x59)));
op[4]=x62;
polyroots4(op,zeror,numroots);
IkReal j5array[4], cj5array[4], sj5array[4], tempj5array[1];
int numsolutions = 0;
for(int ij5 = 0; ij5 < numroots; ++ij5)
{
IkReal htj5 = zeror[ij5];
tempj5array[0]=((2.0)*(atan(htj5)));
for(int kj5 = 0; kj5 < 1; ++kj5)
{
j5array[numsolutions] = tempj5array[kj5];
if( j5array[numsolutions] > IKPI )
{
j5array[numsolutions]-=IK2PI;
}
else if( j5array[numsolutions] < -IKPI )
{
j5array[numsolutions]+=IK2PI;
}
sj5array[numsolutions] = IKsin(j5array[numsolutions]);
cj5array[numsolutions] = IKcos(j5array[numsolutions]);
numsolutions++;
}
}
bool j5valid[4]={true,true,true,true};
_nj5 = 4;
for(int ij5 = 0; ij5 < numsolutions; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
htj5 = IKtan(j5/2);
IkReal x63=((16.0)*new_r01);
IkReal x64=new_r22*new_r22;
IkReal x65=(new_r00*new_r22);
IkReal x66=((8.0)*x65);
IkReal x67=(new_r11*x64);
IkReal x68=(x63*x64);
IkReal x69=((8.0)*x67);
j5evalpoly[0]=(((htj5*((x68+(((-1.0)*x63))))))+(((htj5*htj5*htj5*htj5)*((x66+(((-1.0)*x69))))))+(((htj5*htj5*htj5)*((x63+(((-1.0)*x68))))))+(((htj5*htj5)*(((((16.0)*x65))+(((16.0)*x67))+(((-32.0)*new_r11))))))+x66+(((-1.0)*x69)));
if( IKabs(j5evalpoly[0]) > 0.0000000010000000 )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < numsolutions; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
{
IkReal j7eval[3];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
IkReal x70=cj5*cj5;
IkReal x71=(cj5*new_r22);
IkReal x72=((-1.0)+(((-1.0)*x70*(new_r22*new_r22)))+x70);
j7eval[0]=x72;
j7eval[1]=((IKabs((((new_r01*x71))+((new_r00*sj5)))))+(IKabs((((new_r01*sj5))+(((-1.0)*new_r00*x71))))));
j7eval[2]=IKsign(x72);
if( IKabs(j7eval[0]) < 0.0000010000000000 || IKabs(j7eval[1]) < 0.0000010000000000 || IKabs(j7eval[2]) < 0.0000010000000000 )
{
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
j7eval[0]=new_r22;
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
j7eval[0]=sj5;
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(new_r10, new_r11);
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[4];
IkReal x73=IKsin(j7);
IkReal x74=IKcos(j7);
evalcond[0]=x73;
evalcond[1]=((-1.0)*x74);
evalcond[2]=(x73+(((-1.0)*new_r10)));
evalcond[3]=(x74+(((-1.0)*new_r11)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r11));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[4];
IkReal x75=IKsin(j7);
IkReal x76=IKcos(j7);
evalcond[0]=x75;
evalcond[1]=(x75+new_r10);
evalcond[2]=(x76+new_r11);
evalcond[3]=((-1.0)*x76);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
CheckValue<IkReal> x77=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x77.valid){
continue;
}
if((x77.value) < -0.00001)
continue;
IkReal gconst18=((-1.0)*(IKsqrt(x77.value)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.0)+(IKsign(sj5)))))+(IKabs((cj5+(((-1.0)*gconst18)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
if((((1.0)+(((-1.0)*(gconst18*gconst18))))) < -0.00001)
continue;
sj5=IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18)))));
cj5=gconst18;
if( (gconst18) < -1-IKFAST_SINCOS_THRESH || (gconst18) > 1+IKFAST_SINCOS_THRESH )
continue;
j5=IKacos(gconst18);
CheckValue<IkReal> x78=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x78.valid){
continue;
}
if((x78.value) < -0.00001)
continue;
IkReal gconst18=((-1.0)*(IKsqrt(x78.value)));
j7eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if((((1.0)+(((-1.0)*(gconst18*gconst18))))) < -0.00001)
continue;
CheckValue<IkReal> x79=IKPowWithIntegerCheck(gconst18,-1);
if(!x79.valid){
continue;
}
if( IKabs((((gconst18*new_r10))+(((-1.0)*new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18)))))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r11*(x79.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((gconst18*new_r10))+(((-1.0)*new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18))))))))))+IKsqr((new_r11*(x79.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((gconst18*new_r10))+(((-1.0)*new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18))))))))), (new_r11*(x79.value)));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x80=IKcos(j7);
IkReal x81=IKsin(j7);
IkReal x82=((1.0)*gconst18);
if((((1.0)+(((-1.0)*gconst18*x82)))) < -0.00001)
continue;
IkReal x83=IKsqrt(((1.0)+(((-1.0)*gconst18*x82))));
evalcond[0]=x81;
evalcond[1]=((-1.0)*x80);
evalcond[2]=((((-1.0)*x80*x82))+new_r11);
evalcond[3]=((((-1.0)*x81*x82))+new_r10);
evalcond[4]=(((x80*x83))+new_r01);
evalcond[5]=(((x81*x83))+new_r00);
evalcond[6]=(((new_r00*x83))+x81+(((-1.0)*new_r10*x82)));
evalcond[7]=((((-1.0)*new_r11*x82))+((new_r01*x83))+x80);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x84=IKPowWithIntegerCheck(IKsign(gconst18),-1);
if(!x84.valid){
continue;
}
CheckValue<IkReal> x85 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x85.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x84.value)))+(x85.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x86=IKcos(j7);
IkReal x87=IKsin(j7);
IkReal x88=((1.0)*gconst18);
if((((1.0)+(((-1.0)*gconst18*x88)))) < -0.00001)
continue;
IkReal x89=IKsqrt(((1.0)+(((-1.0)*gconst18*x88))));
evalcond[0]=x87;
evalcond[1]=((-1.0)*x86);
evalcond[2]=((((-1.0)*x86*x88))+new_r11);
evalcond[3]=((((-1.0)*x87*x88))+new_r10);
evalcond[4]=(((x86*x89))+new_r01);
evalcond[5]=(new_r00+((x87*x89)));
evalcond[6]=(((new_r00*x89))+x87+(((-1.0)*new_r10*x88)));
evalcond[7]=((((-1.0)*new_r11*x88))+((new_r01*x89))+x86);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
CheckValue<IkReal> x90=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x90.valid){
continue;
}
if((x90.value) < -0.00001)
continue;
IkReal gconst18=((-1.0)*(IKsqrt(x90.value)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((cj5+(((-1.0)*gconst18)))))+(IKabs(((1.0)+(IKsign(sj5)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
if((((1.0)+(((-1.0)*(gconst18*gconst18))))) < -0.00001)
continue;
sj5=((-1.0)*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18)))))));
cj5=gconst18;
if( (gconst18) < -1-IKFAST_SINCOS_THRESH || (gconst18) > 1+IKFAST_SINCOS_THRESH )
continue;
j5=((-1.0)*(IKacos(gconst18)));
CheckValue<IkReal> x91=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x91.valid){
continue;
}
if((x91.value) < -0.00001)
continue;
IkReal gconst18=((-1.0)*(IKsqrt(x91.value)));
j7eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if((((1.0)+(((-1.0)*(gconst18*gconst18))))) < -0.00001)
continue;
CheckValue<IkReal> x92=IKPowWithIntegerCheck(gconst18,-1);
if(!x92.valid){
continue;
}
if( IKabs((((gconst18*new_r10))+((new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18)))))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r11*(x92.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((gconst18*new_r10))+((new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18))))))))))+IKsqr((new_r11*(x92.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((gconst18*new_r10))+((new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst18*gconst18))))))))), (new_r11*(x92.value)));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x93=IKcos(j7);
IkReal x94=IKsin(j7);
IkReal x95=((1.0)*gconst18);
if((((1.0)+(((-1.0)*gconst18*x95)))) < -0.00001)
continue;
IkReal x96=IKsqrt(((1.0)+(((-1.0)*gconst18*x95))));
IkReal x97=((1.0)*x96);
evalcond[0]=x94;
evalcond[1]=((-1.0)*x93);
evalcond[2]=(new_r11+(((-1.0)*x93*x95)));
evalcond[3]=((((-1.0)*x94*x95))+new_r10);
evalcond[4]=(new_r01+(((-1.0)*x93*x97)));
evalcond[5]=((((-1.0)*x94*x97))+new_r00);
evalcond[6]=((((-1.0)*new_r10*x95))+x94+(((-1.0)*new_r00*x97)));
evalcond[7]=((((-1.0)*new_r11*x95))+(((-1.0)*new_r01*x97))+x93);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x98=IKPowWithIntegerCheck(IKsign(gconst18),-1);
if(!x98.valid){
continue;
}
CheckValue<IkReal> x99 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x99.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x98.value)))+(x99.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x100=IKcos(j7);
IkReal x101=IKsin(j7);
IkReal x102=((1.0)*gconst18);
if((((1.0)+(((-1.0)*gconst18*x102)))) < -0.00001)
continue;
IkReal x103=IKsqrt(((1.0)+(((-1.0)*gconst18*x102))));
IkReal x104=((1.0)*x103);
evalcond[0]=x101;
evalcond[1]=((-1.0)*x100);
evalcond[2]=((((-1.0)*x100*x102))+new_r11);
evalcond[3]=((((-1.0)*x101*x102))+new_r10);
evalcond[4]=((((-1.0)*x100*x104))+new_r01);
evalcond[5]=((((-1.0)*x101*x104))+new_r00);
evalcond[6]=((((-1.0)*new_r00*x104))+(((-1.0)*new_r10*x102))+x101);
evalcond[7]=((((-1.0)*new_r11*x102))+(((-1.0)*new_r01*x104))+x100);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
CheckValue<IkReal> x105=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x105.valid){
continue;
}
if((x105.value) < -0.00001)
continue;
IkReal gconst19=IKsqrt(x105.value);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.0)+(IKsign(sj5)))))+(IKabs((cj5+(((-1.0)*gconst19)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
if((((1.0)+(((-1.0)*(gconst19*gconst19))))) < -0.00001)
continue;
sj5=IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19)))));
cj5=gconst19;
if( (gconst19) < -1-IKFAST_SINCOS_THRESH || (gconst19) > 1+IKFAST_SINCOS_THRESH )
continue;
j5=IKacos(gconst19);
CheckValue<IkReal> x106=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x106.valid){
continue;
}
if((x106.value) < -0.00001)
continue;
IkReal gconst19=IKsqrt(x106.value);
j7eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if((((1.0)+(((-1.0)*(gconst19*gconst19))))) < -0.00001)
continue;
CheckValue<IkReal> x107=IKPowWithIntegerCheck(gconst19,-1);
if(!x107.valid){
continue;
}
if( IKabs((((gconst19*new_r10))+(((-1.0)*new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19)))))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r11*(x107.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((gconst19*new_r10))+(((-1.0)*new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19))))))))))+IKsqr((new_r11*(x107.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((gconst19*new_r10))+(((-1.0)*new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19))))))))), (new_r11*(x107.value)));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x108=IKcos(j7);
IkReal x109=IKsin(j7);
IkReal x110=((1.0)*gconst19);
if((((1.0)+(((-1.0)*gconst19*x110)))) < -0.00001)
continue;
IkReal x111=IKsqrt(((1.0)+(((-1.0)*gconst19*x110))));
evalcond[0]=x109;
evalcond[1]=((-1.0)*x108);
evalcond[2]=((((-1.0)*x108*x110))+new_r11);
evalcond[3]=((((-1.0)*x109*x110))+new_r10);
evalcond[4]=(((x108*x111))+new_r01);
evalcond[5]=(((x109*x111))+new_r00);
evalcond[6]=((((-1.0)*new_r10*x110))+x109+((new_r00*x111)));
evalcond[7]=((((-1.0)*new_r11*x110))+x108+((new_r01*x111)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x112=IKPowWithIntegerCheck(IKsign(gconst19),-1);
if(!x112.valid){
continue;
}
CheckValue<IkReal> x113 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x113.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x112.value)))+(x113.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x114=IKcos(j7);
IkReal x115=IKsin(j7);
IkReal x116=((1.0)*gconst19);
if((((1.0)+(((-1.0)*gconst19*x116)))) < -0.00001)
continue;
IkReal x117=IKsqrt(((1.0)+(((-1.0)*gconst19*x116))));
evalcond[0]=x115;
evalcond[1]=((-1.0)*x114);
evalcond[2]=((((-1.0)*x114*x116))+new_r11);
evalcond[3]=((((-1.0)*x115*x116))+new_r10);
evalcond[4]=(((x114*x117))+new_r01);
evalcond[5]=(new_r00+((x115*x117)));
evalcond[6]=((((-1.0)*new_r10*x116))+x115+((new_r00*x117)));
evalcond[7]=((((-1.0)*new_r11*x116))+x114+((new_r01*x117)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
CheckValue<IkReal> x118=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x118.valid){
continue;
}
if((x118.value) < -0.00001)
continue;
IkReal gconst19=IKsqrt(x118.value);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.0)+(IKsign(sj5)))))+(IKabs((cj5+(((-1.0)*gconst19)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
if((((1.0)+(((-1.0)*(gconst19*gconst19))))) < -0.00001)
continue;
sj5=((-1.0)*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19)))))));
cj5=gconst19;
if( (gconst19) < -1-IKFAST_SINCOS_THRESH || (gconst19) > 1+IKFAST_SINCOS_THRESH )
continue;
j5=((-1.0)*(IKacos(gconst19)));
CheckValue<IkReal> x119=IKPowWithIntegerCheck(((1.0)+(((-1.0)*(new_r22*new_r22)))),-1);
if(!x119.valid){
continue;
}
if((x119.value) < -0.00001)
continue;
IkReal gconst19=IKsqrt(x119.value);
j7eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if((((1.0)+(((-1.0)*(gconst19*gconst19))))) < -0.00001)
continue;
CheckValue<IkReal> x120=IKPowWithIntegerCheck(gconst19,-1);
if(!x120.valid){
continue;
}
if( IKabs((((new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19))))))))+((gconst19*new_r10)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r11*(x120.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19))))))))+((gconst19*new_r10))))+IKsqr((new_r11*(x120.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((new_r00*(IKsqrt(((1.0)+(((-1.0)*(gconst19*gconst19))))))))+((gconst19*new_r10))), (new_r11*(x120.value)));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x121=IKcos(j7);
IkReal x122=IKsin(j7);
IkReal x123=((1.0)*gconst19);
if((((1.0)+(((-1.0)*gconst19*x123)))) < -0.00001)
continue;
IkReal x124=IKsqrt(((1.0)+(((-1.0)*gconst19*x123))));
IkReal x125=((1.0)*x124);
evalcond[0]=x122;
evalcond[1]=((-1.0)*x121);
evalcond[2]=((((-1.0)*x121*x123))+new_r11);
evalcond[3]=(new_r10+(((-1.0)*x122*x123)));
evalcond[4]=((((-1.0)*x121*x125))+new_r01);
evalcond[5]=(new_r00+(((-1.0)*x122*x125)));
evalcond[6]=((((-1.0)*new_r10*x123))+(((-1.0)*new_r00*x125))+x122);
evalcond[7]=((((-1.0)*new_r01*x125))+x121+(((-1.0)*new_r11*x123)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x126=IKPowWithIntegerCheck(IKsign(gconst19),-1);
if(!x126.valid){
continue;
}
CheckValue<IkReal> x127 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x127.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x126.value)))+(x127.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x128=IKcos(j7);
IkReal x129=IKsin(j7);
IkReal x130=((1.0)*gconst19);
if((((1.0)+(((-1.0)*gconst19*x130)))) < -0.00001)
continue;
IkReal x131=IKsqrt(((1.0)+(((-1.0)*gconst19*x130))));
IkReal x132=((1.0)*x131);
evalcond[0]=x129;
evalcond[1]=((-1.0)*x128);
evalcond[2]=((((-1.0)*x128*x130))+new_r11);
evalcond[3]=((((-1.0)*x129*x130))+new_r10);
evalcond[4]=((((-1.0)*x128*x132))+new_r01);
evalcond[5]=((((-1.0)*x129*x132))+new_r00);
evalcond[6]=((((-1.0)*new_r10*x130))+(((-1.0)*new_r00*x132))+x129);
evalcond[7]=((((-1.0)*new_r11*x130))+(((-1.0)*new_r01*x132))+x128);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j7]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x133=(new_r00*sj5);
CheckValue<IkReal> x134=IKPowWithIntegerCheck(sj5,-1);
if(!x134.valid){
continue;
}
if( IKabs((((cj5*new_r10))+(((-1.0)*x133)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x134.value)*(((((-1.0)*new_r10*new_r22*(cj5*cj5)))+((cj5*new_r22*x133))+(((-1.0)*new_r01)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((cj5*new_r10))+(((-1.0)*x133))))+IKsqr(((x134.value)*(((((-1.0)*new_r10*new_r22*(cj5*cj5)))+((cj5*new_r22*x133))+(((-1.0)*new_r01))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((cj5*new_r10))+(((-1.0)*x133))), ((x134.value)*(((((-1.0)*new_r10*new_r22*(cj5*cj5)))+((cj5*new_r22*x133))+(((-1.0)*new_r01))))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[10];
IkReal x135=IKsin(j7);
IkReal x136=IKcos(j7);
IkReal x137=(new_r10*sj5);
IkReal x138=((1.0)*cj5);
IkReal x139=(cj5*new_r01);
IkReal x140=(new_r11*sj5);
IkReal x141=(cj5*new_r00);
IkReal x142=((1.0)*new_r22);
IkReal x143=(new_r22*x135);
IkReal x144=(sj5*x136);
evalcond[0]=((((-1.0)*new_r10*x138))+((new_r00*sj5))+x135);
evalcond[1]=((((-1.0)*new_r11*x138))+((new_r01*sj5))+x136);
evalcond[2]=(x140+x143+x139);
evalcond[3]=(((new_r22*x139))+x135+((new_r22*x140)));
evalcond[4]=(((cj5*x143))+x144+new_r01);
evalcond[5]=(x141+x137+(((-1.0)*x136*x142)));
evalcond[6]=(((sj5*x135))+(((-1.0)*new_r22*x136*x138))+new_r00);
evalcond[7]=((((-1.0)*x136*x138))+new_r11+((sj5*x143)));
evalcond[8]=(((new_r22*x137))+((new_r22*x141))+(((-1.0)*x136)));
evalcond[9]=((((-1.0)*x135*x138))+(((-1.0)*x142*x144))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x145=((1.0)*new_r01);
CheckValue<IkReal> x146=IKPowWithIntegerCheck(new_r22,-1);
if(!x146.valid){
continue;
}
if( IKabs(((x146.value)*(((((-1.0)*new_r11*sj5))+(((-1.0)*cj5*x145)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((cj5*new_r11))+(((-1.0)*sj5*x145)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x146.value)*(((((-1.0)*new_r11*sj5))+(((-1.0)*cj5*x145))))))+IKsqr((((cj5*new_r11))+(((-1.0)*sj5*x145))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((x146.value)*(((((-1.0)*new_r11*sj5))+(((-1.0)*cj5*x145))))), (((cj5*new_r11))+(((-1.0)*sj5*x145))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[10];
IkReal x147=IKsin(j7);
IkReal x148=IKcos(j7);
IkReal x149=(new_r10*sj5);
IkReal x150=((1.0)*cj5);
IkReal x151=(cj5*new_r01);
IkReal x152=(new_r11*sj5);
IkReal x153=(cj5*new_r00);
IkReal x154=((1.0)*new_r22);
IkReal x155=(new_r22*x147);
IkReal x156=(sj5*x148);
evalcond[0]=(((new_r00*sj5))+x147+(((-1.0)*new_r10*x150)));
evalcond[1]=(((new_r01*sj5))+x148+(((-1.0)*new_r11*x150)));
evalcond[2]=(x155+x152+x151);
evalcond[3]=(x147+((new_r22*x151))+((new_r22*x152)));
evalcond[4]=(x156+new_r01+((cj5*x155)));
evalcond[5]=(x153+x149+(((-1.0)*x148*x154)));
evalcond[6]=((((-1.0)*new_r22*x148*x150))+new_r00+((sj5*x147)));
evalcond[7]=(((sj5*x155))+(((-1.0)*x148*x150))+new_r11);
evalcond[8]=(((new_r22*x153))+((new_r22*x149))+(((-1.0)*x148)));
evalcond[9]=((((-1.0)*x154*x156))+(((-1.0)*x147*x150))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x157=cj5*cj5;
IkReal x158=(cj5*new_r22);
CheckValue<IkReal> x159=IKPowWithIntegerCheck(IKsign(((-1.0)+x157+(((-1.0)*x157*(new_r22*new_r22))))),-1);
if(!x159.valid){
continue;
}
CheckValue<IkReal> x160 = IKatan2WithCheck(IkReal((((new_r01*x158))+((new_r00*sj5)))),IkReal((((new_r01*sj5))+(((-1.0)*new_r00*x158)))),IKFAST_ATAN2_MAGTHRESH);
if(!x160.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x159.value)))+(x160.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[10];
IkReal x161=IKsin(j7);
IkReal x162=IKcos(j7);
IkReal x163=(new_r10*sj5);
IkReal x164=((1.0)*cj5);
IkReal x165=(cj5*new_r01);
IkReal x166=(new_r11*sj5);
IkReal x167=(cj5*new_r00);
IkReal x168=((1.0)*new_r22);
IkReal x169=(new_r22*x161);
IkReal x170=(sj5*x162);
evalcond[0]=(((new_r00*sj5))+(((-1.0)*new_r10*x164))+x161);
evalcond[1]=(((new_r01*sj5))+(((-1.0)*new_r11*x164))+x162);
evalcond[2]=(x169+x166+x165);
evalcond[3]=(x161+((new_r22*x165))+((new_r22*x166)));
evalcond[4]=(((cj5*x169))+x170+new_r01);
evalcond[5]=(x163+x167+(((-1.0)*x162*x168)));
evalcond[6]=(new_r00+((sj5*x161))+(((-1.0)*new_r22*x162*x164)));
evalcond[7]=((((-1.0)*x162*x164))+new_r11+((sj5*x169)));
evalcond[8]=((((-1.0)*x162))+((new_r22*x163))+((new_r22*x167)));
evalcond[9]=((((-1.0)*x161*x164))+(((-1.0)*x168*x170))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5, j7]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x172=IKPowWithIntegerCheck(sj6,-1);
if(!x172.valid){
continue;
}
IkReal x171=x172.value;
CheckValue<IkReal> x173=IKPowWithIntegerCheck(new_r12,-1);
if(!x173.valid){
continue;
}
if( IKabs((x171*(x173.value)*(((-1.0)+(new_r02*new_r02)+(cj6*cj6))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r02*x171)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x171*(x173.value)*(((-1.0)+(new_r02*new_r02)+(cj6*cj6)))))+IKsqr(((-1.0)*new_r02*x171))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2((x171*(x173.value)*(((-1.0)+(new_r02*new_r02)+(cj6*cj6)))), ((-1.0)*new_r02*x171));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x174=IKcos(j5);
IkReal x175=IKsin(j5);
IkReal x176=(sj6*x175);
IkReal x177=(new_r12*x175);
IkReal x178=(new_r02*x174);
IkReal x179=(sj6*x174);
evalcond[0]=(x179+new_r02);
evalcond[1]=(x176+new_r12);
evalcond[2]=((((-1.0)*new_r02*x175))+((new_r12*x174)));
evalcond[3]=(sj6+x178+x177);
evalcond[4]=(((cj6*x177))+((cj6*x178))+((new_r22*sj6)));
evalcond[5]=((((-1.0)*new_r00*x179))+(((-1.0)*new_r10*x176))+((cj6*new_r20)));
evalcond[6]=((((-1.0)*new_r11*x176))+(((-1.0)*new_r01*x179))+((cj6*new_r21)));
evalcond[7]=((-1.0)+(((-1.0)*sj6*x178))+(((-1.0)*new_r12*x176))+((cj6*new_r22)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j7eval[3];
j7eval[0]=sj6;
j7eval[1]=IKsign(sj6);
j7eval[2]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(j7eval[0]) < 0.0000010000000000 || IKabs(j7eval[1]) < 0.0000010000000000 || IKabs(j7eval[2]) < 0.0000010000000000 )
{
{
IkReal j7eval[1];
j7eval[0]=sj6;
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7eval[2];
j7eval[0]=sj6;
j7eval[1]=sj5;
if( IKabs(j7eval[0]) < 0.0000010000000000 || IKabs(j7eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j6))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x180=((1.0)*new_r01);
if( IKabs(((((-1.0)*cj5*x180))+(((-1.0)*new_r00*sj5)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((cj5*new_r00))+(((-1.0)*sj5*x180)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*cj5*x180))+(((-1.0)*new_r00*sj5))))+IKsqr((((cj5*new_r00))+(((-1.0)*sj5*x180))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((((-1.0)*cj5*x180))+(((-1.0)*new_r00*sj5))), (((cj5*new_r00))+(((-1.0)*sj5*x180))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x181=IKsin(j7);
IkReal x182=IKcos(j7);
IkReal x183=((1.0)*cj5);
IkReal x184=(sj5*x181);
IkReal x185=((1.0)*x182);
IkReal x186=(x182*x183);
evalcond[0]=(((new_r11*sj5))+((cj5*new_r01))+x181);
evalcond[1]=(((new_r00*sj5))+x181+(((-1.0)*new_r10*x183)));
evalcond[2]=(((new_r01*sj5))+x182+(((-1.0)*new_r11*x183)));
evalcond[3]=(((cj5*x181))+new_r01+((sj5*x182)));
evalcond[4]=(((new_r10*sj5))+(((-1.0)*x185))+((cj5*new_r00)));
evalcond[5]=((((-1.0)*x186))+x184+new_r00);
evalcond[6]=((((-1.0)*x186))+x184+new_r11);
evalcond[7]=((((-1.0)*sj5*x185))+new_r10+(((-1.0)*x181*x183)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j6)))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x187=((1.0)*new_r00);
if( IKabs((((cj5*new_r01))+(((-1.0)*sj5*x187)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r01*sj5))+(((-1.0)*cj5*x187)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((cj5*new_r01))+(((-1.0)*sj5*x187))))+IKsqr(((((-1.0)*new_r01*sj5))+(((-1.0)*cj5*x187))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((cj5*new_r01))+(((-1.0)*sj5*x187))), ((((-1.0)*new_r01*sj5))+(((-1.0)*cj5*x187))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x188=IKcos(j7);
IkReal x189=IKsin(j7);
IkReal x190=((1.0)*cj5);
IkReal x191=(sj5*x188);
IkReal x192=(cj5*x188);
IkReal x193=((1.0)*x189);
IkReal x194=(x189*x190);
evalcond[0]=(((new_r10*sj5))+((cj5*new_r00))+x188);
evalcond[1]=(((new_r00*sj5))+x189+(((-1.0)*new_r10*x190)));
evalcond[2]=(((new_r01*sj5))+x188+(((-1.0)*new_r11*x190)));
evalcond[3]=(((new_r11*sj5))+((cj5*new_r01))+(((-1.0)*x193)));
evalcond[4]=(x192+new_r00+((sj5*x189)));
evalcond[5]=((((-1.0)*x194))+x191+new_r01);
evalcond[6]=((((-1.0)*x194))+x191+new_r10);
evalcond[7]=((((-1.0)*x188*x190))+(((-1.0)*sj5*x193))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(new_r10, new_r11);
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x195=IKsin(j7);
IkReal x196=IKcos(j7);
IkReal x197=((1.0)*x196);
evalcond[0]=(((sj6*x195))+new_r21);
evalcond[1]=(x195+(((-1.0)*new_r10)));
evalcond[2]=(x196+(((-1.0)*new_r11)));
evalcond[3]=(((cj6*x195))+new_r01);
evalcond[4]=((((-1.0)*sj6*x197))+new_r20);
evalcond[5]=((((-1.0)*cj6*x197))+new_r00);
evalcond[6]=(x195+((cj6*new_r01))+((new_r21*sj6)));
evalcond[7]=(((new_r20*sj6))+(((-1.0)*x197))+((cj6*new_r00)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r11));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x198=IKsin(j7);
IkReal x199=IKcos(j7);
IkReal x200=((1.0)*cj6);
IkReal x201=((1.0)*x199);
evalcond[0]=(x198+new_r10);
evalcond[1]=(x199+new_r11);
evalcond[2]=(((sj6*x198))+new_r21);
evalcond[3]=((((-1.0)*sj6*x201))+new_r20);
evalcond[4]=(((cj6*x198))+(((-1.0)*new_r01)));
evalcond[5]=((((-1.0)*x199*x200))+(((-1.0)*new_r00)));
evalcond[6]=(x198+((new_r21*sj6))+(((-1.0)*new_r01*x200)));
evalcond[7]=((((-1.0)*new_r00*x200))+((new_r20*sj6))+(((-1.0)*x201)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
j7eval[0]=1.0;
if( IKabs(j7eval[0]) < 0.0000000100000000 )
{
continue; // no branches [j7]
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=-1.0;
op[1]=0;
op[2]=1.0;
polyroots2(op,zeror,numroots);
IkReal j7array[2], cj7array[2], sj7array[2], tempj7array[1];
int numsolutions = 0;
for(int ij7 = 0; ij7 < numroots; ++ij7)
{
IkReal htj7 = zeror[ij7];
tempj7array[0]=((2.0)*(atan(htj7)));
for(int kj7 = 0; kj7 < 1; ++kj7)
{
j7array[numsolutions] = tempj7array[kj7];
if( j7array[numsolutions] > IKPI )
{
j7array[numsolutions]-=IK2PI;
}
else if( j7array[numsolutions] < -IKPI )
{
j7array[numsolutions]+=IK2PI;
}
sj7array[numsolutions] = IKsin(j7array[numsolutions]);
cj7array[numsolutions] = IKcos(j7array[numsolutions]);
numsolutions++;
}
}
bool j7valid[2]={true,true};
_nj7 = 2;
for(int ij7 = 0; ij7 < numsolutions; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
htj7 = IKtan(j7/2);
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < numsolutions; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j7]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x203=IKPowWithIntegerCheck(sj6,-1);
if(!x203.valid){
continue;
}
IkReal x202=x203.value;
CheckValue<IkReal> x204=IKPowWithIntegerCheck(sj5,-1);
if(!x204.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*x202)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x202*(x204.value)*((((cj5*cj6*new_r21))+(((-1.0)*new_r01*sj6)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*x202))+IKsqr((x202*(x204.value)*((((cj5*cj6*new_r21))+(((-1.0)*new_r01*sj6))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r21*x202), (x202*(x204.value)*((((cj5*cj6*new_r21))+(((-1.0)*new_r01*sj6))))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[12];
IkReal x205=IKsin(j7);
IkReal x206=IKcos(j7);
IkReal x207=(new_r10*sj5);
IkReal x208=((1.0)*cj5);
IkReal x209=(cj5*new_r01);
IkReal x210=(cj5*cj6);
IkReal x211=(new_r11*sj5);
IkReal x212=(cj6*x205);
IkReal x213=(sj5*x206);
IkReal x214=((1.0)*x206);
evalcond[0]=(new_r21+((sj6*x205)));
evalcond[1]=((((-1.0)*sj6*x214))+new_r20);
evalcond[2]=(((new_r00*sj5))+x205+(((-1.0)*new_r10*x208)));
evalcond[3]=(((new_r01*sj5))+x206+(((-1.0)*new_r11*x208)));
evalcond[4]=(x211+x212+x209);
evalcond[5]=(((x205*x210))+x213+new_r01);
evalcond[6]=((((-1.0)*cj6*x214))+((cj5*new_r00))+x207);
evalcond[7]=((((-1.0)*cj6*x206*x208))+new_r00+((sj5*x205)));
evalcond[8]=(((sj5*x212))+(((-1.0)*x206*x208))+new_r11);
evalcond[9]=((((-1.0)*cj6*x213))+(((-1.0)*x205*x208))+new_r10);
evalcond[10]=(((cj6*x209))+((cj6*x211))+x205+((new_r21*sj6)));
evalcond[11]=(((cj6*x207))+((new_r20*sj6))+((new_r00*x210))+(((-1.0)*x214)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x215=IKPowWithIntegerCheck(sj6,-1);
if(!x215.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*(x215.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r01*sj5))+((cj5*new_r11)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*(x215.value)))+IKsqr(((((-1.0)*new_r01*sj5))+((cj5*new_r11))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r21*(x215.value)), ((((-1.0)*new_r01*sj5))+((cj5*new_r11))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[12];
IkReal x216=IKsin(j7);
IkReal x217=IKcos(j7);
IkReal x218=(new_r10*sj5);
IkReal x219=((1.0)*cj5);
IkReal x220=(cj5*new_r01);
IkReal x221=(cj5*cj6);
IkReal x222=(new_r11*sj5);
IkReal x223=(cj6*x216);
IkReal x224=(sj5*x217);
IkReal x225=((1.0)*x217);
evalcond[0]=(((sj6*x216))+new_r21);
evalcond[1]=(new_r20+(((-1.0)*sj6*x225)));
evalcond[2]=(((new_r00*sj5))+(((-1.0)*new_r10*x219))+x216);
evalcond[3]=((((-1.0)*new_r11*x219))+((new_r01*sj5))+x217);
evalcond[4]=(x220+x223+x222);
evalcond[5]=(((x216*x221))+x224+new_r01);
evalcond[6]=(((cj5*new_r00))+x218+(((-1.0)*cj6*x225)));
evalcond[7]=(((sj5*x216))+(((-1.0)*cj6*x217*x219))+new_r00);
evalcond[8]=((((-1.0)*x217*x219))+((sj5*x223))+new_r11);
evalcond[9]=((((-1.0)*cj6*x224))+new_r10+(((-1.0)*x216*x219)));
evalcond[10]=(((cj6*x222))+((cj6*x220))+x216+((new_r21*sj6)));
evalcond[11]=(((new_r00*x221))+((new_r20*sj6))+((cj6*x218))+(((-1.0)*x225)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x226=IKPowWithIntegerCheck(IKsign(sj6),-1);
if(!x226.valid){
continue;
}
CheckValue<IkReal> x227 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),IkReal(new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x227.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x226.value)))+(x227.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[12];
IkReal x228=IKsin(j7);
IkReal x229=IKcos(j7);
IkReal x230=(new_r10*sj5);
IkReal x231=((1.0)*cj5);
IkReal x232=(cj5*new_r01);
IkReal x233=(cj5*cj6);
IkReal x234=(new_r11*sj5);
IkReal x235=(cj6*x228);
IkReal x236=(sj5*x229);
IkReal x237=((1.0)*x229);
evalcond[0]=(((sj6*x228))+new_r21);
evalcond[1]=((((-1.0)*sj6*x237))+new_r20);
evalcond[2]=(((new_r00*sj5))+x228+(((-1.0)*new_r10*x231)));
evalcond[3]=(((new_r01*sj5))+x229+(((-1.0)*new_r11*x231)));
evalcond[4]=(x232+x234+x235);
evalcond[5]=(((x228*x233))+x236+new_r01);
evalcond[6]=(((cj5*new_r00))+x230+(((-1.0)*cj6*x237)));
evalcond[7]=(((sj5*x228))+new_r00+(((-1.0)*cj6*x229*x231)));
evalcond[8]=(new_r11+(((-1.0)*x229*x231))+((sj5*x235)));
evalcond[9]=(new_r10+(((-1.0)*x228*x231))+(((-1.0)*cj6*x236)));
evalcond[10]=(((cj6*x232))+((cj6*x234))+x228+((new_r21*sj6)));
evalcond[11]=(((cj6*x230))+((new_r20*sj6))+((new_r00*x233))+(((-1.0)*x237)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x238=IKPowWithIntegerCheck(IKsign(sj6),-1);
if(!x238.valid){
continue;
}
CheckValue<IkReal> x239 = IKatan2WithCheck(IkReal(((-1.0)*new_r12)),IkReal(((-1.0)*new_r02)),IKFAST_ATAN2_MAGTHRESH);
if(!x239.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x238.value)))+(x239.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x240=IKcos(j5);
IkReal x241=IKsin(j5);
IkReal x242=(sj6*x241);
IkReal x243=(new_r12*x241);
IkReal x244=(new_r02*x240);
IkReal x245=(sj6*x240);
evalcond[0]=(x245+new_r02);
evalcond[1]=(x242+new_r12);
evalcond[2]=(((new_r12*x240))+(((-1.0)*new_r02*x241)));
evalcond[3]=(sj6+x243+x244);
evalcond[4]=(((new_r22*sj6))+((cj6*x243))+((cj6*x244)));
evalcond[5]=((((-1.0)*new_r00*x245))+(((-1.0)*new_r10*x242))+((cj6*new_r20)));
evalcond[6]=((((-1.0)*new_r01*x245))+(((-1.0)*new_r11*x242))+((cj6*new_r21)));
evalcond[7]=((-1.0)+(((-1.0)*sj6*x244))+(((-1.0)*new_r12*x242))+((cj6*new_r22)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j7eval[3];
j7eval[0]=sj6;
j7eval[1]=IKsign(sj6);
j7eval[2]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(j7eval[0]) < 0.0000010000000000 || IKabs(j7eval[1]) < 0.0000010000000000 || IKabs(j7eval[2]) < 0.0000010000000000 )
{
{
IkReal j7eval[1];
j7eval[0]=sj6;
if( IKabs(j7eval[0]) < 0.0000010000000000 )
{
{
IkReal j7eval[2];
j7eval[0]=sj6;
j7eval[1]=sj5;
if( IKabs(j7eval[0]) < 0.0000010000000000 || IKabs(j7eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j6))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x246=((1.0)*new_r01);
if( IKabs(((((-1.0)*cj5*x246))+(((-1.0)*new_r00*sj5)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((cj5*new_r00))+(((-1.0)*sj5*x246)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*cj5*x246))+(((-1.0)*new_r00*sj5))))+IKsqr((((cj5*new_r00))+(((-1.0)*sj5*x246))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((((-1.0)*cj5*x246))+(((-1.0)*new_r00*sj5))), (((cj5*new_r00))+(((-1.0)*sj5*x246))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x247=IKsin(j7);
IkReal x248=IKcos(j7);
IkReal x249=((1.0)*cj5);
IkReal x250=(sj5*x247);
IkReal x251=((1.0)*x248);
IkReal x252=(x248*x249);
evalcond[0]=(((new_r11*sj5))+((cj5*new_r01))+x247);
evalcond[1]=(((new_r00*sj5))+x247+(((-1.0)*new_r10*x249)));
evalcond[2]=(((new_r01*sj5))+x248+(((-1.0)*new_r11*x249)));
evalcond[3]=(((sj5*x248))+((cj5*x247))+new_r01);
evalcond[4]=(((new_r10*sj5))+((cj5*new_r00))+(((-1.0)*x251)));
evalcond[5]=(x250+new_r00+(((-1.0)*x252)));
evalcond[6]=(x250+new_r11+(((-1.0)*x252)));
evalcond[7]=((((-1.0)*sj5*x251))+new_r10+(((-1.0)*x247*x249)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j6)))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
IkReal x253=((1.0)*new_r00);
if( IKabs((((cj5*new_r01))+(((-1.0)*sj5*x253)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*cj5*x253))+(((-1.0)*new_r01*sj5)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((cj5*new_r01))+(((-1.0)*sj5*x253))))+IKsqr(((((-1.0)*cj5*x253))+(((-1.0)*new_r01*sj5))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2((((cj5*new_r01))+(((-1.0)*sj5*x253))), ((((-1.0)*cj5*x253))+(((-1.0)*new_r01*sj5))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x254=IKcos(j7);
IkReal x255=IKsin(j7);
IkReal x256=((1.0)*cj5);
IkReal x257=(sj5*x254);
IkReal x258=(cj5*x254);
IkReal x259=((1.0)*x255);
IkReal x260=(x255*x256);
evalcond[0]=(((new_r10*sj5))+((cj5*new_r00))+x254);
evalcond[1]=((((-1.0)*new_r10*x256))+((new_r00*sj5))+x255);
evalcond[2]=((((-1.0)*new_r11*x256))+((new_r01*sj5))+x254);
evalcond[3]=(((new_r11*sj5))+((cj5*new_r01))+(((-1.0)*x259)));
evalcond[4]=(x258+((sj5*x255))+new_r00);
evalcond[5]=(x257+new_r01+(((-1.0)*x260)));
evalcond[6]=(x257+new_r10+(((-1.0)*x260)));
evalcond[7]=((((-1.0)*x254*x256))+(((-1.0)*sj5*x259))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(new_r10, new_r11);
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x261=IKsin(j7);
IkReal x262=IKcos(j7);
IkReal x263=((1.0)*x262);
evalcond[0]=(((sj6*x261))+new_r21);
evalcond[1]=(x261+(((-1.0)*new_r10)));
evalcond[2]=(x262+(((-1.0)*new_r11)));
evalcond[3]=(((cj6*x261))+new_r01);
evalcond[4]=((((-1.0)*sj6*x263))+new_r20);
evalcond[5]=((((-1.0)*cj6*x263))+new_r00);
evalcond[6]=(x261+((cj6*new_r01))+((new_r21*sj6)));
evalcond[7]=(((new_r20*sj6))+((cj6*new_r00))+(((-1.0)*x263)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r11));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[8];
IkReal x264=IKsin(j7);
IkReal x265=IKcos(j7);
IkReal x266=((1.0)*cj6);
IkReal x267=((1.0)*x265);
evalcond[0]=(x264+new_r10);
evalcond[1]=(x265+new_r11);
evalcond[2]=(((sj6*x264))+new_r21);
evalcond[3]=((((-1.0)*sj6*x267))+new_r20);
evalcond[4]=(((cj6*x264))+(((-1.0)*new_r01)));
evalcond[5]=((((-1.0)*new_r00))+(((-1.0)*x265*x266)));
evalcond[6]=((((-1.0)*new_r01*x266))+x264+((new_r21*sj6)));
evalcond[7]=(((new_r20*sj6))+(((-1.0)*new_r00*x266))+(((-1.0)*x267)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j7eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
j7eval[0]=1.0;
if( IKabs(j7eval[0]) < 0.0000000100000000 )
{
continue; // no branches [j7]
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=-1.0;
op[1]=0;
op[2]=1.0;
polyroots2(op,zeror,numroots);
IkReal j7array[2], cj7array[2], sj7array[2], tempj7array[1];
int numsolutions = 0;
for(int ij7 = 0; ij7 < numroots; ++ij7)
{
IkReal htj7 = zeror[ij7];
tempj7array[0]=((2.0)*(atan(htj7)));
for(int kj7 = 0; kj7 < 1; ++kj7)
{
j7array[numsolutions] = tempj7array[kj7];
if( j7array[numsolutions] > IKPI )
{
j7array[numsolutions]-=IK2PI;
}
else if( j7array[numsolutions] < -IKPI )
{
j7array[numsolutions]+=IK2PI;
}
sj7array[numsolutions] = IKsin(j7array[numsolutions]);
cj7array[numsolutions] = IKcos(j7array[numsolutions]);
numsolutions++;
}
}
bool j7valid[2]={true,true};
_nj7 = 2;
for(int ij7 = 0; ij7 < numsolutions; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
htj7 = IKtan(j7/2);
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < numsolutions; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j7]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x269=IKPowWithIntegerCheck(sj6,-1);
if(!x269.valid){
continue;
}
IkReal x268=x269.value;
CheckValue<IkReal> x270=IKPowWithIntegerCheck(sj5,-1);
if(!x270.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*x268)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x268*(x270.value)*((((cj5*cj6*new_r21))+(((-1.0)*new_r01*sj6)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*x268))+IKsqr((x268*(x270.value)*((((cj5*cj6*new_r21))+(((-1.0)*new_r01*sj6))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r21*x268), (x268*(x270.value)*((((cj5*cj6*new_r21))+(((-1.0)*new_r01*sj6))))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[12];
IkReal x271=IKsin(j7);
IkReal x272=IKcos(j7);
IkReal x273=(new_r10*sj5);
IkReal x274=((1.0)*cj5);
IkReal x275=(cj5*new_r01);
IkReal x276=(cj5*cj6);
IkReal x277=(new_r11*sj5);
IkReal x278=(cj6*x271);
IkReal x279=(sj5*x272);
IkReal x280=((1.0)*x272);
evalcond[0]=(((sj6*x271))+new_r21);
evalcond[1]=((((-1.0)*sj6*x280))+new_r20);
evalcond[2]=(((new_r00*sj5))+x271+(((-1.0)*new_r10*x274)));
evalcond[3]=(((new_r01*sj5))+x272+(((-1.0)*new_r11*x274)));
evalcond[4]=(x277+x275+x278);
evalcond[5]=(((x271*x276))+x279+new_r01);
evalcond[6]=(((cj5*new_r00))+(((-1.0)*cj6*x280))+x273);
evalcond[7]=(((sj5*x271))+(((-1.0)*cj6*x272*x274))+new_r00);
evalcond[8]=((((-1.0)*x272*x274))+((sj5*x278))+new_r11);
evalcond[9]=((((-1.0)*cj6*x279))+(((-1.0)*x271*x274))+new_r10);
evalcond[10]=(x271+((new_r21*sj6))+((cj6*x277))+((cj6*x275)));
evalcond[11]=(((new_r20*sj6))+((new_r00*x276))+(((-1.0)*x280))+((cj6*x273)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x281=IKPowWithIntegerCheck(sj6,-1);
if(!x281.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*(x281.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r01*sj5))+((cj5*new_r11)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*(x281.value)))+IKsqr(((((-1.0)*new_r01*sj5))+((cj5*new_r11))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j7array[0]=IKatan2(((-1.0)*new_r21*(x281.value)), ((((-1.0)*new_r01*sj5))+((cj5*new_r11))));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[12];
IkReal x282=IKsin(j7);
IkReal x283=IKcos(j7);
IkReal x284=(new_r10*sj5);
IkReal x285=((1.0)*cj5);
IkReal x286=(cj5*new_r01);
IkReal x287=(cj5*cj6);
IkReal x288=(new_r11*sj5);
IkReal x289=(cj6*x282);
IkReal x290=(sj5*x283);
IkReal x291=((1.0)*x283);
evalcond[0]=(((sj6*x282))+new_r21);
evalcond[1]=((((-1.0)*sj6*x291))+new_r20);
evalcond[2]=(((new_r00*sj5))+x282+(((-1.0)*new_r10*x285)));
evalcond[3]=(((new_r01*sj5))+x283+(((-1.0)*new_r11*x285)));
evalcond[4]=(x289+x288+x286);
evalcond[5]=(x290+new_r01+((x282*x287)));
evalcond[6]=(((cj5*new_r00))+x284+(((-1.0)*cj6*x291)));
evalcond[7]=((((-1.0)*cj6*x283*x285))+((sj5*x282))+new_r00);
evalcond[8]=(((sj5*x289))+new_r11+(((-1.0)*x283*x285)));
evalcond[9]=((((-1.0)*cj6*x290))+(((-1.0)*x282*x285))+new_r10);
evalcond[10]=(x282+((cj6*x288))+((cj6*x286))+((new_r21*sj6)));
evalcond[11]=(((new_r20*sj6))+(((-1.0)*x291))+((cj6*x284))+((new_r00*x287)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x292=IKPowWithIntegerCheck(IKsign(sj6),-1);
if(!x292.valid){
continue;
}
CheckValue<IkReal> x293 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),IkReal(new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x293.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x292.value)))+(x293.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[12];
IkReal x294=IKsin(j7);
IkReal x295=IKcos(j7);
IkReal x296=(new_r10*sj5);
IkReal x297=((1.0)*cj5);
IkReal x298=(cj5*new_r01);
IkReal x299=(cj5*cj6);
IkReal x300=(new_r11*sj5);
IkReal x301=(cj6*x294);
IkReal x302=(sj5*x295);
IkReal x303=((1.0)*x295);
evalcond[0]=(((sj6*x294))+new_r21);
evalcond[1]=((((-1.0)*sj6*x303))+new_r20);
evalcond[2]=((((-1.0)*new_r10*x297))+((new_r00*sj5))+x294);
evalcond[3]=((((-1.0)*new_r11*x297))+((new_r01*sj5))+x295);
evalcond[4]=(x300+x301+x298);
evalcond[5]=(x302+((x294*x299))+new_r01);
evalcond[6]=(((cj5*new_r00))+x296+(((-1.0)*cj6*x303)));
evalcond[7]=(((sj5*x294))+(((-1.0)*cj6*x295*x297))+new_r00);
evalcond[8]=(((sj5*x301))+(((-1.0)*x295*x297))+new_r11);
evalcond[9]=((((-1.0)*cj6*x302))+new_r10+(((-1.0)*x294*x297)));
evalcond[10]=(((cj6*x298))+((cj6*x300))+x294+((new_r21*sj6)));
evalcond[11]=(((new_r20*sj6))+((cj6*x296))+((new_r00*x299))+(((-1.0)*x303)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j7array[1], cj7array[1], sj7array[1];
bool j7valid[1]={false};
_nj7 = 1;
CheckValue<IkReal> x304=IKPowWithIntegerCheck(IKsign(sj6),-1);
if(!x304.valid){
continue;
}
CheckValue<IkReal> x305 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),IkReal(new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x305.valid){
continue;
}
j7array[0]=((-1.5707963267949)+(((1.5707963267949)*(x304.value)))+(x305.value));
sj7array[0]=IKsin(j7array[0]);
cj7array[0]=IKcos(j7array[0]);
if( j7array[0] > IKPI )
{
j7array[0]-=IK2PI;
}
else if( j7array[0] < -IKPI )
{ j7array[0]+=IK2PI;
}
j7valid[0] = true;
for(int ij7 = 0; ij7 < 1; ++ij7)
{
if( !j7valid[ij7] )
{
continue;
}
_ij7[0] = ij7; _ij7[1] = -1;
for(int iij7 = ij7+1; iij7 < 1; ++iij7)
{
if( j7valid[iij7] && IKabs(cj7array[ij7]-cj7array[iij7]) < IKFAST_SOLUTION_THRESH && IKabs(sj7array[ij7]-sj7array[iij7]) < IKFAST_SOLUTION_THRESH )
{
j7valid[iij7]=false; _ij7[1] = iij7; break;
}
}
j7 = j7array[ij7]; cj7 = cj7array[ij7]; sj7 = sj7array[ij7];
{
IkReal evalcond[2];
evalcond[0]=(((sj6*(IKsin(j7))))+new_r21);
evalcond[1]=((((-1.0)*sj6*(IKcos(j7))))+new_r20);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j5eval[3];
j5eval[0]=sj6;
j5eval[1]=((IKabs(new_r12))+(IKabs(new_r02)));
j5eval[2]=IKsign(sj6);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
j5eval[0]=new_r12;
j5eval[1]=sj6;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j6))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
sj6=0;
cj6=1.0;
j6=0;
IkReal x306=((1.0)*new_r11);
IkReal x307=((((-1.0)*new_r00*new_r01))+(((-1.0)*new_r10*x306)));
j5eval[0]=x307;
j5eval[1]=((IKabs((((new_r10*sj7))+((new_r01*sj7)))))+(IKabs(((((-1.0)*sj7*x306))+((new_r00*sj7))))));
j5eval[2]=IKsign(x307);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
sj6=0;
cj6=1.0;
j6=0;
IkReal x308=((((-1.0)*(new_r01*new_r01)))+(((-1.0)*(new_r11*new_r11))));
j5eval[0]=x308;
j5eval[1]=((IKabs((((new_r11*sj7))+((cj7*new_r01)))))+(IKabs((((new_r01*sj7))+(((-1.0)*cj7*new_r11))))));
j5eval[2]=IKsign(x308);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
sj6=0;
cj6=1.0;
j6=0;
IkReal x309=((1.0)*new_r11);
IkReal x310=((((-1.0)*new_r01*sj7))+(((-1.0)*cj7*x309)));
j5eval[0]=x310;
j5eval[1]=IKsign(x310);
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(cj7*cj7)))+(((-1.0)*new_r00*x309)))))+(IKabs((((new_r00*new_r01))+((cj7*sj7))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
IkReal x311=((-1.0)*new_r01);
IkReal x313 = ((new_r01*new_r01)+(new_r11*new_r11));
if(IKabs(x313)==0){
continue;
}
IkReal x312=pow(x313,-0.5);
CheckValue<IkReal> x314 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x311),IKFAST_ATAN2_MAGTHRESH);
if(!x314.valid){
continue;
}
IkReal gconst0=((-1.0)*(x314.value));
IkReal gconst1=(new_r11*x312);
IkReal gconst2=(x311*x312);
CheckValue<IkReal> x315 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x315.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((x315.value)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x316=((-1.0)*new_r01);
CheckValue<IkReal> x319 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x316),IKFAST_ATAN2_MAGTHRESH);
if(!x319.valid){
continue;
}
IkReal x317=((-1.0)*(x319.value));
IkReal x318=x312;
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x317;
IkReal gconst0=x317;
IkReal gconst1=(new_r11*x318);
IkReal gconst2=(x316*x318);
IkReal x320=new_r11*new_r11;
IkReal x321=(new_r10*new_r11);
IkReal x322=((((-1.0)*x321))+(((-1.0)*new_r00*new_r01)));
IkReal x323=x312;
IkReal x324=(new_r11*x323);
j5eval[0]=x322;
j5eval[1]=((IKabs((((new_r00*x324))+(((-1.0)*x320*x323)))))+(IKabs((((new_r01*x324))+((x321*x323))))));
j5eval[2]=IKsign(x322);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x325=((-1.0)*new_r01);
CheckValue<IkReal> x328 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x325),IKFAST_ATAN2_MAGTHRESH);
if(!x328.valid){
continue;
}
IkReal x326=((-1.0)*(x328.value));
IkReal x327=x312;
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x326;
IkReal gconst0=x326;
IkReal gconst1=(new_r11*x327);
IkReal gconst2=(x325*x327);
IkReal x329=new_r11*new_r11;
CheckValue<IkReal> x332=IKPowWithIntegerCheck(((new_r01*new_r01)+x329),-1);
if(!x332.valid){
continue;
}
IkReal x330=x332.value;
IkReal x331=(x329*x330);
j5eval[0]=((IKabs((((new_r00*new_r01*x331))+((new_r01*new_r11*x330))+((new_r00*x330*(new_r01*new_r01*new_r01))))))+(IKabs((((new_r01*new_r10))+x331))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x333=((-1.0)*new_r01);
CheckValue<IkReal> x336 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x333),IKFAST_ATAN2_MAGTHRESH);
if(!x336.valid){
continue;
}
IkReal x334=((-1.0)*(x336.value));
IkReal x335=x312;
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x334;
IkReal gconst0=x334;
IkReal gconst1=(new_r11*x335);
IkReal gconst2=(x333*x335);
IkReal x337=new_r01*new_r01;
IkReal x338=new_r11*new_r11;
CheckValue<IkReal> x345=IKPowWithIntegerCheck((x338+x337),-1);
if(!x345.valid){
continue;
}
IkReal x339=x345.value;
IkReal x340=(x338*x339);
CheckValue<IkReal> x346=IKPowWithIntegerCheck(((((-1.0)*x337))+(((-1.0)*x338))),-1);
if(!x346.valid){
continue;
}
IkReal x341=x346.value;
IkReal x342=((1.0)*x341);
IkReal x343=(new_r11*x342);
IkReal x344=(new_r01*x342);
j5eval[0]=((IKabs(((((-1.0)*x343*(new_r01*new_r01*new_r01)))+(((-1.0)*new_r01*x343*(new_r11*new_r11)))+(((-1.0)*new_r01*x343)))))+(IKabs((((x337*x340))+((x339*(x337*x337)))+(((-1.0)*x340))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[2];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x347=IKPowWithIntegerCheck(gconst2,-1);
if(!x347.valid){
continue;
}
sj5array[0]=(new_r10*(x347.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x348=IKcos(j5);
IkReal x349=IKsin(j5);
IkReal x350=((-1.0)*x348);
evalcond[0]=(new_r01*x348);
evalcond[1]=(new_r10*x350);
evalcond[2]=(gconst2*x350);
evalcond[3]=(gconst2+((new_r01*x349)));
evalcond[4]=(new_r01+((gconst2*x349)));
evalcond[5]=(((new_r10*x349))+(((-1.0)*gconst2)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
evalcond[1]=gconst1;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x351=((-1.0)*new_r01);
CheckValue<IkReal> x353 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x351),IKFAST_ATAN2_MAGTHRESH);
if(!x353.valid){
continue;
}
IkReal x352=((-1.0)*(x353.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x352;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst0=x352;
IkReal gconst1=new_r11;
IkReal gconst2=x351;
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs((new_r01*new_r11)))+(IKabs(((1.0)+(((-1.0)*(new_r01*new_r01)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x354=((-1.0)*new_r01);
CheckValue<IkReal> x356 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x354),IKFAST_ATAN2_MAGTHRESH);
if(!x356.valid){
continue;
}
IkReal x355=((-1.0)*(x356.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x355;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst0=x355;
IkReal gconst1=new_r11;
IkReal gconst2=x354;
j5eval[0]=-1.0;
j5eval[1]=((IKabs(new_r01*new_r01))+(IKabs((new_r01*new_r11))));
j5eval[2]=-1.0;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x357=((-1.0)*new_r01);
CheckValue<IkReal> x359 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(x357),IKFAST_ATAN2_MAGTHRESH);
if(!x359.valid){
continue;
}
IkReal x358=((-1.0)*(x359.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x358;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst0=x358;
IkReal gconst1=new_r11;
IkReal gconst2=x357;
j5eval[0]=1.0;
j5eval[1]=1.0;
j5eval[2]=((((0.5)*(IKabs(((-1.0)+(((2.0)*(new_r01*new_r01))))))))+(IKabs((new_r01*new_r11))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x360=((1.0)*new_r01);
CheckValue<IkReal> x361 = IKatan2WithCheck(IkReal(((new_r01*new_r01)+(((-1.0)*(gconst1*gconst1))))),IkReal(((((-1.0)*new_r11*x360))+((gconst1*gconst2)))),IKFAST_ATAN2_MAGTHRESH);
if(!x361.valid){
continue;
}
CheckValue<IkReal> x362=IKPowWithIntegerCheck(IKsign((((gconst1*new_r11))+(((-1.0)*gconst2*x360)))),-1);
if(!x362.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x361.value)+(((1.5707963267949)*(x362.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x363=IKsin(j5);
IkReal x364=IKcos(j5);
IkReal x365=(gconst1*x363);
IkReal x366=(gconst1*x364);
IkReal x367=(gconst2*x363);
IkReal x368=((1.0)*x364);
IkReal x369=(gconst2*x368);
evalcond[0]=(gconst1+((new_r01*x364))+((new_r11*x363)));
evalcond[1]=(x366+x367+new_r01);
evalcond[2]=((((-1.0)*x369))+x365);
evalcond[3]=(gconst2+((new_r01*x363))+(((-1.0)*new_r11*x368)));
evalcond[4]=((((-1.0)*x369))+x365+new_r11);
evalcond[5]=((((-1.0)*x366))+(((-1.0)*x367)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x370=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst2*gconst2)))+(((-1.0)*(gconst1*gconst1))))),-1);
if(!x370.valid){
continue;
}
CheckValue<IkReal> x371 = IKatan2WithCheck(IkReal((gconst2*new_r01)),IkReal((gconst1*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x371.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x370.value)))+(x371.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x372=IKsin(j5);
IkReal x373=IKcos(j5);
IkReal x374=(gconst1*x372);
IkReal x375=(gconst1*x373);
IkReal x376=(gconst2*x372);
IkReal x377=((1.0)*x373);
IkReal x378=(gconst2*x377);
evalcond[0]=(gconst1+((new_r01*x373))+((new_r11*x372)));
evalcond[1]=(x376+x375+new_r01);
evalcond[2]=((((-1.0)*x378))+x374);
evalcond[3]=(gconst2+((new_r01*x372))+(((-1.0)*new_r11*x377)));
evalcond[4]=((((-1.0)*x378))+x374+new_r11);
evalcond[5]=((((-1.0)*x376))+(((-1.0)*x375)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x379 = IKatan2WithCheck(IkReal(gconst1*gconst1),IkReal(((-1.0)*gconst1*gconst2)),IKFAST_ATAN2_MAGTHRESH);
if(!x379.valid){
continue;
}
CheckValue<IkReal> x380=IKPowWithIntegerCheck(IKsign((((gconst2*new_r01))+(((-1.0)*gconst1*new_r11)))),-1);
if(!x380.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x379.value)+(((1.5707963267949)*(x380.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x381=IKsin(j5);
IkReal x382=IKcos(j5);
IkReal x383=(gconst1*x381);
IkReal x384=(gconst1*x382);
IkReal x385=(gconst2*x381);
IkReal x386=((1.0)*x382);
IkReal x387=(gconst2*x386);
evalcond[0]=(((new_r01*x382))+gconst1+((new_r11*x381)));
evalcond[1]=(x384+x385+new_r01);
evalcond[2]=(x383+(((-1.0)*x387)));
evalcond[3]=(((new_r01*x381))+(((-1.0)*new_r11*x386))+gconst2);
evalcond[4]=(x383+(((-1.0)*x387))+new_r11);
evalcond[5]=((((-1.0)*x385))+(((-1.0)*x384)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x389 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x389.valid){
continue;
}
IkReal x388=((-1.0)*(x389.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x388;
new_r01=0;
new_r10=0;
IkReal gconst0=x388;
IkReal x390 = new_r11*new_r11;
if(IKabs(x390)==0){
continue;
}
IkReal gconst1=(new_r11*(pow(x390,-0.5)));
IkReal gconst2=0;
j5eval[0]=new_r00;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x392 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x392.valid){
continue;
}
IkReal x391=((-1.0)*(x392.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x391;
new_r01=0;
new_r10=0;
IkReal gconst0=x391;
IkReal x393 = new_r11*new_r11;
if(IKabs(x393)==0){
continue;
}
IkReal gconst1=(new_r11*(pow(x393,-0.5)));
IkReal gconst2=0;
j5eval[0]=new_r11;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x394=IKPowWithIntegerCheck(gconst1,-1);
if(!x394.valid){
continue;
}
sj5array[0]=((-1.0)*new_r00*(x394.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x395=IKcos(j5);
IkReal x396=IKsin(j5);
evalcond[0]=(gconst1*x395);
evalcond[1]=(new_r00*x395);
evalcond[2]=((-1.0)*new_r11*x395);
evalcond[3]=(gconst1+((new_r00*x396)));
evalcond[4]=(((new_r11*x396))+gconst1);
evalcond[5]=(((gconst1*x396))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x397=IKPowWithIntegerCheck(new_r11,-1);
if(!x397.valid){
continue;
}
sj5array[0]=((-1.0)*gconst1*(x397.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x398=IKcos(j5);
IkReal x399=IKsin(j5);
IkReal x400=(gconst1*x399);
evalcond[0]=(gconst1*x398);
evalcond[1]=(new_r00*x398);
evalcond[2]=((-1.0)*new_r11*x398);
evalcond[3]=(gconst1+((new_r00*x399)));
evalcond[4]=(x400+new_r00);
evalcond[5]=(x400+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x401=IKPowWithIntegerCheck(new_r00,-1);
if(!x401.valid){
continue;
}
sj5array[0]=((-1.0)*gconst1*(x401.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x402=IKcos(j5);
IkReal x403=IKsin(j5);
IkReal x404=(gconst1*x403);
evalcond[0]=(gconst1*x402);
evalcond[1]=(new_r00*x402);
evalcond[2]=((-1.0)*new_r11*x402);
evalcond[3]=(gconst1+((new_r11*x403)));
evalcond[4]=(x404+new_r00);
evalcond[5]=(x404+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r11);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
IkReal x405=((-1.0)*new_r01);
CheckValue<IkReal> x407 = IKatan2WithCheck(IkReal(0),IkReal(x405),IKFAST_ATAN2_MAGTHRESH);
if(!x407.valid){
continue;
}
IkReal x406=((-1.0)*(x407.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x406;
new_r11=0;
IkReal gconst0=x406;
IkReal gconst1=0;
IkReal x408 = new_r01*new_r01;
if(IKabs(x408)==0){
continue;
}
IkReal gconst2=(x405*(pow(x408,-0.5)));
j5eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x409=((-1.0)*new_r01);
CheckValue<IkReal> x411 = IKatan2WithCheck(IkReal(0),IkReal(x409),IKFAST_ATAN2_MAGTHRESH);
if(!x411.valid){
continue;
}
IkReal x410=((-1.0)*(x411.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x410;
new_r11=0;
IkReal gconst0=x410;
IkReal gconst1=0;
IkReal x412 = new_r01*new_r01;
if(IKabs(x412)==0){
continue;
}
IkReal gconst2=(x409*(pow(x412,-0.5)));
j5eval[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x413=((-1.0)*new_r01);
CheckValue<IkReal> x415 = IKatan2WithCheck(IkReal(0),IkReal(x413),IKFAST_ATAN2_MAGTHRESH);
if(!x415.valid){
continue;
}
IkReal x414=((-1.0)*(x415.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst1;
cj7=gconst2;
j7=x414;
new_r11=0;
IkReal gconst0=x414;
IkReal gconst1=0;
IkReal x416 = new_r01*new_r01;
if(IKabs(x416)==0){
continue;
}
IkReal gconst2=(x413*(pow(x416,-0.5)));
j5eval[0]=new_r01;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x417=IKPowWithIntegerCheck(new_r01,-1);
if(!x417.valid){
continue;
}
CheckValue<IkReal> x418=IKPowWithIntegerCheck(gconst2,-1);
if(!x418.valid){
continue;
}
if( IKabs(((-1.0)*gconst2*(x417.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r00*(x418.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst2*(x417.value)))+IKsqr((new_r00*(x418.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst2*(x417.value)), (new_r00*(x418.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x419=IKcos(j5);
IkReal x420=IKsin(j5);
IkReal x421=((1.0)*gconst2);
evalcond[0]=(new_r01*x419);
evalcond[1]=((-1.0)*gconst2*x419);
evalcond[2]=(gconst2+((new_r01*x420)));
evalcond[3]=(((gconst2*x420))+new_r01);
evalcond[4]=((((-1.0)*x419*x421))+new_r00);
evalcond[5]=((((-1.0)*x420*x421))+new_r10);
evalcond[6]=((((-1.0)*new_r10*x419))+((new_r00*x420)));
evalcond[7]=((((-1.0)*x421))+((new_r10*x420))+((new_r00*x419)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x422 = IKatan2WithCheck(IkReal(((-1.0)*new_r01)),IkReal(new_r00),IKFAST_ATAN2_MAGTHRESH);
if(!x422.valid){
continue;
}
CheckValue<IkReal> x423=IKPowWithIntegerCheck(IKsign(gconst2),-1);
if(!x423.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x422.value)+(((1.5707963267949)*(x423.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x424=IKcos(j5);
IkReal x425=IKsin(j5);
IkReal x426=((1.0)*gconst2);
evalcond[0]=(new_r01*x424);
evalcond[1]=((-1.0)*gconst2*x424);
evalcond[2]=(gconst2+((new_r01*x425)));
evalcond[3]=(((gconst2*x425))+new_r01);
evalcond[4]=((((-1.0)*x424*x426))+new_r00);
evalcond[5]=((((-1.0)*x425*x426))+new_r10);
evalcond[6]=((((-1.0)*new_r10*x424))+((new_r00*x425)));
evalcond[7]=((((-1.0)*x426))+((new_r10*x425))+((new_r00*x424)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x427=IKPowWithIntegerCheck(IKsign(gconst2),-1);
if(!x427.valid){
continue;
}
CheckValue<IkReal> x428 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r00),IKFAST_ATAN2_MAGTHRESH);
if(!x428.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x427.value)))+(x428.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x429=IKcos(j5);
IkReal x430=IKsin(j5);
IkReal x431=((1.0)*gconst2);
evalcond[0]=(new_r01*x429);
evalcond[1]=((-1.0)*gconst2*x429);
evalcond[2]=(((new_r01*x430))+gconst2);
evalcond[3]=(((gconst2*x430))+new_r01);
evalcond[4]=((((-1.0)*x429*x431))+new_r00);
evalcond[5]=((((-1.0)*x430*x431))+new_r10);
evalcond[6]=(((new_r00*x430))+(((-1.0)*new_r10*x429)));
evalcond[7]=((((-1.0)*x431))+((new_r10*x430))+((new_r00*x429)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x432=((1.0)*new_r01);
CheckValue<IkReal> x433=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst2*x432))+((gconst1*new_r11)))),-1);
if(!x433.valid){
continue;
}
CheckValue<IkReal> x434 = IKatan2WithCheck(IkReal(((new_r01*new_r01)+(((-1.0)*(gconst1*gconst1))))),IkReal((((gconst1*gconst2))+(((-1.0)*new_r11*x432)))),IKFAST_ATAN2_MAGTHRESH);
if(!x434.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x433.value)))+(x434.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x435=IKsin(j5);
IkReal x436=IKcos(j5);
IkReal x437=((1.0)*gconst2);
IkReal x438=(gconst1*x435);
IkReal x439=(gconst1*x436);
IkReal x440=((1.0)*x436);
IkReal x441=(x436*x437);
evalcond[0]=(((new_r01*x436))+gconst1+((new_r11*x435)));
evalcond[1]=(((gconst2*x435))+x439+new_r01);
evalcond[2]=(((new_r00*x435))+gconst1+(((-1.0)*new_r10*x440)));
evalcond[3]=(((new_r01*x435))+gconst2+(((-1.0)*new_r11*x440)));
evalcond[4]=((((-1.0)*x441))+x438+new_r00);
evalcond[5]=((((-1.0)*x441))+x438+new_r11);
evalcond[6]=((((-1.0)*x437))+((new_r00*x436))+((new_r10*x435)));
evalcond[7]=((((-1.0)*x439))+(((-1.0)*x435*x437))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x442=((1.0)*gconst2);
CheckValue<IkReal> x443 = IKatan2WithCheck(IkReal(((gconst1*gconst1)+((new_r01*new_r10)))),IkReal((((new_r00*new_r01))+(((-1.0)*gconst1*x442)))),IKFAST_ATAN2_MAGTHRESH);
if(!x443.valid){
continue;
}
CheckValue<IkReal> x444=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst1*new_r00))+(((-1.0)*new_r10*x442)))),-1);
if(!x444.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x443.value)+(((1.5707963267949)*(x444.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x445=IKsin(j5);
IkReal x446=IKcos(j5);
IkReal x447=((1.0)*gconst2);
IkReal x448=(gconst1*x445);
IkReal x449=(gconst1*x446);
IkReal x450=((1.0)*x446);
IkReal x451=(x446*x447);
evalcond[0]=(((new_r01*x446))+gconst1+((new_r11*x445)));
evalcond[1]=(((gconst2*x445))+x449+new_r01);
evalcond[2]=(((new_r00*x445))+(((-1.0)*new_r10*x450))+gconst1);
evalcond[3]=(((new_r01*x445))+gconst2+(((-1.0)*new_r11*x450)));
evalcond[4]=((((-1.0)*x451))+x448+new_r00);
evalcond[5]=((((-1.0)*x451))+x448+new_r11);
evalcond[6]=(((new_r00*x446))+(((-1.0)*x447))+((new_r10*x445)));
evalcond[7]=((((-1.0)*x445*x447))+(((-1.0)*x449))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x452=((1.0)*new_r11);
CheckValue<IkReal> x453 = IKatan2WithCheck(IkReal((((gconst1*new_r10))+((gconst1*new_r01)))),IkReal((((gconst1*new_r00))+(((-1.0)*gconst1*x452)))),IKFAST_ATAN2_MAGTHRESH);
if(!x453.valid){
continue;
}
CheckValue<IkReal> x454=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r10*x452))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x454.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x453.value)+(((1.5707963267949)*(x454.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x455=IKsin(j5);
IkReal x456=IKcos(j5);
IkReal x457=((1.0)*gconst2);
IkReal x458=(gconst1*x455);
IkReal x459=(gconst1*x456);
IkReal x460=((1.0)*x456);
IkReal x461=(x456*x457);
evalcond[0]=(((new_r11*x455))+((new_r01*x456))+gconst1);
evalcond[1]=(x459+new_r01+((gconst2*x455)));
evalcond[2]=(((new_r00*x455))+gconst1+(((-1.0)*new_r10*x460)));
evalcond[3]=(((new_r01*x455))+(((-1.0)*new_r11*x460))+gconst2);
evalcond[4]=((((-1.0)*x461))+x458+new_r00);
evalcond[5]=((((-1.0)*x461))+x458+new_r11);
evalcond[6]=(((new_r10*x455))+((new_r00*x456))+(((-1.0)*x457)));
evalcond[7]=((((-1.0)*x459))+(((-1.0)*x455*x457))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x462=((-1.0)*new_r11);
IkReal x464 = ((new_r01*new_r01)+(new_r11*new_r11));
if(IKabs(x464)==0){
continue;
}
IkReal x463=pow(x464,-0.5);
CheckValue<IkReal> x465 = IKatan2WithCheck(IkReal(x462),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x465.valid){
continue;
}
IkReal gconst3=((3.14159265358979)+(((-1.0)*(x465.value))));
IkReal gconst4=(x462*x463);
IkReal gconst5=((1.0)*new_r01*x463);
CheckValue<IkReal> x466 = IKatan2WithCheck(IkReal(((-1.0)*new_r11)),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x466.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+(x466.value)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x467=((-1.0)*new_r11);
CheckValue<IkReal> x470 = IKatan2WithCheck(IkReal(x467),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x470.valid){
continue;
}
IkReal x468=((1.0)*(x470.value));
IkReal x469=x463;
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x468)));
IkReal gconst3=((3.14159265358979)+(((-1.0)*x468)));
IkReal gconst4=(x467*x469);
IkReal gconst5=((1.0)*new_r01*x469);
IkReal x471=new_r11*new_r11;
IkReal x472=((1.0)*new_r01);
IkReal x473=((1.0)*new_r10);
IkReal x474=((((-1.0)*new_r00*x472))+(((-1.0)*new_r11*x473)));
IkReal x475=x463;
IkReal x476=(new_r11*x475);
j5eval[0]=x474;
j5eval[1]=((IKabs((((x471*x475))+(((-1.0)*new_r00*x476)))))+(IKabs(((((-1.0)*x472*x476))+(((-1.0)*x473*x476))))));
j5eval[2]=IKsign(x474);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x477=((-1.0)*new_r11);
CheckValue<IkReal> x480 = IKatan2WithCheck(IkReal(x477),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x480.valid){
continue;
}
IkReal x478=((1.0)*(x480.value));
IkReal x479=x463;
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x478)));
IkReal gconst3=((3.14159265358979)+(((-1.0)*x478)));
IkReal gconst4=(x477*x479);
IkReal gconst5=((1.0)*new_r01*x479);
IkReal x481=new_r11*new_r11;
IkReal x482=new_r01*new_r01*new_r01;
CheckValue<IkReal> x486=IKPowWithIntegerCheck(((new_r01*new_r01)+x481),-1);
if(!x486.valid){
continue;
}
IkReal x483=x486.value;
IkReal x484=(x481*x483);
IkReal x485=(x482*x483);
j5eval[0]=((IKabs((((new_r10*x485))+((new_r01*new_r10*x484))+x484)))+(IKabs((((new_r01*new_r11*x483))+((new_r00*x485))+((new_r00*new_r01*x484))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x487=((-1.0)*new_r11);
CheckValue<IkReal> x490 = IKatan2WithCheck(IkReal(x487),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x490.valid){
continue;
}
IkReal x488=((1.0)*(x490.value));
IkReal x489=x463;
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x488)));
IkReal gconst3=((3.14159265358979)+(((-1.0)*x488)));
IkReal gconst4=(x487*x489);
IkReal gconst5=((1.0)*new_r01*x489);
IkReal x491=new_r01*new_r01;
IkReal x492=new_r11*new_r11;
CheckValue<IkReal> x499=IKPowWithIntegerCheck((x492+x491),-1);
if(!x499.valid){
continue;
}
IkReal x493=x499.value;
IkReal x494=(x492*x493);
CheckValue<IkReal> x500=IKPowWithIntegerCheck(((((-1.0)*x491))+(((-1.0)*x492))),-1);
if(!x500.valid){
continue;
}
IkReal x495=x500.value;
IkReal x496=((1.0)*x495);
IkReal x497=(new_r11*x496);
IkReal x498=(new_r01*x496);
j5eval[0]=((IKabs((((x493*(x491*x491)))+((x491*x494))+(((-1.0)*x494)))))+(IKabs(((((-1.0)*new_r01*x497))+(((-1.0)*new_r01*x497*(new_r11*new_r11)))+(((-1.0)*x497*(new_r01*new_r01*new_r01)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[2];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x501=IKPowWithIntegerCheck(gconst5,-1);
if(!x501.valid){
continue;
}
sj5array[0]=(new_r10*(x501.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x502=IKcos(j5);
IkReal x503=IKsin(j5);
IkReal x504=((-1.0)*x502);
evalcond[0]=(new_r01*x502);
evalcond[1]=(new_r10*x504);
evalcond[2]=(gconst5*x504);
evalcond[3]=(gconst5+((new_r01*x503)));
evalcond[4]=(((gconst5*x503))+new_r01);
evalcond[5]=((((-1.0)*gconst5))+((new_r10*x503)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
evalcond[1]=gconst4;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x505=((-1.0)*new_r11);
CheckValue<IkReal> x507 = IKatan2WithCheck(IkReal(x505),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x507.valid){
continue;
}
IkReal x506=((1.0)*(x507.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x506)));
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x506)));
IkReal gconst4=x505;
IkReal gconst5=((1.0)*new_r01);
j5eval[0]=1.0;
j5eval[1]=1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r01*new_r01))))))+(IKabs(((1.0)*new_r01*new_r11))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[4];
IkReal x508=((-1.0)*new_r11);
CheckValue<IkReal> x510 = IKatan2WithCheck(IkReal(x508),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x510.valid){
continue;
}
IkReal x509=((1.0)*(x510.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x509)));
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x509)));
IkReal gconst4=x508;
IkReal gconst5=((1.0)*new_r01);
j5eval[0]=-1.0;
j5eval[1]=new_r01;
j5eval[2]=1.0;
j5eval[3]=-1.0;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 || IKabs(j5eval[3]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x511=((-1.0)*new_r11);
CheckValue<IkReal> x513 = IKatan2WithCheck(IkReal(x511),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x513.valid){
continue;
}
IkReal x512=((1.0)*(x513.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x512)));
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x512)));
IkReal gconst4=x511;
IkReal gconst5=((1.0)*new_r01);
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((2.0)*new_r01*new_r11)))+(IKabs(((-1.0)+(((2.0)*(new_r01*new_r01)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x514=((1.0)*new_r01);
CheckValue<IkReal> x515 = IKatan2WithCheck(IkReal(((new_r01*new_r01)+(((-1.0)*(gconst4*gconst4))))),IkReal(((((-1.0)*new_r11*x514))+((gconst4*gconst5)))),IKFAST_ATAN2_MAGTHRESH);
if(!x515.valid){
continue;
}
CheckValue<IkReal> x516=IKPowWithIntegerCheck(IKsign((((gconst4*new_r11))+(((-1.0)*gconst5*x514)))),-1);
if(!x516.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x515.value)+(((1.5707963267949)*(x516.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x517=IKsin(j5);
IkReal x518=IKcos(j5);
IkReal x519=((1.0)*gconst5);
IkReal x520=(gconst4*x517);
IkReal x521=(gconst4*x518);
IkReal x522=(x518*x519);
evalcond[0]=(((new_r01*x518))+((new_r11*x517))+gconst4);
evalcond[1]=(x521+new_r01+((gconst5*x517)));
evalcond[2]=((((-1.0)*x522))+x520);
evalcond[3]=(((new_r01*x517))+gconst5+(((-1.0)*new_r11*x518)));
evalcond[4]=((((-1.0)*x522))+x520+new_r11);
evalcond[5]=((((-1.0)*x521))+(((-1.0)*x517*x519)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x523=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst4*gconst4)))+(((-1.0)*(gconst5*gconst5))))),-1);
if(!x523.valid){
continue;
}
CheckValue<IkReal> x524 = IKatan2WithCheck(IkReal((gconst5*new_r01)),IkReal((gconst4*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x524.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x523.value)))+(x524.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x525=IKsin(j5);
IkReal x526=IKcos(j5);
IkReal x527=((1.0)*gconst5);
IkReal x528=(gconst4*x525);
IkReal x529=(gconst4*x526);
IkReal x530=(x526*x527);
evalcond[0]=(((new_r01*x526))+gconst4+((new_r11*x525)));
evalcond[1]=(((gconst5*x525))+x529+new_r01);
evalcond[2]=((((-1.0)*x530))+x528);
evalcond[3]=(((new_r01*x525))+gconst5+(((-1.0)*new_r11*x526)));
evalcond[4]=((((-1.0)*x530))+x528+new_r11);
evalcond[5]=((((-1.0)*x525*x527))+(((-1.0)*x529)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x531=IKPowWithIntegerCheck(IKsign((((gconst5*new_r01))+(((-1.0)*gconst4*new_r11)))),-1);
if(!x531.valid){
continue;
}
CheckValue<IkReal> x532 = IKatan2WithCheck(IkReal(gconst4*gconst4),IkReal(((-1.0)*gconst4*gconst5)),IKFAST_ATAN2_MAGTHRESH);
if(!x532.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x531.value)))+(x532.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x533=IKsin(j5);
IkReal x534=IKcos(j5);
IkReal x535=((1.0)*gconst5);
IkReal x536=(gconst4*x533);
IkReal x537=(gconst4*x534);
IkReal x538=(x534*x535);
evalcond[0]=(((new_r01*x534))+gconst4+((new_r11*x533)));
evalcond[1]=(((gconst5*x533))+x537+new_r01);
evalcond[2]=((((-1.0)*x538))+x536);
evalcond[3]=(((new_r01*x533))+gconst5+(((-1.0)*new_r11*x534)));
evalcond[4]=((((-1.0)*x538))+x536+new_r11);
evalcond[5]=((((-1.0)*x533*x535))+(((-1.0)*x537)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
IkReal x539=((-1.0)*new_r11);
CheckValue<IkReal> x541 = IKatan2WithCheck(IkReal(x539),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x541.valid){
continue;
}
IkReal x540=((1.0)*(x541.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x540)));
new_r01=0;
new_r10=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x540)));
IkReal x542 = new_r11*new_r11;
if(IKabs(x542)==0){
continue;
}
IkReal gconst4=(x539*(pow(x542,-0.5)));
IkReal gconst5=0;
j5eval[0]=new_r00;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x543=((-1.0)*new_r11);
CheckValue<IkReal> x545 = IKatan2WithCheck(IkReal(x543),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x545.valid){
continue;
}
IkReal x544=((1.0)*(x545.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x544)));
new_r01=0;
new_r10=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x544)));
IkReal x546 = new_r11*new_r11;
if(IKabs(x546)==0){
continue;
}
IkReal gconst4=(x543*(pow(x546,-0.5)));
IkReal gconst5=0;
j5eval[0]=new_r11;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x547=IKPowWithIntegerCheck(gconst4,-1);
if(!x547.valid){
continue;
}
sj5array[0]=((-1.0)*new_r00*(x547.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x548=IKcos(j5);
IkReal x549=IKsin(j5);
evalcond[0]=(gconst4*x548);
evalcond[1]=(new_r00*x548);
evalcond[2]=((-1.0)*new_r11*x548);
evalcond[3]=(((new_r00*x549))+gconst4);
evalcond[4]=(gconst4+((new_r11*x549)));
evalcond[5]=(((gconst4*x549))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x550=IKPowWithIntegerCheck(new_r11,-1);
if(!x550.valid){
continue;
}
sj5array[0]=((-1.0)*gconst4*(x550.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x551=IKcos(j5);
IkReal x552=IKsin(j5);
IkReal x553=(gconst4*x552);
evalcond[0]=(gconst4*x551);
evalcond[1]=(new_r00*x551);
evalcond[2]=((-1.0)*new_r11*x551);
evalcond[3]=(gconst4+((new_r00*x552)));
evalcond[4]=(x553+new_r00);
evalcond[5]=(x553+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x554=IKPowWithIntegerCheck(new_r00,-1);
if(!x554.valid){
continue;
}
sj5array[0]=((-1.0)*gconst4*(x554.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x555=IKcos(j5);
IkReal x556=IKsin(j5);
IkReal x557=(gconst4*x556);
evalcond[0]=(gconst4*x555);
evalcond[1]=(new_r00*x555);
evalcond[2]=((-1.0)*new_r11*x555);
evalcond[3]=(((new_r11*x556))+gconst4);
evalcond[4]=(x557+new_r00);
evalcond[5]=(x557+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r11);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x559 = IKatan2WithCheck(IkReal(0),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x559.valid){
continue;
}
IkReal x558=((1.0)*(x559.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x558)));
new_r11=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x558)));
IkReal gconst4=0;
IkReal x560 = new_r01*new_r01;
if(IKabs(x560)==0){
continue;
}
IkReal gconst5=((1.0)*new_r01*(pow(x560,-0.5)));
j5eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x562 = IKatan2WithCheck(IkReal(0),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x562.valid){
continue;
}
IkReal x561=((1.0)*(x562.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x561)));
new_r11=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x561)));
IkReal gconst4=0;
IkReal x563 = new_r01*new_r01;
if(IKabs(x563)==0){
continue;
}
IkReal gconst5=((1.0)*new_r01*(pow(x563,-0.5)));
j5eval[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x565 = IKatan2WithCheck(IkReal(0),IkReal(((-1.0)*new_r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x565.valid){
continue;
}
IkReal x564=((1.0)*(x565.value));
sj6=0;
cj6=1.0;
j6=0;
sj7=gconst4;
cj7=gconst5;
j7=((3.14159265)+(((-1.0)*x564)));
new_r11=0;
IkReal gconst3=((3.14159265358979)+(((-1.0)*x564)));
IkReal gconst4=0;
IkReal x566 = new_r01*new_r01;
if(IKabs(x566)==0){
continue;
}
IkReal gconst5=((1.0)*new_r01*(pow(x566,-0.5)));
j5eval[0]=new_r01;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x567=IKPowWithIntegerCheck(new_r01,-1);
if(!x567.valid){
continue;
}
CheckValue<IkReal> x568=IKPowWithIntegerCheck(gconst5,-1);
if(!x568.valid){
continue;
}
if( IKabs(((-1.0)*gconst5*(x567.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r00*(x568.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst5*(x567.value)))+IKsqr((new_r00*(x568.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst5*(x567.value)), (new_r00*(x568.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x569=IKcos(j5);
IkReal x570=IKsin(j5);
IkReal x571=((1.0)*gconst5);
evalcond[0]=(new_r01*x569);
evalcond[1]=((-1.0)*gconst5*x569);
evalcond[2]=(((new_r01*x570))+gconst5);
evalcond[3]=(((gconst5*x570))+new_r01);
evalcond[4]=((((-1.0)*x569*x571))+new_r00);
evalcond[5]=((((-1.0)*x570*x571))+new_r10);
evalcond[6]=(((new_r00*x570))+(((-1.0)*new_r10*x569)));
evalcond[7]=(((new_r10*x570))+((new_r00*x569))+(((-1.0)*x571)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x572 = IKatan2WithCheck(IkReal(((-1.0)*new_r01)),IkReal(new_r00),IKFAST_ATAN2_MAGTHRESH);
if(!x572.valid){
continue;
}
CheckValue<IkReal> x573=IKPowWithIntegerCheck(IKsign(gconst5),-1);
if(!x573.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x572.value)+(((1.5707963267949)*(x573.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x574=IKcos(j5);
IkReal x575=IKsin(j5);
IkReal x576=((1.0)*gconst5);
evalcond[0]=(new_r01*x574);
evalcond[1]=((-1.0)*gconst5*x574);
evalcond[2]=(((new_r01*x575))+gconst5);
evalcond[3]=(((gconst5*x575))+new_r01);
evalcond[4]=((((-1.0)*x574*x576))+new_r00);
evalcond[5]=((((-1.0)*x575*x576))+new_r10);
evalcond[6]=(((new_r00*x575))+(((-1.0)*new_r10*x574)));
evalcond[7]=(((new_r00*x574))+((new_r10*x575))+(((-1.0)*x576)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x577 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r00),IKFAST_ATAN2_MAGTHRESH);
if(!x577.valid){
continue;
}
CheckValue<IkReal> x578=IKPowWithIntegerCheck(IKsign(gconst5),-1);
if(!x578.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x577.value)+(((1.5707963267949)*(x578.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x579=IKcos(j5);
IkReal x580=IKsin(j5);
IkReal x581=((1.0)*gconst5);
evalcond[0]=(new_r01*x579);
evalcond[1]=((-1.0)*gconst5*x579);
evalcond[2]=(gconst5+((new_r01*x580)));
evalcond[3]=(((gconst5*x580))+new_r01);
evalcond[4]=((((-1.0)*x579*x581))+new_r00);
evalcond[5]=((((-1.0)*x580*x581))+new_r10);
evalcond[6]=((((-1.0)*new_r10*x579))+((new_r00*x580)));
evalcond[7]=(((new_r00*x579))+(((-1.0)*x581))+((new_r10*x580)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x582=((1.0)*new_r01);
CheckValue<IkReal> x583 = IKatan2WithCheck(IkReal(((new_r01*new_r01)+(((-1.0)*(gconst4*gconst4))))),IkReal(((((-1.0)*new_r11*x582))+((gconst4*gconst5)))),IKFAST_ATAN2_MAGTHRESH);
if(!x583.valid){
continue;
}
CheckValue<IkReal> x584=IKPowWithIntegerCheck(IKsign((((gconst4*new_r11))+(((-1.0)*gconst5*x582)))),-1);
if(!x584.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x583.value)+(((1.5707963267949)*(x584.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x585=IKsin(j5);
IkReal x586=IKcos(j5);
IkReal x587=((1.0)*gconst5);
IkReal x588=(gconst4*x585);
IkReal x589=((1.0)*x586);
IkReal x590=(x586*x587);
evalcond[0]=(gconst4+((new_r01*x586))+((new_r11*x585)));
evalcond[1]=(((gconst5*x585))+((gconst4*x586))+new_r01);
evalcond[2]=(gconst4+((new_r00*x585))+(((-1.0)*new_r10*x589)));
evalcond[3]=(gconst5+(((-1.0)*new_r11*x589))+((new_r01*x585)));
evalcond[4]=((((-1.0)*x590))+x588+new_r00);
evalcond[5]=((((-1.0)*x590))+x588+new_r11);
evalcond[6]=(((new_r00*x586))+(((-1.0)*x587))+((new_r10*x585)));
evalcond[7]=((((-1.0)*gconst4*x589))+(((-1.0)*x585*x587))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x591=((1.0)*gconst4);
CheckValue<IkReal> x592 = IKatan2WithCheck(IkReal(((gconst4*gconst4)+((new_r01*new_r10)))),IkReal((((new_r00*new_r01))+(((-1.0)*gconst5*x591)))),IKFAST_ATAN2_MAGTHRESH);
if(!x592.valid){
continue;
}
CheckValue<IkReal> x593=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r00*x591))+(((-1.0)*gconst5*new_r10)))),-1);
if(!x593.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x592.value)+(((1.5707963267949)*(x593.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x594=IKsin(j5);
IkReal x595=IKcos(j5);
IkReal x596=((1.0)*gconst5);
IkReal x597=(gconst4*x594);
IkReal x598=((1.0)*x595);
IkReal x599=(x595*x596);
evalcond[0]=(((new_r11*x594))+gconst4+((new_r01*x595)));
evalcond[1]=(((gconst5*x594))+((gconst4*x595))+new_r01);
evalcond[2]=(gconst4+(((-1.0)*new_r10*x598))+((new_r00*x594)));
evalcond[3]=((((-1.0)*new_r11*x598))+gconst5+((new_r01*x594)));
evalcond[4]=((((-1.0)*x599))+x597+new_r00);
evalcond[5]=((((-1.0)*x599))+x597+new_r11);
evalcond[6]=(((new_r10*x594))+((new_r00*x595))+(((-1.0)*x596)));
evalcond[7]=((((-1.0)*gconst4*x598))+(((-1.0)*x594*x596))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x600=((1.0)*new_r11);
CheckValue<IkReal> x601 = IKatan2WithCheck(IkReal((((gconst4*new_r10))+((gconst4*new_r01)))),IkReal((((gconst4*new_r00))+(((-1.0)*gconst4*x600)))),IKFAST_ATAN2_MAGTHRESH);
if(!x601.valid){
continue;
}
CheckValue<IkReal> x602=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r10*x600))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x602.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x601.value)+(((1.5707963267949)*(x602.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x603=IKsin(j5);
IkReal x604=IKcos(j5);
IkReal x605=((1.0)*gconst5);
IkReal x606=(gconst4*x603);
IkReal x607=((1.0)*x604);
IkReal x608=(x604*x605);
evalcond[0]=(gconst4+((new_r11*x603))+((new_r01*x604)));
evalcond[1]=(((gconst5*x603))+((gconst4*x604))+new_r01);
evalcond[2]=((((-1.0)*new_r10*x607))+gconst4+((new_r00*x603)));
evalcond[3]=((((-1.0)*new_r11*x607))+gconst5+((new_r01*x603)));
evalcond[4]=(x606+(((-1.0)*x608))+new_r00);
evalcond[5]=(x606+(((-1.0)*x608))+new_r11);
evalcond[6]=(((new_r10*x603))+((new_r00*x604))+(((-1.0)*x605)));
evalcond[7]=((((-1.0)*x603*x605))+new_r10+(((-1.0)*gconst4*x607)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j7))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
if( IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r01))+IKsqr(new_r00)-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*new_r01), new_r00);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x609=IKsin(j5);
IkReal x610=IKcos(j5);
IkReal x611=((1.0)*x610);
evalcond[0]=(x609+new_r01);
evalcond[1]=((((-1.0)*x611))+new_r00);
evalcond[2]=((((-1.0)*x611))+new_r11);
evalcond[3]=((((-1.0)*x609))+new_r10);
evalcond[4]=(((new_r11*x609))+((new_r01*x610)));
evalcond[5]=((((-1.0)*new_r10*x611))+((new_r00*x609)));
evalcond[6]=((-1.0)+((new_r10*x609))+((new_r00*x610)));
evalcond[7]=((1.0)+(((-1.0)*new_r11*x611))+((new_r01*x609)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r00))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r00));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x612=IKcos(j5);
IkReal x613=IKsin(j5);
IkReal x614=((1.0)*x612);
evalcond[0]=(x612+new_r00);
evalcond[1]=(x612+new_r11);
evalcond[2]=(x613+new_r10);
evalcond[3]=((((-1.0)*x613))+new_r01);
evalcond[4]=(((new_r11*x613))+((new_r01*x612)));
evalcond[5]=((((-1.0)*new_r10*x614))+((new_r00*x613)));
evalcond[6]=((1.0)+((new_r10*x613))+((new_r00*x612)));
evalcond[7]=((-1.0)+(((-1.0)*new_r11*x614))+((new_r01*x613)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
sj6=0;
cj6=1.0;
j6=0;
new_r11=0;
new_r00=0;
j5eval[0]=new_r01;
j5eval[1]=IKsign(new_r01);
j5eval[2]=((IKabs(cj7))+(IKabs(sj7)));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
sj6=0;
cj6=1.0;
j6=0;
new_r11=0;
new_r00=0;
j5eval[0]=new_r01;
j5eval[1]=new_r10;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
sj6=0;
cj6=1.0;
j6=0;
new_r11=0;
new_r00=0;
j5eval[0]=new_r01;
j5eval[1]=sj7;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j7))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
sj5array[0]=new_r10;
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x615=IKcos(j5);
IkReal x616=IKsin(j5);
IkReal x617=((-1.0)*x615);
evalcond[0]=(new_r01*x615);
evalcond[1]=(x616+new_r01);
evalcond[2]=x617;
evalcond[3]=(new_r10*x617);
evalcond[4]=((1.0)+((new_r01*x616)));
evalcond[5]=((-1.0)+((new_r10*x616)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
sj5array[0]=new_r01;
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x618=IKcos(j5);
IkReal x619=IKsin(j5);
evalcond[0]=x618;
evalcond[1]=(new_r01*x618);
evalcond[2]=(x619+new_r10);
evalcond[3]=((-1.0)*new_r10*x618);
evalcond[4]=((-1.0)+((new_r01*x619)));
evalcond[5]=((1.0)+((new_r10*x619)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x621=IKPowWithIntegerCheck(new_r01,-1);
if(!x621.valid){
continue;
}
IkReal x620=x621.value;
CheckValue<IkReal> x622=IKPowWithIntegerCheck(sj7,-1);
if(!x622.valid){
continue;
}
CheckValue<IkReal> x623=IKPowWithIntegerCheck(x620,-2);
if(!x623.valid){
continue;
}
if( IKabs(((-1.0)*cj7*x620)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x620*(x622.value)*(((cj7*cj7)+(((-1.0)*(x623.value))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*cj7*x620))+IKsqr((x620*(x622.value)*(((cj7*cj7)+(((-1.0)*(x623.value)))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*cj7*x620), (x620*(x622.value)*(((cj7*cj7)+(((-1.0)*(x623.value)))))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x624=IKcos(j5);
IkReal x625=IKsin(j5);
IkReal x626=(cj7*x625);
IkReal x627=((1.0)*x624);
evalcond[0]=(cj7+((new_r01*x625)));
evalcond[1]=(sj7+((new_r01*x624)));
evalcond[2]=(sj7+(((-1.0)*new_r10*x627)));
evalcond[3]=(((new_r10*x625))+(((-1.0)*cj7)));
evalcond[4]=(((sj7*x624))+x626+new_r01);
evalcond[5]=(((sj7*x625))+(((-1.0)*cj7*x627)));
evalcond[6]=((((-1.0)*sj7*x627))+(((-1.0)*x626))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x628=IKPowWithIntegerCheck(new_r01,-1);
if(!x628.valid){
continue;
}
CheckValue<IkReal> x629=IKPowWithIntegerCheck(new_r10,-1);
if(!x629.valid){
continue;
}
if( IKabs(((-1.0)*cj7*(x628.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((sj7*(x629.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*cj7*(x628.value)))+IKsqr((sj7*(x629.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*cj7*(x628.value)), (sj7*(x629.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x630=IKcos(j5);
IkReal x631=IKsin(j5);
IkReal x632=(cj7*x631);
IkReal x633=((1.0)*x630);
evalcond[0]=(cj7+((new_r01*x631)));
evalcond[1]=(sj7+((new_r01*x630)));
evalcond[2]=(sj7+(((-1.0)*new_r10*x633)));
evalcond[3]=(((new_r10*x631))+(((-1.0)*cj7)));
evalcond[4]=(((sj7*x630))+x632+new_r01);
evalcond[5]=(((sj7*x631))+(((-1.0)*cj7*x633)));
evalcond[6]=((((-1.0)*sj7*x633))+(((-1.0)*x632))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x634 = IKatan2WithCheck(IkReal(((-1.0)*cj7)),IkReal(((-1.0)*sj7)),IKFAST_ATAN2_MAGTHRESH);
if(!x634.valid){
continue;
}
CheckValue<IkReal> x635=IKPowWithIntegerCheck(IKsign(new_r01),-1);
if(!x635.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x634.value)+(((1.5707963267949)*(x635.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x636=IKcos(j5);
IkReal x637=IKsin(j5);
IkReal x638=(cj7*x637);
IkReal x639=((1.0)*x636);
evalcond[0]=(cj7+((new_r01*x637)));
evalcond[1]=(sj7+((new_r01*x636)));
evalcond[2]=(sj7+(((-1.0)*new_r10*x639)));
evalcond[3]=(((new_r10*x637))+(((-1.0)*cj7)));
evalcond[4]=(((sj7*x636))+x638+new_r01);
evalcond[5]=(((sj7*x637))+(((-1.0)*cj7*x639)));
evalcond[6]=((((-1.0)*sj7*x639))+(((-1.0)*x638))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
sj6=0;
cj6=1.0;
j6=0;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
j5eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x641 = IKatan2WithCheck(IkReal(new_r00),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x641.valid){
continue;
}
IkReal x640=x641.value;
j5array[0]=((-1.0)*x640);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x640)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r10*(IKcos(j5))))+((new_r00*(IKsin(j5)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
sj6=0;
cj6=1.0;
j6=0;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x643 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x643.valid){
continue;
}
IkReal x642=x643.value;
j5array[0]=((-1.0)*x642);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x642)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r11*(IKcos(j5))))+((new_r01*(IKsin(j5)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
sj6=0;
cj6=1.0;
j6=0;
new_r01=0;
new_r10=0;
j5eval[0]=new_r11;
j5eval[1]=IKsign(new_r11);
j5eval[2]=((IKabs(cj7))+(IKabs(sj7)));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
sj6=0;
cj6=1.0;
j6=0;
new_r01=0;
new_r10=0;
j5eval[0]=new_r00;
j5eval[1]=IKsign(new_r00);
j5eval[2]=((IKabs(cj7))+(IKabs(sj7)));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
sj6=0;
cj6=1.0;
j6=0;
new_r01=0;
new_r10=0;
j5eval[0]=new_r00;
j5eval[1]=new_r11;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x644=IKPowWithIntegerCheck(new_r00,-1);
if(!x644.valid){
continue;
}
CheckValue<IkReal> x645=IKPowWithIntegerCheck(new_r11,-1);
if(!x645.valid){
continue;
}
if( IKabs(((-1.0)*sj7*(x644.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((cj7*(x645.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*sj7*(x644.value)))+IKsqr((cj7*(x645.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*sj7*(x644.value)), (cj7*(x645.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x646=IKsin(j5);
IkReal x647=IKcos(j5);
IkReal x648=((1.0)*cj7);
IkReal x649=(sj7*x646);
IkReal x650=(x647*x648);
evalcond[0]=(sj7+((new_r00*x646)));
evalcond[1]=(sj7+((new_r11*x646)));
evalcond[2]=(cj7+(((-1.0)*new_r11*x647)));
evalcond[3]=((((-1.0)*x648))+((new_r00*x647)));
evalcond[4]=(((sj7*x647))+((cj7*x646)));
evalcond[5]=((((-1.0)*x650))+x649+new_r00);
evalcond[6]=((((-1.0)*x650))+x649+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x651 = IKatan2WithCheck(IkReal(((-1.0)*sj7)),IkReal(cj7),IKFAST_ATAN2_MAGTHRESH);
if(!x651.valid){
continue;
}
CheckValue<IkReal> x652=IKPowWithIntegerCheck(IKsign(new_r00),-1);
if(!x652.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x651.value)+(((1.5707963267949)*(x652.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x653=IKsin(j5);
IkReal x654=IKcos(j5);
IkReal x655=((1.0)*cj7);
IkReal x656=(sj7*x653);
IkReal x657=(x654*x655);
evalcond[0]=(sj7+((new_r00*x653)));
evalcond[1]=(sj7+((new_r11*x653)));
evalcond[2]=((((-1.0)*new_r11*x654))+cj7);
evalcond[3]=((((-1.0)*x655))+((new_r00*x654)));
evalcond[4]=(((sj7*x654))+((cj7*x653)));
evalcond[5]=((((-1.0)*x657))+x656+new_r00);
evalcond[6]=((((-1.0)*x657))+x656+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x658=IKPowWithIntegerCheck(IKsign(new_r11),-1);
if(!x658.valid){
continue;
}
CheckValue<IkReal> x659 = IKatan2WithCheck(IkReal(((-1.0)*sj7)),IkReal(cj7),IKFAST_ATAN2_MAGTHRESH);
if(!x659.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x658.value)))+(x659.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x660=IKsin(j5);
IkReal x661=IKcos(j5);
IkReal x662=((1.0)*cj7);
IkReal x663=(sj7*x660);
IkReal x664=(x661*x662);
evalcond[0]=(sj7+((new_r00*x660)));
evalcond[1]=(sj7+((new_r11*x660)));
evalcond[2]=(cj7+(((-1.0)*new_r11*x661)));
evalcond[3]=((((-1.0)*x662))+((new_r00*x661)));
evalcond[4]=(((sj7*x661))+((cj7*x660)));
evalcond[5]=((((-1.0)*x664))+x663+new_r00);
evalcond[6]=((((-1.0)*x664))+x663+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x665=((1.0)*new_r11);
CheckValue<IkReal> x666=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r01*sj7))+(((-1.0)*cj7*x665)))),-1);
if(!x666.valid){
continue;
}
CheckValue<IkReal> x667 = IKatan2WithCheck(IkReal((((new_r00*new_r01))+((cj7*sj7)))),IkReal(((1.0)+(((-1.0)*(cj7*cj7)))+(((-1.0)*new_r00*x665)))),IKFAST_ATAN2_MAGTHRESH);
if(!x667.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x666.value)))+(x667.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x668=IKcos(j5);
IkReal x669=IKsin(j5);
IkReal x670=((1.0)*cj7);
IkReal x671=(sj7*x669);
IkReal x672=((1.0)*x668);
IkReal x673=(x668*x670);
evalcond[0]=(sj7+((new_r11*x669))+((new_r01*x668)));
evalcond[1]=(((sj7*x668))+new_r01+((cj7*x669)));
evalcond[2]=(sj7+((new_r00*x669))+(((-1.0)*new_r10*x672)));
evalcond[3]=(cj7+(((-1.0)*new_r11*x672))+((new_r01*x669)));
evalcond[4]=(x671+new_r00+(((-1.0)*x673)));
evalcond[5]=(x671+new_r11+(((-1.0)*x673)));
evalcond[6]=(((new_r10*x669))+((new_r00*x668))+(((-1.0)*x670)));
evalcond[7]=((((-1.0)*x669*x670))+new_r10+(((-1.0)*sj7*x672)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x674=IKPowWithIntegerCheck(IKsign(((((-1.0)*(new_r01*new_r01)))+(((-1.0)*(new_r11*new_r11))))),-1);
if(!x674.valid){
continue;
}
CheckValue<IkReal> x675 = IKatan2WithCheck(IkReal((((new_r11*sj7))+((cj7*new_r01)))),IkReal((((new_r01*sj7))+(((-1.0)*cj7*new_r11)))),IKFAST_ATAN2_MAGTHRESH);
if(!x675.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x674.value)))+(x675.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x676=IKcos(j5);
IkReal x677=IKsin(j5);
IkReal x678=((1.0)*cj7);
IkReal x679=(sj7*x677);
IkReal x680=((1.0)*x676);
IkReal x681=(x676*x678);
evalcond[0]=(((new_r11*x677))+((new_r01*x676))+sj7);
evalcond[1]=(((cj7*x677))+new_r01+((sj7*x676)));
evalcond[2]=((((-1.0)*new_r10*x680))+((new_r00*x677))+sj7);
evalcond[3]=(((new_r01*x677))+cj7+(((-1.0)*new_r11*x680)));
evalcond[4]=((((-1.0)*x681))+x679+new_r00);
evalcond[5]=((((-1.0)*x681))+x679+new_r11);
evalcond[6]=(((new_r00*x676))+((new_r10*x677))+(((-1.0)*x678)));
evalcond[7]=((((-1.0)*sj7*x680))+new_r10+(((-1.0)*x677*x678)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x682=((1.0)*new_r11);
CheckValue<IkReal> x683=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r10*x682))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x683.valid){
continue;
}
CheckValue<IkReal> x684 = IKatan2WithCheck(IkReal((((new_r10*sj7))+((new_r01*sj7)))),IkReal((((new_r00*sj7))+(((-1.0)*sj7*x682)))),IKFAST_ATAN2_MAGTHRESH);
if(!x684.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x683.value)))+(x684.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x685=IKcos(j5);
IkReal x686=IKsin(j5);
IkReal x687=((1.0)*cj7);
IkReal x688=(sj7*x686);
IkReal x689=((1.0)*x685);
IkReal x690=(x685*x687);
evalcond[0]=(sj7+((new_r01*x685))+((new_r11*x686)));
evalcond[1]=(((sj7*x685))+((cj7*x686))+new_r01);
evalcond[2]=((((-1.0)*new_r10*x689))+sj7+((new_r00*x686)));
evalcond[3]=(cj7+((new_r01*x686))+(((-1.0)*new_r11*x689)));
evalcond[4]=(x688+(((-1.0)*x690))+new_r00);
evalcond[5]=(x688+(((-1.0)*x690))+new_r11);
evalcond[6]=((((-1.0)*x687))+((new_r00*x685))+((new_r10*x686)));
evalcond[7]=((((-1.0)*sj7*x689))+(((-1.0)*x686*x687))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j6)))), 6.28318530717959)));
evalcond[1]=new_r02;
evalcond[2]=new_r12;
evalcond[3]=new_r21;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
IkReal x691=((1.0)*new_r10);
IkReal x692=((((-1.0)*new_r11*x691))+(((-1.0)*new_r00*new_r01)));
j5eval[0]=x692;
j5eval[1]=((IKabs((((cj7*new_r00))+((cj7*new_r11)))))+(IKabs((((cj7*new_r01))+(((-1.0)*cj7*x691))))));
j5eval[2]=IKsign(x692);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
IkReal x693=((1.0)*new_r10);
IkReal x694=((((-1.0)*sj7*x693))+(((-1.0)*cj7*new_r00)));
j5eval[0]=x694;
j5eval[1]=((IKabs((((new_r00*new_r01))+((cj7*sj7)))))+(IKabs(((cj7*cj7)+(((-1.0)*new_r01*x693))))));
j5eval[2]=IKsign(x694);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
IkReal x695=((1.0)*new_r00);
IkReal x696=((((-1.0)*sj7*x695))+((cj7*new_r10)));
j5eval[0]=x696;
j5eval[1]=IKsign(x696);
j5eval[2]=((IKabs(((((-1.0)*(cj7*cj7)))+(new_r00*new_r00))))+(IKabs(((((-1.0)*new_r10*x695))+((cj7*sj7))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
IkReal x697=((-1.0)*new_r00);
IkReal x699 = ((new_r10*new_r10)+(new_r00*new_r00));
if(IKabs(x699)==0){
continue;
}
IkReal x698=pow(x699,-0.5);
CheckValue<IkReal> x700 = IKatan2WithCheck(IkReal(new_r10),IkReal(x697),IKFAST_ATAN2_MAGTHRESH);
if(!x700.valid){
continue;
}
IkReal gconst6=((-1.0)*(x700.value));
IkReal gconst7=((-1.0)*new_r10*x698);
IkReal gconst8=(x697*x698);
CheckValue<IkReal> x701 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x701.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((j7+(x701.value))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x702=((-1.0)*new_r00);
CheckValue<IkReal> x705 = IKatan2WithCheck(IkReal(new_r10),IkReal(x702),IKFAST_ATAN2_MAGTHRESH);
if(!x705.valid){
continue;
}
IkReal x703=((-1.0)*(x705.value));
IkReal x704=x698;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x703;
IkReal gconst6=x703;
IkReal gconst7=((-1.0)*new_r10*x704);
IkReal gconst8=(x702*x704);
IkReal x706=new_r00*new_r00;
IkReal x707=((1.0)*new_r11);
IkReal x708=((1.0)*new_r00*new_r01);
IkReal x709=((((-1.0)*x708))+(((-1.0)*new_r10*x707)));
IkReal x710=x698;
IkReal x711=(new_r00*x710);
j5eval[0]=x709;
j5eval[1]=((IKabs(((((-1.0)*x706*x710))+(((-1.0)*x707*x711)))))+(IKabs(((((-1.0)*x708*x710))+((new_r10*x711))))));
j5eval[2]=IKsign(x709);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x712=((-1.0)*new_r00);
CheckValue<IkReal> x715 = IKatan2WithCheck(IkReal(new_r10),IkReal(x712),IKFAST_ATAN2_MAGTHRESH);
if(!x715.valid){
continue;
}
IkReal x713=((-1.0)*(x715.value));
IkReal x714=x698;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x713;
IkReal gconst6=x713;
IkReal gconst7=((-1.0)*new_r10*x714);
IkReal gconst8=(x712*x714);
IkReal x716=new_r10*new_r10;
IkReal x717=new_r00*new_r00;
CheckValue<IkReal> x720=IKPowWithIntegerCheck((x717+x716),-1);
if(!x720.valid){
continue;
}
IkReal x718=x720.value;
IkReal x719=(new_r00*x718);
j5eval[0]=((IKabs((((new_r01*x716*x719))+((new_r01*x719*(new_r00*new_r00)))+((new_r10*x719)))))+(IKabs((((x717*x718))+(((-1.0)*new_r01*new_r10))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x721=((-1.0)*new_r00);
CheckValue<IkReal> x724 = IKatan2WithCheck(IkReal(new_r10),IkReal(x721),IKFAST_ATAN2_MAGTHRESH);
if(!x724.valid){
continue;
}
IkReal x722=((-1.0)*(x724.value));
IkReal x723=x698;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x722;
IkReal gconst6=x722;
IkReal gconst7=((-1.0)*new_r10*x723);
IkReal gconst8=(x721*x723);
IkReal x725=new_r00*new_r00;
IkReal x726=new_r10*new_r10;
CheckValue<IkReal> x730=IKPowWithIntegerCheck((x725+x726),-1);
if(!x730.valid){
continue;
}
IkReal x727=x730.value;
IkReal x728=(new_r10*x727);
IkReal x729=((1.0)*x727);
j5eval[0]=((IKabs(((((-1.0)*x729*(x726*x726)))+(((-1.0)*x725*x726*x729))+((x725*x727)))))+(IKabs((((new_r00*x728))+((new_r00*x728*(new_r10*new_r10)))+((x728*(new_r00*new_r00*new_r00)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x732 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x732.valid){
continue;
}
IkReal x731=((-1.0)*(x732.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x731;
new_r11=0;
new_r00=0;
IkReal gconst6=x731;
IkReal x733 = new_r10*new_r10;
if(IKabs(x733)==0){
continue;
}
IkReal gconst7=((-1.0)*new_r10*(pow(x733,-0.5)));
IkReal gconst8=0;
j5eval[0]=new_r10;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x734=IKPowWithIntegerCheck(gconst7,-1);
if(!x734.valid){
continue;
}
cj5array[0]=(new_r01*(x734.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x735=IKsin(j5);
IkReal x736=IKcos(j5);
IkReal x737=((1.0)*gconst7);
evalcond[0]=(new_r01*x735);
evalcond[1]=(new_r10*x735);
evalcond[2]=(gconst7*x735);
evalcond[3]=(gconst7+(((-1.0)*new_r10*x736)));
evalcond[4]=((((-1.0)*x736*x737))+new_r10);
evalcond[5]=(((new_r01*x736))+(((-1.0)*x737)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x738=IKPowWithIntegerCheck(new_r10,-1);
if(!x738.valid){
continue;
}
cj5array[0]=(gconst7*(x738.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x739=IKsin(j5);
IkReal x740=IKcos(j5);
IkReal x741=((1.0)*gconst7);
IkReal x742=(x740*x741);
evalcond[0]=(new_r01*x739);
evalcond[1]=(new_r10*x739);
evalcond[2]=(gconst7*x739);
evalcond[3]=(new_r01+(((-1.0)*x742)));
evalcond[4]=(new_r10+(((-1.0)*x742)));
evalcond[5]=(((new_r01*x740))+(((-1.0)*x741)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
evalcond[1]=gconst8;
evalcond[2]=gconst7;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x743=((-1.0)*new_r00);
CheckValue<IkReal> x745 = IKatan2WithCheck(IkReal(new_r10),IkReal(x743),IKFAST_ATAN2_MAGTHRESH);
if(!x745.valid){
continue;
}
IkReal x744=((-1.0)*(x745.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x744;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst6=x744;
IkReal gconst7=((-1.0)*new_r10);
IkReal gconst8=x743;
j5eval[0]=1.0;
j5eval[1]=1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r10*new_r10))))))+(IKabs((new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x746=((-1.0)*new_r00);
CheckValue<IkReal> x748 = IKatan2WithCheck(IkReal(new_r10),IkReal(x746),IKFAST_ATAN2_MAGTHRESH);
if(!x748.valid){
continue;
}
IkReal x747=((-1.0)*(x748.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x747;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst6=x747;
IkReal gconst7=((-1.0)*new_r10);
IkReal gconst8=x746;
j5eval[0]=-1.0;
j5eval[1]=((IKabs(((-1.0)+(new_r10*new_r10))))+(IKabs((new_r00*new_r10))));
j5eval[2]=-1.0;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x749=((-1.0)*new_r00);
CheckValue<IkReal> x751 = IKatan2WithCheck(IkReal(new_r10),IkReal(x749),IKFAST_ATAN2_MAGTHRESH);
if(!x751.valid){
continue;
}
IkReal x750=((-1.0)*(x751.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x750;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst6=x750;
IkReal gconst7=((-1.0)*new_r10);
IkReal gconst8=x749;
j5eval[0]=1.0;
j5eval[1]=((((0.5)*(IKabs(((1.0)+(((-2.0)*(new_r10*new_r10))))))))+(IKabs((new_r00*new_r10))));
j5eval[2]=1.0;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x752=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst7*new_r10))+(((-1.0)*gconst8*new_r00)))),-1);
if(!x752.valid){
continue;
}
CheckValue<IkReal> x753 = IKatan2WithCheck(IkReal((((new_r00*new_r10))+((gconst7*gconst8)))),IkReal(((gconst8*gconst8)+(((-1.0)*(new_r10*new_r10))))),IKFAST_ATAN2_MAGTHRESH);
if(!x753.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x752.value)))+(x753.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x754=IKsin(j5);
IkReal x755=IKcos(j5);
IkReal x756=((1.0)*gconst7);
IkReal x757=(gconst8*x754);
IkReal x758=(gconst8*x755);
IkReal x759=(x755*x756);
evalcond[0]=(x757+(((-1.0)*x759)));
evalcond[1]=(gconst8+((new_r00*x755))+((new_r10*x754)));
evalcond[2]=(((gconst7*x754))+x758+new_r00);
evalcond[3]=(gconst7+(((-1.0)*new_r10*x755))+((new_r00*x754)));
evalcond[4]=((((-1.0)*x754*x756))+(((-1.0)*x758)));
evalcond[5]=(x757+new_r10+(((-1.0)*x759)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x760 = IKatan2WithCheck(IkReal((gconst7*new_r00)),IkReal((gconst8*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x760.valid){
continue;
}
CheckValue<IkReal> x761=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst8*gconst8)))+(((-1.0)*(gconst7*gconst7))))),-1);
if(!x761.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x760.value)+(((1.5707963267949)*(x761.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x762=IKsin(j5);
IkReal x763=IKcos(j5);
IkReal x764=((1.0)*gconst7);
IkReal x765=(gconst8*x762);
IkReal x766=(gconst8*x763);
IkReal x767=(x763*x764);
evalcond[0]=((((-1.0)*x767))+x765);
evalcond[1]=(((new_r10*x762))+gconst8+((new_r00*x763)));
evalcond[2]=(((gconst7*x762))+x766+new_r00);
evalcond[3]=((((-1.0)*new_r10*x763))+gconst7+((new_r00*x762)));
evalcond[4]=((((-1.0)*x762*x764))+(((-1.0)*x766)));
evalcond[5]=((((-1.0)*x767))+x765+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x768 = IKatan2WithCheck(IkReal((gconst7*gconst8)),IkReal(gconst8*gconst8),IKFAST_ATAN2_MAGTHRESH);
if(!x768.valid){
continue;
}
CheckValue<IkReal> x769=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst7*new_r10))+(((-1.0)*gconst8*new_r00)))),-1);
if(!x769.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x768.value)+(((1.5707963267949)*(x769.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x770=IKsin(j5);
IkReal x771=IKcos(j5);
IkReal x772=((1.0)*gconst7);
IkReal x773=(gconst8*x770);
IkReal x774=(gconst8*x771);
IkReal x775=(x771*x772);
evalcond[0]=(x773+(((-1.0)*x775)));
evalcond[1]=(gconst8+((new_r00*x771))+((new_r10*x770)));
evalcond[2]=(x774+((gconst7*x770))+new_r00);
evalcond[3]=((((-1.0)*new_r10*x771))+gconst7+((new_r00*x770)));
evalcond[4]=((((-1.0)*x774))+(((-1.0)*x770*x772)));
evalcond[5]=(x773+(((-1.0)*x775))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
IkReal x776=((-1.0)*new_r00);
CheckValue<IkReal> x778 = IKatan2WithCheck(IkReal(0),IkReal(x776),IKFAST_ATAN2_MAGTHRESH);
if(!x778.valid){
continue;
}
IkReal x777=((-1.0)*(x778.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x777;
new_r01=0;
new_r10=0;
IkReal gconst6=x777;
IkReal gconst7=0;
IkReal x779 = new_r00*new_r00;
if(IKabs(x779)==0){
continue;
}
IkReal gconst8=(x776*(pow(x779,-0.5)));
j5eval[0]=new_r11;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x780=IKPowWithIntegerCheck(gconst8,-1);
if(!x780.valid){
continue;
}
cj5array[0]=(new_r11*(x780.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x781=IKsin(j5);
IkReal x782=IKcos(j5);
evalcond[0]=(new_r00*x781);
evalcond[1]=(new_r11*x781);
evalcond[2]=(gconst8*x781);
evalcond[3]=(gconst8+((new_r00*x782)));
evalcond[4]=(new_r00+((gconst8*x782)));
evalcond[5]=(gconst8+(((-1.0)*new_r11*x782)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x783=IKPowWithIntegerCheck(new_r11,-1);
if(!x783.valid){
continue;
}
cj5array[0]=(gconst8*(x783.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x784=IKsin(j5);
IkReal x785=IKcos(j5);
IkReal x786=(gconst8*x785);
evalcond[0]=(new_r00*x784);
evalcond[1]=(new_r11*x784);
evalcond[2]=(gconst8*x784);
evalcond[3]=(gconst8+((new_r00*x785)));
evalcond[4]=(x786+new_r00);
evalcond[5]=((((-1.0)*x786))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r00);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x788 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x788.valid){
continue;
}
IkReal x787=((-1.0)*(x788.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x787;
new_r00=0;
IkReal gconst6=x787;
IkReal x789 = new_r10*new_r10;
if(IKabs(x789)==0){
continue;
}
IkReal gconst7=((-1.0)*new_r10*(pow(x789,-0.5)));
IkReal gconst8=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x791 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x791.valid){
continue;
}
IkReal x790=((-1.0)*(x791.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x790;
new_r00=0;
IkReal gconst6=x790;
IkReal x792 = new_r10*new_r10;
if(IKabs(x792)==0){
continue;
}
IkReal gconst7=((-1.0)*new_r10*(pow(x792,-0.5)));
IkReal gconst8=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x794 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x794.valid){
continue;
}
IkReal x793=((-1.0)*(x794.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst7;
cj7=gconst8;
j7=x793;
new_r00=0;
IkReal gconst6=x793;
IkReal x795 = new_r10*new_r10;
if(IKabs(x795)==0){
continue;
}
IkReal gconst7=((-1.0)*new_r10*(pow(x795,-0.5)));
IkReal gconst8=0;
j5eval[0]=new_r10;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x796=IKPowWithIntegerCheck(gconst7,-1);
if(!x796.valid){
continue;
}
CheckValue<IkReal> x797=IKPowWithIntegerCheck(new_r10,-1);
if(!x797.valid){
continue;
}
if( IKabs((new_r11*(x796.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((gconst7*(x797.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((new_r11*(x796.value)))+IKsqr((gconst7*(x797.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2((new_r11*(x796.value)), (gconst7*(x797.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x798=IKsin(j5);
IkReal x799=IKcos(j5);
IkReal x800=((1.0)*gconst7);
IkReal x801=((1.0)*x799);
IkReal x802=(x799*x800);
evalcond[0]=(new_r10*x798);
evalcond[1]=(gconst7*x798);
evalcond[2]=(gconst7+(((-1.0)*new_r10*x801)));
evalcond[3]=(new_r01+(((-1.0)*x802)));
evalcond[4]=((((-1.0)*x798*x800))+new_r11);
evalcond[5]=(new_r10+(((-1.0)*x802)));
evalcond[6]=(((new_r01*x798))+(((-1.0)*new_r11*x801)));
evalcond[7]=(((new_r11*x798))+((new_r01*x799))+(((-1.0)*x800)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x803=IKPowWithIntegerCheck(IKsign(gconst7),-1);
if(!x803.valid){
continue;
}
CheckValue<IkReal> x804 = IKatan2WithCheck(IkReal(new_r11),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x804.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x803.value)))+(x804.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x805=IKsin(j5);
IkReal x806=IKcos(j5);
IkReal x807=((1.0)*gconst7);
IkReal x808=((1.0)*x806);
IkReal x809=(x806*x807);
evalcond[0]=(new_r10*x805);
evalcond[1]=(gconst7*x805);
evalcond[2]=(gconst7+(((-1.0)*new_r10*x808)));
evalcond[3]=(new_r01+(((-1.0)*x809)));
evalcond[4]=((((-1.0)*x805*x807))+new_r11);
evalcond[5]=(new_r10+(((-1.0)*x809)));
evalcond[6]=(((new_r01*x805))+(((-1.0)*new_r11*x808)));
evalcond[7]=(((new_r11*x805))+((new_r01*x806))+(((-1.0)*x807)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x810=IKPowWithIntegerCheck(IKsign(gconst7),-1);
if(!x810.valid){
continue;
}
CheckValue<IkReal> x811 = IKatan2WithCheck(IkReal(new_r11),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x811.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x810.value)))+(x811.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x812=IKsin(j5);
IkReal x813=IKcos(j5);
IkReal x814=((1.0)*gconst7);
IkReal x815=((1.0)*x813);
IkReal x816=(x813*x814);
evalcond[0]=(new_r10*x812);
evalcond[1]=(gconst7*x812);
evalcond[2]=(gconst7+(((-1.0)*new_r10*x815)));
evalcond[3]=((((-1.0)*x816))+new_r01);
evalcond[4]=((((-1.0)*x812*x814))+new_r11);
evalcond[5]=((((-1.0)*x816))+new_r10);
evalcond[6]=(((new_r01*x812))+(((-1.0)*new_r11*x815)));
evalcond[7]=(((new_r11*x812))+((new_r01*x813))+(((-1.0)*x814)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x817=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst7*new_r10))+(((-1.0)*gconst8*new_r00)))),-1);
if(!x817.valid){
continue;
}
CheckValue<IkReal> x818 = IKatan2WithCheck(IkReal((((new_r00*new_r10))+((gconst7*gconst8)))),IkReal(((gconst8*gconst8)+(((-1.0)*(new_r10*new_r10))))),IKFAST_ATAN2_MAGTHRESH);
if(!x818.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x817.value)))+(x818.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x819=IKsin(j5);
IkReal x820=IKcos(j5);
IkReal x821=((1.0)*gconst7);
IkReal x822=(gconst8*x819);
IkReal x823=(gconst8*x820);
IkReal x824=((1.0)*x820);
IkReal x825=(x820*x821);
evalcond[0]=(((new_r10*x819))+gconst8+((new_r00*x820)));
evalcond[1]=(((gconst7*x819))+new_r00+x823);
evalcond[2]=(((new_r00*x819))+gconst7+(((-1.0)*new_r10*x824)));
evalcond[3]=(((new_r01*x819))+gconst8+(((-1.0)*new_r11*x824)));
evalcond[4]=((((-1.0)*x825))+new_r01+x822);
evalcond[5]=((((-1.0)*x825))+new_r10+x822);
evalcond[6]=(((new_r11*x819))+((new_r01*x820))+(((-1.0)*x821)));
evalcond[7]=((((-1.0)*x819*x821))+(((-1.0)*x823))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x826=((1.0)*new_r10);
CheckValue<IkReal> x827=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst7*x826))+(((-1.0)*gconst8*new_r00)))),-1);
if(!x827.valid){
continue;
}
CheckValue<IkReal> x828 = IKatan2WithCheck(IkReal((((new_r00*new_r01))+((gconst7*gconst8)))),IkReal(((gconst8*gconst8)+(((-1.0)*new_r01*x826)))),IKFAST_ATAN2_MAGTHRESH);
if(!x828.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x827.value)))+(x828.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x829=IKsin(j5);
IkReal x830=IKcos(j5);
IkReal x831=((1.0)*gconst7);
IkReal x832=(gconst8*x829);
IkReal x833=(gconst8*x830);
IkReal x834=((1.0)*x830);
IkReal x835=(x830*x831);
evalcond[0]=(gconst8+((new_r10*x829))+((new_r00*x830)));
evalcond[1]=(new_r00+x833+((gconst7*x829)));
evalcond[2]=((((-1.0)*new_r10*x834))+gconst7+((new_r00*x829)));
evalcond[3]=((((-1.0)*new_r11*x834))+((new_r01*x829))+gconst8);
evalcond[4]=((((-1.0)*x835))+new_r01+x832);
evalcond[5]=((((-1.0)*x835))+new_r10+x832);
evalcond[6]=(((new_r01*x830))+((new_r11*x829))+(((-1.0)*x831)));
evalcond[7]=((((-1.0)*x833))+new_r11+(((-1.0)*x829*x831)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x836=((1.0)*new_r10);
CheckValue<IkReal> x837=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r11*x836))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x837.valid){
continue;
}
CheckValue<IkReal> x838 = IKatan2WithCheck(IkReal((((gconst8*new_r11))+((gconst8*new_r00)))),IkReal(((((-1.0)*gconst8*x836))+((gconst8*new_r01)))),IKFAST_ATAN2_MAGTHRESH);
if(!x838.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x837.value)))+(x838.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x839=IKsin(j5);
IkReal x840=IKcos(j5);
IkReal x841=((1.0)*gconst7);
IkReal x842=(gconst8*x839);
IkReal x843=(gconst8*x840);
IkReal x844=((1.0)*x840);
IkReal x845=(x840*x841);
evalcond[0]=(gconst8+((new_r00*x840))+((new_r10*x839)));
evalcond[1]=(new_r00+x843+((gconst7*x839)));
evalcond[2]=((((-1.0)*new_r10*x844))+gconst7+((new_r00*x839)));
evalcond[3]=((((-1.0)*new_r11*x844))+gconst8+((new_r01*x839)));
evalcond[4]=((((-1.0)*x845))+new_r01+x842);
evalcond[5]=((((-1.0)*x845))+new_r10+x842);
evalcond[6]=(((new_r11*x839))+((new_r01*x840))+(((-1.0)*x841)));
evalcond[7]=((((-1.0)*x843))+(((-1.0)*x839*x841))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x848 = ((new_r10*new_r10)+(new_r00*new_r00));
if(IKabs(x848)==0){
continue;
}
IkReal x846=pow(x848,-0.5);
IkReal x847=((1.0)*x846);
CheckValue<IkReal> x849 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x849.valid){
continue;
}
IkReal gconst9=((3.14159265358979)+(((-1.0)*(x849.value))));
IkReal gconst10=(new_r10*x847);
IkReal gconst11=(new_r00*x847);
CheckValue<IkReal> x850 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x850.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j7+(x850.value))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
CheckValue<IkReal> x854 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x854.valid){
continue;
}
IkReal x851=((1.0)*(x854.value));
IkReal x852=x846;
IkReal x853=((1.0)*x852);
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x851)));
IkReal gconst9=((3.14159265358979)+(((-1.0)*x851)));
IkReal gconst10=(new_r10*x853);
IkReal gconst11=(new_r00*x853);
IkReal x855=new_r00*new_r00;
IkReal x856=((1.0)*new_r00);
IkReal x857=((((-1.0)*new_r01*x856))+(((-1.0)*new_r10*new_r11)));
IkReal x858=x846;
IkReal x859=(new_r00*x858);
j5eval[0]=x857;
j5eval[1]=((IKabs(((((-1.0)*new_r10*x856*x858))+((new_r01*x859)))))+(IKabs((((x855*x858))+((new_r11*x859))))));
j5eval[2]=IKsign(x857);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x863 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x863.valid){
continue;
}
IkReal x860=((1.0)*(x863.value));
IkReal x861=x846;
IkReal x862=((1.0)*x861);
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x860)));
IkReal gconst9=((3.14159265358979)+(((-1.0)*x860)));
IkReal gconst10=(new_r10*x862);
IkReal gconst11=(new_r00*x862);
IkReal x864=new_r10*new_r10;
IkReal x865=new_r00*new_r00;
IkReal x866=((1.0)*new_r01);
CheckValue<IkReal> x870=IKPowWithIntegerCheck((x865+x864),-1);
if(!x870.valid){
continue;
}
IkReal x867=x870.value;
IkReal x868=(new_r10*x867);
IkReal x869=(new_r01*x867);
j5eval[0]=((IKabs(((((-1.0)*x866*x868*(new_r10*new_r10)))+(((-1.0)*x865*x866*x868))+((x865*x867)))))+(IKabs((((new_r00*x868))+((new_r00*x864*x869))+((x869*(new_r00*new_r00*new_r00)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x874 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x874.valid){
continue;
}
IkReal x871=((1.0)*(x874.value));
IkReal x872=x846;
IkReal x873=((1.0)*x872);
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x871)));
IkReal gconst9=((3.14159265358979)+(((-1.0)*x871)));
IkReal gconst10=(new_r10*x873);
IkReal gconst11=(new_r00*x873);
IkReal x875=new_r00*new_r00;
IkReal x876=new_r10*new_r10;
CheckValue<IkReal> x880=IKPowWithIntegerCheck((x875+x876),-1);
if(!x880.valid){
continue;
}
IkReal x877=x880.value;
IkReal x878=(new_r10*x877);
IkReal x879=((1.0)*x877);
j5eval[0]=((IKabs((((new_r00*x878))+((x878*(new_r00*new_r00*new_r00)))+((new_r00*x878*(new_r10*new_r10))))))+(IKabs(((((-1.0)*x875*x876*x879))+(((-1.0)*x879*(x876*x876)))+((x875*x877))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x882 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x882.valid){
continue;
}
IkReal x881=((1.0)*(x882.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x881)));
new_r11=0;
new_r00=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x881)));
IkReal x883 = new_r10*new_r10;
if(IKabs(x883)==0){
continue;
}
IkReal gconst10=((1.0)*new_r10*(pow(x883,-0.5)));
IkReal gconst11=0;
j5eval[0]=new_r10;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x884=IKPowWithIntegerCheck(gconst10,-1);
if(!x884.valid){
continue;
}
cj5array[0]=(new_r01*(x884.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x885=IKsin(j5);
IkReal x886=IKcos(j5);
IkReal x887=((1.0)*x886);
evalcond[0]=(new_r01*x885);
evalcond[1]=(new_r10*x885);
evalcond[2]=(gconst10*x885);
evalcond[3]=((((-1.0)*new_r10*x887))+gconst10);
evalcond[4]=((((-1.0)*gconst10*x887))+new_r10);
evalcond[5]=(((new_r01*x886))+(((-1.0)*gconst10)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x888=IKPowWithIntegerCheck(new_r10,-1);
if(!x888.valid){
continue;
}
cj5array[0]=(gconst10*(x888.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x889=IKsin(j5);
IkReal x890=IKcos(j5);
IkReal x891=((1.0)*gconst10);
IkReal x892=(x890*x891);
evalcond[0]=(new_r01*x889);
evalcond[1]=(new_r10*x889);
evalcond[2]=(gconst10*x889);
evalcond[3]=((((-1.0)*x892))+new_r01);
evalcond[4]=((((-1.0)*x892))+new_r10);
evalcond[5]=(((new_r01*x890))+(((-1.0)*x891)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
evalcond[1]=gconst11;
evalcond[2]=gconst10;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
CheckValue<IkReal> x894 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x894.valid){
continue;
}
IkReal x893=((1.0)*(x894.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x893)));
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x893)));
IkReal gconst10=((1.0)*new_r10);
IkReal gconst11=((1.0)*new_r00);
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r10*new_r10))))))+(IKabs(((1.0)*new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
CheckValue<IkReal> x896 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x896.valid){
continue;
}
IkReal x895=((1.0)*(x896.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x895)));
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x895)));
IkReal gconst10=((1.0)*new_r10);
IkReal gconst11=((1.0)*new_r00);
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r10*new_r10))))))+(IKabs(((1.0)*new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
CheckValue<IkReal> x898 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x898.valid){
continue;
}
IkReal x897=((1.0)*(x898.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x897)));
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x897)));
IkReal gconst10=((1.0)*new_r10);
IkReal gconst11=((1.0)*new_r00);
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((1.0)+(((-2.0)*(new_r10*new_r10))))))+(IKabs(((2.0)*new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x899 = IKatan2WithCheck(IkReal((((gconst10*gconst11))+((new_r00*new_r10)))),IkReal(((((-1.0)*(new_r10*new_r10)))+(gconst11*gconst11))),IKFAST_ATAN2_MAGTHRESH);
if(!x899.valid){
continue;
}
CheckValue<IkReal> x900=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst10*new_r10))+(((-1.0)*gconst11*new_r00)))),-1);
if(!x900.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x899.value)+(((1.5707963267949)*(x900.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x901=IKsin(j5);
IkReal x902=IKcos(j5);
IkReal x903=(gconst11*x901);
IkReal x904=(gconst10*x901);
IkReal x905=((1.0)*x902);
IkReal x906=(gconst10*x905);
evalcond[0]=((((-1.0)*x906))+x903);
evalcond[1]=(gconst11+((new_r10*x901))+((new_r00*x902)));
evalcond[2]=(((gconst11*x902))+new_r00+x904);
evalcond[3]=(gconst10+((new_r00*x901))+(((-1.0)*new_r10*x905)));
evalcond[4]=((((-1.0)*gconst11*x905))+(((-1.0)*x904)));
evalcond[5]=((((-1.0)*x906))+new_r10+x903);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x907=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst11*gconst11)))+(((-1.0)*(gconst10*gconst10))))),-1);
if(!x907.valid){
continue;
}
CheckValue<IkReal> x908 = IKatan2WithCheck(IkReal((gconst10*new_r00)),IkReal((gconst11*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x908.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x907.value)))+(x908.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x909=IKsin(j5);
IkReal x910=IKcos(j5);
IkReal x911=(gconst11*x909);
IkReal x912=(gconst10*x909);
IkReal x913=((1.0)*x910);
IkReal x914=(gconst10*x913);
evalcond[0]=((((-1.0)*x914))+x911);
evalcond[1]=(gconst11+((new_r10*x909))+((new_r00*x910)));
evalcond[2]=(((gconst11*x910))+new_r00+x912);
evalcond[3]=(gconst10+((new_r00*x909))+(((-1.0)*new_r10*x913)));
evalcond[4]=((((-1.0)*x912))+(((-1.0)*gconst11*x913)));
evalcond[5]=((((-1.0)*x914))+new_r10+x911);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x915 = IKatan2WithCheck(IkReal((gconst10*gconst11)),IkReal(gconst11*gconst11),IKFAST_ATAN2_MAGTHRESH);
if(!x915.valid){
continue;
}
CheckValue<IkReal> x916=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst10*new_r10))+(((-1.0)*gconst11*new_r00)))),-1);
if(!x916.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x915.value)+(((1.5707963267949)*(x916.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x917=IKsin(j5);
IkReal x918=IKcos(j5);
IkReal x919=(gconst11*x917);
IkReal x920=(gconst10*x917);
IkReal x921=((1.0)*x918);
IkReal x922=(gconst10*x921);
evalcond[0]=((((-1.0)*x922))+x919);
evalcond[1]=(gconst11+((new_r10*x917))+((new_r00*x918)));
evalcond[2]=(((gconst11*x918))+new_r00+x920);
evalcond[3]=(gconst10+(((-1.0)*new_r10*x921))+((new_r00*x917)));
evalcond[4]=((((-1.0)*x920))+(((-1.0)*gconst11*x921)));
evalcond[5]=((((-1.0)*x922))+new_r10+x919);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x924 = IKatan2WithCheck(IkReal(0),IkReal(((-1.0)*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x924.valid){
continue;
}
IkReal x923=((1.0)*(x924.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x923)));
new_r01=0;
new_r10=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x923)));
IkReal gconst10=0;
IkReal x925 = new_r00*new_r00;
if(IKabs(x925)==0){
continue;
}
IkReal gconst11=((1.0)*new_r00*(pow(x925,-0.5)));
j5eval[0]=new_r11;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x926=IKPowWithIntegerCheck(gconst11,-1);
if(!x926.valid){
continue;
}
cj5array[0]=(new_r11*(x926.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x927=IKsin(j5);
IkReal x928=IKcos(j5);
evalcond[0]=(new_r00*x927);
evalcond[1]=(new_r11*x927);
evalcond[2]=(gconst11*x927);
evalcond[3]=(gconst11+((new_r00*x928)));
evalcond[4]=(((gconst11*x928))+new_r00);
evalcond[5]=(gconst11+(((-1.0)*new_r11*x928)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x929=IKPowWithIntegerCheck(new_r11,-1);
if(!x929.valid){
continue;
}
cj5array[0]=(gconst11*(x929.value));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x930=IKsin(j5);
IkReal x931=IKcos(j5);
IkReal x932=(gconst11*x931);
evalcond[0]=(new_r00*x930);
evalcond[1]=(new_r11*x930);
evalcond[2]=(gconst11*x930);
evalcond[3]=(gconst11+((new_r00*x931)));
evalcond[4]=(new_r00+x932);
evalcond[5]=((((-1.0)*x932))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r00);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x934 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x934.valid){
continue;
}
IkReal x933=((1.0)*(x934.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x933)));
new_r00=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x933)));
IkReal x935 = new_r10*new_r10;
if(IKabs(x935)==0){
continue;
}
IkReal gconst10=((1.0)*new_r10*(pow(x935,-0.5)));
IkReal gconst11=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x937 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x937.valid){
continue;
}
IkReal x936=((1.0)*(x937.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x936)));
new_r00=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x936)));
IkReal x938 = new_r10*new_r10;
if(IKabs(x938)==0){
continue;
}
IkReal gconst10=((1.0)*new_r10*(pow(x938,-0.5)));
IkReal gconst11=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x940 = IKatan2WithCheck(IkReal(new_r10),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x940.valid){
continue;
}
IkReal x939=((1.0)*(x940.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst10;
cj7=gconst11;
j7=((3.14159265)+(((-1.0)*x939)));
new_r00=0;
IkReal gconst9=((3.14159265358979)+(((-1.0)*x939)));
IkReal x941 = new_r10*new_r10;
if(IKabs(x941)==0){
continue;
}
IkReal gconst10=((1.0)*new_r10*(pow(x941,-0.5)));
IkReal gconst11=0;
j5eval[0]=new_r10;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x942=IKPowWithIntegerCheck(gconst10,-1);
if(!x942.valid){
continue;
}
CheckValue<IkReal> x943=IKPowWithIntegerCheck(new_r10,-1);
if(!x943.valid){
continue;
}
if( IKabs((new_r11*(x942.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((gconst10*(x943.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((new_r11*(x942.value)))+IKsqr((gconst10*(x943.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2((new_r11*(x942.value)), (gconst10*(x943.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x944=IKsin(j5);
IkReal x945=IKcos(j5);
IkReal x946=(gconst10*x944);
IkReal x947=((1.0)*x945);
IkReal x948=(gconst10*x947);
evalcond[0]=(new_r10*x944);
evalcond[1]=x946;
evalcond[2]=(gconst10+(((-1.0)*new_r10*x947)));
evalcond[3]=((((-1.0)*x948))+new_r01);
evalcond[4]=((((-1.0)*x946))+new_r11);
evalcond[5]=((((-1.0)*x948))+new_r10);
evalcond[6]=(((new_r01*x944))+(((-1.0)*new_r11*x947)));
evalcond[7]=(((new_r01*x945))+((new_r11*x944))+(((-1.0)*gconst10)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x949=IKPowWithIntegerCheck(IKsign(gconst10),-1);
if(!x949.valid){
continue;
}
CheckValue<IkReal> x950 = IKatan2WithCheck(IkReal(new_r11),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x950.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x949.value)))+(x950.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x951=IKsin(j5);
IkReal x952=IKcos(j5);
IkReal x953=(gconst10*x951);
IkReal x954=((1.0)*x952);
IkReal x955=(gconst10*x954);
evalcond[0]=(new_r10*x951);
evalcond[1]=x953;
evalcond[2]=(gconst10+(((-1.0)*new_r10*x954)));
evalcond[3]=(new_r01+(((-1.0)*x955)));
evalcond[4]=((((-1.0)*x953))+new_r11);
evalcond[5]=(new_r10+(((-1.0)*x955)));
evalcond[6]=(((new_r01*x951))+(((-1.0)*new_r11*x954)));
evalcond[7]=(((new_r01*x952))+(((-1.0)*gconst10))+((new_r11*x951)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x956=IKPowWithIntegerCheck(IKsign(gconst10),-1);
if(!x956.valid){
continue;
}
CheckValue<IkReal> x957 = IKatan2WithCheck(IkReal(new_r11),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x957.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x956.value)))+(x957.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x958=IKsin(j5);
IkReal x959=IKcos(j5);
IkReal x960=(gconst10*x958);
IkReal x961=((1.0)*x959);
IkReal x962=(gconst10*x961);
evalcond[0]=(new_r10*x958);
evalcond[1]=x960;
evalcond[2]=(gconst10+(((-1.0)*new_r10*x961)));
evalcond[3]=(new_r01+(((-1.0)*x962)));
evalcond[4]=((((-1.0)*x960))+new_r11);
evalcond[5]=(new_r10+(((-1.0)*x962)));
evalcond[6]=(((new_r01*x958))+(((-1.0)*new_r11*x961)));
evalcond[7]=(((new_r01*x959))+(((-1.0)*gconst10))+((new_r11*x958)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x963 = IKatan2WithCheck(IkReal((((gconst10*gconst11))+((new_r00*new_r10)))),IkReal(((((-1.0)*(new_r10*new_r10)))+(gconst11*gconst11))),IKFAST_ATAN2_MAGTHRESH);
if(!x963.valid){
continue;
}
CheckValue<IkReal> x964=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst10*new_r10))+(((-1.0)*gconst11*new_r00)))),-1);
if(!x964.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x963.value)+(((1.5707963267949)*(x964.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x965=IKsin(j5);
IkReal x966=IKcos(j5);
IkReal x967=(gconst11*x965);
IkReal x968=((1.0)*x966);
IkReal x969=(gconst10*x965);
IkReal x970=(gconst10*x968);
evalcond[0]=(((new_r00*x966))+gconst11+((new_r10*x965)));
evalcond[1]=(((gconst11*x966))+new_r00+x969);
evalcond[2]=(((new_r00*x965))+gconst10+(((-1.0)*new_r10*x968)));
evalcond[3]=(((new_r01*x965))+gconst11+(((-1.0)*new_r11*x968)));
evalcond[4]=(new_r01+x967+(((-1.0)*x970)));
evalcond[5]=(new_r10+x967+(((-1.0)*x970)));
evalcond[6]=(((new_r11*x965))+((new_r01*x966))+(((-1.0)*gconst10)));
evalcond[7]=((((-1.0)*x969))+new_r11+(((-1.0)*gconst11*x968)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x971=((1.0)*new_r10);
CheckValue<IkReal> x972 = IKatan2WithCheck(IkReal((((gconst10*gconst11))+((new_r00*new_r01)))),IkReal(((((-1.0)*new_r01*x971))+(gconst11*gconst11))),IKFAST_ATAN2_MAGTHRESH);
if(!x972.valid){
continue;
}
CheckValue<IkReal> x973=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst11*new_r00))+(((-1.0)*gconst10*x971)))),-1);
if(!x973.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x972.value)+(((1.5707963267949)*(x973.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x974=IKsin(j5);
IkReal x975=IKcos(j5);
IkReal x976=(gconst11*x974);
IkReal x977=((1.0)*x975);
IkReal x978=(gconst10*x974);
IkReal x979=(gconst10*x977);
evalcond[0]=(gconst11+((new_r10*x974))+((new_r00*x975)));
evalcond[1]=(((gconst11*x975))+new_r00+x978);
evalcond[2]=(gconst10+(((-1.0)*new_r10*x977))+((new_r00*x974)));
evalcond[3]=(((new_r01*x974))+gconst11+(((-1.0)*new_r11*x977)));
evalcond[4]=(new_r01+x976+(((-1.0)*x979)));
evalcond[5]=(new_r10+x976+(((-1.0)*x979)));
evalcond[6]=(((new_r01*x975))+((new_r11*x974))+(((-1.0)*gconst10)));
evalcond[7]=((((-1.0)*x978))+(((-1.0)*gconst11*x977))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x980=((1.0)*new_r10);
CheckValue<IkReal> x981 = IKatan2WithCheck(IkReal((((gconst11*new_r00))+((gconst11*new_r11)))),IkReal((((gconst11*new_r01))+(((-1.0)*gconst11*x980)))),IKFAST_ATAN2_MAGTHRESH);
if(!x981.valid){
continue;
}
CheckValue<IkReal> x982=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r11*x980))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x982.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x981.value)+(((1.5707963267949)*(x982.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x983=IKsin(j5);
IkReal x984=IKcos(j5);
IkReal x985=(gconst11*x983);
IkReal x986=((1.0)*x984);
IkReal x987=(gconst10*x983);
IkReal x988=(gconst10*x986);
evalcond[0]=(((new_r00*x984))+gconst11+((new_r10*x983)));
evalcond[1]=(((gconst11*x984))+new_r00+x987);
evalcond[2]=(((new_r00*x983))+gconst10+(((-1.0)*new_r10*x986)));
evalcond[3]=(gconst11+(((-1.0)*new_r11*x986))+((new_r01*x983)));
evalcond[4]=((((-1.0)*x988))+new_r01+x985);
evalcond[5]=((((-1.0)*x988))+new_r10+x985);
evalcond[6]=((((-1.0)*gconst10))+((new_r11*x983))+((new_r01*x984)));
evalcond[7]=((((-1.0)*x987))+(((-1.0)*gconst11*x986))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x989=((-1.0)*new_r10);
IkReal x991 = ((new_r10*new_r10)+(new_r00*new_r00));
if(IKabs(x991)==0){
continue;
}
IkReal x990=pow(x991,-0.5);
CheckValue<IkReal> x992 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x989),IKFAST_ATAN2_MAGTHRESH);
if(!x992.valid){
continue;
}
IkReal gconst12=((-1.0)*(x992.value));
IkReal gconst13=(new_r00*x990);
IkReal gconst14=(x989*x990);
CheckValue<IkReal> x993 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x993.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((x993.value)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x994=((-1.0)*new_r10);
CheckValue<IkReal> x997 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x994),IKFAST_ATAN2_MAGTHRESH);
if(!x997.valid){
continue;
}
IkReal x995=((-1.0)*(x997.value));
IkReal x996=x990;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x995;
IkReal gconst12=x995;
IkReal gconst13=(new_r00*x996);
IkReal gconst14=(x994*x996);
IkReal x998=new_r10*new_r10;
IkReal x999=((1.0)*new_r00);
IkReal x1000=((1.0)*new_r10*new_r11);
IkReal x1001=((((-1.0)*x1000))+(((-1.0)*new_r01*x999)));
IkReal x1002=x990;
IkReal x1003=(new_r10*x1002);
j5eval[0]=x1001;
j5eval[1]=((IKabs(((((-1.0)*x1003*x999))+(((-1.0)*x1000*x1002)))))+(IKabs(((((-1.0)*new_r01*x1003))+((x1002*x998))))));
j5eval[2]=IKsign(x1001);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1004=((-1.0)*new_r10);
CheckValue<IkReal> x1007 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x1004),IKFAST_ATAN2_MAGTHRESH);
if(!x1007.valid){
continue;
}
IkReal x1005=((-1.0)*(x1007.value));
IkReal x1006=x990;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1005;
IkReal gconst12=x1005;
IkReal gconst13=(new_r00*x1006);
IkReal gconst14=(x1004*x1006);
IkReal x1008=new_r10*new_r10;
CheckValue<IkReal> x1011=IKPowWithIntegerCheck((x1008+(new_r00*new_r00)),-1);
if(!x1011.valid){
continue;
}
IkReal x1009=x1011.value;
IkReal x1010=(new_r00*x1009);
j5eval[0]=((IKabs((((new_r01*x1010*(new_r00*new_r00)))+((new_r10*x1010))+((new_r01*x1008*x1010)))))+(IKabs((((x1008*x1009))+((new_r00*new_r11))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1012=((-1.0)*new_r10);
CheckValue<IkReal> x1015 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x1012),IKFAST_ATAN2_MAGTHRESH);
if(!x1015.valid){
continue;
}
IkReal x1013=((-1.0)*(x1015.value));
IkReal x1014=x990;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1013;
IkReal gconst12=x1013;
IkReal gconst13=(new_r00*x1014);
IkReal gconst14=(x1012*x1014);
IkReal x1016=new_r10*new_r10;
IkReal x1017=new_r00*new_r00;
CheckValue<IkReal> x1021=IKPowWithIntegerCheck((x1016+x1017),-1);
if(!x1021.valid){
continue;
}
IkReal x1018=x1021.value;
IkReal x1019=(new_r10*x1018);
IkReal x1020=(x1016*x1018);
j5eval[0]=((IKabs((((x1019*(new_r00*new_r00*new_r00)))+((new_r00*x1019))+((new_r00*x1019*(new_r10*new_r10))))))+(IKabs((x1020+(((-1.0)*x1017*x1020))+(((-1.0)*x1018*(x1017*x1017)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
IkReal x1022=((-1.0)*new_r10);
CheckValue<IkReal> x1024 = IKatan2WithCheck(IkReal(0),IkReal(x1022),IKFAST_ATAN2_MAGTHRESH);
if(!x1024.valid){
continue;
}
IkReal x1023=((-1.0)*(x1024.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1023;
new_r11=0;
new_r00=0;
IkReal gconst12=x1023;
IkReal gconst13=0;
IkReal x1025 = new_r10*new_r10;
if(IKabs(x1025)==0){
continue;
}
IkReal gconst14=(x1022*(pow(x1025,-0.5)));
j5eval[0]=new_r01;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1026=IKPowWithIntegerCheck(gconst14,-1);
if(!x1026.valid){
continue;
}
sj5array[0]=((-1.0)*new_r01*(x1026.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1027=IKcos(j5);
IkReal x1028=IKsin(j5);
evalcond[0]=(new_r01*x1027);
evalcond[1]=(gconst14*x1027);
evalcond[2]=((-1.0)*new_r10*x1027);
evalcond[3]=(gconst14+((new_r01*x1028)));
evalcond[4]=(((new_r10*x1028))+gconst14);
evalcond[5]=(((gconst14*x1028))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1029=IKPowWithIntegerCheck(new_r01,-1);
if(!x1029.valid){
continue;
}
sj5array[0]=((-1.0)*gconst14*(x1029.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1030=IKcos(j5);
IkReal x1031=IKsin(j5);
IkReal x1032=(gconst14*x1031);
evalcond[0]=(new_r01*x1030);
evalcond[1]=(gconst14*x1030);
evalcond[2]=((-1.0)*new_r10*x1030);
evalcond[3]=(x1032+new_r01);
evalcond[4]=(gconst14+((new_r10*x1031)));
evalcond[5]=(x1032+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
evalcond[1]=gconst14;
evalcond[2]=gconst13;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x1033=((-1.0)*new_r10);
CheckValue<IkReal> x1035 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x1033),IKFAST_ATAN2_MAGTHRESH);
if(!x1035.valid){
continue;
}
IkReal x1034=((-1.0)*(x1035.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1034;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst12=x1034;
IkReal gconst13=new_r00;
IkReal gconst14=x1033;
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r10*new_r10))))))+(IKabs((new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x1036=((-1.0)*new_r10);
CheckValue<IkReal> x1038 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x1036),IKFAST_ATAN2_MAGTHRESH);
if(!x1038.valid){
continue;
}
IkReal x1037=((-1.0)*(x1038.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1037;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst12=x1037;
IkReal gconst13=new_r00;
IkReal gconst14=x1036;
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r10*new_r10))))))+(IKabs((new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x1039=((-1.0)*new_r10);
CheckValue<IkReal> x1041 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(x1039),IKFAST_ATAN2_MAGTHRESH);
if(!x1041.valid){
continue;
}
IkReal x1040=((-1.0)*(x1041.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1040;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst12=x1040;
IkReal gconst13=new_r00;
IkReal gconst14=x1039;
j5eval[0]=1.0;
j5eval[1]=1.0;
j5eval[2]=((((0.5)*(IKabs(((-1.0)+(((2.0)*(new_r10*new_r10))))))))+(IKabs((new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1042=((1.0)*gconst14);
CheckValue<IkReal> x1043=IKPowWithIntegerCheck(IKsign((((gconst13*new_r00))+(((-1.0)*new_r10*x1042)))),-1);
if(!x1043.valid){
continue;
}
CheckValue<IkReal> x1044 = IKatan2WithCheck(IkReal(((gconst14*gconst14)+(((-1.0)*(new_r00*new_r00))))),IkReal(((((-1.0)*gconst13*x1042))+((new_r00*new_r10)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1044.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1043.value)))+(x1044.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1045=IKsin(j5);
IkReal x1046=IKcos(j5);
IkReal x1047=(gconst14*x1045);
IkReal x1048=(gconst14*x1046);
IkReal x1049=(gconst13*x1045);
IkReal x1050=((1.0)*x1046);
IkReal x1051=(gconst13*x1050);
evalcond[0]=((((-1.0)*x1051))+x1047);
evalcond[1]=(gconst14+((new_r00*x1046))+((new_r10*x1045)));
evalcond[2]=(x1049+x1048+new_r00);
evalcond[3]=(gconst13+((new_r00*x1045))+(((-1.0)*new_r10*x1050)));
evalcond[4]=((((-1.0)*x1048))+(((-1.0)*x1049)));
evalcond[5]=((((-1.0)*x1051))+x1047+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1052=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst14*gconst14)))+(((-1.0)*(gconst13*gconst13))))),-1);
if(!x1052.valid){
continue;
}
CheckValue<IkReal> x1053 = IKatan2WithCheck(IkReal((gconst13*new_r00)),IkReal((gconst14*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x1053.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1052.value)))+(x1053.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1054=IKsin(j5);
IkReal x1055=IKcos(j5);
IkReal x1056=(gconst14*x1054);
IkReal x1057=(gconst14*x1055);
IkReal x1058=(gconst13*x1054);
IkReal x1059=((1.0)*x1055);
IkReal x1060=(gconst13*x1059);
evalcond[0]=(x1056+(((-1.0)*x1060)));
evalcond[1]=(gconst14+((new_r00*x1055))+((new_r10*x1054)));
evalcond[2]=(x1057+x1058+new_r00);
evalcond[3]=(gconst13+((new_r00*x1054))+(((-1.0)*new_r10*x1059)));
evalcond[4]=((((-1.0)*x1057))+(((-1.0)*x1058)));
evalcond[5]=(x1056+new_r10+(((-1.0)*x1060)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1061 = IKatan2WithCheck(IkReal(gconst13*gconst13),IkReal((gconst13*gconst14)),IKFAST_ATAN2_MAGTHRESH);
if(!x1061.valid){
continue;
}
CheckValue<IkReal> x1062=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst13*new_r00))+((gconst14*new_r10)))),-1);
if(!x1062.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1061.value)+(((1.5707963267949)*(x1062.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1063=IKsin(j5);
IkReal x1064=IKcos(j5);
IkReal x1065=(gconst14*x1063);
IkReal x1066=(gconst14*x1064);
IkReal x1067=(gconst13*x1063);
IkReal x1068=((1.0)*x1064);
IkReal x1069=(gconst13*x1068);
evalcond[0]=(x1065+(((-1.0)*x1069)));
evalcond[1]=(gconst14+((new_r00*x1064))+((new_r10*x1063)));
evalcond[2]=(x1067+x1066+new_r00);
evalcond[3]=((((-1.0)*new_r10*x1068))+gconst13+((new_r00*x1063)));
evalcond[4]=((((-1.0)*x1067))+(((-1.0)*x1066)));
evalcond[5]=(x1065+new_r10+(((-1.0)*x1069)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1070=IKPowWithIntegerCheck(gconst13,-1);
if(!x1070.valid){
continue;
}
sj5array[0]=(new_r11*(x1070.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1071=IKcos(j5);
IkReal x1072=IKsin(j5);
IkReal x1073=((-1.0)*x1071);
evalcond[0]=(new_r00*x1071);
evalcond[1]=(new_r11*x1073);
evalcond[2]=(gconst13*x1073);
evalcond[3]=(gconst13+((new_r00*x1072)));
evalcond[4]=(((gconst13*x1072))+new_r00);
evalcond[5]=(((new_r11*x1072))+(((-1.0)*gconst13)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x1075 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1075.valid){
continue;
}
IkReal x1074=((-1.0)*(x1075.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1074;
new_r11=0;
new_r10=0;
new_r22=0;
new_r02=0;
IkReal gconst12=x1074;
IkReal x1076 = ((1.0)+(((-1.0)*(new_r01*new_r01))));
if(IKabs(x1076)==0){
continue;
}
IkReal gconst13=(new_r00*(pow(x1076,-0.5)));
IkReal gconst14=0;
j5eval[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x1078 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1078.valid){
continue;
}
IkReal x1077=((-1.0)*(x1078.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1077;
new_r11=0;
new_r10=0;
new_r22=0;
new_r02=0;
IkReal gconst12=x1077;
IkReal x1079 = ((1.0)+(((-1.0)*(new_r01*new_r01))));
if(IKabs(x1079)==0){
continue;
}
IkReal gconst13=(new_r00*(pow(x1079,-0.5)));
IkReal gconst14=0;
j5eval[0]=new_r00;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
CheckValue<IkReal> x1081 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1081.valid){
continue;
}
IkReal x1080=((-1.0)*(x1081.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1080;
new_r11=0;
new_r10=0;
new_r22=0;
new_r02=0;
IkReal gconst12=x1080;
IkReal x1082 = ((1.0)+(((-1.0)*(new_r01*new_r01))));
if(IKabs(x1082)==0){
continue;
}
IkReal gconst13=(new_r00*(pow(x1082,-0.5)));
IkReal gconst14=0;
j5eval[0]=new_r00;
j5eval[1]=new_r01;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1083=IKPowWithIntegerCheck(new_r00,-1);
if(!x1083.valid){
continue;
}
CheckValue<IkReal> x1084=IKPowWithIntegerCheck(new_r01,-1);
if(!x1084.valid){
continue;
}
if( IKabs(((-1.0)*gconst13*(x1083.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((gconst13*(x1084.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst13*(x1083.value)))+IKsqr((gconst13*(x1084.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst13*(x1083.value)), (gconst13*(x1084.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1085=IKsin(j5);
IkReal x1086=IKcos(j5);
IkReal x1087=((1.0)*gconst13);
IkReal x1088=(gconst13*x1085);
evalcond[0]=(new_r01*x1085);
evalcond[1]=(new_r00*x1086);
evalcond[2]=((-1.0)*x1088);
evalcond[3]=((-1.0)*gconst13*x1086);
evalcond[4]=(((new_r00*x1085))+gconst13);
evalcond[5]=(x1088+new_r00);
evalcond[6]=(new_r01+(((-1.0)*x1086*x1087)));
evalcond[7]=(((new_r01*x1086))+(((-1.0)*x1087)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1089=IKPowWithIntegerCheck(new_r00,-1);
if(!x1089.valid){
continue;
}
CheckValue<IkReal> x1090=IKPowWithIntegerCheck(gconst13,-1);
if(!x1090.valid){
continue;
}
if( IKabs(((-1.0)*gconst13*(x1089.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r01*(x1090.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst13*(x1089.value)))+IKsqr((new_r01*(x1090.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst13*(x1089.value)), (new_r01*(x1090.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1091=IKsin(j5);
IkReal x1092=IKcos(j5);
IkReal x1093=((1.0)*gconst13);
IkReal x1094=(gconst13*x1091);
evalcond[0]=(new_r01*x1091);
evalcond[1]=(new_r00*x1092);
evalcond[2]=((-1.0)*x1094);
evalcond[3]=((-1.0)*gconst13*x1092);
evalcond[4]=(((new_r00*x1091))+gconst13);
evalcond[5]=(x1094+new_r00);
evalcond[6]=((((-1.0)*x1092*x1093))+new_r01);
evalcond[7]=(((new_r01*x1092))+(((-1.0)*x1093)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1095 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x1095.valid){
continue;
}
CheckValue<IkReal> x1096=IKPowWithIntegerCheck(IKsign(gconst13),-1);
if(!x1096.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1095.value)+(((1.5707963267949)*(x1096.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1097=IKsin(j5);
IkReal x1098=IKcos(j5);
IkReal x1099=((1.0)*gconst13);
IkReal x1100=(gconst13*x1097);
evalcond[0]=(new_r01*x1097);
evalcond[1]=(new_r00*x1098);
evalcond[2]=((-1.0)*x1100);
evalcond[3]=((-1.0)*gconst13*x1098);
evalcond[4]=(((new_r00*x1097))+gconst13);
evalcond[5]=(x1100+new_r00);
evalcond[6]=(new_r01+(((-1.0)*x1098*x1099)));
evalcond[7]=(((new_r01*x1098))+(((-1.0)*x1099)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r10);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x1102 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1102.valid){
continue;
}
IkReal x1101=((-1.0)*(x1102.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1101;
new_r10=0;
IkReal gconst12=x1101;
IkReal x1103 = new_r00*new_r00;
if(IKabs(x1103)==0){
continue;
}
IkReal gconst13=(new_r00*(pow(x1103,-0.5)));
IkReal gconst14=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x1105 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1105.valid){
continue;
}
IkReal x1104=((-1.0)*(x1105.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1104;
new_r10=0;
IkReal gconst12=x1104;
IkReal x1106 = new_r00*new_r00;
if(IKabs(x1106)==0){
continue;
}
IkReal gconst13=(new_r00*(pow(x1106,-0.5)));
IkReal gconst14=0;
j5eval[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
CheckValue<IkReal> x1108 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1108.valid){
continue;
}
IkReal x1107=((-1.0)*(x1108.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst13;
cj7=gconst14;
j7=x1107;
new_r10=0;
IkReal gconst12=x1107;
IkReal x1109 = new_r00*new_r00;
if(IKabs(x1109)==0){
continue;
}
IkReal gconst13=(new_r00*(pow(x1109,-0.5)));
IkReal gconst14=0;
j5eval[0]=new_r00;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1110=IKPowWithIntegerCheck(new_r00,-1);
if(!x1110.valid){
continue;
}
CheckValue<IkReal> x1111=IKPowWithIntegerCheck(gconst13,-1);
if(!x1111.valid){
continue;
}
if( IKabs(((-1.0)*gconst13*(x1110.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r01*(x1111.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst13*(x1110.value)))+IKsqr((new_r01*(x1111.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst13*(x1110.value)), (new_r01*(x1111.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1112=IKcos(j5);
IkReal x1113=IKsin(j5);
IkReal x1114=((1.0)*gconst13);
evalcond[0]=(new_r00*x1112);
evalcond[1]=((-1.0)*gconst13*x1112);
evalcond[2]=(gconst13+((new_r00*x1113)));
evalcond[3]=(((gconst13*x1113))+new_r00);
evalcond[4]=((((-1.0)*x1112*x1114))+new_r01);
evalcond[5]=((((-1.0)*x1113*x1114))+new_r11);
evalcond[6]=(((new_r01*x1113))+(((-1.0)*new_r11*x1112)));
evalcond[7]=(((new_r11*x1113))+((new_r01*x1112))+(((-1.0)*x1114)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1115 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x1115.valid){
continue;
}
CheckValue<IkReal> x1116=IKPowWithIntegerCheck(IKsign(gconst13),-1);
if(!x1116.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1115.value)+(((1.5707963267949)*(x1116.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1117=IKcos(j5);
IkReal x1118=IKsin(j5);
IkReal x1119=((1.0)*gconst13);
evalcond[0]=(new_r00*x1117);
evalcond[1]=((-1.0)*gconst13*x1117);
evalcond[2]=(gconst13+((new_r00*x1118)));
evalcond[3]=(((gconst13*x1118))+new_r00);
evalcond[4]=(new_r01+(((-1.0)*x1117*x1119)));
evalcond[5]=(new_r11+(((-1.0)*x1118*x1119)));
evalcond[6]=(((new_r01*x1118))+(((-1.0)*new_r11*x1117)));
evalcond[7]=(((new_r11*x1118))+((new_r01*x1117))+(((-1.0)*x1119)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1120 = IKatan2WithCheck(IkReal(new_r11),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x1120.valid){
continue;
}
CheckValue<IkReal> x1121=IKPowWithIntegerCheck(IKsign(gconst13),-1);
if(!x1121.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1120.value)+(((1.5707963267949)*(x1121.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1122=IKcos(j5);
IkReal x1123=IKsin(j5);
IkReal x1124=((1.0)*gconst13);
evalcond[0]=(new_r00*x1122);
evalcond[1]=((-1.0)*gconst13*x1122);
evalcond[2]=(gconst13+((new_r00*x1123)));
evalcond[3]=(((gconst13*x1123))+new_r00);
evalcond[4]=((((-1.0)*x1122*x1124))+new_r01);
evalcond[5]=((((-1.0)*x1123*x1124))+new_r11);
evalcond[6]=(((new_r01*x1123))+(((-1.0)*new_r11*x1122)));
evalcond[7]=(((new_r01*x1122))+(((-1.0)*x1124))+((new_r11*x1123)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1125=((1.0)*gconst14);
CheckValue<IkReal> x1126=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r10*x1125))+((gconst13*new_r00)))),-1);
if(!x1126.valid){
continue;
}
CheckValue<IkReal> x1127 = IKatan2WithCheck(IkReal(((gconst14*gconst14)+(((-1.0)*(new_r00*new_r00))))),IkReal(((((-1.0)*gconst13*x1125))+((new_r00*new_r10)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1127.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1126.value)))+(x1127.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1128=IKsin(j5);
IkReal x1129=IKcos(j5);
IkReal x1130=((1.0)*gconst13);
IkReal x1131=(gconst14*x1128);
IkReal x1132=(gconst14*x1129);
IkReal x1133=((1.0)*x1129);
IkReal x1134=(x1129*x1130);
evalcond[0]=(gconst14+((new_r10*x1128))+((new_r00*x1129)));
evalcond[1]=(x1132+((gconst13*x1128))+new_r00);
evalcond[2]=(gconst13+(((-1.0)*new_r10*x1133))+((new_r00*x1128)));
evalcond[3]=((((-1.0)*new_r11*x1133))+gconst14+((new_r01*x1128)));
evalcond[4]=(x1131+(((-1.0)*x1134))+new_r01);
evalcond[5]=(x1131+(((-1.0)*x1134))+new_r10);
evalcond[6]=((((-1.0)*x1130))+((new_r01*x1129))+((new_r11*x1128)));
evalcond[7]=((((-1.0)*x1132))+(((-1.0)*x1128*x1130))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1135=((1.0)*gconst14);
CheckValue<IkReal> x1136 = IKatan2WithCheck(IkReal(((gconst14*gconst14)+((new_r00*new_r11)))),IkReal(((((-1.0)*gconst13*x1135))+((new_r00*new_r01)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1136.valid){
continue;
}
CheckValue<IkReal> x1137=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst13*new_r11))+(((-1.0)*new_r01*x1135)))),-1);
if(!x1137.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1136.value)+(((1.5707963267949)*(x1137.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1138=IKsin(j5);
IkReal x1139=IKcos(j5);
IkReal x1140=((1.0)*gconst13);
IkReal x1141=(gconst14*x1138);
IkReal x1142=(gconst14*x1139);
IkReal x1143=((1.0)*x1139);
IkReal x1144=(x1139*x1140);
evalcond[0]=(gconst14+((new_r00*x1139))+((new_r10*x1138)));
evalcond[1]=(x1142+((gconst13*x1138))+new_r00);
evalcond[2]=(gconst13+((new_r00*x1138))+(((-1.0)*new_r10*x1143)));
evalcond[3]=(gconst14+(((-1.0)*new_r11*x1143))+((new_r01*x1138)));
evalcond[4]=(x1141+(((-1.0)*x1144))+new_r01);
evalcond[5]=(x1141+(((-1.0)*x1144))+new_r10);
evalcond[6]=((((-1.0)*x1140))+((new_r11*x1138))+((new_r01*x1139)));
evalcond[7]=((((-1.0)*x1142))+new_r11+(((-1.0)*x1138*x1140)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1145=((1.0)*new_r10);
CheckValue<IkReal> x1146 = IKatan2WithCheck(IkReal((((gconst14*new_r00))+((gconst14*new_r11)))),IkReal((((gconst14*new_r01))+(((-1.0)*gconst14*x1145)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1146.valid){
continue;
}
CheckValue<IkReal> x1147=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r11*x1145))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x1147.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1146.value)+(((1.5707963267949)*(x1147.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1148=IKsin(j5);
IkReal x1149=IKcos(j5);
IkReal x1150=((1.0)*gconst13);
IkReal x1151=(gconst14*x1148);
IkReal x1152=(gconst14*x1149);
IkReal x1153=((1.0)*x1149);
IkReal x1154=(x1149*x1150);
evalcond[0]=(((new_r00*x1149))+gconst14+((new_r10*x1148)));
evalcond[1]=(x1152+((gconst13*x1148))+new_r00);
evalcond[2]=(((new_r00*x1148))+gconst13+(((-1.0)*new_r10*x1153)));
evalcond[3]=(gconst14+((new_r01*x1148))+(((-1.0)*new_r11*x1153)));
evalcond[4]=(x1151+(((-1.0)*x1154))+new_r01);
evalcond[5]=(x1151+(((-1.0)*x1154))+new_r10);
evalcond[6]=((((-1.0)*x1150))+((new_r01*x1149))+((new_r11*x1148)));
evalcond[7]=((((-1.0)*x1152))+(((-1.0)*x1148*x1150))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1155=((-1.0)*new_r00);
IkReal x1157 = ((new_r10*new_r10)+(new_r00*new_r00));
if(IKabs(x1157)==0){
continue;
}
IkReal x1156=pow(x1157,-0.5);
CheckValue<IkReal> x1158 = IKatan2WithCheck(IkReal(x1155),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1158.valid){
continue;
}
IkReal gconst15=((3.14159265358979)+(((-1.0)*(x1158.value))));
IkReal gconst16=(x1155*x1156);
IkReal gconst17=((1.0)*new_r10*x1156);
CheckValue<IkReal> x1159 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1159.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+(x1159.value)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x1160=((-1.0)*new_r00);
CheckValue<IkReal> x1163 = IKatan2WithCheck(IkReal(x1160),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1163.valid){
continue;
}
IkReal x1161=((1.0)*(x1163.value));
IkReal x1162=x1156;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1161)));
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1161)));
IkReal gconst16=(x1160*x1162);
IkReal gconst17=((1.0)*new_r10*x1162);
IkReal x1164=new_r10*new_r10;
IkReal x1165=(new_r10*new_r11);
IkReal x1166=((((-1.0)*new_r00*new_r01))+(((-1.0)*x1165)));
IkReal x1167=x1156;
IkReal x1168=(new_r10*x1167);
j5eval[0]=x1166;
j5eval[1]=((IKabs((((x1165*x1167))+((new_r00*x1168)))))+(IKabs(((((-1.0)*x1164*x1167))+((new_r01*x1168))))));
j5eval[2]=IKsign(x1166);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1169=((-1.0)*new_r00);
CheckValue<IkReal> x1172 = IKatan2WithCheck(IkReal(x1169),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1172.valid){
continue;
}
IkReal x1170=((1.0)*(x1172.value));
IkReal x1171=x1156;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1170)));
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1170)));
IkReal gconst16=(x1169*x1171);
IkReal gconst17=((1.0)*new_r10*x1171);
IkReal x1173=new_r10*new_r10;
IkReal x1174=new_r00*new_r00*new_r00;
CheckValue<IkReal> x1178=IKPowWithIntegerCheck((x1173+(new_r00*new_r00)),-1);
if(!x1178.valid){
continue;
}
IkReal x1175=x1178.value;
IkReal x1176=(x1173*x1175);
IkReal x1177=(x1174*x1175);
j5eval[0]=((IKabs((((new_r00*new_r01*x1176))+((new_r01*x1177))+((new_r00*new_r10*x1175)))))+(IKabs((((new_r00*new_r11*x1176))+x1176+((new_r11*x1177))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1179=((-1.0)*new_r00);
CheckValue<IkReal> x1182 = IKatan2WithCheck(IkReal(x1179),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1182.valid){
continue;
}
IkReal x1180=((1.0)*(x1182.value));
IkReal x1181=x1156;
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1180)));
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1180)));
IkReal gconst16=(x1179*x1181);
IkReal gconst17=((1.0)*new_r10*x1181);
IkReal x1183=new_r10*new_r10;
IkReal x1184=new_r00*new_r00;
CheckValue<IkReal> x1188=IKPowWithIntegerCheck((x1184+x1183),-1);
if(!x1188.valid){
continue;
}
IkReal x1185=x1188.value;
IkReal x1186=(new_r10*x1185);
IkReal x1187=(x1183*x1185);
j5eval[0]=((IKabs((x1187+(((-1.0)*x1184*x1187))+(((-1.0)*x1185*(x1184*x1184))))))+(IKabs((((x1186*(new_r00*new_r00*new_r00)))+((new_r00*x1186))+((new_r00*x1186*(new_r10*new_r10)))))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
CheckValue<IkReal> x1190 = IKatan2WithCheck(IkReal(0),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1190.valid){
continue;
}
IkReal x1189=((1.0)*(x1190.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1189)));
new_r11=0;
new_r00=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1189)));
IkReal gconst16=0;
IkReal x1191 = new_r10*new_r10;
if(IKabs(x1191)==0){
continue;
}
IkReal gconst17=((1.0)*new_r10*(pow(x1191,-0.5)));
j5eval[0]=new_r01;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1192=IKPowWithIntegerCheck(gconst17,-1);
if(!x1192.valid){
continue;
}
sj5array[0]=((-1.0)*new_r01*(x1192.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1193=IKcos(j5);
IkReal x1194=IKsin(j5);
evalcond[0]=(new_r01*x1193);
evalcond[1]=(gconst17*x1193);
evalcond[2]=((-1.0)*new_r10*x1193);
evalcond[3]=(gconst17+((new_r01*x1194)));
evalcond[4]=(gconst17+((new_r10*x1194)));
evalcond[5]=(((gconst17*x1194))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1195=IKPowWithIntegerCheck(new_r01,-1);
if(!x1195.valid){
continue;
}
sj5array[0]=((-1.0)*gconst17*(x1195.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1196=IKcos(j5);
IkReal x1197=IKsin(j5);
IkReal x1198=(gconst17*x1197);
evalcond[0]=(new_r01*x1196);
evalcond[1]=(gconst17*x1196);
evalcond[2]=((-1.0)*new_r10*x1196);
evalcond[3]=(x1198+new_r01);
evalcond[4]=(gconst17+((new_r10*x1197)));
evalcond[5]=(x1198+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
evalcond[1]=gconst17;
evalcond[2]=gconst16;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
IkReal x1199=((-1.0)*new_r00);
CheckValue<IkReal> x1201 = IKatan2WithCheck(IkReal(x1199),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1201.valid){
continue;
}
IkReal x1200=((1.0)*(x1201.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1200)));
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1200)));
IkReal gconst16=x1199;
IkReal gconst17=((1.0)*new_r10);
j5eval[0]=1.0;
j5eval[1]=1.0;
j5eval[2]=((IKabs(((1.0)+(((-1.0)*(new_r10*new_r10))))))+(IKabs(((1.0)*new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x1202=((-1.0)*new_r00);
CheckValue<IkReal> x1204 = IKatan2WithCheck(IkReal(x1202),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1204.valid){
continue;
}
IkReal x1203=((1.0)*(x1204.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1203)));
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1203)));
IkReal gconst16=x1202;
IkReal gconst17=((1.0)*new_r10);
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((1.0)*new_r00*new_r10)))+(IKabs(((-1.0)+(new_r10*new_r10)))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
IkReal x1205=((-1.0)*new_r00);
CheckValue<IkReal> x1207 = IKatan2WithCheck(IkReal(x1205),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x1207.valid){
continue;
}
IkReal x1206=((1.0)*(x1207.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1206)));
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1206)));
IkReal gconst16=x1205;
IkReal gconst17=((1.0)*new_r10);
j5eval[0]=-1.0;
j5eval[1]=-1.0;
j5eval[2]=((IKabs(((-1.0)+(((2.0)*(new_r10*new_r10))))))+(IKabs(((2.0)*new_r00*new_r10))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1208=((1.0)*gconst17);
CheckValue<IkReal> x1209 = IKatan2WithCheck(IkReal(((((-1.0)*(new_r00*new_r00)))+(gconst17*gconst17))),IkReal((((new_r00*new_r10))+(((-1.0)*gconst16*x1208)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1209.valid){
continue;
}
CheckValue<IkReal> x1210=IKPowWithIntegerCheck(IKsign((((gconst16*new_r00))+(((-1.0)*new_r10*x1208)))),-1);
if(!x1210.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1209.value)+(((1.5707963267949)*(x1210.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1211=IKsin(j5);
IkReal x1212=IKcos(j5);
IkReal x1213=((1.0)*gconst16);
IkReal x1214=(gconst17*x1211);
IkReal x1215=((1.0)*x1212);
IkReal x1216=(x1212*x1213);
evalcond[0]=(x1214+(((-1.0)*x1216)));
evalcond[1]=(((new_r10*x1211))+gconst17+((new_r00*x1212)));
evalcond[2]=(new_r00+((gconst16*x1211))+((gconst17*x1212)));
evalcond[3]=(gconst16+((new_r00*x1211))+(((-1.0)*new_r10*x1215)));
evalcond[4]=((((-1.0)*gconst17*x1215))+(((-1.0)*x1211*x1213)));
evalcond[5]=(x1214+new_r10+(((-1.0)*x1216)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1217=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst17*gconst17)))+(((-1.0)*(gconst16*gconst16))))),-1);
if(!x1217.valid){
continue;
}
CheckValue<IkReal> x1218 = IKatan2WithCheck(IkReal((gconst16*new_r00)),IkReal((gconst17*new_r00)),IKFAST_ATAN2_MAGTHRESH);
if(!x1218.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1217.value)))+(x1218.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1219=IKsin(j5);
IkReal x1220=IKcos(j5);
IkReal x1221=((1.0)*gconst16);
IkReal x1222=(gconst17*x1219);
IkReal x1223=((1.0)*x1220);
IkReal x1224=(x1220*x1221);
evalcond[0]=(x1222+(((-1.0)*x1224)));
evalcond[1]=(((new_r10*x1219))+gconst17+((new_r00*x1220)));
evalcond[2]=(((gconst17*x1220))+new_r00+((gconst16*x1219)));
evalcond[3]=(gconst16+((new_r00*x1219))+(((-1.0)*new_r10*x1223)));
evalcond[4]=((((-1.0)*gconst17*x1223))+(((-1.0)*x1219*x1221)));
evalcond[5]=(x1222+(((-1.0)*x1224))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1225=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst16*new_r00))+((gconst17*new_r10)))),-1);
if(!x1225.valid){
continue;
}
CheckValue<IkReal> x1226 = IKatan2WithCheck(IkReal(gconst16*gconst16),IkReal((gconst16*gconst17)),IKFAST_ATAN2_MAGTHRESH);
if(!x1226.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1225.value)))+(x1226.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1227=IKsin(j5);
IkReal x1228=IKcos(j5);
IkReal x1229=((1.0)*gconst16);
IkReal x1230=(gconst17*x1227);
IkReal x1231=((1.0)*x1228);
IkReal x1232=(x1228*x1229);
evalcond[0]=(x1230+(((-1.0)*x1232)));
evalcond[1]=(gconst17+((new_r00*x1228))+((new_r10*x1227)));
evalcond[2]=(((gconst17*x1228))+((gconst16*x1227))+new_r00);
evalcond[3]=(gconst16+((new_r00*x1227))+(((-1.0)*new_r10*x1231)));
evalcond[4]=((((-1.0)*x1227*x1229))+(((-1.0)*gconst17*x1231)));
evalcond[5]=(x1230+(((-1.0)*x1232))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1233=IKPowWithIntegerCheck(gconst16,-1);
if(!x1233.valid){
continue;
}
sj5array[0]=(new_r11*(x1233.value));
if( sj5array[0] >= -1-IKFAST_SINCOS_THRESH && sj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKasin(sj5array[0]);
cj5array[0] = IKcos(j5array[0]);
sj5array[1] = sj5array[0];
j5array[1] = j5array[0] > 0 ? (IKPI-j5array[0]) : (-IKPI-j5array[0]);
cj5array[1] = -cj5array[0];
}
else if( isnan(sj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1234=IKcos(j5);
IkReal x1235=IKsin(j5);
IkReal x1236=((-1.0)*x1234);
evalcond[0]=(new_r00*x1234);
evalcond[1]=(new_r11*x1236);
evalcond[2]=(gconst16*x1236);
evalcond[3]=(gconst16+((new_r00*x1235)));
evalcond[4]=(((gconst16*x1235))+new_r00);
evalcond[5]=(((new_r11*x1235))+(((-1.0)*gconst16)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
IkReal x1237=((-1.0)*new_r00);
CheckValue<IkReal> x1239 = IKatan2WithCheck(IkReal(x1237),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1239.valid){
continue;
}
IkReal x1238=((1.0)*(x1239.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1238)));
new_r11=0;
new_r10=0;
new_r22=0;
new_r02=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1238)));
IkReal x1240 = ((1.0)+(((-1.0)*(new_r01*new_r01))));
if(IKabs(x1240)==0){
continue;
}
IkReal gconst16=(x1237*(pow(x1240,-0.5)));
IkReal gconst17=0;
j5eval[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1241=((-1.0)*new_r00);
CheckValue<IkReal> x1243 = IKatan2WithCheck(IkReal(x1241),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1243.valid){
continue;
}
IkReal x1242=((1.0)*(x1243.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1242)));
new_r11=0;
new_r10=0;
new_r22=0;
new_r02=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1242)));
IkReal x1244 = ((1.0)+(((-1.0)*(new_r01*new_r01))));
if(IKabs(x1244)==0){
continue;
}
IkReal gconst16=(x1241*(pow(x1244,-0.5)));
IkReal gconst17=0;
j5eval[0]=new_r00;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
IkReal x1245=((-1.0)*new_r00);
CheckValue<IkReal> x1247 = IKatan2WithCheck(IkReal(x1245),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1247.valid){
continue;
}
IkReal x1246=((1.0)*(x1247.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1246)));
new_r11=0;
new_r10=0;
new_r22=0;
new_r02=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1246)));
IkReal x1248 = ((1.0)+(((-1.0)*(new_r01*new_r01))));
if(IKabs(x1248)==0){
continue;
}
IkReal gconst16=(x1245*(pow(x1248,-0.5)));
IkReal gconst17=0;
j5eval[0]=new_r00;
j5eval[1]=new_r01;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1249=IKPowWithIntegerCheck(new_r00,-1);
if(!x1249.valid){
continue;
}
CheckValue<IkReal> x1250=IKPowWithIntegerCheck(new_r01,-1);
if(!x1250.valid){
continue;
}
if( IKabs(((-1.0)*gconst16*(x1249.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((gconst16*(x1250.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst16*(x1249.value)))+IKsqr((gconst16*(x1250.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst16*(x1249.value)), (gconst16*(x1250.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1251=IKsin(j5);
IkReal x1252=IKcos(j5);
IkReal x1253=((1.0)*gconst16);
IkReal x1254=(gconst16*x1251);
evalcond[0]=(new_r01*x1251);
evalcond[1]=(new_r00*x1252);
evalcond[2]=((-1.0)*x1254);
evalcond[3]=((-1.0)*gconst16*x1252);
evalcond[4]=(((new_r00*x1251))+gconst16);
evalcond[5]=(x1254+new_r00);
evalcond[6]=((((-1.0)*x1252*x1253))+new_r01);
evalcond[7]=((((-1.0)*x1253))+((new_r01*x1252)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1255=IKPowWithIntegerCheck(new_r00,-1);
if(!x1255.valid){
continue;
}
CheckValue<IkReal> x1256=IKPowWithIntegerCheck(gconst16,-1);
if(!x1256.valid){
continue;
}
if( IKabs(((-1.0)*gconst16*(x1255.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r01*(x1256.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst16*(x1255.value)))+IKsqr((new_r01*(x1256.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst16*(x1255.value)), (new_r01*(x1256.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1257=IKsin(j5);
IkReal x1258=IKcos(j5);
IkReal x1259=((1.0)*gconst16);
IkReal x1260=(gconst16*x1257);
evalcond[0]=(new_r01*x1257);
evalcond[1]=(new_r00*x1258);
evalcond[2]=((-1.0)*x1260);
evalcond[3]=((-1.0)*gconst16*x1258);
evalcond[4]=(((new_r00*x1257))+gconst16);
evalcond[5]=(x1260+new_r00);
evalcond[6]=((((-1.0)*x1258*x1259))+new_r01);
evalcond[7]=((((-1.0)*x1259))+((new_r01*x1258)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1261 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x1261.valid){
continue;
}
CheckValue<IkReal> x1262=IKPowWithIntegerCheck(IKsign(gconst16),-1);
if(!x1262.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1261.value)+(((1.5707963267949)*(x1262.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1263=IKsin(j5);
IkReal x1264=IKcos(j5);
IkReal x1265=((1.0)*gconst16);
IkReal x1266=(gconst16*x1263);
evalcond[0]=(new_r01*x1263);
evalcond[1]=(new_r00*x1264);
evalcond[2]=((-1.0)*x1266);
evalcond[3]=((-1.0)*gconst16*x1264);
evalcond[4]=(gconst16+((new_r00*x1263)));
evalcond[5]=(x1266+new_r00);
evalcond[6]=((((-1.0)*x1264*x1265))+new_r01);
evalcond[7]=(((new_r01*x1264))+(((-1.0)*x1265)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r10);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
IkReal x1267=((-1.0)*new_r00);
CheckValue<IkReal> x1269 = IKatan2WithCheck(IkReal(x1267),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1269.valid){
continue;
}
IkReal x1268=((1.0)*(x1269.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1268)));
new_r10=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1268)));
IkReal x1270 = new_r00*new_r00;
if(IKabs(x1270)==0){
continue;
}
IkReal gconst16=(x1267*(pow(x1270,-0.5)));
IkReal gconst17=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1271=((-1.0)*new_r00);
CheckValue<IkReal> x1273 = IKatan2WithCheck(IkReal(x1271),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1273.valid){
continue;
}
IkReal x1272=((1.0)*(x1273.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1272)));
new_r10=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1272)));
IkReal x1274 = new_r00*new_r00;
if(IKabs(x1274)==0){
continue;
}
IkReal gconst16=(x1271*(pow(x1274,-0.5)));
IkReal gconst17=0;
j5eval[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x1275=((-1.0)*new_r00);
CheckValue<IkReal> x1277 = IKatan2WithCheck(IkReal(x1275),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x1277.valid){
continue;
}
IkReal x1276=((1.0)*(x1277.value));
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
sj7=gconst16;
cj7=gconst17;
j7=((3.14159265)+(((-1.0)*x1276)));
new_r10=0;
IkReal gconst15=((3.14159265358979)+(((-1.0)*x1276)));
IkReal x1278 = new_r00*new_r00;
if(IKabs(x1278)==0){
continue;
}
IkReal gconst16=(x1275*(pow(x1278,-0.5)));
IkReal gconst17=0;
j5eval[0]=new_r00;
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1279=IKPowWithIntegerCheck(new_r00,-1);
if(!x1279.valid){
continue;
}
CheckValue<IkReal> x1280=IKPowWithIntegerCheck(gconst16,-1);
if(!x1280.valid){
continue;
}
if( IKabs(((-1.0)*gconst16*(x1279.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r01*(x1280.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*gconst16*(x1279.value)))+IKsqr((new_r01*(x1280.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*gconst16*(x1279.value)), (new_r01*(x1280.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1281=IKcos(j5);
IkReal x1282=IKsin(j5);
IkReal x1283=(gconst16*x1282);
IkReal x1284=((1.0)*x1281);
evalcond[0]=(new_r00*x1281);
evalcond[1]=((-1.0)*gconst16*x1281);
evalcond[2]=(gconst16+((new_r00*x1282)));
evalcond[3]=(x1283+new_r00);
evalcond[4]=(new_r01+(((-1.0)*gconst16*x1284)));
evalcond[5]=((((-1.0)*x1283))+new_r11);
evalcond[6]=(((new_r01*x1282))+(((-1.0)*new_r11*x1284)));
evalcond[7]=(((new_r11*x1282))+((new_r01*x1281))+(((-1.0)*gconst16)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1285 = IKatan2WithCheck(IkReal(((-1.0)*new_r00)),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x1285.valid){
continue;
}
CheckValue<IkReal> x1286=IKPowWithIntegerCheck(IKsign(gconst16),-1);
if(!x1286.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1285.value)+(((1.5707963267949)*(x1286.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1287=IKcos(j5);
IkReal x1288=IKsin(j5);
IkReal x1289=(gconst16*x1288);
IkReal x1290=((1.0)*x1287);
evalcond[0]=(new_r00*x1287);
evalcond[1]=((-1.0)*gconst16*x1287);
evalcond[2]=(gconst16+((new_r00*x1288)));
evalcond[3]=(x1289+new_r00);
evalcond[4]=((((-1.0)*gconst16*x1290))+new_r01);
evalcond[5]=((((-1.0)*x1289))+new_r11);
evalcond[6]=((((-1.0)*new_r11*x1290))+((new_r01*x1288)));
evalcond[7]=(((new_r11*x1288))+((new_r01*x1287))+(((-1.0)*gconst16)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1291=IKPowWithIntegerCheck(IKsign(gconst16),-1);
if(!x1291.valid){
continue;
}
CheckValue<IkReal> x1292 = IKatan2WithCheck(IkReal(new_r11),IkReal(new_r01),IKFAST_ATAN2_MAGTHRESH);
if(!x1292.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1291.value)))+(x1292.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1293=IKcos(j5);
IkReal x1294=IKsin(j5);
IkReal x1295=(gconst16*x1294);
IkReal x1296=((1.0)*x1293);
evalcond[0]=(new_r00*x1293);
evalcond[1]=((-1.0)*gconst16*x1293);
evalcond[2]=(gconst16+((new_r00*x1294)));
evalcond[3]=(x1295+new_r00);
evalcond[4]=((((-1.0)*gconst16*x1296))+new_r01);
evalcond[5]=((((-1.0)*x1295))+new_r11);
evalcond[6]=((((-1.0)*new_r11*x1296))+((new_r01*x1294)));
evalcond[7]=(((new_r11*x1294))+(((-1.0)*gconst16))+((new_r01*x1293)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1297=((1.0)*gconst17);
CheckValue<IkReal> x1298=IKPowWithIntegerCheck(IKsign((((gconst16*new_r00))+(((-1.0)*new_r10*x1297)))),-1);
if(!x1298.valid){
continue;
}
CheckValue<IkReal> x1299 = IKatan2WithCheck(IkReal(((((-1.0)*(new_r00*new_r00)))+(gconst17*gconst17))),IkReal(((((-1.0)*gconst16*x1297))+((new_r00*new_r10)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1299.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1298.value)))+(x1299.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1300=IKcos(j5);
IkReal x1301=IKsin(j5);
IkReal x1302=(gconst17*x1301);
IkReal x1303=((1.0)*x1300);
IkReal x1304=(gconst16*x1301);
IkReal x1305=(gconst16*x1303);
evalcond[0]=(gconst17+((new_r10*x1301))+((new_r00*x1300)));
evalcond[1]=(x1304+((gconst17*x1300))+new_r00);
evalcond[2]=((((-1.0)*new_r10*x1303))+gconst16+((new_r00*x1301)));
evalcond[3]=(gconst17+((new_r01*x1301))+(((-1.0)*new_r11*x1303)));
evalcond[4]=(x1302+(((-1.0)*x1305))+new_r01);
evalcond[5]=(x1302+(((-1.0)*x1305))+new_r10);
evalcond[6]=(((new_r11*x1301))+(((-1.0)*gconst16))+((new_r01*x1300)));
evalcond[7]=((((-1.0)*x1304))+(((-1.0)*gconst17*x1303))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1306=((1.0)*gconst17);
CheckValue<IkReal> x1307 = IKatan2WithCheck(IkReal((((new_r00*new_r11))+(gconst17*gconst17))),IkReal(((((-1.0)*gconst16*x1306))+((new_r00*new_r01)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1307.valid){
continue;
}
CheckValue<IkReal> x1308=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst16*new_r11))+(((-1.0)*new_r01*x1306)))),-1);
if(!x1308.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1307.value)+(((1.5707963267949)*(x1308.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1309=IKcos(j5);
IkReal x1310=IKsin(j5);
IkReal x1311=(gconst17*x1310);
IkReal x1312=((1.0)*x1309);
IkReal x1313=(gconst16*x1310);
IkReal x1314=(gconst16*x1312);
evalcond[0]=(gconst17+((new_r10*x1310))+((new_r00*x1309)));
evalcond[1]=(x1313+((gconst17*x1309))+new_r00);
evalcond[2]=((((-1.0)*new_r10*x1312))+((new_r00*x1310))+gconst16);
evalcond[3]=(((new_r01*x1310))+(((-1.0)*new_r11*x1312))+gconst17);
evalcond[4]=(x1311+(((-1.0)*x1314))+new_r01);
evalcond[5]=(x1311+(((-1.0)*x1314))+new_r10);
evalcond[6]=(((new_r11*x1310))+(((-1.0)*gconst16))+((new_r01*x1309)));
evalcond[7]=((((-1.0)*x1313))+(((-1.0)*gconst17*x1312))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1315=((1.0)*new_r10);
CheckValue<IkReal> x1316=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r11*x1315))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x1316.valid){
continue;
}
CheckValue<IkReal> x1317 = IKatan2WithCheck(IkReal((((gconst17*new_r11))+((gconst17*new_r00)))),IkReal(((((-1.0)*gconst17*x1315))+((gconst17*new_r01)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1317.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1316.value)))+(x1317.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1318=IKcos(j5);
IkReal x1319=IKsin(j5);
IkReal x1320=(gconst17*x1319);
IkReal x1321=((1.0)*x1318);
IkReal x1322=(gconst16*x1319);
IkReal x1323=(gconst16*x1321);
evalcond[0]=(((new_r00*x1318))+gconst17+((new_r10*x1319)));
evalcond[1]=(x1322+((gconst17*x1318))+new_r00);
evalcond[2]=(((new_r00*x1319))+(((-1.0)*new_r10*x1321))+gconst16);
evalcond[3]=(((new_r01*x1319))+(((-1.0)*new_r11*x1321))+gconst17);
evalcond[4]=(x1320+(((-1.0)*x1323))+new_r01);
evalcond[5]=(x1320+(((-1.0)*x1323))+new_r10);
evalcond[6]=(((new_r01*x1318))+((new_r11*x1319))+(((-1.0)*gconst16)));
evalcond[7]=((((-1.0)*x1322))+(((-1.0)*gconst17*x1321))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
if( IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r01) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r00))+IKsqr(new_r01)-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*new_r00), new_r01);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1324=IKsin(j5);
IkReal x1325=IKcos(j5);
IkReal x1326=((1.0)*x1325);
evalcond[0]=(x1324+new_r00);
evalcond[1]=((((-1.0)*x1326))+new_r01);
evalcond[2]=((((-1.0)*x1324))+new_r11);
evalcond[3]=((((-1.0)*x1326))+new_r10);
evalcond[4]=(((new_r00*x1325))+((new_r10*x1324)));
evalcond[5]=(((new_r01*x1324))+(((-1.0)*new_r11*x1326)));
evalcond[6]=((-1.0)+((new_r01*x1325))+((new_r11*x1324)));
evalcond[7]=((1.0)+((new_r00*x1324))+(((-1.0)*new_r10*x1326)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j7)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
if( IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r11))+IKsqr(((-1.0)*new_r01))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*new_r11), ((-1.0)*new_r01));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1327=IKcos(j5);
IkReal x1328=IKsin(j5);
IkReal x1329=((1.0)*x1327);
evalcond[0]=(x1327+new_r01);
evalcond[1]=(x1328+new_r11);
evalcond[2]=(x1327+new_r10);
evalcond[3]=((((-1.0)*x1328))+new_r00);
evalcond[4]=(((new_r00*x1327))+((new_r10*x1328)));
evalcond[5]=(((new_r01*x1328))+(((-1.0)*new_r11*x1329)));
evalcond[6]=((1.0)+((new_r01*x1327))+((new_r11*x1328)));
evalcond[7]=((-1.0)+((new_r00*x1328))+(((-1.0)*new_r10*x1329)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r11=0;
new_r00=0;
j5eval[0]=new_r10;
j5eval[1]=IKsign(new_r10);
j5eval[2]=((IKabs(cj7))+(IKabs(sj7)));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[3];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r11=0;
new_r00=0;
j5eval[0]=new_r01;
j5eval[1]=IKsign(new_r01);
j5eval[2]=((IKabs(cj7))+(IKabs(sj7)));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r11=0;
new_r00=0;
j5eval[0]=new_r01;
j5eval[1]=new_r10;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1330=IKPowWithIntegerCheck(new_r01,-1);
if(!x1330.valid){
continue;
}
CheckValue<IkReal> x1331=IKPowWithIntegerCheck(new_r10,-1);
if(!x1331.valid){
continue;
}
if( IKabs(((-1.0)*cj7*(x1330.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((sj7*(x1331.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*cj7*(x1330.value)))+IKsqr((sj7*(x1331.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*cj7*(x1330.value)), (sj7*(x1331.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x1332=IKsin(j5);
IkReal x1333=IKcos(j5);
IkReal x1334=(cj7*x1332);
IkReal x1335=((1.0)*x1333);
IkReal x1336=(sj7*x1335);
evalcond[0]=(cj7+((new_r01*x1332)));
evalcond[1]=(cj7+((new_r10*x1332)));
evalcond[2]=(sj7+(((-1.0)*new_r10*x1335)));
evalcond[3]=((((-1.0)*sj7))+((new_r01*x1333)));
evalcond[4]=(((cj7*x1333))+((sj7*x1332)));
evalcond[5]=(x1334+new_r01+(((-1.0)*x1336)));
evalcond[6]=(x1334+new_r10+(((-1.0)*x1336)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1337=IKPowWithIntegerCheck(IKsign(new_r01),-1);
if(!x1337.valid){
continue;
}
CheckValue<IkReal> x1338 = IKatan2WithCheck(IkReal(((-1.0)*cj7)),IkReal(sj7),IKFAST_ATAN2_MAGTHRESH);
if(!x1338.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1337.value)))+(x1338.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x1339=IKsin(j5);
IkReal x1340=IKcos(j5);
IkReal x1341=(cj7*x1339);
IkReal x1342=((1.0)*x1340);
IkReal x1343=(sj7*x1342);
evalcond[0]=(cj7+((new_r01*x1339)));
evalcond[1]=(cj7+((new_r10*x1339)));
evalcond[2]=(sj7+(((-1.0)*new_r10*x1342)));
evalcond[3]=((((-1.0)*sj7))+((new_r01*x1340)));
evalcond[4]=(((sj7*x1339))+((cj7*x1340)));
evalcond[5]=(x1341+(((-1.0)*x1343))+new_r01);
evalcond[6]=(x1341+(((-1.0)*x1343))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1344=IKPowWithIntegerCheck(IKsign(new_r10),-1);
if(!x1344.valid){
continue;
}
CheckValue<IkReal> x1345 = IKatan2WithCheck(IkReal(((-1.0)*cj7)),IkReal(sj7),IKFAST_ATAN2_MAGTHRESH);
if(!x1345.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1344.value)))+(x1345.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x1346=IKsin(j5);
IkReal x1347=IKcos(j5);
IkReal x1348=(cj7*x1346);
IkReal x1349=((1.0)*x1347);
IkReal x1350=(sj7*x1349);
evalcond[0]=(cj7+((new_r01*x1346)));
evalcond[1]=(cj7+((new_r10*x1346)));
evalcond[2]=(sj7+(((-1.0)*new_r10*x1349)));
evalcond[3]=((((-1.0)*sj7))+((new_r01*x1347)));
evalcond[4]=(((sj7*x1346))+((cj7*x1347)));
evalcond[5]=(x1348+(((-1.0)*x1350))+new_r01);
evalcond[6]=(x1348+(((-1.0)*x1350))+new_r10);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
j5eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1352 = IKatan2WithCheck(IkReal(new_r00),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x1352.valid){
continue;
}
IkReal x1351=x1352.value;
j5array[0]=((-1.0)*x1351);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1351)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r10*(IKcos(j5))))+((new_r00*(IKsin(j5)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1354 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x1354.valid){
continue;
}
IkReal x1353=x1354.value;
j5array[0]=((-1.0)*x1353);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1353)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r11*(IKcos(j5))))+((new_r01*(IKsin(j5)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[3];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r01=0;
new_r10=0;
j5eval[0]=new_r00;
j5eval[1]=((IKabs(cj7))+(IKabs(sj7)));
j5eval[2]=IKsign(new_r00);
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 || IKabs(j5eval[2]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
sj6=0;
cj6=-1.0;
j6=3.14159265358979;
new_r01=0;
new_r10=0;
j5eval[0]=new_r00;
j5eval[1]=new_r11;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1355=IKPowWithIntegerCheck(new_r00,-1);
if(!x1355.valid){
continue;
}
CheckValue<IkReal> x1356=IKPowWithIntegerCheck(new_r11,-1);
if(!x1356.valid){
continue;
}
if( IKabs(((-1.0)*sj7*(x1355.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((cj7*(x1356.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*sj7*(x1355.value)))+IKsqr((cj7*(x1356.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-1.0)*sj7*(x1355.value)), (cj7*(x1356.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x1357=IKcos(j5);
IkReal x1358=IKsin(j5);
IkReal x1359=((1.0)*sj7);
IkReal x1360=((1.0)*x1357);
evalcond[0]=(sj7+((new_r00*x1358)));
evalcond[1]=(cj7+((new_r00*x1357)));
evalcond[2]=(cj7+(((-1.0)*new_r11*x1360)));
evalcond[3]=((((-1.0)*x1359))+((new_r11*x1358)));
evalcond[4]=(((cj7*x1358))+(((-1.0)*x1357*x1359)));
evalcond[5]=(((cj7*x1357))+new_r00+((sj7*x1358)));
evalcond[6]=(new_r11+(((-1.0)*x1358*x1359))+(((-1.0)*cj7*x1360)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1361 = IKatan2WithCheck(IkReal(((-1.0)*sj7)),IkReal(((-1.0)*cj7)),IKFAST_ATAN2_MAGTHRESH);
if(!x1361.valid){
continue;
}
CheckValue<IkReal> x1362=IKPowWithIntegerCheck(IKsign(new_r00),-1);
if(!x1362.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1361.value)+(((1.5707963267949)*(x1362.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[7];
IkReal x1363=IKcos(j5);
IkReal x1364=IKsin(j5);
IkReal x1365=((1.0)*sj7);
IkReal x1366=((1.0)*x1363);
evalcond[0]=(sj7+((new_r00*x1364)));
evalcond[1]=(cj7+((new_r00*x1363)));
evalcond[2]=(cj7+(((-1.0)*new_r11*x1366)));
evalcond[3]=((((-1.0)*x1365))+((new_r11*x1364)));
evalcond[4]=(((cj7*x1364))+(((-1.0)*x1363*x1365)));
evalcond[5]=(((cj7*x1363))+new_r00+((sj7*x1364)));
evalcond[6]=((((-1.0)*x1364*x1365))+new_r11+(((-1.0)*cj7*x1366)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1367=((1.0)*new_r00);
CheckValue<IkReal> x1368 = IKatan2WithCheck(IkReal(((((-1.0)*(cj7*cj7)))+(new_r00*new_r00))),IkReal(((((-1.0)*new_r10*x1367))+((cj7*sj7)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1368.valid){
continue;
}
CheckValue<IkReal> x1369=IKPowWithIntegerCheck(IKsign(((((-1.0)*sj7*x1367))+((cj7*new_r10)))),-1);
if(!x1369.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(x1368.value)+(((1.5707963267949)*(x1369.value))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1370=IKcos(j5);
IkReal x1371=IKsin(j5);
IkReal x1372=((1.0)*sj7);
IkReal x1373=(cj7*x1371);
IkReal x1374=(cj7*x1370);
IkReal x1375=((1.0)*x1370);
IkReal x1376=(x1370*x1372);
evalcond[0]=(cj7+((new_r10*x1371))+((new_r00*x1370)));
evalcond[1]=(x1374+new_r00+((sj7*x1371)));
evalcond[2]=(sj7+((new_r00*x1371))+(((-1.0)*new_r10*x1375)));
evalcond[3]=((((-1.0)*new_r11*x1375))+cj7+((new_r01*x1371)));
evalcond[4]=(x1373+(((-1.0)*x1376))+new_r01);
evalcond[5]=(x1373+(((-1.0)*x1376))+new_r10);
evalcond[6]=((((-1.0)*x1372))+((new_r11*x1371))+((new_r01*x1370)));
evalcond[7]=((((-1.0)*x1371*x1372))+(((-1.0)*x1374))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1377=((1.0)*new_r10);
CheckValue<IkReal> x1378=IKPowWithIntegerCheck(IKsign(((((-1.0)*cj7*new_r00))+(((-1.0)*sj7*x1377)))),-1);
if(!x1378.valid){
continue;
}
CheckValue<IkReal> x1379 = IKatan2WithCheck(IkReal((((new_r00*new_r01))+((cj7*sj7)))),IkReal(((cj7*cj7)+(((-1.0)*new_r01*x1377)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1379.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1378.value)))+(x1379.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1380=IKcos(j5);
IkReal x1381=IKsin(j5);
IkReal x1382=((1.0)*sj7);
IkReal x1383=(cj7*x1381);
IkReal x1384=(cj7*x1380);
IkReal x1385=((1.0)*x1380);
IkReal x1386=(x1380*x1382);
evalcond[0]=(((new_r10*x1381))+cj7+((new_r00*x1380)));
evalcond[1]=(x1384+((sj7*x1381))+new_r00);
evalcond[2]=(sj7+(((-1.0)*new_r10*x1385))+((new_r00*x1381)));
evalcond[3]=(cj7+((new_r01*x1381))+(((-1.0)*new_r11*x1385)));
evalcond[4]=((((-1.0)*x1386))+x1383+new_r01);
evalcond[5]=((((-1.0)*x1386))+x1383+new_r10);
evalcond[6]=((((-1.0)*x1382))+((new_r11*x1381))+((new_r01*x1380)));
evalcond[7]=((((-1.0)*x1381*x1382))+(((-1.0)*x1384))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1387=((1.0)*new_r10);
CheckValue<IkReal> x1388=IKPowWithIntegerCheck(IKsign(((((-1.0)*new_r11*x1387))+(((-1.0)*new_r00*new_r01)))),-1);
if(!x1388.valid){
continue;
}
CheckValue<IkReal> x1389 = IKatan2WithCheck(IkReal((((cj7*new_r00))+((cj7*new_r11)))),IkReal((((cj7*new_r01))+(((-1.0)*cj7*x1387)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1389.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1388.value)))+(x1389.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[8];
IkReal x1390=IKcos(j5);
IkReal x1391=IKsin(j5);
IkReal x1392=((1.0)*sj7);
IkReal x1393=(cj7*x1391);
IkReal x1394=(cj7*x1390);
IkReal x1395=((1.0)*x1390);
IkReal x1396=(x1390*x1392);
evalcond[0]=(cj7+((new_r10*x1391))+((new_r00*x1390)));
evalcond[1]=(x1394+((sj7*x1391))+new_r00);
evalcond[2]=(sj7+((new_r00*x1391))+(((-1.0)*new_r10*x1395)));
evalcond[3]=(cj7+(((-1.0)*new_r11*x1395))+((new_r01*x1391)));
evalcond[4]=(x1393+new_r01+(((-1.0)*x1396)));
evalcond[5]=(x1393+new_r10+(((-1.0)*x1396)));
evalcond[6]=(((new_r11*x1391))+((new_r01*x1390))+(((-1.0)*x1392)));
evalcond[7]=((((-1.0)*x1391*x1392))+(((-1.0)*x1394))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r12))+(IKabs(new_r02)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j5eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j5eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j5eval[0]=((IKabs((new_r11*new_r22)))+(IKabs((new_r01*new_r22))));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j5]
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1398 = IKatan2WithCheck(IkReal((new_r01*new_r22)),IkReal((new_r11*new_r22)),IKFAST_ATAN2_MAGTHRESH);
if(!x1398.valid){
continue;
}
IkReal x1397=x1398.value;
j5array[0]=((-1.0)*x1397);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1397)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[5];
IkReal x1399=IKsin(j5);
IkReal x1400=IKcos(j5);
IkReal x1401=(new_r10*x1399);
IkReal x1402=((1.0)*x1400);
IkReal x1403=(new_r00*x1400);
evalcond[0]=(((new_r11*x1399))+((new_r01*x1400)));
evalcond[1]=(x1403+x1401);
evalcond[2]=(((new_r00*x1399))+(((-1.0)*new_r10*x1402)));
evalcond[3]=(((new_r01*x1399))+(((-1.0)*new_r11*x1402)));
evalcond[4]=(((new_r22*x1401))+((new_r22*x1403)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1405 = IKatan2WithCheck(IkReal(new_r00),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x1405.valid){
continue;
}
IkReal x1404=x1405.value;
j5array[0]=((-1.0)*x1404);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1404)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[5];
IkReal x1406=IKsin(j5);
IkReal x1407=IKcos(j5);
IkReal x1408=(new_r11*x1406);
IkReal x1409=((1.0)*x1407);
IkReal x1410=(new_r22*x1407);
evalcond[0]=(((new_r01*x1407))+x1408);
evalcond[1]=(((new_r00*x1406))+(((-1.0)*new_r10*x1409)));
evalcond[2]=(((new_r01*x1406))+(((-1.0)*new_r11*x1409)));
evalcond[3]=(((new_r01*x1410))+((new_r22*x1408)));
evalcond[4]=(((new_r00*x1410))+((new_r10*new_r22*x1406)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
CheckValue<IkReal> x1412 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x1412.valid){
continue;
}
IkReal x1411=x1412.value;
j5array[0]=((-1.0)*x1411);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1411)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[5];
IkReal x1413=IKsin(j5);
IkReal x1414=IKcos(j5);
IkReal x1415=(new_r10*x1413);
IkReal x1416=((1.0)*x1414);
IkReal x1417=(new_r00*x1414);
evalcond[0]=(x1415+x1417);
evalcond[1]=((((-1.0)*new_r10*x1416))+((new_r00*x1413)));
evalcond[2]=((((-1.0)*new_r11*x1416))+((new_r01*x1413)));
evalcond[3]=(((new_r11*new_r22*x1413))+((new_r01*new_r22*x1414)));
evalcond[4]=(((new_r22*x1415))+((new_r22*x1417)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1419=IKPowWithIntegerCheck(sj6,-1);
if(!x1419.valid){
continue;
}
IkReal x1418=x1419.value;
CheckValue<IkReal> x1420=IKPowWithIntegerCheck(new_r12,-1);
if(!x1420.valid){
continue;
}
if( IKabs((x1418*(x1420.value)*(((-1.0)+(new_r02*new_r02)+(cj6*cj6))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r02*x1418)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x1418*(x1420.value)*(((-1.0)+(new_r02*new_r02)+(cj6*cj6)))))+IKsqr(((-1.0)*new_r02*x1418))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2((x1418*(x1420.value)*(((-1.0)+(new_r02*new_r02)+(cj6*cj6)))), ((-1.0)*new_r02*x1418));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[18];
IkReal x1421=IKcos(j5);
IkReal x1422=IKsin(j5);
IkReal x1423=(cj6*cj7);
IkReal x1424=(cj6*sj7);
IkReal x1425=(new_r10*x1422);
IkReal x1426=((1.0)*x1421);
IkReal x1427=(new_r02*x1421);
IkReal x1428=(new_r00*x1421);
IkReal x1429=((1.0)*x1422);
IkReal x1430=(new_r01*x1421);
IkReal x1431=(sj7*x1422);
IkReal x1432=(cj6*x1422);
evalcond[0]=(new_r02+((sj6*x1421)));
evalcond[1]=(new_r12+((sj6*x1422)));
evalcond[2]=((((-1.0)*new_r02*x1429))+((new_r12*x1421)));
evalcond[3]=(sj6+x1427+((new_r12*x1422)));
evalcond[4]=(sj7+(((-1.0)*new_r10*x1426))+((new_r00*x1422)));
evalcond[5]=(cj7+(((-1.0)*new_r11*x1426))+((new_r01*x1422)));
evalcond[6]=(((cj7*x1422))+new_r01+((x1421*x1424)));
evalcond[7]=(x1424+x1430+((new_r11*x1422)));
evalcond[8]=((((-1.0)*x1423*x1426))+x1431+new_r00);
evalcond[9]=(((x1422*x1424))+(((-1.0)*cj7*x1426))+new_r11);
evalcond[10]=((((-1.0)*x1423))+x1425+x1428);
evalcond[11]=((((-1.0)*sj7*x1426))+(((-1.0)*x1423*x1429))+new_r10);
evalcond[12]=(((cj6*x1427))+((new_r22*sj6))+((new_r12*x1432)));
evalcond[13]=(sj7+((new_r11*x1432))+((cj6*x1430))+((new_r21*sj6)));
evalcond[14]=((((-1.0)*new_r00*sj6*x1426))+(((-1.0)*sj6*x1425))+((cj6*new_r20)));
evalcond[15]=((((-1.0)*new_r11*sj6*x1429))+(((-1.0)*new_r01*sj6*x1426))+((cj6*new_r21)));
evalcond[16]=((-1.0)+(((-1.0)*new_r12*sj6*x1429))+(((-1.0)*new_r02*sj6*x1426))+((cj6*new_r22)));
evalcond[17]=(((new_r20*sj6))+((cj6*x1425))+((cj6*x1428))+(((-1.0)*cj7)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[12]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[13]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[14]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[15]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[16]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[17]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1433=IKPowWithIntegerCheck(IKsign(sj6),-1);
if(!x1433.valid){
continue;
}
CheckValue<IkReal> x1434 = IKatan2WithCheck(IkReal(((-1.0)*new_r12)),IkReal(((-1.0)*new_r02)),IKFAST_ATAN2_MAGTHRESH);
if(!x1434.valid){
continue;
}
j5array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1433.value)))+(x1434.value));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[18];
IkReal x1435=IKcos(j5);
IkReal x1436=IKsin(j5);
IkReal x1437=(cj6*cj7);
IkReal x1438=(cj6*sj7);
IkReal x1439=(new_r10*x1436);
IkReal x1440=((1.0)*x1435);
IkReal x1441=(new_r02*x1435);
IkReal x1442=(new_r00*x1435);
IkReal x1443=((1.0)*x1436);
IkReal x1444=(new_r01*x1435);
IkReal x1445=(sj7*x1436);
IkReal x1446=(cj6*x1436);
evalcond[0]=(((sj6*x1435))+new_r02);
evalcond[1]=(((sj6*x1436))+new_r12);
evalcond[2]=((((-1.0)*new_r02*x1443))+((new_r12*x1435)));
evalcond[3]=(sj6+((new_r12*x1436))+x1441);
evalcond[4]=(sj7+((new_r00*x1436))+(((-1.0)*new_r10*x1440)));
evalcond[5]=(cj7+((new_r01*x1436))+(((-1.0)*new_r11*x1440)));
evalcond[6]=(((x1435*x1438))+((cj7*x1436))+new_r01);
evalcond[7]=(((new_r11*x1436))+x1438+x1444);
evalcond[8]=((((-1.0)*x1437*x1440))+x1445+new_r00);
evalcond[9]=(((x1436*x1438))+(((-1.0)*cj7*x1440))+new_r11);
evalcond[10]=((((-1.0)*x1437))+x1439+x1442);
evalcond[11]=((((-1.0)*x1437*x1443))+(((-1.0)*sj7*x1440))+new_r10);
evalcond[12]=(((new_r12*x1446))+((cj6*x1441))+((new_r22*sj6)));
evalcond[13]=(((new_r11*x1446))+sj7+((cj6*x1444))+((new_r21*sj6)));
evalcond[14]=((((-1.0)*new_r00*sj6*x1440))+(((-1.0)*sj6*x1439))+((cj6*new_r20)));
evalcond[15]=((((-1.0)*new_r11*sj6*x1443))+(((-1.0)*new_r01*sj6*x1440))+((cj6*new_r21)));
evalcond[16]=((-1.0)+(((-1.0)*new_r12*sj6*x1443))+(((-1.0)*new_r02*sj6*x1440))+((cj6*new_r22)));
evalcond[17]=(((new_r20*sj6))+((cj6*x1442))+((cj6*x1439))+(((-1.0)*cj7)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[12]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[13]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[14]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[15]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[16]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[17]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(8);
vinfos[0].jointtype = 17;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 17;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 17;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
vinfos[7].jointtype = 1;
vinfos[7].foffset = j7;
vinfos[7].indices[0] = _ij7[0];
vinfos[7].indices[1] = _ij7[1];
vinfos[7].maxsolutions = _nj7;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
}
}
}
}static inline void polyroots3(IkReal rawcoeffs[3+1], IkReal rawroots[3], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots2(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[3];
const int maxsteps = 110;
for(int i = 0; i < 3; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[3];
IkReal err[3];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 3; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 3; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 3; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 3; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[3] = {false};
for(int i = 0; i < 3; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 3; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
static inline void polyroots2(IkReal rawcoeffs[2+1], IkReal rawroots[2], int& numroots) {
IkReal det = rawcoeffs[1]*rawcoeffs[1]-4*rawcoeffs[0]*rawcoeffs[2];
if( det < 0 ) {
numroots=0;
}
else if( det == 0 ) {
rawroots[0] = -0.5*rawcoeffs[1]/rawcoeffs[0];
numroots = 1;
}
else {
det = IKsqrt(det);
rawroots[0] = (-rawcoeffs[1]+det)/(2*rawcoeffs[0]);
rawroots[1] = (-rawcoeffs[1]-det)/(2*rawcoeffs[0]);//rawcoeffs[2]/(rawcoeffs[0]*rawroots[0]);
numroots = 2;
}
}
static inline void polyroots4(IkReal rawcoeffs[4+1], IkReal rawroots[4], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots3(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[4];
const int maxsteps = 110;
for(int i = 0; i < 4; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[4];
IkReal err[4];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 4; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 4; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 4; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 4; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[4] = {false};
for(int i = 0; i < 4; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 4; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
};
/// solves the inverse kinematics equations.
/// \param pfree is an array specifying the free joints of the chain.
IKFAST_API bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions) {
IKSolver solver;
return solver.ComputeIk(eetrans,eerot,pfree,solutions);
}
IKFAST_API bool ComputeIk2(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions, void* pOpenRAVEManip) {
IKSolver solver;
return solver.ComputeIk(eetrans,eerot,pfree,solutions);
}
IKFAST_API const char* GetKinematicsHash() { return "d559213b8fa0a6e94448a10b84cefc7c"; }
IKFAST_API const char* GetIkFastVersion() { return "0x10000049"; }
#ifdef IKFAST_NAMESPACE
} // end namespace
#endif
#ifndef IKFAST_NO_MAIN
#include <stdio.h>
#include <stdlib.h>
#ifdef IKFAST_NAMESPACE
using namespace IKFAST_NAMESPACE;
#endif
int main(int argc, char** argv)
{
if( argc != 12+GetNumFreeParameters()+1 ) {
printf("\nUsage: ./ik r00 r01 r02 t0 r10 r11 r12 t1 r20 r21 r22 t2 free0 ...\n\n"
"Returns the ik solutions given the transformation of the end effector specified by\n"
"a 3x3 rotation R (rXX), and a 3x1 translation (tX).\n"
"There are %d free parameters that have to be specified.\n\n",GetNumFreeParameters());
return 1;
}
IkSolutionList<IkReal> solutions;
std::vector<IkReal> vfree(GetNumFreeParameters());
IkReal eerot[9],eetrans[3];
eerot[0] = atof(argv[1]); eerot[1] = atof(argv[2]); eerot[2] = atof(argv[3]); eetrans[0] = atof(argv[4]);
eerot[3] = atof(argv[5]); eerot[4] = atof(argv[6]); eerot[5] = atof(argv[7]); eetrans[1] = atof(argv[8]);
eerot[6] = atof(argv[9]); eerot[7] = atof(argv[10]); eerot[8] = atof(argv[11]); eetrans[2] = atof(argv[12]);
for(std::size_t i = 0; i < vfree.size(); ++i)
vfree[i] = atof(argv[13+i]);
bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);
if( !bSuccess ) {
fprintf(stderr,"Failed to get ik solution\n");
return -1;
}
printf("Found %d ik solutions:\n", (int)solutions.GetNumSolutions());
std::vector<IkReal> solvalues(GetNumJoints());
for(std::size_t i = 0; i < solutions.GetNumSolutions(); ++i) {
const IkSolutionBase<IkReal>& sol = solutions.GetSolution(i);
printf("sol%d (free=%d): ", (int)i, (int)sol.GetFree().size());
std::vector<IkReal> vsolfree(sol.GetFree().size());
sol.GetSolution(&solvalues[0],vsolfree.size()>0?&vsolfree[0]:NULL);
for( std::size_t j = 0; j < solvalues.size(); ++j)
printf("%.15f, ", solvalues[j]);
printf("\n");
}
return 0;
}
#endif
| 587,721 |
C++
| 27.3144 | 874 | 0.647503 |
makolon/hsr_isaac_tamp/hsr_tamp/README.md
|
# HSR-TAMP
| 11 |
Markdown
| 4.999998 | 10 | 0.636364 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_2d/tamp_planner.py
|
#!/usr/bin/env python3
import os
import time
import random
import numpy as np
from itertools import product
from utils.optimizer.optimizer import cfree_motion_fn, get_optimize_fn
from utils.primitives import (
# generator
get_pose_gen, get_stack_pose_gen, get_block_pose_gen, \
get_center_pose_gen, get_stack_center_pose_gen, get_block_center_pose_gen, \
# test function
collision_test, stack_test, get_region_test, get_block_region_test, \
# utility
distance_fn, inverse_kin_fn, duration_fn, stack_inverse_kin_fn, \
plan_motion, draw_state, get_random_seed, update_state, \
# constant
SUCTION_HEIGHT, MOVE_COST, GRASP, ENVIRONMENT_NAMES, PROBLEMS)
from hsr_tamp.pddlstream.algorithms.meta import solve, create_parser
from hsr_tamp.pddlstream.algorithms.downward import get_cost_scale
from hsr_tamp.pddlstream.algorithms.constraints import PlanConstraints, WILD
from hsr_tamp.pddlstream.algorithms.visualization import VISUALIZATIONS_DIR
from hsr_tamp.pddlstream.language.external import defer_shared, get_defer_all_unbound, get_defer_any_unbound
from hsr_tamp.pddlstream.language.constants import And, Equal, PDDLProblem, TOTAL_COST, print_solution, Or, Output
from hsr_tamp.pddlstream.language.function import FunctionInfo
from hsr_tamp.pddlstream.language.generator import from_gen_fn, from_list_fn, from_test, from_fn
from hsr_tamp.pddlstream.language.stream import StreamInfo
from hsr_tamp.pddlstream.language.temporal import get_end, compute_duration, retime_plan
from hsr_tamp.pddlstream.utils import ensure_dir, safe_rm_dir, user_input, read, INF, get_file_path, str_from_object, \
sorted_str_from_list, implies, inclusive_range, Profiler
##################################################
TIGHT_SKELETON = [
('move', ['r0', '?q0', WILD, '?q1']),
('pick', ['r0', 'B', '?p0', '?g0', '?q1']),
('move', ['r0', '?q1', WILD, '?q2']),
('place', ['r0', 'B', '?p1', '?g0', '?q2']),
('move', ['r0', '?q2', WILD, '?q3']),
('pick', ['r0', 'A', '?p2', '?g1', '?q3']),
('move', ['r0', '?q3', WILD, '?q4']),
('place', ['r0', 'A', '?p3', '?g1', '?q4']),
('move', ['r0', '?q4', WILD, '?q5']),
]
MUTEXES = [
#[('kin', '?b1', '?p1', '?q'), ('kin', '?b2', '?p2', '?q')],
]
class TAMPPlanner(object):
def create_problem(self, tamp_problem, hand_empty=False, manipulate_cost=1.):
initial = tamp_problem.initial
assert(not initial.holding)
init = [
Equal(('Cost',), manipulate_cost),
Equal((TOTAL_COST,), 0)] + [('Placeable', b, r) for b in initial.block_poses.keys()
for r in tamp_problem.regions if (r in ENVIRONMENT_NAMES)]
goal_literals = []
### Block specification
for b, p in initial.block_poses.items():
init += [
('Block', b),
('Pose', b, p),
('AtPose', b, p),
]
for b, r in tamp_problem.goal_in.items():
if isinstance(r, np.ndarray):
init += [('Pose', b, r)]
goal_literals += [('AtPose', b, r)]
else:
blocks = [b] if isinstance(b, str) else b
regions = [r] if isinstance(r, str) else r
conditions = []
for body, region in product(blocks, regions):
init += [('Region', region), ('Placeable', body, region)]
conditions += [('In', body, region)]
goal_literals.append(Or(*conditions))
for on_list in tamp_problem.goal_on:
init += [('Placeable', on_list[1], on_list[0])]
goal_literals += [('On', on_list[1], on_list[0])]
### Robot specification
for r, q in initial.robot_confs.items():
init += [
('Robot', r),
('CanMove', r),
('Conf', q),
('AtConf', r, q),
('HandEmpty', r),
]
if hand_empty:
goal_literals += [('HandEmpty', r)]
if tamp_problem.goal_conf is not None:
goal_literals += [('AtConf', r, q)]
goal = And(*goal_literals)
return init, goal
def pddlstream_from_tamp(self, tamp_problem, use_stream=True, use_optimizer=False, collisions=True, center=False):
domain_pddl = read(get_file_path(__file__, 'task/stack/domain.pddl'))
external_paths = []
if use_stream:
external_paths.append(get_file_path(__file__, 'task/stack/stream.pddl'))
if use_optimizer:
external_paths.append(get_file_path(__file__, 'optimizer/optimizer.pddl'))
external_pddl = [read(path) for path in external_paths]
constant_map = {}
if center:
stream_map = {
's-grasp': from_fn(lambda b: (GRASP,)),
's-motion': from_fn(plan_motion),
's-ik': from_fn(inverse_kin_fn),
's-stackik': from_fn(stack_inverse_kin_fn),
's-region': from_gen_fn(get_center_pose_gen(tamp_problem.regions)),
's-blockregion': from_gen_fn(get_block_center_pose_gen(tamp_problem.regions)),
't-region': from_test(get_region_test(tamp_problem.regions)),
't-blockregion': from_test(get_block_region_test(tamp_problem.regions)),
't-cfree': from_test(lambda *args: implies(collisions, not collision_test(*args))),
't-cstack': from_test(lambda *args: implies(collisions, not stack_test(*args))),
'dist': distance_fn,
'duration': duration_fn,
}
else:
stream_map = {
's-grasp': from_fn(lambda b: (GRASP,)),
's-motion': from_fn(plan_motion),
's-ik': from_fn(inverse_kin_fn),
's-stackik': from_fn(stack_inverse_kin_fn),
's-region': from_gen_fn(get_pose_gen(tamp_problem.regions)),
's-blockregion': from_gen_fn(get_block_pose_gen(tamp_problem.regions)),
't-region': from_test(get_region_test(tamp_problem.regions)),
't-blockregion': from_test(get_block_region_test(tamp_problem.regions)),
't-cfree': from_test(lambda *args: implies(collisions, not collision_test(*args))),
't-cstack': from_test(lambda *args: implies(collisions, not stack_test(*args))),
'dist': distance_fn,
'duration': duration_fn,
}
if use_optimizer:
stream_map.update({
'gurobi': from_list_fn(get_optimize_fn(tamp_problem.regions, collisions=collisions)),
'rrt': from_fn(cfree_motion_fn),
})
init, goal = self.create_problem(tamp_problem)
return PDDLProblem(domain_pddl, constant_map, external_pddl, stream_map, init, goal)
def display_plan(self, tamp_problem, plan, display=True, save=False, time_step=0.025, sec_per_step=1e-3):
from utils.viewer import ContinuousTMPViewer, COLORS
if save:
example_name = 'continuous_tamp'
directory = os.path.join(VISUALIZATIONS_DIR, '{}/'.format(example_name))
safe_rm_dir(directory)
ensure_dir(directory)
colors = dict(zip(sorted(tamp_problem.initial.block_poses.keys()), COLORS))
viewer = ContinuousTMPViewer(SUCTION_HEIGHT, tamp_problem.regions, title='Continuous TAMP')
state = tamp_problem.initial
print()
print(state)
duration = compute_duration(plan)
real_time = None if sec_per_step is None else (duration * sec_per_step / time_step)
print('Duration: {} | Step size: {} | Real time: {}'.format(duration, time_step, real_time))
draw_state(viewer, state, colors)
if display:
user_input('Start?')
if plan is not None:
for t in inclusive_range(0, duration, time_step):
for action in plan:
if action.start <= t <= get_end(action):
update_state(state, action, t - action.start)
print('t={} | {}'.format(t, state))
draw_state(viewer, state, colors)
if save:
viewer.save(os.path.join(directory, 't={}'.format(t)))
if display:
if sec_per_step is None:
user_input('Continue?')
else:
time.sleep(sec_per_step)
if display:
user_input('Finish?')
return state
def set_deterministic(self, seed=0):
random.seed(seed=seed)
np.random.seed(seed=seed)
def initialize(self, parser):
parser.add_argument('-c', '--cfree', action='store_true', help='Disables collisions')
parser.add_argument('-d', '--deterministic', action='store_true', help='Uses a deterministic sampler')
parser.add_argument('-t', '--max_time', default=30, type=int, help='The max time')
parser.add_argument('-n', '--number', default=4, type=int, help='The number of blocks')
parser.add_argument('-p', '--problem', default='gearbox', help='The name of the problem to solve')
parser.add_argument('-v', '--visualize', action='store_true', help='Visualizes graphs')
args = parser.parse_args()
print('Arguments:', args)
np.set_printoptions(precision=2)
if args.deterministic:
self.set_deterministic()
print('Random seed:', get_random_seed())
problem_from_name = {fn.__name__: fn for fn in PROBLEMS}
if args.problem not in problem_from_name:
raise ValueError(args.problem)
print('Problem:', args.problem)
problem_fn = problem_from_name[args.problem]
tamp_problem = problem_fn(args.number)
print(tamp_problem)
return tamp_problem, args
def dump_pddlstream(self, pddlstream_problem):
print('Initial:', sorted_str_from_list(pddlstream_problem.init))
print('Goal:', str_from_object(pddlstream_problem.goal))
def plan(self):
parser = create_parser()
parser.add_argument('-g', '--gurobi', action='store_true', help='Uses gurobi')
parser.add_argument('-o', '--optimal', action='store_true', help='Runs in an anytime mode')
parser.add_argument('-s', '--skeleton', action='store_true', help='Enforces skeleton plan constraints')
tamp_problem, args = self.initialize(parser)
defer_fn = defer_shared # always True
stream_info = {
's-grasp': StreamInfo(defer_fn=defer_fn),
's-region': StreamInfo(defer_fn=defer_fn),
's-ik': StreamInfo(defer_fn=get_defer_all_unbound(inputs='?g')),
's-motion': StreamInfo(defer_fn=get_defer_any_unbound()),
't-region': StreamInfo(eager=False, p_success=0),
't-blockregion': StreamInfo(eager=False, p_success=0),
't-cfree': StreamInfo(defer_fn=get_defer_any_unbound(), eager=False),
't-cstack': StreamInfo(eager=False),
'gurobi-cfree': StreamInfo(eager=False, negate=True),
'dist': FunctionInfo(eager=False, defer_fn=get_defer_any_unbound(), opt_fn=lambda q1, q2: MOVE_COST),
}
hierarchy = [
# ABSTRIPSLayer(pos_pre=['atconf']), #, horizon=1),
]
skeletons = [TIGHT_SKELETON] if args.skeleton else None
assert implies(args.skeleton, args.problem == 'tight')
max_cost = INF
constraints = PlanConstraints(skeletons=skeletons,
exact=True,
max_cost=max_cost)
replan_actions = set()
pddlstream_problem = self.pddlstream_from_tamp(tamp_problem, collisions=not args.cfree,
center=True, use_stream=not args.gurobi, use_optimizer=args.gurobi)
self.dump_pddlstream(pddlstream_problem)
success_cost = 0 if args.optimal else INF
planner = 'max-astar'
effort_weight = 1. / get_cost_scale()
with Profiler(field='cumtime', num=20):
solution = solve(pddlstream_problem, algorithm=args.algorithm, constraints=constraints, stream_info=stream_info,
replan_actions=replan_actions, planner=planner, max_planner_time=10, hierarchy=hierarchy,
max_time=args.max_time, max_iterations=INF, debug=False, verbose=True,
unit_costs=args.unit, success_cost=success_cost,
unit_efforts=True, effort_weight=effort_weight,
search_sample_ratio=1, visualize=args.visualize)
print_solution(solution)
plan, cost, evaluations = solution
return plan, cost, evaluations
def execute(self):
parser = create_parser()
parser.add_argument('-g', '--gurobi', action='store_true', help='Uses gurobi')
parser.add_argument('-o', '--optimal', action='store_true', help='Runs in an anytime mode')
parser.add_argument('-s', '--skeleton', action='store_true', help='Enforces skeleton plan constraints')
tamp_problem, _ = self.initialize(parser)
plan, _, _ = self.plan()
print('plan: ', plan)
if plan is not None:
self.display_plan(tamp_problem, retime_plan(plan))
if __name__ == '__main__':
tamp_planner = TAMPPlanner()
tamp_planner.execute()
| 13,511 |
Python
| 43.447368 | 124 | 0.574199 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_2d/utils/viewer.py
|
from __future__ import print_function
try:
from Tkinter import Tk, Canvas, Toplevel
except ImportError:
from tkinter import Tk, Canvas, Toplevel
# NOTE - this will overwrite (but remember) existing drawings
# TODO - try PyGame, PyCairo, or Pyglet
SUCTION_WIDTH = 1.5 # 1.01 | 1.5
STEM_WIDTH = 1.
STEM_HEIGHT = 2.5
PIXEL_BUFFER = 10
ENV_HEIGHT = 1.
COLOR_FROM_NAME = {
'stove': 'red',
'table': 'brown', # brown | tan
'shelf': 'grey',
}
COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'white', 'black']
BACKGROUND_COLOR = 'light blue' # tan | light blue
# http://www.science.smith.edu/dftwiki/index.php/File:TkInterColorCharts.png
def get_width(interval):
return interval[1] - interval[0]
##################################################
class ContinuousTMPViewer(object):
def __init__(self, suction_height, regions, tl_x=0, tl_y=0, width=400, height=200,
title='Grid', background=BACKGROUND_COLOR):
self.tk = Tk()
# tk.geometry('%dx%d+%d+%d'%(width, height, 100, 0))
self.tk.withdraw()
self.top = Toplevel(self.tk)
self.top.wm_title(title)
self.top.protocol('WM_DELETE_WINDOW', self.top.destroy)
self.suction_height = suction_height
self.regions = regions
self.width = width
self.height = height
self.canvas = Canvas(self.top, width=self.width, height=self.height, background=background)
self.canvas.pack()
# self.center()
self.move_frame(tl_x, tl_y)
min_x = min(x1 for x1, _ in regions.values())
max_x = max(x2 for _, x2 in regions.values())
max_width = max_x - min_x
self.dist_to_pixel = (self.width - 2 * PIXEL_BUFFER) / max_width # Maintains aspect ratio
self.dist_width = self.width / self.dist_to_pixel
self.dist_height = self.height / self.dist_to_pixel
self.ground_height = self.height - self.dist_to_pixel * ENV_HEIGHT
self.robot_dist = self.dist_height / 2.
self.dynamic = []
self.static = []
self.draw_environment()
def center(self):
self.top.update_idletasks()
w = self.top.winfo_screenwidth()
h = self.top.winfo_screenheight()
size = tuple(int(_) for _ in self.top.geometry().split('+')[0].split('x'))
x = w / 2 - size[0] / 2
y = h / 2 - size[1] / 2
self.top.geometry("%dx%d+%d+%d" % (size + (x, y)))
def move_frame(self, x, y):
self.top.update_idletasks()
size = tuple(int(_) for _ in self.top.geometry().split('+')[0].split('x'))
self.top.geometry("%dx%d+%d+%d" % (size + (x, y)))
def scale_x(self, x): # x \in [-self.dist_width/2, self.dist_width/2]
return self.width / 2. + self.dist_to_pixel * x
def scale_y(self, y): # y \in [0, self.dist_height]
return self.ground_height - self.dist_to_pixel * y
def draw_block(self, x, y, width, height, name='', color='blue'):
self.dynamic.extend([
self.canvas.create_rectangle(self.scale_x(x - width / 2.), self.scale_y(y),
self.scale_x(x + width / 2.), self.scale_y(y + height),
fill=color, outline='black', width=2),
self.canvas.create_text(self.scale_x(x), self.scale_y(y + height / 2), text=name),
])
def draw_region(self, region, name=''):
# TODO: draw table legs (with an offset)
x1, x2 = map(self.scale_x, region)
y1, y2 = self.ground_height, self.height
color = COLOR_FROM_NAME.get(name, name)
self.static.extend([
self.canvas.create_rectangle(x1, y1, x2, y2, fill=color, outline='black', width=2),
self.canvas.create_text((x1 + x2) / 2, (y1 + y2) / 2, text=name),
])
def draw_environment(self):
# TODO: automatically draw in order
self.static = []
for name, region in sorted(self.regions.items(), key=lambda pair: get_width(pair[1]), reverse=True):
self.draw_region(region, name=name)
def draw_robot(self, x, y, name='', color='yellow'): # TODO - could also visualize as top grasps instead of side grasps
#y = self.robot_dist
self.dynamic.extend([
self.canvas.create_rectangle(self.scale_x(x - SUCTION_WIDTH / 2.),
self.scale_y(y - self.suction_height / 2.),
self.scale_x(x + SUCTION_WIDTH / 2.),
self.scale_y(y + self.suction_height / 2.),
fill=color, outline='black', width=2),
self.canvas.create_text(self.scale_x(x), self.scale_y(y), text=name),
self.canvas.create_rectangle(self.scale_x(x - STEM_WIDTH / 2.),
self.scale_y(y + self.suction_height / 2.),
self.scale_x(x + STEM_WIDTH / 2.),
self.scale_y(y + self.suction_height / 2. + STEM_HEIGHT),
fill=color, outline='black', width=2),
])
def clear_state(self):
for part in self.dynamic:
self.canvas.delete(part)
self.dynamic = []
def clear_all(self):
self.canvas.delete('all')
def save(self, filename):
# TODO: screen recording based on location like I did before
# TODO: only works on windows
# self.canvas.postscript(file='%s.ps'%filename, colormode='color')
#from PIL import ImageGrab
try:
import pyscreenshot as ImageGrab
except ImportError:
print('Unable to load pyscreenshot')
return None
# TODO: screenshot is in the wrong place
x, y = self.top.winfo_x(), 2*self.top.winfo_y()
width, height = self.top.winfo_width(), self.top.winfo_height() # winfo_width, winfo_reqheight
path = filename + '.png'
print('Saved', path)
ImageGrab.grab((x, y, x+width, y+height)).save(path)
return path
| 6,136 |
Python
| 39.375 | 124 | 0.551662 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_2d/utils/primitives.py
|
from collections import namedtuple
import numpy as np
import string
import random
GROUND_NAME = 'gray'
BLOCK_WIDTH = 2
BLOCK_HEIGHT = BLOCK_WIDTH
GROUND_Y = 0.
SUCTION_HEIGHT = 1.
GRASP = -np.array([0, BLOCK_HEIGHT + SUCTION_HEIGHT/2]) # TODO: side grasps
CARRY_Y = 2*BLOCK_WIDTH+SUCTION_HEIGHT
APPROACH = -np.array([0, CARRY_Y]) - GRASP
MOVE_COST = 10.
COST_PER_DIST = 1.
DISTANCE_PER_TIME = 4.0
def get_block_box(b, p=np.zeros(2)):
extent = np.array([BLOCK_WIDTH, BLOCK_HEIGHT]) # TODO: vary per block
lower = p - extent/2.
upper = p + extent/2.
return lower, upper
def boxes_overlap(box1, box2):
lower1, upper1 = box1
lower2, upper2 = box2
return np.less_equal(lower1, upper2).all() and \
np.less_equal(lower2, upper1).all()
def interval_contains(i1, i2):
"""
:param i1: The container interval
:param i2: The possibly contained interval
:return:
"""
return (i1[0] <= i2[0]) and (i2[1] <= i1[1])
def interval_overlap(i1, i2):
return (i2[0] <= i1[1]) and (i1[0] <= i2[1])
def get_block_interval(b, p):
lower, upper = get_block_box(b, p)
return lower[0], upper[0]
def get_block_interval_margin(b, p):
collision_margin = 0.1
lower, upper = get_block_box(b, p)
return lower[0]-collision_margin, upper[0]+collision_margin
def sample_region(b, region):
x1, x2 = np.array(region, dtype=float) - get_block_interval(b, np.zeros(2))
if x2 < x1:
return None
x = np.random.uniform(x1, x2)
return np.array([x, 0])
def rejection_sample_region(b, region, placed={}, max_attempts=10):
for _ in range(max_attempts):
p = sample_region(b, region)
if p is None:
break
if not any(collision_test(b, p, b2, p2) for b2, p2 in placed.items()):
return p
return None
def rejection_sample_placed(block_poses={}, block_regions={}, regions={}, max_attempts=10):
assert(not set(block_poses.keys()) & set(block_regions.keys()))
for _ in range(max_attempts):
placed = block_poses.copy()
remaining = list(block_regions.items())
random.shuffle(remaining)
for b, r in remaining:
p = rejection_sample_region(b, regions[r], placed)
if p is None:
break
placed[b] = p
else:
return placed
return None
def sample_center_region(b, region):
x1, x2 = np.array(region, dtype=float) - get_block_interval(b, np.zeros(2))
if x2 < x1:
return None
x = (x1+x2)/2.
return np.array([x, 0])
################################################## Streams
def collision_test(b1, p1, b2, p2):
if b1 == b2:
return False
return interval_overlap(get_block_interval(b1, p1),
get_block_interval(b2, p2))
def collision_test(b1, p1, b2, p2):
if b1 == b2:
return False
return interval_overlap(get_block_interval_margin(b1, p1),
get_block_interval_margin(b2, p2))
def stack_test(bu, pu, bl, pl):
if interval_contains(get_block_interval(bl, pl)+np.array([-BLOCK_WIDTH,+BLOCK_WIDTH])/2., get_block_interval(bu, pu)):
return (pu[1] > pl[1]) and (pu[1] <= pl[1]+BLOCK_HEIGHT)
else:
return False
def stack_free_test(b1, p1, b2, p2):
if interval_overlap(get_block_interval(b1, p1), get_block_interval(b2, p2)):
return (p1[1] > p2[1])
else:
return False
def str_eq(s1, s2, ignore_case=True):
if ignore_case:
s1 = s1.lower()
s2 = s2.lower()
return s1 == s2
def interpolate(waypoints, velocity=1):
import scipy
differences = [0.] + [np.linalg.norm(q2 - q1) for q1, q2 in zip(waypoints[:-1], waypoints[1:])]
times = np.cumsum(differences) / velocity
return scipy.interpolate.interp1d(times, waypoints, kind='linear')
def plan_motion(q1, q2, fluents=[]):
x1, y1 = q1
x2, y2 = q2
t = [q1, np.array([x1, CARRY_Y]), np.array([x2, CARRY_Y]), q2]
grasp = None
placed = {}
for fluent in fluents:
predicate, args = fluent[0], fluent[1:]
if str_eq(predicate, 'AtGrasp'):
assert grasp is None
r, b, g = args
grasp = g
elif str_eq(predicate, 'AtPose'):
b, p = args
assert b not in placed
placed[b] = p
elif str_eq(predicate, 'AtConf'):
continue
else:
raise NotImplementedError(predicate)
if grasp is None:
return (t,)
for q in t:
p1 = forward_kin(q, grasp)
box1 = get_block_box(None, p1)
for b2, p2 in placed.items():
box2 = get_block_box(b2, p2)
if boxes_overlap(box1, box2):
return None
return (t,)
def forward_kin(q, g):
p = q + g
return p
def inverse_kin(p, g):
q = p - g
return q
def approach_kin(q):
a = q - APPROACH
return a
def distance_fn(q1, q2):
ord = 1 # 1 | 2
return MOVE_COST + COST_PER_DIST*np.linalg.norm(q2 - q1, ord=ord)
def pick_distance_fn(q1, b, q2):
ord = 1 # 1 | 2
return MOVE_COST + COST_PER_DIST*np.linalg.norm(q2 - q1, ord=ord)
def duration_fn(traj):
distance = sum(np.linalg.norm(q2 - q1) for q1, q2 in zip(traj, traj[1:]))
return distance / DISTANCE_PER_TIME
def inverse_kin_fn(b, p, g):
q = inverse_kin(p, g)
#return (q,)
a = approach_kin(q)
return (a,)
def stack_inverse_kin_fn(b, p, g):
q = p - g
a = q - APPROACH - np.array([0, p[1]])
return (a,)
def unreliable_ik_fn(*args):
# For testing the algorithms
while 1e-2 < np.random.random():
yield None
yield inverse_kin_fn(*args)
def get_region_test(regions=[]):
def test(b, p, r):
return interval_contains(regions[r], get_block_interval(b, p))
return test
def get_block_region_test(regions=[]):
def test(bu, pu, bl, pl):
if interval_contains(get_block_interval(bl, pl)+np.array([-BLOCK_WIDTH,+BLOCK_WIDTH])/2., get_block_interval(bu, pu)):
return (pu[1] > pl[1]) and (pu[1] <= pl[1]+BLOCK_HEIGHT+0.1)
else:
return False
return test
def get_reach_test(robot_movable_region):
def test(r, q):
return (robot_movable_region[r][0] <= q[0]) and (q[0] <= robot_movable_region[r][1])
return test
def get_pose_gen(regions=[]):
def gen_fn(b, r):
while True:
p = sample_region(b, regions[r])
if p is None:
break
yield (p,)
return gen_fn
def get_center_pose_gen(regions=[]):
def gen_fn(b, r):
while True:
p = sample_center_region(b, regions[r])
if p is None:
break
yield (p,)
return gen_fn
def get_block_pose_gen(regions=[]):
def get_fn(bu, bl, pl):
while True:
p = sample_region(bu, get_block_interval(bl, pl)+np.array([-BLOCK_WIDTH,+BLOCK_WIDTH])/2.)
if p is None:
break
p[1] = pl[1] + BLOCK_HEIGHT
yield (p,)
return get_fn
def get_block_center_pose_gen(regions=[]):
def get_fn(bu, bl, pl):
while True:
p = sample_center_region(bu, get_block_interval(bl, pl)+np.array([-BLOCK_WIDTH,+BLOCK_WIDTH])/2.)
if p is None:
break
p[0] = pl[0]
p[1] = pl[1] + BLOCK_HEIGHT
yield (p,)
return get_fn
def get_stack_pose_gen(regions=[]):
def get_fn(bu, bl, pl):
while True:
p = sample_region(bu, get_block_interval(bl, pl)+np.array([-BLOCK_WIDTH,+BLOCK_WIDTH])/2.)
if p is None:
break
if stack_test(p, pl):
yield (p,)
return get_fn
def get_stack_center_pose_gen(regions=[]):
def get_fn(bu, bl, pl):
while True:
p = sample_center_region(bu, get_block_interval(bl, pl)+np.array([-BLOCK_WIDTH,+BLOCK_WIDTH])/2.)
if p is None:
break
if stack_test(p, pl):
yield (p,)
return get_fn
################################################## Problems
ENVIRONMENT_NAMES = [GROUND_NAME]
TAMPState = namedtuple('TAMPState', ['robot_confs', 'holding', 'block_poses'])
TAMPProblem = namedtuple('TAMPProblem', ['initial', 'regions',
'goal_conf', 'goal_in', 'goal_on'])
GOAL1_NAME = 'red'
GOAL2_NAME = 'orange'
STOVE_NAME = 'stove'
TABLE_NAME = 'table'
INITIAL_CONF = np.array([-5, CARRY_Y + 1])
GOAL_CONF = INITIAL_CONF
REGIONS = {
GROUND_NAME: (-10, 10),
GOAL1_NAME: (-2.25, -0.25),
GOAL2_NAME: (0.25, 2.25),
}
def make_blocks(num):
return [string.ascii_uppercase[i] for i in range(num)]
def gearbox(n_blocks=4, n_robots=1, deterministic=True):
confs = [INITIAL_CONF, np.array([-1, 1])*INITIAL_CONF]
robots = ['r{}'.format(x) for x in range(n_robots)]
initial_confs = dict(zip(robots, confs))
blocks = make_blocks(n_blocks)
if deterministic:
lower, upper = REGIONS[GROUND_NAME]
poses = [np.array([-7.5, 0]), np.array([-5.0, 0]), np.array([5.0, 0]), np.array([7.5, 0])]
poses.extend(np.array([lower + BLOCK_WIDTH/2 + (BLOCK_WIDTH + 1) * x, 0])
for x in range(n_blocks-len(poses)))
block_poses = dict(zip(blocks, poses))
else:
block_regions = {blocks[0]: GROUND_NAME}
block_regions.update({b: GOAL1_NAME for b in blocks[1:2]})
block_regions.update({b: GROUND_NAME for b in blocks[2:]})
block_poses = rejection_sample_placed(block_regions=block_regions, regions=REGIONS)
initial = TAMPState(initial_confs, {}, block_poses)
goal_in = {blocks[0]: GOAL1_NAME, blocks[2]: GOAL2_NAME}
goal_on = ((blocks[0], blocks[1]), (blocks[2], blocks[3]))
return TAMPProblem(initial, REGIONS, GOAL_CONF, goal_in, goal_on)
PROBLEMS = [
gearbox,
]
################################################## Draw functions
def draw_robot(viewer, robot, pose, **kwargs):
x, y = pose
viewer.draw_robot(x, y, name=robot, **kwargs)
def draw_block(viewer, block, pose, **kwargs):
x, y = pose
viewer.draw_block(x, y, BLOCK_WIDTH, BLOCK_HEIGHT, name=block, **kwargs)
def draw_state(viewer, state, colors):
# TODO: could draw the current time
viewer.clear_state()
#viewer.draw_environment()
print(state)
for robot, conf in state.robot_confs.items():
draw_robot(viewer, robot, conf)
for block, pose in state.block_poses.items():
draw_block(viewer, block, pose, color=colors[block])
for robot, holding in state.holding.items():
block, grasp = holding
pose = forward_kin(state.robot_confs[robot], grasp)
draw_block(viewer, block, pose, color=colors[block])
viewer.tk.update()
def get_random_seed():
return np.random.get_state()[1][0]
##################################################
def apply_action(state, action):
robot_confs, holding, block_poses = state
# TODO: don't mutate block_poses?
name, args = action[:2]
if name == 'move':
if len(args) == 4:
robot, _, traj, _ = args
else:
robot, q1, q2 = args
traj = [q1, q2]
#traj = plan_motion(*args)[0] if len(args) == 2 else args[1]
for conf in traj[1:]:
robot_confs[robot] = conf
yield TAMPState(robot_confs, holding, block_poses)
elif name == 'pick':
# TODO: approach and retreat trajectory
robot, block, _, grasp, _ = args
holding[robot] = (block, grasp)
del block_poses[block]
yield TAMPState(robot_confs, holding, block_poses)
elif name == 'place':
robot, block, pose, _, _ = args
del holding[robot]
block_poses[block] = pose
yield TAMPState(robot_confs, holding, block_poses)
else:
raise ValueError(name)
##################################################
def prune_duplicates(traj):
# TODO: could use the more general sparcify function
new_traj = [traj[0]]
for conf in traj[1:]:
if 0 < np.linalg.norm(np.array(conf) - np.array(new_traj[-1])):
new_traj.append(conf)
return new_traj
def get_value_at_time(traj, fraction):
waypoints = prune_duplicates(traj)
if len(waypoints) == 1:
return waypoints[0]
distances = [0.] + [np.linalg.norm(np.array(q2) - np.array(q1))
for q1, q2 in zip(waypoints, waypoints[1:])]
cum_distances = np.cumsum(distances)
cum_fractions = np.minimum(cum_distances / cum_distances[-1], np.ones(cum_distances.shape))
index = np.digitize(fraction, cum_fractions, right=False)
if index == len(waypoints):
index -= 1
waypoint_fraction = (fraction - cum_fractions[index - 1]) / (cum_fractions[index] - cum_fractions[index - 1])
waypoint1, waypoint2 = np.array(waypoints[index - 1]), np.array(waypoints[index])
conf = (1 - waypoint_fraction) * waypoint1 + waypoint_fraction * waypoint2
return conf
def update_state(state, action, t):
robot_confs, holding, block_poses = state
name, args, start, duration = action
fraction = float(t) / duration
fraction = max(0, min(fraction, 1))
assert 0 <= fraction <= 1
threshold = 0.5
if name == 'move':
robot, _, traj, _ = args
robot_confs[robot] = get_value_at_time(traj, fraction)
elif name == 'pick':
robot, block, pose, grasp, conf = args[:5]
traj = [conf, pose - grasp]
if fraction < threshold:
robot_confs[robot] = get_value_at_time(traj, fraction / threshold)
else:
holding[robot] = (block, grasp)
block_poses.pop(block, None)
robot_confs[robot] = get_value_at_time(traj[::-1], (fraction - threshold) / (1 - threshold))
elif name == 'place':
robot, block, pose, grasp, conf = args[:5]
traj = [conf, pose - grasp]
if fraction < threshold:
robot_confs[robot] = get_value_at_time(traj, fraction / threshold)
else:
holding.pop(robot, None)
block_poses[block] = pose
robot_confs[robot] = get_value_at_time(traj[::-1], (fraction - threshold) / (1 - threshold))
elif name == 'stack':
robot, u_block, u_pose, grasp, conf, l_block, l_pose = args
traj = [conf, u_pose - grasp]
if fraction < threshold:
robot_confs[robot] = get_value_at_time(traj, fraction / threshold)
else:
holding.pop(robot, None)
block_poses[u_block] = u_pose
robot_confs[robot] = get_value_at_time(traj[::-1], (fraction - threshold) / (1 - threshold))
elif name == 'cook':
# TODO: update the object color
pass
else:
raise ValueError(name)
return TAMPState(robot_confs, holding, block_poses)
| 14,894 |
Python
| 28.436759 | 126 | 0.568148 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_2d/utils/optimizer/optimizer.py
|
from __future__ import print_function
import numpy as np
import random
import time
import os
from utils.primitives import BLOCK_WIDTH, sample_region, plan_motion, GRASP
from hsr_tamp.pddlstream.language.constants import partition_facts, NOT, MINIMIZE, get_constraints, is_parameter
from hsr_tamp.pddlstream.language.optimizer import OptimizerOutput
from hsr_tamp.pddlstream.utils import INF, elapsed_time
MIN_CLEARANCE = 1e-3 # 0 | 1e-3
NAN = float('nan')
def has_gurobi():
try:
import gurobipy
except ImportError:
return False
return True
def value_from_var(vars):
import gurobipy
if isinstance(vars, float):
return vars
if isinstance(vars, gurobipy.Var):
return vars.X # .Xn
new_vars = list(map(value_from_var, vars))
if isinstance(vars, np.ndarray):
return np.array(new_vars)
return new_vars
def unbounded_var(model):
from gurobipy import GRB
return model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY)
def np_var(model, d=2, lower=None, upper=None):
from gurobipy import GRB
if lower is None:
lower = d*[-GRB.INFINITY]
if upper is None:
upper = d*[+GRB.INFINITY]
return np.array([model.addVar(lb=lb, ub=ub) for lb, ub in zip(lower, upper)])
def copy_model(model):
model.update()
return model.copy()
def vars_from_expr(expr):
return [expr.getVar(i) for i in range(expr.size())]
def set_value(var, value):
var.LB = value
var.UB = value
def set_guess(var, value, hard=True):
if hard:
# solver will try to build a single feasible solution from the provided set of variable values
var.Start = value
else:
# variable hints provide guidance to the MIP solver that affects the entire solution process
var.VarHintVal = value
##################################################
def collision_constraint(model, name, b1, p1, b2, p2):
from gurobipy import GRB
dist = unbounded_var(model)
abs_dist = unbounded_var(model)
model.addConstr(dist, GRB.EQUAL, p2[0] - p1[0], name=name)
model.addConstr(BLOCK_WIDTH + MIN_CLEARANCE, GRB.LESS_EQUAL, abs_dist, name=name)
model.addGenConstrAbs(abs_dist, dist, name=name) # abs_
def kinematics_constraint(model, name, b, q, p, g):
from gurobipy import GRB
for i in range(len(q)):
model.addConstr(q[i] + g[i], GRB.EQUAL, p[i], name=name)
#model.addConstr(p[1], GRB.EQUAL, 0, name=name) # IK vs pick/place semantics
def contained_constraint(model, regions, name, b, p, r):
from gurobipy import GRB
px, py = p
x1, x2 = regions[r]
model.addConstr(x1, GRB.LESS_EQUAL, px - BLOCK_WIDTH / 2, name=name)
model.addConstr(px + BLOCK_WIDTH / 2, GRB.LESS_EQUAL, x2, name=name)
model.addConstr(py, GRB.EQUAL, 0, name=name)
def motion_constraint(model, name, q1, t, q2):
from gurobipy import GRB
for i in range(len(q1)):
model.addConstr(t[0][i], GRB.EQUAL, q1[i], name=name)
for i in range(len(q2)):
model.addConstr(t[1][i], GRB.EQUAL, q2[i], name=name)
def distance_cost(model, q1, q2, norm=1):
from gurobipy import GRB
# TODO: cost on endpoints and subtract from total cost
terms = []
for i in range(len(q1)):
delta = q2[i] - q1[i]
if norm == 1:
# TODO: doesn't work with deletion filter (additional constraints)
distance = model.addVar(lb=0., ub=GRB.INFINITY)
model.addConstr(-delta <= distance)
model.addConstr(delta <= distance)
terms.append(distance)
elif norm == 2:
terms.append(delta * delta)
else:
raise RuntimeError(norm)
return terms
##################################################
def sample_sphere_surface(d, uniform=True):
# TODO: hyperspherical coordinates
# https://en.wikipedia.org/wiki/N-sphere#Spherical_coordinates
while True:
v = np.random.randn(d)
r = np.sqrt(v.dot(v))
if not uniform or (r <= 1.):
return v / r
def sample_sphere(d, **kwargs):
v = sample_sphere_surface(d, **kwargs)
r = np.random.rand()
return np.power(r, 1./d)*v
def sample_subspace(d, m):
# TODO: linear spaces sampling method
# https://arxiv.org/abs/1810.06271
A = np.random.randn(m, d)
b = np.random.randn(m)
return A, b
##################################################
def sample_targets(model, variables):
# TODO: project without inequality constraints (placement)
# TODO: manifold learning for feasible subspace
# TODO: sample from neighborhood of the previous solution
from gurobipy import GRB
model.update()
objective_terms = []
for var in variables:
# TODO: apply only to some variables
if (-INF < var.LB) and (var.UB < INF):
# TODO: inequality constraint version of this
extent = var.UB - var.LB
value = random.uniform(var.LB, var.UB)
delta = var - value
distance = model.addVar(lb=0., ub=GRB.INFINITY)
model.addConstr(-delta <= distance)
model.addConstr(delta <= distance)
objective_terms.append(distance / extent)
# covar_from_paramord.X = 0 # Attribute 'X' cannot be set
print(var, var.LB, var.UB, value)
# TODO: start with feasible solution and then expand
return objective_terms
def sample_solutions(model, variables, num_samples=INF, norm=2, closest=True):
from gurobipy import GRB, quicksum, abs_
start_time = time.time()
objective = model.getObjective()
#sprint(objective, objective.getValue())
# model = model.feasibility()
# model.setObjective(0.0)
if norm == 2:
model.setParam(GRB.Param.NonConvex, 2) # PSDTol
objective_terms = []
if closest:
min_distance = model.addVar(lb=0., ub=GRB.INFINITY)
objective_terms.append(min_distance)
solutions = [] # TODO: sample initial solution from this set
while len(solutions) < num_samples:
terms = []
for var in variables:
for index, coord in enumerate(var):
value = coord.X
set_guess(coord, value, hard=True)
delta = model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY)
model.addConstr(delta == coord - value)
if norm == 1:
term = model.addVar(lb=0., ub=GRB.INFINITY)
model.addConstr(term == abs_(delta))
elif norm == 2:
term = delta*delta
else:
raise NotImplementedError(norm)
terms.append(term) # TODO: scale
distance = quicksum(terms)
if closest:
model.addConstr(min_distance <= distance)
else:
objective_terms.append(distance) # TODO: weight
model.setObjective(quicksum(objective_terms), sense=GRB.MAXIMIZE) # MINIMIZE | MAXIMIZE
model.optimize()
print('# {} | objective: {:.3f} | cost: {:.3f} | runtime: {:.3f}'.format(
len(solutions), model.ObjVal, objective.getValue(), elapsed_time(start_time))) # min_distance.X
solution = [value_from_var(var) for var in variables]
solutions.append(solution)
yield solution
##################################################
def get_optimize_fn(regions, collisions=True, max_time=5., hard=False,
diagnostic='all', diagnose_cost=False, verbose=False):
# https://www.gurobi.com/documentation/8.1/examples/diagnose_and_cope_with_inf.html
# https://www.gurobi.com/documentation/8.1/examples/tsp_py.html#subsubsection:tsp.py
# https://examples.xpress.fico.com/example.pl?id=Infeasible_python
# https://www.fico.com/fico-xpress-optimization/docs/latest/examples/python/GUID-E77AC35C-9488-3F0A-98B4-7F5FD81AFF1D.html
if not has_gurobi():
raise ImportError('This generator requires Gurobi: http://www.gurobi.com/')
from gurobipy import Model, GRB, quicksum, abs_
min_x = min(x1 for x1, _ in regions.values())
max_x = max(x2 for _, x2 in regions.values())
min_y, max_y = 0, (max_x - min_x) / 2.
lower = [min_x, min_y]
upper = [max_x, max_y]
# lower = 2*[-INF]
# upper = 2*[+INF]
# lower = upper = None
def fn(outputs, facts, hint={}):
# TODO: pass in the variables and constraint streams instead?
# The true test is placing two blocks in a tight region obstructed by one
constraint_indices = {i for i, term in enumerate(facts) if term[0] != MINIMIZE}
positive, negative, costs = partition_facts(facts)
#print('Parameters:', outputs)
#print('Constraints:', positive + negative)
if costs:
print('Costs:', costs)
# https://github.com/yijiangh/coop_assembly/blob/e52abef7c1cfb1d3e32691d163abc85dd77f27a2/src/coop_assembly/geometry_generation/caelan.py
model = Model(name='TAMP')
model.setParam(GRB.Param.OutputFlag, verbose)
model.setParam(GRB.Param.TimeLimit, max_time)
model.setParam(GRB.Param.Cutoff, GRB.INFINITY) # TODO: account for scaling
#if num_solutions < INF:
# model.setParam(GRB.Param.SolutionLimit, num_solutions)
# Limit how many solutions to collect
#model.setParam(GRB.Param.PoolSolutions, 2)
# Limit the search space by setting a gap for the worst possible solution that will be accepted
#model.setParam(GRB.Param.PoolGap, 0.10) # PoolGapAbs
# do a systematic search for the k-best solutions
#model.setParam(GRB.Param.PoolSearchMode, 2) # 0 | 1 | 2
# https://www.gurobi.com/documentation/9.1/examples/poolsearch_py.html#subsubsection:poolsearch.py
##########
# TODO: remove anything that's just a domain condition?
variable_indices = {}
var_from_param = {}
for index, fact in enumerate(facts):
prefix, args = fact[0], fact[1:]
if prefix == 'conf':
param, = args
if is_parameter(param):
var_from_param[param] = np_var(model, lower=lower, upper=upper)
elif prefix == 'pose':
_, param = args
if is_parameter(param):
var_from_param[param] = np_var(model, lower=lower, upper=upper)
elif prefix == 'grasp': # TODO: iterate over combinations
_, param = args
if is_parameter(param):
var_from_param[param] = GRASP
elif prefix == 'traj':
raise NotImplementedError()
#param, = args
#if param not in var_from_id:
# var_from_id[id(param)] = [np_var(model), np_var(model)]
else:
continue
variable_indices[index] = fact
dimension = sum(len(var) for var in var_from_param.values())
def get_var(p):
return var_from_param[p] if is_parameter(p) else p
##########
codimension = 0
objective_terms = [] # TODO: could make a variable to impose a cost constraint
constraint_from_name = {}
for index, fact in enumerate(facts):
prefix, args = fact[0], fact[1:]
name = str(index)
if prefix == 'kin':
kinematics_constraint(model, name, *map(get_var, args))
codimension += 2
elif prefix in ('contain', 'contained'):
contained_constraint(model, regions, name, *map(get_var, args))
codimension += 1
elif prefix == 'cfree' and collisions:
# TODO: drop collision constraints until violated
collision_constraint(model, name, *map(get_var, args))
elif prefix == 'motion':
#motion_constraint(model, name, *map(get_var, args))
raise NotImplementedError()
elif prefix == NOT:
fact = args[0]
predicate, args = fact[0], fact[1:]
if predicate == 'posecollision' and collisions:
collision_constraint(model, name, *map(get_var, args))
elif prefix == MINIMIZE:
fact = args[0]
func, args = fact[0], fact[1:]
if func in ('dist', 'distance'):
objective_terms.extend(distance_cost(model, *map(get_var, args)))
continue
constraint_from_name[name] = fact
model.update()
##########
#linear_model = model
linear_model = copy_model(model)
#linear_model = Model(name='Linear TAMP')
# TODO: prune linearly dependent constraints
linear_constraints = {c for c in linear_model.getConstrs() if c.sense == GRB.EQUAL}
codimension = len(linear_constraints)
# TODO: account for v.LB == v.UB
#linear_variables = {v for v in linear_model.getVars() if v.VType == GRB.CONTINUOUS}
#print(vars_from_expr(linear_model.getObjective()))
linear_variables = set()
for c in linear_constraints:
linear_variables.update(vars_from_expr(linear_model.getRow(c)))
linear_variables = sorted(linear_variables, key=lambda v: v.VarName)
dimension = len(linear_variables)
print('{} variables (dim={}): {}'.format(len(variable_indices), dimension,
[facts[index] for index in sorted(variable_indices)]))
nontrivial_indices = set(constraint_indices) - set(variable_indices) # TODO: rename
print('{} constraints: (codim={}): {}'.format(len(nontrivial_indices), codimension,
[facts[index] for index in sorted(nontrivial_indices)]))
# # https://en.wikipedia.org/wiki/Linear_subspace
# # TODO: Equations for a subspace
# #for c in model.getConstrs():
# # if c.sense != GRB.EQUAL:
# # model.remove(c)
# variables = [model.getVarByName(v.VarName) for v in linear_variables]
# lower_bound = np.array([v.LB for v in variables])
# upper_bound = np.array([v.UB for v in variables])
# center = (lower_bound + upper_bound) / 2.
# extent = (upper_bound - lower_bound) / 2.
# radius = np.linalg.norm(extent) # sphere
#
# point = radius*sample_sphere(dimension) + center
# #point = center
# basis = [sample_sphere_surface(dimension) for _ in range(codimension)]
# #basis = [np.ones(dimension)]
# multipliers = [unbounded_var(model) for _ in basis]
# subspace_constraints = []
# for i in range(dimension):
# combination = sum([m*b[i] for m, b in zip(multipliers, basis)])
# subspace_constraints.append(model.addConstr(variables[i] - point[i] == combination))
# #for c in subspace_constraints:
# # model.remove(c)
# TODO: generator version
# for v in set(linear_model.getVars()) - linear_variables:
# linear_model.remove(v)
# for c in set(linear_model.getConstrs()) - linear_constraints:
# linear_model.remove(c)
# linear_model.setObjective(quicksum(sample_targets(linear_model, linear_variables)), sense=GRB.MINIMIZE)
# linear_model.optimize()
# for v in linear_variables: # Projection method
# set_value(model.getVarByName(v.VarName), v.X)
##########
# TODO: normalize cost relative to the best cost for a trade-off
# TODO: increasing bound on deterioration in quality
weight = 0
if weight > 0:
primary_variables = {v for var in var_from_param.values() for v in var}
objective_terms.extend(weight * term for term in sample_targets(model, primary_variables))
model.setObjective(quicksum(objective_terms), sense=GRB.MINIMIZE) # (1-weight) * quicksum(objective_terms)
for out, value in hint.items():
for var, coord in zip(get_var(out), value):
# https://www.gurobi.com/documentation/9.1/refman/varhintval.html#attr:VarHintVal
set_guess(var, coord, hard=hard)
#set_value(var, coord)
##########
#m.write("file.lp")
model.optimize()
# https://www.gurobi.com/documentation/7.5/refman/optimization_status_codes.html
#if model.status in (GRB.INFEASIBLE, GRB.INF_OR_UNBD, GRB.CUTOFF): # OPTIMAL | SUBOPTIMAL
if model.SolCount == 0:
if diagnostic is None:
return OptimizerOutput()
elif diagnostic == 'all':
#infeasible = constraint_indices
infeasible = nontrivial_indices
elif diagnostic == 'deletion':
infeasible = deletion_filter(model, constraint_indices)
elif diagnostic == 'elastic':
infeasible = elastic_filter(model, constraint_indices)
elif diagnostic == 'gurobi':
infeasible = compute_inconsistent(model)
else:
raise NotImplementedError(diagnostic)
print('Inconsistent:', [facts[index] for index in sorted(infeasible)])
return OptimizerOutput(infeasible=[infeasible])
#expr.getValue() # TODO: store expressions and evaluate value
# for c in model.getConstrs():
# print(c, c.Slack, c.RHS)
# print(c.__dict__)
# print(dir(c))
##########
print('Solved: {} | Objective: {:.3f} | Solutions: {} | Status: {} | Runtime: {:.3f}'.format(
True, model.ObjVal, model.SolCount, model.status, model.runtime))
if costs and diagnose_cost:
infeasible = deletion_filter(model, constraint_indices, max_objective=model.ObjVal - 1e-6)
else:
# TODO: propagate automatically to optimizer
#infeasible = constraint_indices
infeasible = nontrivial_indices
print('Cost inconsistent:', [facts[index] for index in sorted(infeasible)])
# variables = list(var_from_param.values())
# for index, solution in enumerate(sample_solutions(model, variables, num_samples=15)):
# print(index, solution)
assignment = tuple(value_from_var(get_var(out)) for out in outputs)
return OptimizerOutput(assignments=[assignment], infeasible=[infeasible])
return fn
#return lambda outputs, facts, **kwargs: \
# identify_infeasibility(fn, outputs, facts, diagnose=False, **kwargs)
##################################################
def compute_inconsistent(model):
from gurobipy import GRB
# TODO: search over irreducible infeasible sets
model.setObjective(0.0) # Makes a difference in performance
model.setParam(GRB.Param.IISMethod, 1) # -1 | 0 | 1 | 2 | 3
model.computeIIS()
print('IIS is minimal\n' if model.IISMinimal else 'IIS is not minimal\n')
#assert model.IISMinimal
infeasible = {int(c.constrName) for c in model.getConstrs() if c.IISConstr}
return infeasible
def enumerate_inconsistent(model):
# TODO: exhaustively enumerate IIS
raise NotImplementedError()
##################################################
def constraints_from_indices(model, indices):
names = {str(i) for i in indices}
return [c for c in model.getConstrs() if c.constrName in names]
def deletion_filter(original_model, indices, max_objective=INF):
from gurobipy import GRB
model = copy_model(original_model)
if max_objective < INF:
model.setParam(GRB.Param.Cutoff, max_objective)
else:
model = model.feasibility()
# prune_constraints = set(model.getConstrs()) - set(constraints_from_indices(model, indices))
# for c in prune_constraints:
# model.remove(c)
model.optimize()
#assert model.status in (GRB.INFEASIBLE, GRB.INF_OR_UNBD, GRB.CUTOFF)
assert model.SolCount == 0
inconsistent = set()
for index in sorted(indices):
temp_model = copy_model(model)
constraints = constraints_from_indices(temp_model, {index})
if not constraints:
continue
for c in constraints:
temp_model.remove(c)
temp_model.optimize()
#if temp_model.status == GRB.INFEASIBLE:
if temp_model.SolCount == 0:
model = temp_model
else:
inconsistent.add(index)
return inconsistent
##################################################
def relax_constraints(model, indices):
from gurobipy import GRB
# http://www.sce.carleton.ca/faculty/chinneck/docs/ChinneckDravnieks.pdf
model.setObjective(0.0)
elastic_constraints = constraints_from_indices(model, indices)
objective = model.feasRelax(relaxobjtype=0, # feasRelaxS
minrelax=True,
vars=[], lbpen=[], ubpen=[],
constrs=elastic_constraints,
rhspen=[1.]*len(elastic_constraints))
model.optimize()
if model.status == GRB.INFEASIBLE:
return None
#print('Violation:', objective)
art_vars = [var for var in model.getVars()
if any(var.varname.startswith(p) for p in ['ArtP_', 'ArtN_'])] # Positive & Negative
violations = {}
for var in art_vars:
index = int(var.varname[5:])
violations[index] = violations.get(index, 0) + var.x
#for index, value in sorted(violations.items(), key=lambda (i, v): v):
# print('{}: {}'.format(facts[index], value))
violated = {index for index, value in violations.items() if 1e-6 < value}
return violated
def elastic_filter(original_model, indices, postproces=True):
elastic = set(indices)
inconsistent = set()
while True:
relaxed_model = copy_model(original_model)
violated = relax_constraints(relaxed_model, elastic)
if violated is None:
break
elastic -= violated
inconsistent |= violated
if postproces:
inconsistent = deletion_filter(original_model, inconsistent)
return inconsistent
##################################################
def identify_infeasibility(fn, parameters, terms, **kwargs):
# TODO: apply to general constraint networks
output = fn(parameters, terms, **kwargs)
if output:
return output
active_indices = {i for i, term in enumerate(terms) if term[0] != MINIMIZE}
for index in list(active_indices):
constraints = [terms[i] for i in active_indices - {index}]
output = fn(parameters, constraints, **kwargs)
if output:
active_indices.remove(index)
# TODO: be careful about removing variables
infeasible_facts = [terms[index] for index in sorted(active_indices)]
print('Inconsistent:', infeasible_facts)
return OptimizerOutput(infeasible=[infeasible_facts])
def identify_feasible_subsets(facts, model):
# TODO: add facts corresponding to feasible subproblems
# The trouble is that it's not clear which constraints would be useful to relax
model.setObjective(0.0)
model.computeIIS()
print('IIS is minimal\n' if model.IISMinimal else 'IIS is not minimal\n')
iss_constraints = {c.constrName for c in model.getConstrs() if c.IISConstr}
#iss_constraints = compute_inconsistent(model)
iss_facts = [facts[int(name)] for name in sorted(iss_constraints)]
print(iss_facts)
for c in model.getConstrs():
if c.constrName in iss_constraints:
model.remove(c)
# TODO: reoptimize
# TODO: drop the objective function and decompose into smaller clusters
# Iterate over subsets of constraints that are allowed to be violated/removed
# The relaxation is a heuristic to more intelligently guide this search
# Use L1 penalization to enforce sparsity. Could even frame as a MILP
# The assumption is that there is intersection between the failure and a solution
raise NotImplementedError()
##################################################
def cfree_motion_fn(outputs, facts, hint={}):
if not outputs:
return None
assert(len(outputs) == 1)
# TODO: handle connected components
q0, q1 = None, None
placed = {}
for fact in facts:
if fact[0] == 'motion':
if q0 is not None:
return None
q0, _, q1 = fact[1:]
if fact[0] == NOT:
_, b, p = fact[1][1:]
placed[b] = p
if q0 is None:
t = []
return (t,)
return plan_motion(q0, q1)
##################################################
def get_cfree_pose_fn(regions):
def fn(outputs, certified):
b, r = None, None
placed = {}
for fact in certified:
if fact[0] == 'contained':
b, _, r = fact[1:]
if fact[0] == NOT:
_, _, b2, p2 = fact[1][1:]
placed[b2] = p2
p = sample_region(b, regions[r])
return (p,)
return fn
# def get_pose_generator(regions):
# class PoseGenerator(Generator):
# def __init__(self, *inputs):
# super(PoseGenerator, self).__init__()
# self.b, self.r = inputs
# def generate(self, outputs=None, streams=tuple()):
# # TODO: designate which streams can be handled
# placed = {}
# for stream in streams:
# name, args = stream[0], stream[1:]
# if name in ['collision-free', 'cfree']:
# for i in range(0, len(args), 2):
# b, p = args[i:i+2]
# if self.b != b:
# placed[b] = p
# #p = sample_region(self.b, regions[self.r])
# p = rejection_sample_region(self.b, regions[self.r], placed=placed)
# if p is None:
# return []
# return [(p,)]
# return PoseGenerator
| 26,018 |
Python
| 39.528037 | 145 | 0.589092 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/tamp_hsr_planner.py
|
#!/usr/bin/env python
import numpy as np
from collections import namedtuple
from utils.pybullet_tools.hsrb_problems import PROBLEMS
from utils.pybullet_tools.hsrb_utils import get_arm_joints, get_gripper_joints, get_group_joints, get_group_conf
from utils.pybullet_tools.utils import (
# Simulation utility
connect, disconnect, save_state, has_gui, restore_state, wait_if_gui, \
# Getter
get_pose, get_distance, get_joint_positions, get_max_limit, \
is_placement, point_from_pose, \
LockRenderer, WorldSaver, SEPARATOR)
from utils.pybullet_tools.hsrb_primitives import (
# Geometry
Pose, Conf, State, Cook, Clean, \
# Command
GripperCommand, Attach, Detach, \
# Utility
apply_commands, apply_commands_with_visualization, control_commands, \
# Getter
get_ik_ir_gen, get_motion_gen, get_stable_gen, get_grasp_gen, get_insert_gen, \
# Tester
get_cfree_approach_pose_test, get_cfree_pose_pose_test, get_cfree_traj_pose_test, \
get_supported, get_inserted, \
# Cost function
move_cost_fn)
from hsr_tamp.pddlstream.algorithms.meta import solve, create_parser
from hsr_tamp.pddlstream.language.generator import from_gen_fn, from_list_fn, from_fn, fn_from_constant, empty_gen, from_test
from hsr_tamp.pddlstream.language.constants import print_solution, Equal, AND, PDDLProblem
from hsr_tamp.pddlstream.language.external import defer_shared, never_defer
from hsr_tamp.pddlstream.language.function import FunctionInfo
from hsr_tamp.pddlstream.language.stream import StreamInfo
from hsr_tamp.pddlstream.language.object import SharedOptValue
from hsr_tamp.pddlstream.utils import find_unique, get_file_path, read, str_from_object, Profiler, INF
BASE_CONSTANT = 1
BASE_VELOCITY = 0.5
#######################################################
def extract_point2d(v):
if isinstance(v, Conf):
return v.values[:2]
if isinstance(v, Pose):
return point_from_pose(v.value)[:2]
if isinstance(v, SharedOptValue):
if v.stream == 'sample-place':
r, = v.values
return point_from_pose(get_pose(r))[:2]
if v.stream == 'sample-insert':
r, = v.values
return point_from_pose(get_pose(r))[:2]
if v.stream == 'inverse-kinematics':
p, = v.values
return extract_point2d(p)
if isinstance(v, CustomValue):
if v.stream == 'p-sp':
r, = v.values
return point_from_pose(get_pose(r))[:2]
if v.stream == 'q-ik':
p, = v.values
return extract_point2d(p)
raise ValueError(v.stream)
#######################################################
CustomValue = namedtuple('CustomValue', ['stream', 'values'])
def move_cost_fn(c):
return 1
def opt_move_cost_fn(t):
return 1
def opt_place_fn(o, r):
p2 = CustomValue('p-sp', (r,))
return p2,
def opt_insert_fn(o, r):
p2 = CustomValue('p-si', (r,))
return p2,
def opt_ik_fn(a, o, p, g):
q = CustomValue('q-ik', (p,))
t = CustomValue('t-ik', tuple())
return q, t
def opt_motion_fn(q1, q2):
t = CustomValue('t-pbm', (q1, q2))
return t,
#######################################################
class TAMPPlanner(object):
def pddlstream_from_problem(self, problem, collisions=True, teleport=False):
robot = problem.robot
domain_pddl = read(get_file_path(__file__, 'task/assemble/domain.pddl'))
stream_pddl = read(get_file_path(__file__, 'task/assemble/stream.pddl'))
constant_map = {}
initial_bq = Conf(robot, get_group_joints(robot, 'base'), get_group_conf(robot, 'base'))
init = [
('CanMove',),
('BConf', initial_bq),
('AtBConf', initial_bq),
Equal(('PickCost',), 1),
Equal(('PlaceCost',), 1),
Equal(('InsertCost',), 1),
] + [('Sink', s) for s in problem.sinks] + \
[('Stove', s) for s in problem.stoves] + \
[('Connected', b, d) for b, d in problem.buttons] + \
[('Button', b) for b, _ in problem.buttons]
joints = get_arm_joints(robot, 'arm')
conf = Conf(robot, joints, get_joint_positions(robot, joints))
init += [('Arm', 'arm'), ('AConf', 'arm', conf), ('HandEmpty', 'arm'), ('AtAConf', 'arm', conf)]
init += [('Controllable', 'arm')]
for body in problem.movable:
pose = Pose(body, get_pose(body))
init += [('Graspable', body), ('Pose', body, pose),
('AtPose', body, pose)]
goal = [AND]
if problem.goal_conf is not None:
goal_conf = Pose(robot, problem.goal_conf)
init += [('BConf', goal_conf)]
goal += [('AtBConf', goal_conf)]
for body in problem.surfaces:
pose = Pose(body, get_pose(body))
init += [('RegionPose', body, pose)]
for body in problem.holes:
pose = Pose(body, get_pose(body))
init += [('HolePose', body, pose)]
init += [('Inserted', b1) for b1 in problem.holes]
init += [('Placeable', b1, b2) for b1, b2 in problem.init_placeable]
init += [('Insertable', b1, b2) for b1, b2 in problem.init_insertable]
goal += [('Holding', a, b) for a, b in problem.goal_holding] + \
[('On', a, b) for a, b in problem.goal_on] + \
[('InHole', a, b) for a, b in problem.goal_inserted] + \
[('Cleaned', b) for b in problem.goal_cleaned] + \
[('Cooked', b) for b in problem.goal_cooked]
stream_map = {
'sample-place': from_gen_fn(get_stable_gen(problem, collisions=collisions)),
'sample-insert': from_gen_fn(get_insert_gen(problem, collisions=collisions)),
'sample-grasp': from_list_fn(get_grasp_gen(problem, collisions=False)),
'plan-base-motion': from_fn(get_motion_gen(problem, collisions=True, teleport=teleport)),
'inverse-kinematics': from_gen_fn(get_ik_ir_gen(problem, collisions=collisions, teleport=teleport)),
'test-cfree-pose-pose': from_test(get_cfree_pose_pose_test(collisions=collisions)),
'test-cfree-approach-pose': from_test(get_cfree_approach_pose_test(problem, collisions=collisions)),
'test-cfree-traj-pose': from_test(get_cfree_traj_pose_test(problem, collisions=collisions)),
'test-supported': from_test(get_supported(problem, collisions=collisions)),
'test-inserted': from_test(get_inserted(problem, collisions=collisions)),
'MoveCost': move_cost_fn,
}
return PDDLProblem(domain_pddl, constant_map, stream_pddl, stream_map, init, goal)
def initialize(self, parser):
parser.add_argument('-e', '--enable', action='store_true', help='Enables rendering during planning')
parser.add_argument('-d', '--deterministic', action='store_true', help='Uses a deterministic sampler')
parser.add_argument('-t', '--max_time', default=30, type=int, help='The max time')
parser.add_argument('-c', '--cfree', default=False, type=bool, help="select collision activate")
parser.add_argument('-n', '--number', default=4, type=int, help='The number of blocks')
parser.add_argument('-p', '--problem', default='gearbox_problem', help='The name of the problem to solve')
parser.add_argument('-v', '--visualize', action='store_true', help='Visualizes graphs')
parser.add_argument("--gpu_id", help="select using gpu id", type=str, default="-1")
parser.add_argument("--save", help="select save models", type=str, default=True)
parser.add_argument("--debug", help="save visualization", type=bool, default=False)
parser.add_argument("--teleport", action='store_true', help='Teleports between configurations')
parser.add_argument("--simulate", action='store_true', help='Simulates the system')
args = parser.parse_args()
print('Arguments:', args)
connect(use_gui=True, shadows=False)
np.set_printoptions(precision=2)
if args.deterministic:
self.set_deterministic()
problem_from_name = {fn.__name__: fn for fn in PROBLEMS}
if args.problem not in problem_from_name:
raise ValueError(args.problem)
print('Problem:', args.problem)
problem_fn = problem_from_name[args.problem]
tamp_problem = problem_fn()
return tamp_problem, args
def post_process(self, problem, plan, teleport=False):
if plan is None:
return None
commands = []
for i, (name, args) in enumerate(plan):
if name == 'move_base':
q1, q2, c = args
new_commands = c.commands
elif name == 'pick':
a, b, p, g, _, c = args
[traj_approach, traj_pick, traj_return] = c.commands
close_gripper = GripperCommand(problem.robot, a, g.grasp_width, teleport=teleport)
attach = Attach(problem.robot, a, g, b)
new_commands = new_commands = [traj_approach, traj_pick, close_gripper, attach, traj_pick.reverse(), traj_return]
elif name == 'place':
a, b1, b2, p, g, _, c = args
[traj_approach, traj_place] = c.commands
gripper_joint = get_gripper_joints(problem.robot, a)[0]
position = get_max_limit(problem.robot, gripper_joint)
new_commands = [traj_approach, traj_place]
elif name == 'insert':
a, b1, b2, p1, p2, g, _, _, c = args
[traj_insert, traj_depart, traj_return] = c.commands
gripper_joint = get_gripper_joints(problem.robot, a)[0]
position = get_max_limit(problem.robot, gripper_joint)
open_gripper = GripperCommand(problem.robot, a, position, teleport=teleport)
detach = Detach(problem.robot, a, b1)
new_commands = [traj_insert, detach, open_gripper, traj_depart, traj_return.reverse()]
elif name == 'clean':
body, sink = args
new_commands = [Clean(body)]
elif name == 'cook':
body, stove = args
new_commands = [Cook(body)]
else:
raise ValueError(name)
print(i, name, args, new_commands)
commands += new_commands
return commands
def plan(self):
parser = create_parser()
parser.add_argument('-g', '--gurobi', action='store_true', help='Uses gurobi')
parser.add_argument('-o', '--optimal', action='store_true', help='Runs in an anytime mode')
parser.add_argument('-s', '--skeleton', action='store_true', help='Enforces skeleton plan constraints')
tamp_problem, args = self.initialize(parser)
saver = WorldSaver()
pddlstream_problem = self.pddlstream_from_problem(tamp_problem, collisions=not args.cfree, teleport=args.teleport)
stream_info = {
'MoveCost': FunctionInfo(opt_move_cost_fn),
'sample-place': StreamInfo(opt_gen_fn=from_fn(opt_place_fn)),
'sample-insert': StreamInfo(opt_gen_fn=from_fn(opt_insert_fn)),
'inverse-kinematics': StreamInfo(opt_gen_fn=from_fn(opt_ik_fn)),
'plan-base-motion': StreamInfo(opt_gen_fn=from_fn(opt_motion_fn)),
}
_, _, _, stream_map, init, goal = pddlstream_problem
print('Init:', init)
print('Goal:', goal)
print('Streams:', str_from_object(set(stream_map)))
print(SEPARATOR)
with Profiler():
with LockRenderer(lock=not args.enable):
solution = solve(pddlstream_problem, algorithm=args.algorithm, unit_costs=args.unit,
stream_info=stream_info, success_cost=INF, verbose=True, debug=False)
saver.restore()
print_solution(solution)
plan, cost, evaluations = solution
print('#############################')
print('plan: ', plan)
print('#############################')
if (plan is None) or not has_gui():
return
return plan, cost, evaluations
def execute(self):
parser = create_parser()
parser.add_argument('-g', '--gurobi', action='store_true', help='Uses gurobi')
parser.add_argument('-o', '--optimal', action='store_true', help='Runs in an anytime mode')
parser.add_argument('-s', '--skeleton', action='store_true', help='Enforces skeleton plan constraints')
tamp_problem, args = self.initialize(parser)
saver = WorldSaver()
pddlstream_problem = self.pddlstream_from_problem(tamp_problem, collisions=not args.cfree, teleport=args.teleport)
stream_info = {
'MoveCost': FunctionInfo(opt_move_cost_fn),
'sample-place': StreamInfo(opt_gen_fn=from_fn(opt_place_fn)),
'sample-insert': StreamInfo(opt_gen_fn=from_fn(opt_insert_fn)),
'inverse-kinematics': StreamInfo(opt_gen_fn=from_fn(opt_ik_fn)),
'plan-base-motion': StreamInfo(opt_gen_fn=from_fn(opt_motion_fn)),
}
_, _, _, stream_map, init, goal = pddlstream_problem
print('Init:', init)
print('Goal:', goal)
print('Streams:', str_from_object(set(stream_map)))
print(SEPARATOR)
with Profiler():
with LockRenderer(lock=not args.enable):
solution = solve(pddlstream_problem, algorithm=args.algorithm, unit_costs=args.unit,
stream_info=stream_info, success_cost=INF, verbose=True, debug=False)
saver.restore()
print_solution(solution)
plan, cost, evaluations = solution
print('#############################')
print('plan: ', plan)
print('#############################')
if (plan is None) or not has_gui():
disconnect()
return
with LockRenderer(lock=not args.enable):
commands = self.post_process(tamp_problem, plan)
tamp_problem.remove_gripper()
saver.restore()
saver.restore()
wait_if_gui('Execute?')
if args.simulate:
control_commands(commands)
else:
apply_commands_with_visualization(State(), commands, time_step=0.03)
wait_if_gui('Finish?')
disconnect()
if __name__ == '__main__':
tamp_planner = TAMPPlanner()
tamp_planner.execute()
| 14,569 |
Python
| 41.852941 | 129 | 0.581577 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/tamp_pr2_planner.py
|
#!/usr/bin/env python
from __future__ import print_function
from utils.pybullet_tools.pr2_primitives import Pose, Conf, get_ik_ir_gen, get_motion_gen, \
get_stable_gen, get_grasp_gen, Attach, Detach, Clean, Cook, control_commands, \
get_gripper_joints, GripperCommand, apply_commands, State, get_cfree_approach_pose_test, \
get_cfree_pose_pose_test, get_cfree_traj_pose_test, move_cost_fn
from utils.pybullet_tools.pr2_problems import cleaning_problem, cooking_problem, stacking_problem, holding_problem
from utils.pybullet_tools.pr2_utils import get_arm_joints, ARM_NAMES, get_group_joints, get_group_conf
from utils.pybullet_tools.utils import connect, get_pose, is_placement, point_from_pose, \
disconnect, get_joint_positions, enable_gravity, save_state, restore_state, HideOutput, \
get_distance, LockRenderer, get_min_limit, get_max_limit, has_gui, WorldSaver, wait_if_gui, add_line, SEPARATOR
from hsr_tamp.pddlstream.algorithms.meta import solve, create_parser
from hsr_tamp.pddlstream.language.generator import from_gen_fn, from_list_fn, from_fn, fn_from_constant, empty_gen, from_test
from hsr_tamp.pddlstream.language.constants import Equal, AND, print_solution, PDDLProblem
from hsr_tamp.pddlstream.language.function import FunctionInfo
from hsr_tamp.pddlstream.language.stream import StreamInfo, PartialInputs
from hsr_tamp.pddlstream.language.object import SharedOptValue
from hsr_tamp.pddlstream.language.external import defer_shared, never_defer
from hsr_tamp.pddlstream.utils import read, INF, get_file_path, find_unique, Profiler, str_from_object
from collections import namedtuple
BASE_CONSTANT = 1
BASE_VELOCITY = 0.5
#######################################################
def extract_point2d(v):
if isinstance(v, Conf):
return v.values[:2]
if isinstance(v, Pose):
return point_from_pose(v.value)[:2]
if isinstance(v, SharedOptValue):
if v.stream == 'sample-pose':
r, = v.values
return point_from_pose(get_pose(r))[:2]
if v.stream == 'inverse-kinematics':
p, = v.values
return extract_point2d(p)
if isinstance(v, CustomValue):
if v.stream == 'p-sp':
r, = v.values
return point_from_pose(get_pose(r))[:2]
if v.stream == 'q-ik':
p, = v.values
return extract_point2d(p)
raise ValueError(v.stream)
#######################################################
CustomValue = namedtuple('CustomValue', ['stream', 'values'])
def move_cost_fn(c):
return 1
def opt_move_cost_fn(t):
return 1
def opt_pose_fn(o, r):
p = CustomValue('p-sp', (r,))
return p,
def opt_ik_fn(a, o, p, g):
q = CustomValue('q-ik', (p,))
t = CustomValue('t-ik', tuple())
return q, t
def opt_motion_fn(q1, q2):
t = CustomValue('t-pbm', (q1, q2))
return t,
#######################################################
class TAMPPlanner(object):
def pddlstream_from_problem(self, problem, collisions=True, teleport=False):
robot = problem.robot
domain_pddl = read(get_file_path(__file__, 'task/cook/domain.pddl'))
stream_pddl = read(get_file_path(__file__, 'task/cook/stream.pddl'))
constant_map = {}
initial_bq = Conf(robot, get_group_joints(robot, 'base'), get_group_conf(robot, 'base'))
init = [
('CanMove',),
('BConf', initial_bq),
('AtBConf', initial_bq),
Equal(('PickCost',), 1),
Equal(('PlaceCost',), 1),
] + [('Sink', s) for s in problem.sinks] + \
[('Stove', s) for s in problem.stoves] + \
[('Connected', b, d) for b, d in problem.buttons] + \
[('Button', b) for b, _ in problem.buttons]
for arm in ARM_NAMES:
joints = get_arm_joints(robot, arm)
conf = Conf(robot, joints, get_joint_positions(robot, joints))
init += [('Arm', arm), ('AConf', arm, conf), ('HandEmpty', arm), ('AtAConf', arm, conf)]
if arm in problem.arms:
init += [('Controllable', arm)]
for body in problem.movable:
pose = Pose(body, get_pose(body))
init += [('Graspable', body), ('Pose', body, pose),
('AtPose', body, pose)]
for surface in problem.surfaces:
init += [('Stackable', body, surface)]
if is_placement(body, surface):
init += [('Supported', body, pose, surface)]
goal = [AND]
if problem.goal_conf is not None:
goal_conf = Pose(robot, problem.goal_conf)
init += [('BConf', goal_conf)]
goal += [('AtBConf', goal_conf)]
goal += [('Holding', a, b) for a, b in problem.goal_holding] + \
[('On', b, s) for b, s in problem.goal_on] + \
[('Cleaned', b) for b in problem.goal_cleaned] + \
[('Cooked', b) for b in problem.goal_cooked]
stream_map = {
'sample-pose': from_gen_fn(get_stable_gen(problem, collisions=collisions)),
'sample-grasp': from_list_fn(get_grasp_gen(problem, collisions=False)),
'inverse-kinematics': from_gen_fn(get_ik_ir_gen(problem, collisions=collisions, teleport=teleport)),
'plan-base-motion': from_fn(get_motion_gen(problem, collisions=collisions, teleport=teleport)),
'test-cfree-pose-pose': from_test(get_cfree_pose_pose_test(collisions=collisions)),
'test-cfree-approach-pose': from_test(get_cfree_approach_pose_test(problem, collisions=collisions)),
'test-cfree-traj-pose': from_test(get_cfree_traj_pose_test(problem.robot, collisions=collisions)),
'MoveCost': move_cost_fn,
}
return PDDLProblem(domain_pddl, constant_map, stream_pddl, stream_map, init, goal)
def post_process(self, problem, plan, teleport=False):
if plan is None:
return None
commands = []
for i, (name, args) in enumerate(plan):
if name == 'move_base':
c = args[-1]
new_commands = c.commands
elif name == 'pick':
a, b, p, g, _, c = args
[t] = c.commands
close_gripper = GripperCommand(problem.robot, a, g.grasp_width, teleport=teleport)
attach = Attach(problem.robot, a, g, b)
new_commands = [t, close_gripper, attach, t.reverse()]
elif name == 'place':
a, b, p, g, _, c = args
[t] = c.commands
gripper_joint = get_gripper_joints(problem.robot, a)[0]
position = get_max_limit(problem.robot, gripper_joint)
open_gripper = GripperCommand(problem.robot, a, position, teleport=teleport)
detach = Detach(problem.robot, a, b)
new_commands = [t, detach, open_gripper, t.reverse()]
elif name == 'clean':
body, sink = args
new_commands = [Clean(body)]
elif name == 'cook':
body, stove = args
new_commands = [Cook(body)]
elif name == 'press_clean':
body, sink, arm, button, bq, c = args
[t] = c.commands
new_commands = [t, Clean(body), t.reverse()]
elif name == 'press_cook':
body, sink, arm, button, bq, c = args
[t] = c.commands
new_commands = [t, Cook(body), t.reverse()]
else:
raise ValueError(name)
print(i, name, args, new_commands)
commands += new_commands
return commands
def plan(self, partial=False, defer=False, verbose=True):
parser = create_parser()
parser.add_argument('-cfree', action='store_true', help='Disables collisions during planning')
parser.add_argument('-enable', action='store_true', help='Enables rendering during planning')
parser.add_argument('-teleport', action='store_true', help='Teleports between configurations')
parser.add_argument('-simulate', action='store_true', help='Simulates the system')
args = parser.parse_args()
print('Arguments:', args)
connect(use_gui=True)
problem_fn = stacking_problem
with HideOutput():
problem = problem_fn()
saver = WorldSaver()
pddlstream_problem = self.pddlstream_from_problem(problem, collisions=not args.cfree, teleport=args.teleport)
stream_info = {
'MoveCost': FunctionInfo(opt_move_cost_fn),
}
stream_info.update({
'sample-pose': StreamInfo(opt_gen_fn=PartialInputs('?r')),
'inverse-kinematics': StreamInfo(opt_gen_fn=PartialInputs('?p')),
'plan-base-motion': StreamInfo(opt_gen_fn=PartialInputs('?q1 ?q2'), defer_fn=defer_shared if defer else never_defer),
} if partial else {
'sample-pose': StreamInfo(opt_gen_fn=from_fn(opt_pose_fn)),
'inverse-kinematics': StreamInfo(opt_gen_fn=from_fn(opt_ik_fn)),
'plan-base-motion': StreamInfo(opt_gen_fn=from_fn(opt_motion_fn)),
})
_, _, _, stream_map, init, goal = pddlstream_problem
print('Init:', init)
print('Goal:', goal)
print('Streams:', str_from_object(set(stream_map)))
print(SEPARATOR)
with Profiler():
with LockRenderer(lock=not args.enable):
solution = solve(pddlstream_problem, algorithm=args.algorithm, unit_costs=args.unit,
stream_info=stream_info, success_cost=INF, verbose=True, debug=False)
saver.restore()
print_solution(solution)
plan, cost, evaluations = solution
if (plan is None) or not has_gui():
disconnect()
return
print(SEPARATOR)
with LockRenderer(lock=not args.enable):
commands = self.post_process(problem, plan)
problem.remove_gripper()
saver.restore()
saver.restore()
wait_if_gui('Execute?')
if args.simulate:
control_commands(commands)
else:
apply_commands(State(), commands, time_step=0.01)
wait_if_gui('Finish?')
disconnect()
if __name__ == '__main__':
tamp_planner = TAMPPlanner()
tamp_planner.plan()
| 10,450 |
Python
| 42.365145 | 129 | 0.575407 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/create_dataset_mt.py
|
import subprocess
num_count = 10000
for i in range(num_count):
# Execute create_dataset.py
result = subprocess.run(['python3', 'create_dataset.py', '--skill'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Get results from create_dataset.py
stdout = result.stdout.decode('utf-8')
stderr = result.stderr.decode('utf-8')
# If finish with no error
if result.returncode == 0:
print("create_dataset.py completed successfully.")
else:
# Prin error message
print("create_dataset.py encountered an error:")
print(stderr)
# Rerun create_dataset.py
print("Restarting create_dataset.py...")
| 660 |
Python
| 30.476189 | 120 | 0.665152 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/create_ir_database.py
|
#!/usr/bin/env python
import argparse
import random
import time
from pybullet_tools.pr2_utils import set_arm_conf, get_other_arm, arm_conf, REST_LEFT_ARM, \
get_carry_conf, get_gripper_link, GET_GRASPS, IR_FILENAME, get_database_file, DRAKE_PR2_URDF, \
set_group_conf, get_group_conf, get_base_pose
from pybullet_tools.utils import create_box, disconnect, add_data_path, connect, get_movable_joints, get_joint_positions, \
sample_placement, set_pose, multiply, invert, set_joint_positions, pairwise_collision, inverse_kinematics, \
get_link_pose, get_body_name, write_pickle, uniform_pose_generator, set_base_values, \
load_pybullet, HideOutput, wait_if_gui, draw_point, point_from_pose, has_gui, elapsed_time, \
sub_inverse_kinematics, BodySaver
from pybullet_tools.pr2_problems import create_table
from pybullet_tools.ikfast.pr2.ik import pr2_inverse_kinematics, is_ik_compiled
from pybullet_tools.ikfast.utils import USE_CURRENT
from pybullet_tools.pr2_primitives import get_stable_gen, get_grasp_gen, get_ik_ir_gen
def save_inverse_reachability(robot, arm, grasp_type, tool_link, gripper_from_base_list):
# TODO: store value of torso and roll joint for the IK database. Sample the roll joint.
# TODO: hash the pr2 urdf as well
filename = IR_FILENAME.format(grasp_type, arm)
path = get_database_file(filename)
data = {
'filename': filename,
'robot': get_body_name(robot),
'grasp_type': grasp_type,
'arm': arm,
'torso': get_group_conf(robot, 'torso'),
'carry_conf': get_carry_conf(arm, grasp_type),
'tool_link': tool_link,
'ikfast': is_ik_compiled(),
'gripper_from_base': gripper_from_base_list,
}
write_pickle(path, data)
if has_gui():
handles = []
for gripper_from_base in gripper_from_base_list:
handles.extend(draw_point(point_from_pose(gripper_from_base), color=(1, 0, 0)))
wait_if_gui()
return path
#######################################################
def create_inverse_reachability(robot, body, table, arm, grasp_type, max_attempts=500, num_samples=500):
tool_link = get_gripper_link(robot, arm)
robot_saver = BodySaver(robot)
gripper_from_base_list = []
grasps = GET_GRASPS[grasp_type](body)
start_time = time.time()
while len(gripper_from_base_list) < num_samples:
box_pose = sample_placement(body, table)
set_pose(body, box_pose)
grasp_pose = random.choice(grasps)
gripper_pose = multiply(box_pose, invert(grasp_pose))
for attempt in range(max_attempts):
robot_saver.restore()
base_conf = next(uniform_pose_generator(robot, gripper_pose)) #, reachable_range=(0., 1.)))
#set_base_values(robot, base_conf)
set_group_conf(robot, 'base', base_conf)
if pairwise_collision(robot, table):
continue
grasp_conf = pr2_inverse_kinematics(robot, arm, gripper_pose) #, nearby_conf=USE_CURRENT)
#conf = inverse_kinematics(robot, link, gripper_pose)
if (grasp_conf is None) or pairwise_collision(robot, table):
continue
gripper_from_base = multiply(invert(get_link_pose(robot, tool_link)), get_base_pose(robot))
#wait_if_gui()
gripper_from_base_list.append(gripper_from_base)
print('{} / {} | {} attempts | [{:.3f}]'.format(
len(gripper_from_base_list), num_samples, attempt, elapsed_time(start_time)))
wait_if_gui()
break
else:
print('Failed to find a kinematic solution after {} attempts'.format(max_attempts))
return save_inverse_reachability(robot, arm, grasp_type, tool_link, gripper_from_base_list)
#######################################################
class MockProblem(object):
def __init__(self, robot, fixed=[], grasp_types=[]):
self.robot = robot
self.fixed = fixed
self.grasp_types = grasp_types
def create_inverse_reachability2(robot, body, table, arm, grasp_type, max_attempts=500, num_samples=500):
tool_link = get_gripper_link(robot, arm)
problem = MockProblem(robot, fixed=[table], grasp_types=[grasp_type])
placement_gen_fn = get_stable_gen(problem)
grasp_gen_fn = get_grasp_gen(problem, collisions=True)
ik_ir_fn = get_ik_ir_gen(problem, max_attempts=max_attempts, learned=False, teleport=True)
placement_gen = placement_gen_fn(body, table)
grasps = list(grasp_gen_fn(body))
print('Grasps:', len(grasps))
# TODO: sample the torso height
# TODO: consider IK with respect to the torso frame
start_time = time.time()
gripper_from_base_list = []
while len(gripper_from_base_list) < num_samples:
[(p,)] = next(placement_gen)
(g,) = random.choice(grasps)
output = next(ik_ir_fn(arm, body, p, g), None)
if output is None:
print('Failed to find a solution after {} attempts'.format(max_attempts))
else:
(_, ac) = output
[at,] = ac.commands
at.path[-1].assign()
gripper_from_base = multiply(invert(get_link_pose(robot, tool_link)), get_base_pose(robot))
gripper_from_base_list.append(gripper_from_base)
print('{} / {} [{:.3f}]'.format(
len(gripper_from_base_list), num_samples, elapsed_time(start_time)))
wait_if_gui()
return save_inverse_reachability(robot, arm, grasp_type, tool_link, gripper_from_base_list)
#######################################################
def main():
parser = argparse.ArgumentParser() # Automatically includes help
parser.add_argument('-arm', required=True)
parser.add_argument('-grasp', required=True)
parser.add_argument('-viewer', action='store_true', help='enable viewer.')
args = parser.parse_args()
arm = args.arm
other_arm = get_other_arm(arm)
grasp_type = args.grasp
connect(use_gui=args.viewer)
add_data_path()
with HideOutput():
robot = load_pybullet(DRAKE_PR2_URDF)
set_group_conf(robot, 'torso', [0.2])
set_arm_conf(robot, arm, get_carry_conf(arm, grasp_type))
set_arm_conf(robot, other_arm, arm_conf(other_arm, REST_LEFT_ARM))
#plane = p.loadURDF("plane.urdf")
#table = p.loadURDF("table/table.urdf", 0, 0, 0, 0, 0, 0.707107, 0.707107)
table = create_table()
box = create_box(.07, .07, .14)
#create_inverse_reachability(robot, box, table, arm=arm, grasp_type=grasp_type)
create_inverse_reachability2(robot, box, table, arm=arm, grasp_type=grasp_type)
disconnect()
if __name__ == '__main__':
main()
| 6,677 |
Python
| 42.647059 | 123 | 0.627677 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/README.md
|
# pybullet-planning (previously ss-pybullet)
A repository of [PyBullet](https://pypi.python.org/pypi/pybullet) utility functions for robotic motion planning, manipulation planning, and task and motion planning (TAMP).
This repository was originally developed for the [PDDLStream](https://github.com/caelan/pddlstream) (previously named [STRIPStream](https://github.com/caelan/stripstream)) approach to TAMP.
<!---->
<!--img src="images/pr2.png" height="300"> <img src="images/kuka.png" height="300"-->
<!-- ## PyBullet Planning -->
With the help of [Yijiang Huang](https://github.com/yijiangh), a stable and documented fork of **pybullet-planning** named [pybullet_planning](https://github.com/yijiangh/pybullet_planning) is available through [PyPI](https://pypi.org/project/pybullet-planning/).
However, new features will continue to be introduced first through **pybullet-planning**.
## Citation
Caelan Reed Garrett. PyBullet Planning. https://pypi.org/project/pybullet-planning/. 2018.
## Installation
Install for macOS or Linux using:
<!-- `pybullet-planning$ git clone --recursive git@github.com:caelan/pybullet-planning.git` -->
```
$ git clone --recurse-submodules https://github.com/caelan/pybullet-planning.git
$ cd pybullet-planning
pybullet-planning$ pip install -r requirements.txt
```
<!--
Install PyBullet on OS X or Linux using:
```
$ pip install numpy pybullet
$ git clone --recurse-submodules https://github.com/caelan/ss-pybullet.git
$ cd ss-pybullet
$ git pull --recurse-submodules
```
-->
**pybullet-planning** is intended to have ongoing support for both python2.7 and python3.*
Make sure to recursively update **pybullet-planning**'s submodules when pulling new commits.
```
pybullet-planning$ git pull --recurse-submodules
```
<!-- `pybullet-planning$ git submodule update --init --recursive` -->
## IKFast Compilation
We recommend using [IKFast](http://openrave.org/docs/0.8.2/openravepy/ikfast/), an analytical inverse kinematics solver, instead of PyBullet's damped least squares solver.
IKFast bindings are included for the following robots:
* Franka Panda - `pybullet-planning$ (cd pybullet_tools/ikfast/franka_panda; python setup.py)`
* MOVO - `pybullet-planning$ (cd pybullet_tools/ikfast/movo; python setup.py)`
* PR2 - `pybullet-planning$ (cd pybullet_tools/ikfast/pr2; python setup.py)`
<!-- https://stackoverflow.com/questions/10382141/temporarily-change-current-working-directory-in-bash-to-run-a-command -->
To create IKFast bindings for a new robot, following the instructions in [ikfast_pybind](https://github.com/yijiangh/ikfast_pybind).
<!-- https://pypi.org/project/ikfast-pybind/ -->
## Tests
1) Test PyBullet - ```pybullet-planning$ python -c 'import pybullet'```
## Tutorial
[test_turtlebot](https://github.com/caelan/pybullet-planning/blob/master/examples/test_turtlebot.py) - ```$ python -m examples.test_turtlebot```
<img src="images/turtlebot.png" height="150">
<!--img src="images/turtlebot2.png" height="150"-->
Heavily annotated simple example that demonstrates:
* Creating a PyBullet simulation
* Waiting for user input (useful on macOS)
* Programmatically creating objects
* Getting/setting object base poses
* Loading a robot [URDF](http://wiki.ros.org/urdf)
* Getting/setting robot joint positions
* Looking up named robot links and joints
* Computing an object's current Axis-Aligned Bounding Box (AABB)
* Drawing coordinate frames and bounding boxes
* Checking collisions between two objects
* Temporarily disabling rendering for efficiency purposes
## Planning Examples
* [Kuka IIWA pick motion planning](examples/test_kuka_pick.py) - `pybullet-planning$ python -m examples.test_kuka_pick`
* [TutleBot base motion planning](examples/test_turtlebot_motion.py) - ```pybullet-planning$ python -m examples.test_turtlebot_motion```
* [PR2 base & arm motion planning](examples/test_pr2_motion.py) - ```pybullet-planning$ python -m examples.test_pr2_motion```
* [Franka Panda workspace planning](examples/test_franka.py) - ```pybullet-planning$ python -m examples.test_franka```
* [Kinova MOVO workspace planning](examples/test_movo.py) - ```pybullet-planning$ python -m examples.test_movo```
* [Cylinder SE(3) motion planning](examples/test_se3.py) - ```pybullet-planning$ python -m examples.test_se3```
* [PR2 teleoperation](examples/teleop_pr2.py) - ```pybullet-planning$ python -m examples.teleop_pr2```
<!--img src="images/movo.png" height="150"-->
<img src="images/kuka_pick.png" height="150"> <img src="images/turtlebot_motion.png" height="150">
 <img src="images/pr2_motion.png" height="150">
<img src="images/franka.png" height="150"> <img src="images/movo2.png" height="150">
 <img src="images/se3.png" height="150">
## Debug Examples
* [TAMP environments](examples/test_json.py) - ```pybullet-planning$ python -m examples.test_json```
* [TAMP benchmarks](examples/test_tamp_xml.py) - ```pybullet-planning$ python -m examples.test_tamp_xml```
* [Gripper side grasps](examples/gripper/test_side.py) - ```pybullet-planning$ python -m examples.gripper.test_side```
* [Gripper top grasps](examples/gripper/test_top.py) - ```pybullet-planning$ python -m examples.gripper.test_top```
* [Dropping particles](examples/test_water.py) - ```pybullet-planning$ python -m examples.test_water```
* [PR2 cloning](examples/test_clone.py) - ```pybullet-planning$ python -m examples.test_clone```
<img src="images/json.png" height="150"> <img src="images/tamp_xml.png" height="150">
 <img src="images/water.png" height="150">
<!-- <img src="images/test_side.png" height="150">
 <img src="images/test_top.png" height="150"-->
<!--
* [OpenRAVE bodies](examples/test_kinbody.py) - ```pybullet-planning$ python -m examples.test_kinbody```
* [Kiva shelves](examples/test_kiva.py) - ```pybullet-planning$ python -m examples.test_kiva```
* [LIS/YCB models](examples/test_models.py) - ```pybullet-planning$ python -m examples.test_models```
* [PR2 visibility](examples/test_visibility.py) - ```pybullet-planning$ python -m examples.test_visibility```
* [TurtleBot collisions](examples/test_turtlebot.py) - ```pybullet-planning$ python -m examples.test_turtlebot```
-->
## PDDLStream Examples
See the following examples: https://github.com/caelan/pddlstream/tree/master/examples/pybullet
[<img src="https://img.youtube.com/vi/3HJrkgIGK7c/0.jpg" height="200">](https://www.youtube.com/watch?v=3HJrkgIGK7c)
[<img src="https://img.youtube.com/vi/oWr6m12nXcM/0.jpg" height="200">](https://www.youtube.com/watch?v=oWr6m12nXcM)
## Forks
* https://github.com/yijiangh/pybullet_planning
* https://github.com/rachelholladay/pb_robot
* https://github.com/mike-n-7/pb_robot
* https://github.com/carismoses/pb_robot
## Gallery
* PDDLStream for TAMP - https://github.com/caelan/pddlstream
* Online TAMP under Partial Observability - https://github.com/caelan/SS-Replan
* Automated Construction - https://github.com/caelan/pb-construction
* Learning + TAMP (LTAMP) - https://github.com/caelan/LTAMP
## PyBullet Resources
* PyPI - https://pypi.python.org/pypi/pybullet
* Quickstart - https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/
* Forum - https://pybullet.org/Bullet/phpBB3/
* Wordpress - https://pybullet.org/wordpress/
* Examples - https://github.com/bulletphysics/bullet3/tree/master/examples/pybullet/examples
* Bindings - https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/pybullet.c
## Bullet Resources
* GitHub - https://github.com/bulletphysics/bullet3
| 7,571 |
Markdown
| 47.229299 | 263 | 0.743627 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/README.md
|
# motion-planners
Python implementations of several robotic motion planners
## Citation
Caelan Reed Garrett. Motion Planners. https://github.com/caelan/motion-planners. 2017.
## Algorithms
Sampling-based:
* Probabilistic Roadmap (PRM)
* Rapidly-Exploring Random Tree (RRT)
* RRT-Connect (BiRRT)
* Linear Shortcutting
* MultiRRT
* RRT*
Grid search
* Breadth-First Search (BFS)
* A*
| 386 |
Markdown
| 17.428571 | 86 | 0.759067 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/diverse.py
|
from itertools import combinations, product, permutations
from scipy.spatial.kdtree import KDTree
import numpy as np
from motion_planners.utils import INF, compute_path_cost, get_distance
def compute_median_distance(path1, path2):
differences = [get_distance(q1, q2) for q1, q2 in product(path1, path2)]
return np.median(differences)
def compute_minimax_distance(path1, path2):
overall_distance = 0.
for path, other in permutations([path1, path2]):
tree = KDTree(other)
for q1 in path:
#closest_distance = min(get_distance(q1, q2) for q2 in other)
closest_distance, closest_index = tree.query(q1, k=1, eps=0.)
overall_distance = max(overall_distance, closest_distance)
return overall_distance
def compute_portfolio_distance(path1, path2, min_distance=0.):
# TODO: generic distance_fn
# TODO: min_distance from stats about the portfolio
distance = compute_minimax_distance(path1, path2)
if distance < min_distance:
return 0.
return sum(compute_path_cost(path, get_distance) for path in [path1, path2])
def score_portfolio(portfolio, **kwargs):
# TODO: score based on collision voxel overlap at different resolutions
score_fn = compute_minimax_distance # compute_median_distance | compute_minimax_distance | compute_portfolio_distance
score = INF
for path1, path2 in combinations(portfolio, r=2):
score = min(score, score_fn(path1, path2, **kwargs))
return score
def exhaustively_select_portfolio(candidates, k=10, **kwargs):
if len(candidates) <= k:
return candidates
# TODO: minimum length portfolio such that at nothing is within a certain distance
best_portfolios, best_score = [], 0
for portfolio in combinations(candidates, r=k):
score = score_portfolio(portfolio, **kwargs)
if score > best_score:
best_portfolios, best_score = portfolio, score
return best_portfolios
def greedily_select_portfolio(candidates, k=10):
# Higher score is better
if len(candidates) <= k:
return candidates
raise NotImplementedError()
#return best_portfolios
| 2,161 |
Python
| 35.644067 | 121 | 0.697362 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/multi_rrt.py
|
from collections import Mapping
from random import random
from .rrt import TreeNode, configs
from .utils import irange, argmin, get_pairs, randomize, take, enum
ts = enum('ALL', 'SUCCESS', 'PATH', 'NONE')
# TODO - resample and use nearest neighbors when the tree is large
# TODO - possible bug if a node is already in the tree
class MultiTree(Mapping, object):
def __init__(self, start, distance, sample, extend, collision):
self.nodes = {}
self.distance = distance
self.sample = sample
self.extend = extend
self.collision = collision
self.add(TreeNode(start))
def add(self, *nodes):
for n in nodes:
self.nodes[n.config] = n
def __getitem__(self, q):
return self.nodes[q]
# return first(lambda v: self.distance(v.config, q) < 1e-6, self.nodes)
def __len__(self):
return len(self.nodes)
def __iter__(self):
for n in self.nodes.values():
yield n
def __call__(self, q1, q2=None, iterations=50):
if q1 in self:
path1 = self[q1].retrace()
else:
path1 = self.grow(q1, iterations=iterations)
if q2 is None:
return configs(path1)
if q2 in self:
path2 = self[q2].retrace()
else:
path2 = self.grow(q2, iterations=iterations)
if path1 is None or path2 is None:
return None
for i in range(min(len(path1), len(path2))):
if path1[i] != path2[i]:
break
else:
i += 1
return configs(path1[:i - 1:-1] + path2[i - 1:])
def clear(self):
for n in self:
n.clear()
def draw(self, env):
for n in self:
n.draw(env)
class MultiRRT(MultiTree):
def grow(self, goal_sample, iterations=50, goal_probability=.2, store=ts.PATH, max_tree_size=500):
if not callable(goal_sample):
goal_sample = lambda: goal_sample
nodes, new_nodes = list(
take(randomize(self.nodes.values()), max_tree_size)), []
for i in irange(iterations):
goal = random() < goal_probability or i == 0
s = goal_sample() if goal else self.sample()
last = argmin(lambda n: self.distance(
n.config, s), nodes + new_nodes)
for q in self.extend(last.config, s):
if self.collision(q):
break
last = TreeNode(q, parent=last)
new_nodes.append(last)
else:
if goal:
path = last.retrace()
if store in [ts.ALL, ts.SUCCESS]:
self.add(*new_nodes)
elif store == ts.PATH:
new_nodes_set = set(new_nodes)
self.add(*[n for n in path if n in new_nodes_set])
return path
if store == ts.ALL:
self.add(*new_nodes)
return None
class MultiBiRRT(MultiTree):
def grow(self, goal, iterations=50, store=ts.PATH, max_tree_size=500):
if goal in self:
return self[goal].retrace()
if self.collision(goal):
return None
nodes1, new_nodes1 = list(
take(randomize(self.nodes.values()), max_tree_size)), []
nodes2, new_nodes2 = [], [TreeNode(goal)]
for _ in irange(iterations):
if len(nodes1) + len(new_nodes1) > len(nodes2) + len(new_nodes2):
nodes1, nodes2 = nodes2, nodes1
new_nodes1, new_nodes2 = new_nodes2, new_nodes1
s = self.sample()
last1 = argmin(lambda n: self.distance(
n.config, s), nodes1 + new_nodes1)
for q in self.extend(last1.config, s):
if self.collision(q):
break
last1 = TreeNode(q, parent=last1)
new_nodes1.append(last1)
last2 = argmin(lambda n: self.distance(
n.config, last1.config), nodes2 + new_nodes2)
for q in self.extend(last2.config, last1.config):
if self.collision(q):
break
last2 = TreeNode(q, parent=last2)
new_nodes2.append(last2)
else:
if len(nodes1) == 0:
nodes1, nodes2 = nodes2, nodes1
new_nodes1, new_nodes2 = new_nodes2, new_nodes1
last1, last2 = last2, last1
path1, path2 = last1.retrace(), last2.retrace()[:-1][::-1]
for p, n in get_pairs(path2):
n.parent = p
if len(path2) == 0: # TODO - still some kind of circular error
for n in new_nodes2:
if n.parent == last2:
n.parent = path1[-1]
else:
path2[0].parent = path1[-1]
path = path1 + path2
if store in [ts.ALL, ts.SUCCESS]:
self.add(*(new_nodes1 + new_nodes2[:-1]))
elif store == ts.PATH:
new_nodes_set = set(new_nodes1 + new_nodes2[:-1])
self.add(*[n for n in path if n in new_nodes_set])
return path
if store == ts.ALL:
self.add(*new_nodes1)
return None
| 5,397 |
Python
| 33.382165 | 102 | 0.503798 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/prm.py
|
from collections import namedtuple, Mapping
from heapq import heappop, heappush
import operator
from .utils import INF, get_pairs, merge_dicts, flatten
# TODO - Visibility-PRM, PRM*
class Vertex(object):
def __init__(self, q):
self.q = q
self.edges = {}
self._handle = None
def clear(self):
self._handle = None
def draw(self, env, color=(1, 0, 0, .5)):
from manipulation.primitives.display import draw_node
self._handle = draw_node(env, self.q, color=color)
def __str__(self):
return 'Vertex(' + str(self.q) + ')'
__repr__ = __str__
class Edge(object):
def __init__(self, v1, v2, path):
self.v1, self.v2 = v1, v2
self.v1.edges[v2], self.v2.edges[v1] = self, self
self._path = path
#self._handle = None
self._handles = []
def end(self, start):
if self.v1 == start:
return self.v2
if self.v2 == start:
return self.v1
assert False
def path(self, start):
if self._path is None:
return [self.end(start).q]
if self.v1 == start:
return self._path + [self.v2.q]
if self.v2 == start:
return self._path[::-1] + [self.v1.q]
assert False
def configs(self):
if self._path is None:
return []
return [self.v1.q] + self._path + [self.v2.q]
def clear(self):
#self._handle = None
self._handles = []
def draw(self, env, color=(1, 0, 0, .5)):
if self._path is None:
return
from manipulation.primitives.display import draw_edge
#self._handle = draw_edge(env, self.v1.q, self.v2.q, color=color)
for q1, q2 in get_pairs(self.configs()):
self._handles.append(draw_edge(env, q1, q2, color=color))
def __str__(self):
return 'Edge(' + str(self.v1.q) + ' - ' + str(self.v2.q) + ')'
__repr__ = __str__
##################################################
SearchNode = namedtuple('SearchNode', ['cost', 'parent'])
class Roadmap(Mapping, object):
def __init__(self, samples=[]):
self.vertices = {}
self.edges = []
self.add(samples)
def __getitem__(self, q):
return self.vertices[q]
def __len__(self):
return len(self.vertices)
def __iter__(self):
return iter(self.vertices)
def __call__(self, q1, q2):
if q1 not in self or q2 not in self:
return None
start, goal = self[q1], self[q2]
queue = [(0, start)]
nodes, processed = {start: SearchNode(0, None)}, set()
def retrace(v):
pv = nodes[v].parent
if pv is None:
return [v.q]
return retrace(pv) + v.edges[pv].path(pv)
while len(queue) != 0:
_, cv = heappop(queue)
if cv in processed:
continue
processed.add(cv)
if cv == goal:
return retrace(cv)
for nv, edge in cv.edges.items():
cost = nodes[cv].cost + len(edge.path(cv))
if nv not in nodes or cost < nodes[nv].cost:
nodes[nv] = SearchNode(cost, cv)
heappush(queue, (cost, nv))
return None
def add(self, samples):
new_vertices = []
for q in samples:
if q not in self:
self.vertices[q] = Vertex(q)
new_vertices.append(self[q])
return new_vertices
def connect(self, v1, v2, path=None):
if v1 not in v2.edges: # TODO - what about parallel edges?
edge = Edge(v1, v2, path)
self.edges.append(edge)
return edge
return None
def clear(self):
for v in self.vertices.values():
v.clear()
for e in self.edges:
e.clear()
def draw(self, env):
for v in self.vertices.values():
v.draw(env)
for e in self.edges:
e.draw(env)
@staticmethod
def merge(*roadmaps):
new_roadmap = Roadmap()
new_roadmap.vertices = merge_dicts(
*[roadmap.vertices for roadmap in roadmaps])
new_roadmap.edges = list(
flatten(roadmap.edges for roadmap in roadmaps))
return new_roadmap
class PRM(Roadmap):
def __init__(self, distance, extend, collision, samples=[]):
super(PRM, self).__init__()
self.distance = distance
self.extend = extend
self.collision = collision
self.grow(samples)
def grow(self, samples):
raise NotImplementedError()
def __call__(self, q1, q2):
self.grow([q1, q2])
if q1 not in self or q2 not in self:
return None
start, goal = self[q1], self[q2]
heuristic = lambda v: self.distance(v.q, goal.q) # lambda v: 0
queue = [(heuristic(start), start)]
nodes, processed = {start: SearchNode(0, None)}, set()
def retrace(v):
if nodes[v].parent is None:
return [v.q]
return retrace(nodes[v].parent) + v.edges[nodes[v].parent].path(nodes[v].parent)
while len(queue) != 0:
_, cv = heappop(queue)
if cv in processed:
continue
processed.add(cv)
if cv == goal:
return retrace(cv)
for nv in cv.edges:
cost = nodes[cv].cost + self.distance(cv.q, nv.q)
if nv not in nodes or cost < nodes[nv].cost:
nodes[nv] = SearchNode(cost, cv)
heappush(queue, (cost + heuristic(nv), nv))
return None
class DistancePRM(PRM):
def __init__(self, distance, extend, collision, samples=[], connect_distance=.5):
self.connect_distance = connect_distance
super(self.__class__, self).__init__(
distance, extend, collision, samples=samples)
def grow(self, samples):
old_vertices, new_vertices = self.vertices.keys(), self.add(samples)
for i, v1 in enumerate(new_vertices):
for v2 in new_vertices[i + 1:] + old_vertices:
if self.distance(v1.q, v2.q) <= self.connect_distance:
path = list(self.extend(v1.q, v2.q))[:-1]
if not any(self.collision(q) for q in path):
self.connect(v1, v2, path)
return new_vertices
class DegreePRM(PRM):
def __init__(self, distance, extend, collision, samples=[], target_degree=4, connect_distance=INF):
self.target_degree = target_degree
self.connect_distance = connect_distance
super(self.__class__, self).__init__(
distance, extend, collision, samples=samples)
def grow(self, samples):
# TODO: do sorted edges version
new_vertices = self.add(samples)
if self.target_degree == 0:
return new_vertices
for v1 in new_vertices:
degree = 0
for _, v2 in sorted(filter(lambda pair: pair[1] != v1 and pair[0] <= self.connect_distance,
map(lambda v: (self.distance(v1.q, v.q), v), self.vertices.values())),
key=operator.itemgetter(0)): # TODO - slow, use nearest neighbors
if self.target_degree <= degree:
break
if v2 not in v1.edges:
path = list(self.extend(v1.q, v2.q))[:-1]
if not any(self.collision(q) for q in path):
self.connect(v1, v2, path)
degree += 1
else:
degree += 1
return new_vertices
| 7,745 |
Python
| 30.233871 | 109 | 0.518786 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/rrt.py
|
from random import random
from .utils import irange, argmin, RRT_ITERATIONS
class TreeNode(object):
def __init__(self, config, parent=None):
self.config = config
self.parent = parent
#def retrace(self):
# if self.parent is None:
# return [self]
# return self.parent.retrace() + [self]
def retrace(self):
sequence = []
node = self
while node is not None:
sequence.append(node)
node = node.parent
return sequence[::-1]
def clear(self):
self.node_handle = None
self.edge_handle = None
def draw(self, env, color=(1, 0, 0, .5)):
from manipulation.primitives.display import draw_node, draw_edge
self.node_handle = draw_node(env, self.config, color=color)
if self.parent is not None:
self.edge_handle = draw_edge(
env, self.config, self.parent.config, color=color)
def __str__(self):
return 'TreeNode(' + str(self.config) + ')'
__repr__ = __str__
def configs(nodes):
if nodes is None:
return None
return list(map(lambda n: n.config, nodes))
def rrt(start, goal_sample, distance, sample, extend, collision, goal_test=lambda q: False,
iterations=RRT_ITERATIONS, goal_probability=.2):
if collision(start):
return None
if not callable(goal_sample):
g = goal_sample
goal_sample = lambda: g
nodes = [TreeNode(start)]
for i in irange(iterations):
goal = random() < goal_probability or i == 0
s = goal_sample() if goal else sample()
last = argmin(lambda n: distance(n.config, s), nodes)
for q in extend(last.config, s):
if collision(q):
break
last = TreeNode(q, parent=last)
nodes.append(last)
if goal_test(last.config):
return configs(last.retrace())
else:
if goal:
return configs(last.retrace())
return None
| 2,026 |
Python
| 27.549295 | 91 | 0.571076 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/discrete.py
|
from collections import deque
from heapq import heappop, heappush
from recordclass import recordclass
import numpy as np
from .utils import INF
Node = recordclass('Node', ['g', 'parent'])
def retrace(visited, q):
if q is None:
return []
return retrace(visited, visited[tuple(q)].parent) + [q]
def bfs(start, goal, neighbors, collision, max_iterations=INF):
if collision(start) or collision(goal):
return None
iterations = 0
visited = {tuple(start): Node(0, None)}
expanded = []
queue = deque([start])
while len(queue) != 0 and iterations < max_iterations:
current = queue.popleft()
iterations += 1
expanded.append(current)
if goal is not None and tuple(current) == tuple(goal):
return retrace(visited, current)
for next in neighbors(current):
# TODO - make edges for real (and store bad edges)
if tuple(next) not in visited and not collision(next):
visited[tuple(next)] = Node(
next, visited[tuple(current)].g + 1, current)
queue.append(next)
return None
def astar(start, goal, distance, neighbors, collision,
max_iterations=INF, cost=lambda g, h: g + h): # TODO - put start and goal in neighbors
if collision(start) or collision(goal):
return None
queue = [(cost(0, distance(start, goal)), 0, start)]
visited = {tuple(start): Node(0, None)}
iterations = 0
while len(queue) != 0 and iterations < max_iterations:
_, current_g, current = heappop(queue)
current = np.array(current)
if visited[tuple(current)].g != current_g:
continue
iterations += 1
if tuple(current) == tuple(goal):
return retrace(visited, current)
for next in neighbors(current):
next_g = current_g + distance(current, next)
if (tuple(next) not in visited or next_g < visited[tuple(next)].g) and not collision(next):
visited[tuple(next)] = Node(next_g, current)
# ValueError: The truth value of an array with more than one
# element is ambiguous.
heappush(queue, (cost(next_g, distance(next, goal)), next_g, next))
return None
| 2,285 |
Python
| 35.285714 | 103 | 0.606127 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/rrt_connect.py
|
import time
from itertools import takewhile
from .meta import direct_path
from .smoothing import smooth_path, smooth_path_old
from .rrt import TreeNode, configs
from .utils import irange, argmin, RRT_ITERATIONS, RRT_RESTARTS, RRT_SMOOTHING, INF, elapsed_time, \
negate
def asymmetric_extend(q1, q2, extend_fn, backward=False):
if backward:
return reversed(list(extend_fn(q2, q1)))
return extend_fn(q1, q2)
def extend_towards(tree, target, distance_fn, extend_fn, collision_fn, swap, tree_frequency):
last = argmin(lambda n: distance_fn(n.config, target), tree)
extend = list(asymmetric_extend(last.config, target, extend_fn, swap))
safe = list(takewhile(negate(collision_fn), extend))
for i, q in enumerate(safe):
if (i % tree_frequency == 0) or (i == len(safe) - 1):
last = TreeNode(q, parent=last)
tree.append(last)
success = len(extend) == len(safe)
return last, success
def rrt_connect(q1, q2, distance_fn, sample_fn, extend_fn, collision_fn,
iterations=RRT_ITERATIONS, tree_frequency=1, max_time=INF):
start_time = time.time()
assert tree_frequency >= 1
if collision_fn(q1) or collision_fn(q2):
return None
nodes1, nodes2 = [TreeNode(q1)], [TreeNode(q2)]
for iteration in irange(iterations):
if max_time <= elapsed_time(start_time):
break
swap = len(nodes1) > len(nodes2)
tree1, tree2 = nodes1, nodes2
if swap:
tree1, tree2 = nodes2, nodes1
last1, _ = extend_towards(tree1, sample_fn(), distance_fn, extend_fn, collision_fn,
swap, tree_frequency)
last2, success = extend_towards(tree2, last1.config, distance_fn, extend_fn, collision_fn,
not swap, tree_frequency)
if success:
path1, path2 = last1.retrace(), last2.retrace()
if swap:
path1, path2 = path2, path1
#print('{} iterations, {} nodes'.format(iteration, len(nodes1) + len(nodes2)))
return configs(path1[:-1] + path2[::-1])
return None
#################################################################
def birrt(q1, q2, distance, sample, extend, collision,
restarts=RRT_RESTARTS, smooth=RRT_SMOOTHING, max_time=INF, **kwargs):
# TODO: move to the meta class
start_time = time.time()
if collision(q1) or collision(q2):
return None
path = direct_path(q1, q2, extend, collision)
if path is not None:
return path
for attempt in irange(restarts + 1):
# TODO: use the restart wrapper
if max_time <= elapsed_time(start_time):
break
path = rrt_connect(q1, q2, distance, sample, extend, collision,
max_time=max_time - elapsed_time(start_time), **kwargs)
if path is not None:
#print('{} attempts'.format(attempt))
if smooth is None:
return path
#return smooth_path_old(path, extend, collision, iterations=smooth)
return smooth_path(path, extend, collision, distance_fn=distance, iterations=smooth,
max_time=max_time - elapsed_time(start_time))
return None
| 3,280 |
Python
| 39.506172 | 100 | 0.595427 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/lazy_prm.py
|
from scipy.spatial.kdtree import KDTree
from heapq import heappush, heappop
from collections import namedtuple
from .utils import INF, elapsed_time
from .rrt_connect import direct_path
from .smoothing import smooth_path
import random
import time
import numpy as np
Node = namedtuple('Node', ['g', 'parent'])
unit_cost_fn = lambda v1, v2: 1.
zero_heuristic_fn = lambda v: 0
def retrace_path(visited, vertex):
if vertex is None:
return []
return retrace_path(visited, visited[vertex].parent) + [vertex]
def dijkstra(start_v, neighbors_fn, cost_fn=unit_cost_fn):
# Update the heuristic over time
start_g = 0
visited = {start_v: Node(start_g, None)}
queue = [(start_g, start_v)]
while queue:
current_g, current_v = heappop(queue)
if visited[current_v].g < current_g:
continue
for next_v in neighbors_fn(current_v):
next_g = current_g + cost_fn(current_v, next_v)
if (next_v not in visited) or (next_g < visited[next_v].g):
visited[next_v] = Node(next_g, current_v)
heappush(queue, (next_g, next_v))
return visited
def wastar_search(start_v, end_v, neighbors_fn, cost_fn=unit_cost_fn,
heuristic_fn=zero_heuristic_fn, w=1, max_cost=INF, max_time=INF):
# TODO: lazy wastar to get different paths
#heuristic_fn = lambda v: cost_fn(v, end_v)
priority_fn = lambda g, h: g + w*h
goal_test = lambda v: v == end_v
start_time = time.time()
start_g, start_h = 0, heuristic_fn(start_v)
visited = {start_v: Node(start_g, None)}
queue = [(priority_fn(start_g, start_h), start_g, start_v)]
while queue and (elapsed_time(start_time) < max_time):
_, current_g, current_v = heappop(queue)
if visited[current_v].g < current_g:
continue
if goal_test(current_v):
return retrace_path(visited, current_v)
for next_v in neighbors_fn(current_v):
next_g = current_g + cost_fn(current_v, next_v)
if (next_v not in visited) or (next_g < visited[next_v].g):
visited[next_v] = Node(next_g, current_v)
next_h = heuristic_fn(next_v)
if priority_fn(next_g, next_h) < max_cost:
heappush(queue, (priority_fn(next_g, next_h), next_g, next_v))
return None
def check_path(path, colliding_vertices, colliding_edges, samples, extend_fn, collision_fn):
# TODO: bisect order
vertices = list(path)
random.shuffle(vertices)
for v in vertices:
if v not in colliding_vertices:
colliding_vertices[v] = collision_fn(samples[v])
if colliding_vertices[v]:
return False
edges = list(zip(path, path[1:]))
random.shuffle(edges)
for v1, v2 in edges:
if (v1, v2) not in colliding_edges:
segment = list(extend_fn(samples[v1], samples[v2]))
random.shuffle(segment)
colliding_edges[v1, v2] = any(map(collision_fn, segment))
colliding_edges[v2, v1] = colliding_edges[v1, v2]
if colliding_edges[v1, v2]:
return False
return True
def lazy_prm(start_conf, end_conf, sample_fn, extend_fn, collision_fn, num_samples=100, max_degree=10,
weights=None, p_norm=2, max_distance=INF, approximate_eps=0.0,
max_cost=INF, max_time=INF, max_paths=INF):
# TODO: multi-query motion planning
start_time = time.time()
# TODO: can embed pose and/or points on the robot for other distances
if weights is None:
weights = np.ones(len(start_conf))
embed_fn = lambda q: weights * q
distance_fn = lambda q1, q2: np.linalg.norm(embed_fn(q2) - embed_fn(q1), ord=p_norm)
cost_fn = lambda v1, v2: distance_fn(samples[v1], samples[v2])
# TODO: can compute cost between waypoints from extend_fn
samples = []
while len(samples) < num_samples:
conf = sample_fn()
if (distance_fn(start_conf, conf) + distance_fn(conf, end_conf)) < max_cost:
samples.append(conf)
start_index, end_index = 0, 1
samples[start_index] = start_conf
samples[end_index] = end_conf
embedded = list(map(embed_fn, samples))
kd_tree = KDTree(embedded)
vertices = list(range(len(samples)))
edges = set()
for v1 in vertices:
# TODO: could dynamically compute distances
distances, neighbors = kd_tree.query(embedded[v1], k=max_degree+1, eps=approximate_eps,
p=p_norm, distance_upper_bound=max_distance)
for d, v2 in zip(distances, neighbors):
if (d < max_distance) and (v1 != v2):
edges.update([(v1, v2), (v2, v1)])
neighbors_from_index = {v: set() for v in vertices}
for v1, v2 in edges:
neighbors_from_index[v1].add(v2)
#print(time.time() - start_time, len(edges), float(len(edges))/len(samples))
colliding_vertices, colliding_edges = {}, {}
def neighbors_fn(v1):
for v2 in neighbors_from_index[v1]:
if not (colliding_vertices.get(v2, False) or
colliding_edges.get((v1, v2), False)):
yield v2
visited = dijkstra(end_index, neighbors_fn, cost_fn)
heuristic_fn = lambda v: visited[v].g if v in visited else INF
while elapsed_time(start_time) < max_time:
# TODO: extra cost to prioritize reusing checked edges
path = wastar_search(start_index, end_index, neighbors_fn=neighbors_fn,
cost_fn=cost_fn, heuristic_fn=heuristic_fn,
max_cost=max_cost, max_time=max_time-elapsed_time(start_time))
if path is None:
return None, edges, colliding_vertices, colliding_edges
cost = sum(cost_fn(v1, v2) for v1, v2 in zip(path, path[1:]))
print('Length: {} | Cost: {:.3f} | Vertices: {} | Edges: {} | Time: {:.3f}'.format(
len(path), cost, len(colliding_vertices), len(colliding_edges), elapsed_time(start_time)))
if check_path(path, colliding_vertices, colliding_edges, samples, extend_fn, collision_fn):
break
solution = [start_conf]
for q1, q2 in zip(path, path[1:]):
solution.extend(extend_fn(samples[q1], samples[q2]))
return solution, samples, edges, colliding_vertices, colliding_edges
def replan_loop(start_conf, end_conf, sample_fn, extend_fn, collision_fn, params_list, smooth=0, **kwargs):
if collision_fn(start_conf) or collision_fn(end_conf):
return None
path = direct_path(start_conf, end_conf, extend_fn, collision_fn)
if path is not None:
return path
for num_samples in params_list:
path = lazy_prm(start_conf, end_conf, sample_fn, extend_fn, collision_fn,
num_samples=num_samples, **kwargs)
if path is not None:
return smooth_path(path, extend_fn, collision_fn, iterations=smooth)
return None
| 6,946 |
Python
| 41.882716 | 107 | 0.613015 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/star_roadmap.py
|
from collections import Mapping
#class StarRoadmap(Mapping, object):
class StarRoadmap(Mapping, object):
def __init__(self, center, planner):
self.center = center
self.planner = planner
self.roadmap = {}
"""
def __getitem__(self, q):
return self.roadmap[q]
def __len__(self):
return len(self.roadmap)
def __iter__(self):
return iter(self.roadmap)
"""
def grow(self, goal):
if goal not in self.roadmap:
self.roadmap[goal] = self.planner(self.center, goal)
return self.roadmap[goal]
def __call__(self, start, goal):
start_traj = self.grow(start)
if start_traj is None:
return None
goal_traj = self.grow(goal)
if goal_traj is None:
return None
return start_traj.reverse(), goal_traj
| 859 |
Python
| 23.571428 | 64 | 0.573923 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/utils.py
|
from random import shuffle
from itertools import islice
import time
import contextlib
import pstats
import cProfile
import numpy as np
INF = float('inf')
RRT_ITERATIONS = 20
RRT_RESTARTS = 2
RRT_SMOOTHING = 20
try:
user_input = raw_input
except NameError:
user_input = input
def irange(start, stop=None, step=1): # np.arange
if stop is None:
stop = start
start = 0
while start < stop:
yield start
start += step
def negate(test):
return lambda *args, **kwargs: not test(*args, **kwargs)
def argmin(function, sequence):
# TODO: use min
values = list(sequence)
scores = [function(x) for x in values]
return values[scores.index(min(scores))]
def get_pairs(lst):
return zip(lst[:-1], lst[1:])
def merge_dicts(*args):
result = {}
for d in args:
result.update(d)
return result
# return dict(reduce(operator.add, [d.items() for d in args]))
def flatten(iterable_of_iterables):
return (item for iterables in iterable_of_iterables for item in iterables)
def randomize(sequence):
sequence = list(sequence)
shuffle(sequence)
return sequence
def traverse(sequence, random=False):
# TODO: bisect
return randomize(sequence)
def take(iterable, n=INF):
if n == INF:
n = None # NOTE - islice takes None instead of INF
elif n is None:
n = 0 # NOTE - for some of the uses
return islice(iterable, n)
def enum(*sequential, **named):
enums = dict(zip(sequential, range(len(sequential))), **named)
enums['names'] = sorted(enums.keys(), key=lambda k: enums[k])
return type('Enum', (), enums)
def elapsed_time(start_time):
return time.time() - start_time
@contextlib.contextmanager
def profiler(field='tottime', num=10):
pr = cProfile.Profile()
pr.enable()
yield
pr.disable()
pstats.Stats(pr).sort_stats(field).print_stats(num) # cumtime | tottime
def inf_sequence():
return iter(int, 1)
def get_delta(q1, q2):
return np.array(q2) - np.array(q1)
def get_distance(q1, q2):
return np.linalg.norm(get_delta(q1, q2))
def get_unit_vector(vec):
norm = np.linalg.norm(vec)
if norm == 0:
return vec
return np.array(vec) / norm
def compute_path_cost(path, cost_fn=get_distance):
if path is None:
return INF
return sum(cost_fn(*pair) for pair in get_pairs(path))
def remove_redundant(path, tolerance=1e-3):
assert path
new_path = [path[0]]
for conf in path[1:]:
difference = np.array(new_path[-1]) - np.array(conf)
if not np.allclose(np.zeros(len(difference)), difference, atol=tolerance, rtol=0):
new_path.append(conf)
return new_path
def waypoints_from_path(path, tolerance=1e-3):
path = remove_redundant(path, tolerance=tolerance)
if len(path) < 2:
return path
difference_fn = lambda q2, q1: np.array(q2) - np.array(q1)
#difference_fn = get_difference_fn(body, joints)
waypoints = [path[0]]
last_conf = path[1]
last_difference = get_unit_vector(difference_fn(last_conf, waypoints[-1]))
for conf in path[2:]:
difference = get_unit_vector(difference_fn(conf, waypoints[-1]))
if not np.allclose(last_difference, difference, atol=tolerance, rtol=0):
waypoints.append(last_conf)
difference = get_unit_vector(difference_fn(conf, waypoints[-1]))
last_conf = conf
last_difference = difference
waypoints.append(last_conf)
return waypoints
def convex_combination(x, y, w=0.5):
return (1-w)*np.array(x) + w*np.array(y)
| 3,606 |
Python
| 22.270968 | 90 | 0.644481 |
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/meta.py
|
import time
from .smoothing import smooth_path
from .utils import RRT_RESTARTS, RRT_SMOOTHING, INF, irange, elapsed_time, compute_path_cost, traverse
def direct_path(q1, q2, extend_fn, collision_fn):
# TODO: version which checks whether the segment is valid
if collision_fn(q1) or collision_fn(q2):
return None
path = [q1] + list(extend_fn(q1, q2))
if any(collision_fn(q) for q in traverse(path)):
return None
return path
# path = [q1]
# for q in extend_fn(q1, q2):
# if collision_fn(q):
# return None
# path.append(q)
# return path
def random_restarts(solve_fn, q1, q2, distance_fn, sample_fn, extend_fn, collision_fn,
restarts=RRT_RESTARTS, smooth=RRT_SMOOTHING,
success_cost=0., max_time=INF, max_solutions=1, **kwargs):
start_time = time.time()
solutions = []
if any(collision_fn(q) for q in [q1, q2]):
return solutions
path = direct_path(q1, q2, extend_fn, collision_fn)
if path is not None:
solutions.append(path)
for attempt in irange(restarts + 1):
if (len(solutions) >= max_solutions) or (elapsed_time(start_time) > max_time):
break
attempt_time = (max_time - elapsed_time(start_time))
path = solve_fn(q1, q2, distance_fn, sample_fn, extend_fn, collision_fn,
max_time=attempt_time, **kwargs)
if path is None:
continue
if smooth is not None:
path = smooth_path(path, extend_fn, collision_fn, iterations=smooth)
solutions.append(path)
if compute_path_cost(path, distance_fn) < success_cost:
break
solutions = sorted(solutions, key=lambda path: compute_path_cost(path, distance_fn))
print('Solutions ({}): {} | Time: {:.3f}'.format(len(solutions), [(len(path), round(compute_path_cost(
path, distance_fn), 3)) for path in solutions], elapsed_time(start_time)))
return solutions
| 1,994 |
Python
| 38.117646 | 106 | 0.614845 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.